Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 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));
        }
Esempio n. 4
0
 public NoIdentityAddedTests(ServerFactory <NoIdentityStartup, IdentityDbContext> serverFactory)
 {
     ServerFactory = serverFactory;
 }
Esempio n. 5
0
 protected AuthorizationTests(ServerFactory <TStartup, TContext> serverFactory)
 {
     ServerFactory = serverFactory;
 }
Esempio n. 6
0
 public RegistrationTests(ServerFactory <TStartup, TContext> serverFactory)
 {
     ServerFactory = serverFactory;
 }
Esempio n. 7
0
 public ManagementTests(ServerFactory <TStartup, TContext> serverFactory)
 {
     ServerFactory = serverFactory;
 }
Esempio n. 8
0
 protected LoginTests(ServerFactory <TStartup, TContext> serverFactory)
 {
     ServerFactory = serverFactory;
 }
Esempio n. 9
0
 public LoginTests(ServerFactory <TStartup, TContext> serverFactory)
 {
     ServerFactory = serverFactory;
 }