public static TokensIssuingOptions WithLifetime(this TokensIssuingOptions options, TimeSpan lifetime) { if (options == null) { throw new ArgumentNullException(nameof(options)); } options.Lifetime = lifetime; return(options); }
public void ShouldSetGetEndpoint() { // Given var options = new TokensIssuingOptions(); const string expectedGetEndpoint = "/api/Account/Token"; // When options.WithGetEndpotint(expectedGetEndpoint); // Then Assert.Equal(expectedGetEndpoint, options.GetEndpotint); }
public void ShouldSetTokenIssueEventHandlerTest() { // Given var options = new TokensIssuingOptions(); var tokenIssueEventHandler = new Mock <ITokenIssueEventHandler>().Object; // When options.WithTokenIssueEventHandler(tokenIssueEventHandler); // Then Assert.Equal(tokenIssueEventHandler, options.TokenIssueEventHandler); }
public void ShouldSetLifetime() { // Given var options = new TokensIssuingOptions(); var lifetime = TimeSpan.FromHours(2); // When options.WithLifetime(lifetime); // Then Assert.Equal(lifetime, options.Lifetime); }
public void ShouldSetSigningKey() { // Given var options = new TokensIssuingOptions(); const string expectedSigningAlgorithmName = SecurityAlgorithms.HmacSha256; var expectedSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("23j79h675s78T904gldUt0M5SftPg50H3W85s5A8u68zUV4AIJ")); // When options.WithSigningKey(expectedSigningAlgorithmName, expectedSigningKey); // Then Assert.Equal(expectedSigningAlgorithmName, options.SigningAlgorithmName); Assert.Equal(expectedSigningKey, options.SigningKey); }
public static TokensIssuingOptions WithGetEndpotint(this TokensIssuingOptions options, string endpoint) { if (options == null) { throw new ArgumentNullException(nameof(options)); } if (string.IsNullOrWhiteSpace(endpoint)) { throw new ArgumentNullException(nameof(endpoint)); } options.GetEndpotint = endpoint; return(options); }
public static TokensIssuingOptions WithTokenIssueEventHandler(this TokensIssuingOptions options, ITokenIssueEventHandler eventHandler) { if (options == null) { throw new ArgumentNullException(nameof(options)); } if (eventHandler == null) { throw new ArgumentNullException(nameof(eventHandler)); } options.TokenIssueEventHandler = eventHandler; return(options); }
public static TokensIssuingOptions WithSigningKey(this TokensIssuingOptions options, string signingAlgorithmName, SecurityKey signingKey) { if (options == null) { throw new ArgumentNullException(nameof(options)); } if (string.IsNullOrWhiteSpace(signingAlgorithmName)) { throw new ArgumentNullException(nameof(signingAlgorithmName)); } if (signingKey == null) { throw new ArgumentNullException(nameof(signingKey)); } options.SigningAlgorithmName = signingAlgorithmName; options.SigningKey = signingKey; return(options); }
public void WithLifetimeShouldValidateInput(TokensIssuingOptions options, TimeSpan lifetime) { Assert.Throws <ArgumentNullException>(() => options.WithLifetime(lifetime)); }
public void WithSigningKeyShouldValidateInput(TokensIssuingOptions options, string signingAlgorithmName, SecurityKey signingKey) { Assert.Throws <ArgumentNullException>(() => options.WithSigningKey(signingAlgorithmName, signingKey)); }
public void WithGetEndpotintShouldValidateInput(TokensIssuingOptions options, string endpoint) { Assert.Throws <ArgumentNullException>(() => options.WithGetEndpotint(endpoint)); }
public void SetTokenIssueEventHandlerFailTest(TokensIssuingOptions options, ITokenIssueEventHandler eventHandler) { Assert.Throws <ArgumentNullException>(() => options.WithTokenIssueEventHandler(eventHandler)); }
public void Configure(TokensIssuingOptions options) { options.WithTokenIssueEventHandler(_eventHandler); }