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); }
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); }
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)); }
public NoIdentityAddedTests(ServerFactory <NoIdentityStartup, IdentityDbContext> serverFactory) { ServerFactory = serverFactory; }
protected AuthorizationTests(ServerFactory <TStartup, TContext> serverFactory) { ServerFactory = serverFactory; }
public RegistrationTests(ServerFactory <TStartup, TContext> serverFactory) { ServerFactory = serverFactory; }
public ManagementTests(ServerFactory <TStartup, TContext> serverFactory) { ServerFactory = serverFactory; }
protected LoginTests(ServerFactory <TStartup, TContext> serverFactory) { ServerFactory = serverFactory; }
public LoginTests(ServerFactory <TStartup, TContext> serverFactory) { ServerFactory = serverFactory; }