예제 #1
0
 public void NullServices_Throws()
 {
     Assert.Throws <ArgumentNullException>("services", () =>
     {
         IdentityServices.AddPasswords(services: null);
     });
 }
예제 #2
0
 public void NullServices_Throws()
 {
     Assert.Throws <ArgumentNullException>("services", () =>
     {
         IdentityServices.AddUserStore <User, FakeUserStore>(services: null);
     });
 }
예제 #3
0
 public void NullServices_Throws()
 {
     Assert.Throws <ArgumentNullException>("services", () =>
     {
         IdentityServices.AddInfrastructure(services: null);
     });
 }
예제 #4
0
 public void NullServices_Throws()
 {
     Assert.Throws <ArgumentNullException>("services", () =>
     {
         IdentityServices.AddUserClaims <User>(services: null);
     });
 }
예제 #5
0
 public void NullServices_Throws()
 {
     Assert.Throws <ArgumentNullException>("services", () =>
     {
         IdentityServices.AddTimedLockoutStore <FakeTimedLockoutStore>(
             services: null);
     });
 }
예제 #6
0
 public void NullServices_Throws()
 {
     Assert.Throws <ArgumentNullException>("services", () =>
     {
         IdentityServices.AddSingleUseTokenService <FakeSingleUseTokenService>(
             services: null);
     });
 }
예제 #7
0
 public void NullOptions_Throws()
 {
     Assert.Throws <ArgumentNullException>("options", () =>
     {
         IdentityServices.AddOptions(
             services: new ServiceCollection(),
             options: null);
     });
 }
예제 #8
0
 public void NullServices_Throws()
 {
     Assert.Throws <ArgumentNullException>("services", () =>
     {
         IdentityServices.AddOptions(
             services: null,
             options: new IdentityOptions());
     });
 }
예제 #9
0
 public void NullServices_Throws()
 {
     Assert.Throws <ArgumentNullException>("services", () =>
     {
         IdentityServices.AddUserValidators <User>(
             services: null,
             options: new UserOptions());
     });
 }
예제 #10
0
                public void WhenCalled_AddsRetrieveOperation()
                {
                    var services = new ServiceCollection();

                    IdentityServices.AddUserEmailStore <User, FakeUserEmailStore>(services);

                    var provider = services.BuildServiceProvider();

                    Assert.NotNull(provider.GetRequiredService <IRetrieveOperation <EmailAddress, User> >());
                }
예제 #11
0
                public void WhenCalled_AddsSystemClock()
                {
                    var services = new ServiceCollection();

                    IdentityServices.AddInfrastructure(services);

                    var provider = services.BuildServiceProvider();

                    Assert.NotNull(provider.GetRequiredService <SystemClock>());
                }
예제 #12
0
                public void WhenCalled_AddsCrudStore()
                {
                    var services = new ServiceCollection();

                    IdentityServices.AddUserStore <User, FakeUserStore>(services);

                    var provider = services.BuildServiceProvider();

                    Assert.NotNull(provider.GetRequiredService <ICrudStore <UserKey, User> >());
                }
예제 #13
0
                public void WhenCalled_AddsUserOptions()
                {
                    var services = new ServiceCollection();
                    var options  = new IdentityOptions();

                    IdentityServices.AddOptions(services, options);

                    var provider = services.BuildServiceProvider();

                    Assert.NotNull(provider.GetRequiredService <UserOptions>());
                }
예제 #14
0
                public void WhenCalled_AddsPasswordHasher()
                {
                    var services = new ServiceCollection();

                    IdentityServices.AddPasswords(services);

                    var provider = services.BuildServiceProvider();

                    Assert.NotNull(provider.GetRequiredService <IPasswordHasher>());
                    Assert.True(provider.GetRequiredService <IPasswordHasher>() is Pbkdf2PasswordHasher);
                }
예제 #15
0
                public void WhenCalled_AddsHttpContextAccessor()
                {
                    var services = new ServiceCollection();

                    IdentityServices.AddInfrastructure(services);

                    var provider = services.BuildServiceProvider();

                    Assert.NotNull(provider.GetRequiredService <IHttpContextAccessor>());
                    Assert.True(provider.GetRequiredService <IHttpContextAccessor>() is HttpContextAccessor);
                }
예제 #16
0
                public void WhenCalled_AddsSingleUseTokenService()
                {
                    var services = new ServiceCollection();

                    IdentityServices.AddTimedLockoutStore <FakeTimedLockoutStore>(
                        services);

                    var provider = services.BuildServiceProvider();

                    Assert.NotNull(provider.GetRequiredService <ICrudStore <string, TimedLockout> >());
                    Assert.True(provider.GetRequiredService <ICrudStore <string, TimedLockout> >() is FakeTimedLockoutStore);
                }
예제 #17
0
                public void WhenCalled_AddsSingleUseTokenService()
                {
                    var services = new ServiceCollection();

                    IdentityServices.AddSingleUseTokenService <FakeSingleUseTokenService>(
                        services);

                    var provider = services.BuildServiceProvider();

                    Assert.NotNull(provider.GetRequiredService <ISingleUseTokenService>());
                    Assert.True(provider.GetRequiredService <ISingleUseTokenService>() is FakeSingleUseTokenService);
                }
