public void NullServices_Throws() { Assert.Throws <ArgumentNullException>("services", () => { IdentityServices.AddPasswords(services: null); }); }
public void NullServices_Throws() { Assert.Throws <ArgumentNullException>("services", () => { IdentityServices.AddUserStore <User, FakeUserStore>(services: null); }); }
public void NullServices_Throws() { Assert.Throws <ArgumentNullException>("services", () => { IdentityServices.AddInfrastructure(services: null); }); }
public void NullServices_Throws() { Assert.Throws <ArgumentNullException>("services", () => { IdentityServices.AddUserClaims <User>(services: null); }); }
public void NullServices_Throws() { Assert.Throws <ArgumentNullException>("services", () => { IdentityServices.AddTimedLockoutStore <FakeTimedLockoutStore>( services: null); }); }
public void NullServices_Throws() { Assert.Throws <ArgumentNullException>("services", () => { IdentityServices.AddSingleUseTokenService <FakeSingleUseTokenService>( services: null); }); }
public void NullOptions_Throws() { Assert.Throws <ArgumentNullException>("options", () => { IdentityServices.AddOptions( services: new ServiceCollection(), options: null); }); }
public void NullServices_Throws() { Assert.Throws <ArgumentNullException>("services", () => { IdentityServices.AddOptions( services: null, options: new IdentityOptions()); }); }
public void NullServices_Throws() { Assert.Throws <ArgumentNullException>("services", () => { IdentityServices.AddUserValidators <User>( services: null, options: new UserOptions()); }); }
public void WhenCalled_AddsRetrieveOperation() { var services = new ServiceCollection(); IdentityServices.AddUserEmailStore <User, FakeUserEmailStore>(services); var provider = services.BuildServiceProvider(); Assert.NotNull(provider.GetRequiredService <IRetrieveOperation <EmailAddress, User> >()); }
public void WhenCalled_AddsSystemClock() { var services = new ServiceCollection(); IdentityServices.AddInfrastructure(services); var provider = services.BuildServiceProvider(); Assert.NotNull(provider.GetRequiredService <SystemClock>()); }
public void WhenCalled_AddsCrudStore() { var services = new ServiceCollection(); IdentityServices.AddUserStore <User, FakeUserStore>(services); var provider = services.BuildServiceProvider(); Assert.NotNull(provider.GetRequiredService <ICrudStore <UserKey, User> >()); }
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>()); }
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); }
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); }
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); }
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); }
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); }
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>); }
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>); }
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>)); }
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>)); }
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>)); }
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>); }
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>); }