Esempio n. 1
0
        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"));
        }
Esempio n. 2
0
        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"));
        }
Esempio n. 3
0
        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;
        }
Esempio n. 5
0
        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"));
        }
Esempio n. 6
0
        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();
 }
Esempio n. 8
0
 public TestEndpoint()
 {
     _testConfiguration = TestConfiguration.TestApplicationSettings;
 }