示例#1
0
        public async Task CanLogInWithRecoveryCode()
        {
            // Arrange
            var client    = ServerFactory.CreateClient();
            var newClient = ServerFactory.CreateClient();

            var userName = $"{Guid.NewGuid()}@example.com";
            var password = $"[PLACEHOLDER]-1a";

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

            var showRecoveryCodes = await UserStories.EnableTwoFactorAuthentication(loggedIn);

            var recoveryCode = showRecoveryCodes.Context.RecoveryCodes.First();

            // Act & Assert
            // Use a new client to simulate a new browser session.
            await UserStories.LoginExistingUserRecoveryCodeAsync(newClient, userName, password, recoveryCode);
        }
示例#2
0
        public async Task CanLogInWithRecoveryCode_WithGlobalAuthorizeFilter()
        {
            // Arrange
            var server = ServerFactory.CreateServer(builder =>
                                                    builder.ConfigureServices(services => services.SetupGlobalAuthorizeFilter()));
            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);

            var recoveryCode = showRecoveryCodes.Context.RecoveryCodes.First();

            // Act & Assert
            // Use a new client to simulate a new browser session.
            await UserStories.LoginExistingUserRecoveryCodeAsync(newClient, userName, password, recoveryCode);
        }
示例#3
0
        public async Task CanLogInWithRecoveryCode()
        {
            // 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 recoveryCode = showRecoveryCodes.Context[ShowRecoveryCodes.RecoveryCodes]
                               .Split(' ')
                               .First();

            // Act & Assert
            // Use a new client to simulate a new browser session.
            await UserStories.LoginExistingUserRecoveryCodeAsync(newClient, userName, password, recoveryCode);
        }
示例#4
0
        public async Task CanLogInWithRecoveryCode_WithGlobalAuthorizeFilter()
        {
            // Arrange
            void ConfigureTestServices(IServiceCollection services) =>
            services.SetupGlobalAuthorizeFilter();

            var server = ServerFactory
                         .WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices));
            var client    = server.CreateClient();
            var newClient = server.CreateClient();

            var userName = $"{Guid.NewGuid()}@example.com";
            var password = $"[PLACEHOLDER]-1a";

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

            var showRecoveryCodes = await UserStories.EnableTwoFactorAuthentication(loggedIn);

            var recoveryCode = showRecoveryCodes.Context.RecoveryCodes.First();

            // Act & Assert
            // Use a new client to simulate a new browser session.
            await UserStories.LoginExistingUserRecoveryCodeAsync(newClient, userName, password, recoveryCode);
        }