예제 #18
0
                public void WhenCalled_AddsMinimumLengthPasswordStrengthValidator()
                {
                    var services = new ServiceCollection();

                    IdentityServices.AddPasswords(services);

                    var provider = services.BuildServiceProvider();

                    var validators = provider.GetRequiredService <IEnumerable <IPasswordStrengthValidator> >();

                    Assert.NotNull(validators);
                    Assert.Single(validators);
                    Assert.True(validators.First() is MinimumLengthPasswordStrengthValidator);
                }
예제 #19
0
                public void WhenCalled_AddsUserClaimsConverter()
                {
                    var services = new ServiceCollection();

                    IdentityServices.AddOptions(services, new IdentityOptions());
                    IdentityServices.AddInfrastructure(services);

                    // Act
                    IdentityServices.AddUserClaims <User>(services);

                    var provider = services.BuildServiceProvider();

                    Assert.NotNull(provider.GetRequiredService <IUserClaimsConverter <User> >());
                    Assert.True(provider.GetRequiredService <IUserClaimsConverter <User> >() is UserClaimsConverter <User>);
                }
예제 #20
0
                public void WhenCalled_AddsAuthenticationService()
                {
                    var services = new ServiceCollection();

                    IdentityServices.AddOptions(services, new IdentityOptions());
                    IdentityServices.AddInfrastructure(services);
                    IdentityServices.AddUserStore <User, FakeUserStore>(services);

                    // Act
                    IdentityServices.AddUserClaims <User>(services);

                    var provider = services.BuildServiceProvider();

                    Assert.NotNull(provider.GetRequiredService <IAuthenticationService <ClaimsPrincipal> >());
                    Assert.True(provider.GetRequiredService <IAuthenticationService <ClaimsPrincipal> >() is ClaimsAuthenticationService <User>);
                }
예제 #21
0
                public void RequireEmailWithBlankUser_DoesNotAddEmailValidator()
                {
                    var services = new ServiceCollection();
                    var options  = new UserOptions()
                    {
                        RequireEmail = true
                    };

                    IdentityServices.AddUserValidators <object>(services, options);

                    var provider = services.BuildServiceProvider();

                    var validators = provider.GetRequiredService <IEnumerable <IUserValidator <User> > >();

                    Assert.Empty(validators.Where(v => v is UserEmailRequiredValidator <User>));
                }
예제 #22
0
                public void RequireEmailWithImplementingUser_AddsEmailValidator()
                {
                    var services = new ServiceCollection();
                    var options  = new UserOptions()
                    {
                        RequireEmail = true
                    };

                    IdentityServices.AddUserValidators <User>(services, options);

                    var provider = services.BuildServiceProvider();

                    var validators = provider.GetRequiredService <IEnumerable <IUserValidator <User> > >();

                    Assert.Single(validators.Where(v => v is UserEmailRequiredValidator <User>));
                }
예제 #23
0
                public void NotRequirePasswordWithImplementingUser_DoesNotAddPasswordValidator()
                {
                    var services = new ServiceCollection();
                    var options  = new UserOptions()
                    {
                        RequirePassword = false
                    };

                    IdentityServices.AddUserValidators <User>(services, options);

                    var provider = services.BuildServiceProvider();

                    var validators = provider.GetRequiredService <IEnumerable <IUserValidator <User> > >();

                    Assert.Empty(validators.Where(v => v is UserPasswordHashRequiredValidator <User>));
                }
예제 #24
0
                public void WhenCalled_AddsIUserHelper()
                {
                    var services = Services();

                    IdentityServices.AddInfrastructure(services);
                    IdentityServices.AddPasswords(services);
                    IdentityServices.AddUserEmailStore <User, FakeUserEmailStore>(services);
                    IdentityServices.AddSingleUseTokenService <FakeSingleUseTokenService>(
                        services);
                    IdentityServices.AddTimedLockoutStore <FakeTimedLockoutStore>(services);

                    // Act
                    IdentityServices.AddUserHelpers <User>(services);

                    var provider = services.BuildServiceProvider();

                    Assert.NotNull(provider.GetRequiredService <IUserHelper>());
                    Assert.True(provider.GetRequiredService <IUserHelper>() is UserHelper <User>);
                }
예제 #25
0
                public void NotNullServices_AddsIIdentityService()
                {
                    var services = new ServiceCollection();

                    IdentityServices.AddOptions(services, new IdentityOptions());
                    IdentityServices.AddInfrastructure(services);
                    IdentityServices.AddPasswords(services);
                    IdentityServices.AddUserHelpers <User>(services);
                    IdentityServices.AddUserValidators <User>(services, new UserOptions());
                    IdentityServices.AddSingleUseTokenService <FakeSingleUseTokenService>(
                        services);
                    IdentityServices.AddTimedLockoutStore <FakeTimedLockoutStore>(services);
                    IdentityServices.AddUserEmailStore <User, FakeUserEmailStore>(services);
                    IdentityServices.AddUserStore <User, FakeUserStore>(services);
                    IdentityServices.AddUserClaims <User>(services);

                    // Act
                    IdentityServices.AddIdentityServices <User>(services);

                    var provider = services.BuildServiceProvider();

                    Assert.NotNull(provider.GetRequiredService <IIdentityService <User> >());
                    Assert.True(provider.GetRequiredService <IIdentityService <User> >() is IdentityService <User>);
                }