public void CanChangePasswordWhenMaxAttemptsIsExceeded() { const int maxLoginAttempts = 3; var testApplicationSettings = new TestApplicationSettings { MaxLoginAttempts = maxLoginAttempts, CoolOffPeriod = 1000 }; var userRepository = GetUserRepository(testApplicationSettings); var user = CreateUser(testApplicationSettings); Assert.IsTrue(userRepository.Authenticate("*****@*****.**", "secret")); for (var ctr = 0; ctr < maxLoginAttempts; ctr++) { userRepository.Authenticate("*****@*****.**", "wrongPassword"); } Assert.IsFalse(userRepository.Authenticate("*****@*****.**", "secret")); userRepository.ChangePassword(user, "newPassword"); Assert.IsTrue(userRepository.Authenticate("*****@*****.**", "newPassword")); }
public void UserLoginAttemptsAreResetAfterSuccessfullLogin() { const int maxLoginAttempts = 5; var testApplicationSettings = new TestApplicationSettings { MaxLoginAttempts = maxLoginAttempts }; var userRepository = GetUserRepository(testApplicationSettings); CreateUser(testApplicationSettings); Assert.IsTrue(userRepository.Authenticate("*****@*****.**", "secret")); for (var ctr = 0; ctr < maxLoginAttempts - 1; ctr++) { userRepository.Authenticate("*****@*****.**", "wrongPassword"); } Assert.IsTrue(userRepository.Authenticate("*****@*****.**", "secret")); for (var ctr = 0; ctr < maxLoginAttempts - 1; ctr++) { userRepository.Authenticate("*****@*****.**", "wrongPassword"); } Assert.IsTrue(userRepository.Authenticate("*****@*****.**", "secret")); }
public void UserLoginAttemptsAreResetAfterCoolOffPeriodExpires() { const int maxLoginAttempts = 5; const int coolOffPeriod = 2; // seconds var testApplicationSettings = new TestApplicationSettings { MaxLoginAttempts = maxLoginAttempts, CoolOffPeriod = coolOffPeriod }; var userRepository = GetUserRepository(testApplicationSettings); CreateUser(testApplicationSettings); Assert.IsTrue(userRepository.Authenticate("*****@*****.**", "secret")); for (var ctr = 0; ctr < maxLoginAttempts; ctr++) { userRepository.Authenticate("*****@*****.**", "wrongPassword"); } Assert.IsFalse(userRepository.Authenticate("*****@*****.**", "secret")); // Cool off Thread.Sleep(coolOffPeriod * 1000); for (var ctr = 0; ctr < maxLoginAttempts - 1; ctr++) { userRepository.Authenticate("*****@*****.**", "wrongPassword"); } Assert.IsTrue(userRepository.Authenticate("*****@*****.**", "secret")); }
public TestBindingSteps(TestContext testContext) { var random = new Random(); _ukprn = random.Next(100000); _learnerUln = random.Next(100000); _apprenticeshipId = _ukprn + _learnerUln; _testContext = testContext; _settings = TestConfiguration.TestApplicationSettings; }
public void CanAuthenticateUser() { var testApplicationSettings = new TestApplicationSettings { MaxLoginAttempts = 3 }; var userRepository = GetUserRepository(testApplicationSettings); CreateUser(testApplicationSettings); Assert.IsTrue(userRepository.Authenticate("*****@*****.**", "secret")); Assert.IsFalse(userRepository.Authenticate("[email protected]", "secret")); Assert.IsFalse(userRepository.Authenticate("*****@*****.**", "secre")); }
public void UserCannotLoginAfterExceedingMaxLoginAttempts() { const int maxLoginAttempts = 3; var testApplicationSettings = new TestApplicationSettings { MaxLoginAttempts = maxLoginAttempts }; var userRepository = GetUserRepository(testApplicationSettings); CreateUser(testApplicationSettings); Assert.IsTrue(userRepository.Authenticate("*****@*****.**", "secret")); for (var ctr = 0; ctr < maxLoginAttempts; ctr++) { userRepository.Authenticate("*****@*****.**", "wrongPassword"); } Assert.IsFalse(userRepository.Authenticate("*****@*****.**", "secret")); }
protected BaseTestFixture() { DefaultTestApplicationSettings = new TestApplicationSettings(); }
public TestEndpoint() { _testConfiguration = TestConfiguration.TestApplicationSettings; }