protected ClaimsAuthenticationServiceBase(IRetrieveOperation <UserKey, TUser> userStore, ClaimOptions options, SystemClock clock) { this._store = Guard.Null(nameof(userStore), userStore); this._options = Guard.Null(nameof(options), options); this._clock = Guard.Null(nameof(clock), clock); }
public void WhenCalled_UpdatesValue() { var options = new ClaimOptions(); var value = Guid.NewGuid().ToString(); options.AuthenticationScheme = value; Assert.Equal(value, options.AuthenticationScheme); }
public void EmptyValue_Throws() { var options = new ClaimOptions(); Assert.Throws <ArgumentException>("value", () => { options.AuthenticationScheme = string.Empty; }); }
public void WhiteSpaceValue_Throws() { var options = new ClaimOptions(); Assert.Throws <ArgumentException>("value", () => { options.Issuer = " "; }); }
public void WhenCalled_UpdatesValue() { var options = new ClaimOptions(); var value = Guid.NewGuid().ToString(); options.Issuer = value; Assert.Equal(value, options.Issuer); }
public void NullValue_Throws() { var options = new ClaimOptions(); Assert.Throws <ArgumentNullException>("value", () => { options.Issuer = null; }); }
public void EmptyValue_Throws() { var options = new ClaimOptions(); Assert.Throws <ArgumentException>("value", () => { options.Issuer = string.Empty; }); }
public void WhenCalled_UpdatesValue() { var options = new ClaimOptions(); var value = TimeSpan.FromMinutes(60); options.ValidateSecurityStampInterval = value; Assert.Equal(value, options.ValidateSecurityStampInterval); }
public void WhiteSpaceValue_Throws() { var options = new ClaimOptions(); Assert.Throws <ArgumentException>("value", () => { options.AuthenticationScheme = " "; }); }
public void NullValue_Throws() { var options = new ClaimOptions(); Assert.Throws <ArgumentNullException>("value", () => { options.AuthenticationScheme = null; }); }
public ClaimsAuthenticationService(IHttpContextAccessor httpContextAccessor, IRetrieveOperation <UserKey, TUser> userStore, ClaimOptions options, SystemClock clock) : base(userStore, options, clock) { this._httpContextAccessor = Guard.Null(nameof(httpContextAccessor), httpContextAccessor); this._options = Guard.Null(nameof(options), options); this._clock = Guard.Null(nameof(clock), clock); }
public async Task PrincipalAuthenticatedWithCorrectIdentityAndUserIdentifierClaim_ReturnsCorrectUserKey() { var options = new ClaimOptions(); var identity = new ClaimsIdentity(options.AuthenticationScheme); identity.AddClaim(new Claim(options.ClaimTypes.UserKey, "user-id")); var principal = new ClaimsPrincipal(identity); var userKey = await Converter(options).Convert(principal); Assert.NotNull(userKey); Assert.Equal("user-id", userKey.Value); }
public async Task WhenCalled_SetsCorrectClaimIssuerForAllClaims() { var options = new ClaimOptions() { Issuer = "Test Issuer" }; var principal = await Converter(options).Convert(User()); var identity = GetIdentity(principal); foreach (var claim in principal.Claims) { Assert.Equal("Test Issuer", claim.Issuer); } }
public void DefaultValue_ReturnsCorrectDefault() { var options = new ClaimOptions(); Assert.Equal("ThoughtHavenIdentity", options.AuthenticationScheme); }
public void DefaultValue_ReturnsValue() { var options = new ClaimOptions(); Assert.NotNull(options.ClaimTypes); }
public void DefaultValue_Returns30MinutesDefault() { var options = new ClaimOptions(); Assert.Equal(TimeSpan.FromMinutes(30), options.ValidateSecurityStampInterval); }
private static FakeClaimsAuthenticationServiceBase Authentication( FakeUserStore userStore = null, ClaimOptions options = null, FakeSystemClock clock = null) => new FakeClaimsAuthenticationServiceBase(userStore ?? UserStore(), options ?? Options(), clock ?? Clock());
public UserClaimsConverter(ClaimOptions options, SystemClock clock) { this._options = Guard.Null(nameof(options), options); this._clock = Guard.Null(nameof(clock), clock); }
private static UserClaimsConverter <User> Converter(ClaimOptions options = null, FakeSystemClock clock = null) => new UserClaimsConverter <User>(options ?? Options(), clock ?? Clock());
public void DefaultValue_ReturnsCorrectDefault() { var options = new ClaimOptions(); Assert.Equal(ClaimsIdentity.DefaultIssuer, options.Issuer); }
private static FakeClaimsAuthenticationService2 Authentication( FakeHttpContextAccessor httpContextAccessor = null, FakeUserStore userStore = null, ClaimOptions options = null, FakeSystemClock clock = null) => new FakeClaimsAuthenticationService2(httpContextAccessor ?? HttpContextAccessor(), userStore ?? UserStore(), options ?? Options(), clock ?? Clock());