Esempio n. 1
0
 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);
 }
Esempio n. 2
0
                public void WhenCalled_UpdatesValue()
                {
                    var options = new ClaimOptions();
                    var value   = Guid.NewGuid().ToString();

                    options.AuthenticationScheme = value;

                    Assert.Equal(value, options.AuthenticationScheme);
                }
Esempio n. 3
0
                public void EmptyValue_Throws()
                {
                    var options = new ClaimOptions();

                    Assert.Throws <ArgumentException>("value", () =>
                    {
                        options.AuthenticationScheme = string.Empty;
                    });
                }
Esempio n. 4
0
                public void WhiteSpaceValue_Throws()
                {
                    var options = new ClaimOptions();

                    Assert.Throws <ArgumentException>("value", () =>
                    {
                        options.Issuer = " ";
                    });
                }
Esempio n. 5
0
                public void WhenCalled_UpdatesValue()
                {
                    var options = new ClaimOptions();
                    var value   = Guid.NewGuid().ToString();

                    options.Issuer = value;

                    Assert.Equal(value, options.Issuer);
                }
Esempio n. 6
0
                public void NullValue_Throws()
                {
                    var options = new ClaimOptions();

                    Assert.Throws <ArgumentNullException>("value", () =>
                    {
                        options.Issuer = null;
                    });
                }
Esempio n. 7
0
                public void EmptyValue_Throws()
                {
                    var options = new ClaimOptions();

                    Assert.Throws <ArgumentException>("value", () =>
                    {
                        options.Issuer = string.Empty;
                    });
                }
Esempio n. 8
0
                public void WhenCalled_UpdatesValue()
                {
                    var options = new ClaimOptions();
                    var value   = TimeSpan.FromMinutes(60);

                    options.ValidateSecurityStampInterval = value;

                    Assert.Equal(value, options.ValidateSecurityStampInterval);
                }
Esempio n. 9
0
                public void WhiteSpaceValue_Throws()
                {
                    var options = new ClaimOptions();

                    Assert.Throws <ArgumentException>("value", () =>
                    {
                        options.AuthenticationScheme = " ";
                    });
                }
Esempio n. 10
0
                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);
 }
Esempio n. 12
0
                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);
                }
Esempio n. 13
0
                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);
                    }
                }
Esempio n. 14
0
                public void DefaultValue_ReturnsCorrectDefault()
                {
                    var options = new ClaimOptions();

                    Assert.Equal("ThoughtHavenIdentity", options.AuthenticationScheme);
                }
Esempio n. 15
0
                public void DefaultValue_ReturnsValue()
                {
                    var options = new ClaimOptions();

                    Assert.NotNull(options.ClaimTypes);
                }
Esempio n. 16
0
                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());
Esempio n. 18
0
 public UserClaimsConverter(ClaimOptions options, SystemClock clock)
 {
     this._options = Guard.Null(nameof(options), options);
     this._clock   = Guard.Null(nameof(clock), clock);
 }
Esempio n. 19
0
 private static UserClaimsConverter <User> Converter(ClaimOptions options  = null,
                                                     FakeSystemClock clock = null) =>
 new UserClaimsConverter <User>(options ?? Options(), clock ?? Clock());
Esempio n. 20
0
                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());