public void ValidateUserUserIsLockedOut()
        {
            const string userName = "******";
            var user = new MembershipUser { UserName = userName, IsLockedOut = true };

            var membershipRepository = Substitute.For<IMembershipRepository>();
            membershipRepository.GetUser(user.UserName).Returns(user);

            var settingsRepository = Substitute.For<ISettingsRepository>();
            var emailService = Substitute.For<IEmailService>();
            var localisationService = Substitute.For<ILocalizationService>();
            var membershipService = new MembershipService(membershipRepository, settingsRepository, emailService, localisationService, _activityService, _privateMessageService,
                _membershipUserPointsService, _topicNotificationService, _voteService, _badgeService, _categoryNotificationService, _api, _loggingService);

            var status = membershipService.ValidateUser(userName, "password", 1);
            Assert.IsFalse(status);
            Assert.AreEqual(membershipService.LastLoginStatus, LoginAttemptStatus.UserLockedOut);
        }
示例#2
0
        public void ValidateUserMaxFailedPasswordAttemptMaxExceeded()
        {
            const string userName = "******";
            const int passwordAttempts = 1;
            var user = new MembershipUser
            {
                UserName = userName,
                IsApproved = true,
                Password = "******",
                FailedPasswordAttemptCount = passwordAttempts,
                PasswordSalt = "aaaa"
            };

            var membershipRepository = Substitute.For<IMembershipRepository>();
            membershipRepository.GetUser(user.UserName).Returns(user);

            var settingsRepository = Substitute.For<ISettingsRepository>();
            var emailService = Substitute.For<IEmailService>();
            var localisationService = Substitute.For<ILocalizationService>();
            var membershipService = new MembershipService(membershipRepository, settingsRepository, emailService, localisationService, _activityService, _privateMessageService,
                    _membershipUserPointsService, _topicNotificationService, _voteService, _badgeService, _categoryNotificationService, _api, _loggingService);

            var status = membershipService.ValidateUser(userName, "password", 2);
            Assert.IsFalse(status);
            Assert.IsTrue(user.IsLockedOut);
            Assert.AreEqual(membershipService.LastLoginStatus, LoginAttemptStatus.PasswordIncorrect);
            Assert.AreEqual(user.FailedPasswordAttemptCount, passwordAttempts + 1);
        }