Пример #1
0
        public void user_cant_login_with_wrong_password()
        {
            var clock             = new Clock();
            var passwordStore     = new PasswordStore(clock);
            var passwordGenerator = new PasswordGenerator(passwordStore);
            var username          = "******";
            var password          = passwordGenerator.GeneratePassword(username);
            var success           = passwordStore.IsPasswordValidForUsername(username, password + "te");

            Assert.False(success);
        }
Пример #2
0
        public void Can_create_user_and_verify()
        {
            var clock             = new Clock();
            var passwordStore     = new PasswordStore(clock);
            var passwordGenerator = new PasswordGenerator(passwordStore);
            var username          = "******";
            var password          = passwordGenerator.GeneratePassword(username);
            var success           = passwordStore.IsPasswordValidForUsername(username, password);

            Assert.True(success);
        }
Пример #3
0
        public void user_cant_login_after_password_experation()
        {
            var clockMock    = new Mock <IClock>();
            var fakeDateTime = new DateTime().AddYears(10);

            clockMock.Setup(c => c.Now()).Returns(fakeDateTime);
            var passwordStore     = new PasswordStore(clockMock.Object);
            var passwordGenerator = new PasswordGenerator(passwordStore);
            var username          = "******";
            var password          = passwordGenerator.GeneratePassword(username);

            var futureClockMock    = new Mock <IClock>();
            var futureFakeDateTime = fakeDateTime.AddSeconds(31);

            futureClockMock.Setup(c => c.Now()).Returns(futureFakeDateTime);
            var passwordStoreWithExpiredClock = new PasswordStore(futureClockMock.Object);
            var success = passwordStoreWithExpiredClock.IsPasswordValidForUsername(username, password);

            Assert.False(success);
        }