Beispiel #1
0
        public async Task CanLogInWithAPreviouslyRegisteredUser()
        {
            // Arrange
            var server    = ServerFactory.CreateDefaultServer();
            var client    = ServerFactory.CreateDefaultClient(server);
            var newClient = ServerFactory.CreateDefaultClient(server);

            var userName = $"{Guid.NewGuid()}@example.com";
            var password = $"!Test.Password1$";

            // Act & Assert
            await UserStories.RegisterNewUserAsync(client, userName, password);

            // Use a new client to simulate a new browser session.
            await UserStories.LoginExistingUserAsync(newClient, userName, password);
        }
Beispiel #2
0
        public async Task CanLogInWithTwoFactorAuthentication()
        {
            // Arrange
            var server    = ServerFactory.CreateDefaultServer();
            var client    = ServerFactory.CreateDefaultClient(server);
            var newClient = ServerFactory.CreateDefaultClient(server);

            var userName = $"{Guid.NewGuid()}@example.com";
            var password = $"!Test.Password1$";

            var loggedIn = await UserStories.RegisterNewUserAsync(client, userName, password);

            var showRecoveryCodes = await UserStories.EnableTwoFactorAuthentication(loggedIn, twoFactorEnabled : false);

            var twoFactorKey = showRecoveryCodes.Context[EnableAuthenticator.AuthenticatorKey];

            // Act & Assert
            // Use a new client to simulate a new browser session.
            await UserStories.LoginExistingUser2FaAsync(newClient, userName, password, twoFactorKey);
        }
Beispiel #3
0
        public async Task CannotLogInWithoutRequiredEmailConfirmation()
        {
            // Arrange
            var testEmailSender = new TestEmailSender();
            var server          = ServerFactory.CreateServer(builder =>
            {
                builder.ConfigureServices(services => services
                                          .AddSingleton <IEmailSender>(testEmailSender)
                                          .Configure <IdentityOptions>(opt => opt.SignIn.RequireConfirmedEmail = true));
            });

            var client    = ServerFactory.CreateDefaultClient(server);
            var newClient = ServerFactory.CreateDefaultClient(server);

            var userName = $"{Guid.NewGuid()}@example.com";
            var password = $"!Test.Password1$";

            var loggedIn = await UserStories.RegisterNewUserAsync(client, userName, password);

            // Act & Assert
            // Use a new client to simulate a new browser session.
            await Assert.ThrowsAnyAsync <XunitException>(() => UserStories.LoginExistingUserAsync(newClient, userName, password));
        }
Beispiel #4
0
 public NoIdentityAddedTests(ServerFactory <NoIdentityStartup, IdentityDbContext> serverFactory)
 {
     ServerFactory = serverFactory;
 }
Beispiel #5
0
 protected AuthorizationTests(ServerFactory <TStartup, TContext> serverFactory)
 {
     ServerFactory = serverFactory;
 }
Beispiel #6
0
 public RegistrationTests(ServerFactory <TStartup, TContext> serverFactory)
 {
     ServerFactory = serverFactory;
 }
Beispiel #7
0
 public ManagementTests(ServerFactory <TStartup, TContext> serverFactory)
 {
     ServerFactory = serverFactory;
 }
Beispiel #8
0
 protected LoginTests(ServerFactory <TStartup, TContext> serverFactory)
 {
     ServerFactory = serverFactory;
 }
Beispiel #9
0
 public LoginTests(ServerFactory <TStartup, TContext> serverFactory)
 {
     ServerFactory = serverFactory;
 }