public void AgencyPasswordPolicy_IsPasswordPolicyDisabled() { passwordConfiguration = new PasswordConfigurationNew(); controllerInstance = new AgencyPasswordPolicy(passwordConfiguration); passwordViolations = controllerInstance.ValidatePotentialPassword(userName, "123"); Assert.IsFalse(passwordViolations.Count > 0); }
public List <string> GetPolicyViolations(Guid userId, string password) { var user = UnitOfWork.Find <User>(userId); var agencyPolicy = new AgencyPasswordPolicy(user.PrimaryAgency.Configuration.PasswordConfiguration); return(agencyPolicy.ValidatePasswordChange(user, password)); }
public List <string> GetPolicyViolations(Guid agencyId, string username, string password) { var agency = UnitOfWork.Find <Agency>(agencyId); var agencyPolicy = new AgencyPasswordPolicy(agency.Configuration.PasswordConfiguration); return(agencyPolicy.ValidatePotentialPassword(username, password)); }
public List <string> GetPolicyDetails(Guid userId) { var user = UnitOfWork.Find <User>(userId); var agencyPolicy = new AgencyPasswordPolicy(user.PrimaryAgency.Configuration.PasswordConfiguration); return(agencyPolicy.GetPolicyDetails()); }
public void AgencyPasswordPolicy_ValidateNullPassword() { passwordConfiguration = new PasswordConfigurationNew(); controllerInstance = new AgencyPasswordPolicy(passwordConfiguration); passwordViolations = controllerInstance.ValidatePotentialPassword(userName, null); Assert.IsTrue(passwordViolations.Count > 0); Assert.AreEqual(PasswordCannotBeBlankViolation, passwordViolations[0]); }
public void ValidateBlankPassword() { _controllerInstance = new AgencyPasswordPolicy(_passwordConfiguration); Assert.IsInstanceOf(typeof(AgencyPasswordPolicy), _controllerInstance); _passwordViolations = _controllerInstance.ValidatePotentialPassword(UserName, ""); Assert.IsTrue(_passwordViolations.Count > 0); Assert.AreEqual(PasswordCannotBeBlankViolation, _passwordViolations[0]); }
public void ValidateNullPassword() { _passwordConfiguration.PasswordPolicy = false; _controllerInstance = new AgencyPasswordPolicy(_passwordConfiguration); _passwordViolations = _controllerInstance.ValidatePotentialPassword(UserName, null); Assert.IsTrue(_passwordViolations.Count > 0); Assert.AreEqual(PasswordCannotBeBlankViolation, _passwordViolations[0]); }
public void ValidateSameUserNameAndPassword() { _passwordConfiguration.PasswordPolicy = true; _controllerInstance = new AgencyPasswordPolicy(_passwordConfiguration); _passwordViolations = _controllerInstance.ValidatePotentialPassword(UserName, "tritech"); Assert.IsTrue(_passwordViolations.Count > 0); Assert.AreEqual(PasswordIsUsernameViolation, _passwordViolations[0]); }
public void IsAlphaDisabled() { _passwordConfiguration.PasswordPolicy = true; _passwordConfiguration.MaximumLength = 15; _controllerInstance = new AgencyPasswordPolicy(_passwordConfiguration); _passwordViolations = _controllerInstance.ValidatePotentialPassword(UserName, "123@"); Assert.IsFalse(_passwordViolations.Count > 0); }
public void AgencyPasswordPolicy_IsAlphaDisabled() { passwordConfiguration = new PasswordConfigurationNew(); passwordConfiguration.PasswordPolicy = true; passwordConfiguration.MaximumLength = 15; controllerInstance = new AgencyPasswordPolicy(passwordConfiguration); passwordViolations = controllerInstance.ValidatePotentialPassword(userName, "123@"); Assert.IsFalse(passwordViolations.Count > 0); }
public void AgencyPasswordPolicy_ValidateSameUserNameAndPassword() { passwordConfiguration = new PasswordConfigurationNew(); passwordConfiguration.PasswordPolicy = true; controllerInstance = new AgencyPasswordPolicy(passwordConfiguration); passwordViolations = controllerInstance.ValidatePotentialPassword(userName, "tritech"); Assert.IsTrue(passwordViolations.Count > 0); Assert.AreEqual(PasswordIsUsernameViolation, passwordViolations[0]); }
public void ValidatePasswordForAlpha() { _passwordConfiguration.PasswordPolicy = true; _passwordConfiguration.IsAlpha = true; _controllerInstance = new AgencyPasswordPolicy(_passwordConfiguration); _passwordViolations = _controllerInstance.ValidatePotentialPassword(UserName, "123"); Assert.IsTrue(_passwordViolations.Count > 0); Assert.AreEqual(PasswordRequiresAlpha, _passwordViolations[0]); }
public void ValidatePasswordForMaxLength() { _passwordConfiguration.PasswordPolicy = true; _passwordConfiguration.MaximumLength = 10; _controllerInstance = new AgencyPasswordPolicy(_passwordConfiguration); _passwordViolations = _controllerInstance.ValidatePotentialPassword(UserName, "anc@123bbbbbbbbbbbbbbbbb"); Assert.IsTrue(_passwordViolations.Count > 0); Assert.AreEqual(string.Format(PasswordTooLong, _passwordConfiguration.MaximumLength), _passwordViolations[0]); }
public void AgencyPasswordPolicy_ValidatePasswordForDafaultMaxLength() { passwordConfiguration = new PasswordConfigurationNew(); passwordConfiguration.PasswordPolicy = true; controllerInstance = new AgencyPasswordPolicy(passwordConfiguration); passwordViolations = controllerInstance.ValidatePotentialPassword(userName, "anc@123"); Assert.IsTrue(passwordViolations.Count > 0); Assert.AreEqual(string.Format(PasswordTooLong, passwordConfiguration.MaximumLength), passwordViolations[0]); }
public void ValidatePasswordForInvalidUser() { const string Password = "******"; _passwordConfiguration.PasswordPolicy = true; _passwordConfiguration.PasswordReuse = 2; _passwordConfiguration.MaximumLength = 15; _controllerInstance = new AgencyPasswordPolicy(_passwordConfiguration); _controllerInstance.ValidatePasswordChange(null, Password); }
public void ValidatePasswordForDefaultMinLength() { var passwordConfiguration = PasswordConfiguration.Empty; passwordConfiguration.PasswordPolicy = true; _controllerInstance = new AgencyPasswordPolicy(passwordConfiguration); _passwordViolations = _controllerInstance.ValidatePotentialPassword(UserName, "a"); Assert.IsTrue(_passwordViolations.Count > 0); Assert.AreEqual(string.Format(PasswordTooLong, PasswordConfiguration.Empty.MinimumLength), _passwordViolations[0]); }
public void AgencyPasswordPolicy_ValidatePasswordForAlpha() { passwordConfiguration = new PasswordConfigurationNew(); passwordConfiguration.PasswordPolicy = true; passwordConfiguration.IsAlpha = true; controllerInstance = new AgencyPasswordPolicy(passwordConfiguration); passwordViolations = controllerInstance.ValidatePotentialPassword(userName, "123"); Assert.IsTrue(passwordViolations.Count > 0); Assert.AreEqual(PasswordRequiresAlpha, passwordViolations[0]); }
public void ValidatePasswordForNumericAndSymbols() { _passwordConfiguration.PasswordPolicy = true; _passwordConfiguration.IsNumeric = true; _passwordConfiguration.IsSymbol = true; _passwordConfiguration.MinimumLength = 5; _passwordConfiguration.MaximumLength = 10; _controllerInstance = new AgencyPasswordPolicy(_passwordConfiguration); _passwordViolations = _controllerInstance.ValidatePotentialPassword(UserName, "abc"); Assert.IsTrue(_passwordViolations.Count > 1); }
public void AgencyPasswordPolicy_ValidatePasswordForNumericAndSymbols() { passwordConfiguration = new PasswordConfigurationNew(); passwordConfiguration.PasswordPolicy = true; passwordConfiguration.IsNumeric = true; passwordConfiguration.IsSymbol = true; passwordConfiguration.MinimumLength = 5; passwordConfiguration.MaximumLength = 10; controllerInstance = new AgencyPasswordPolicy(passwordConfiguration); passwordViolations = controllerInstance.ValidatePotentialPassword(userName, "abc"); Assert.IsTrue(passwordViolations.Count > 1); }
public void IsPasswordExpired_2() { //Arrange _passwordConfiguration.PasswordPolicy = true; _passwordConfiguration.ExpirationDays = -1; _user.SetPassword("password"); _controllerInstance = new AgencyPasswordPolicy(_passwordConfiguration); //Act var result = _controllerInstance.IsPasswordExpired(_user); //Assert Assert.True(result); }
public void ValidatePasswordForInvalidReuseCount() { const string Password = "******"; _user.PasswordHistory = new Collection <PasswordHistory> { new PasswordHistory(new Password(new Guid(), _user.Id, "abc")), new PasswordHistory(new Password(new Guid(), _user.Id, "xyz")) }; _passwordConfiguration.PasswordPolicy = true; _passwordConfiguration.PasswordReuse = 5; _passwordConfiguration.MaximumLength = 15; _controllerInstance = new AgencyPasswordPolicy(_passwordConfiguration); _passwordViolations = _controllerInstance.ValidatePasswordChange(_user, Password); Assert.IsFalse(_passwordViolations.Count > 0); }
public void ValidatePasswordChange() { const string Password = "******"; _user.PasswordHistory = new Collection <PasswordHistory> { new PasswordHistory(new Password(new Guid(), _user.Id, Password)) }; _passwordConfiguration.PasswordPolicy = true; _passwordConfiguration.PasswordReuse = 1; _passwordConfiguration.MaximumLength = 15; _controllerInstance = new AgencyPasswordPolicy(_passwordConfiguration); _passwordViolations = _controllerInstance.ValidatePasswordChange(_user, Password); Assert.IsTrue(_passwordViolations.Count > 0); Assert.AreEqual(string.Format(PasswordReuse, _passwordConfiguration.PasswordReuse), _passwordViolations[0]); }
public void AgencyPasswordPolicy_CheckPasswordDate() { UserNew userdetails = new UserNew(); passwordConfiguration = new PasswordConfigurationNew(); passwordConfiguration.PasswordPolicy = true; passwordConfiguration.MaximumLength = 15; controllerInstance = new AgencyPasswordPolicy(passwordConfiguration); try { controllerInstance.IsPasswordExpired(userdetails); Assert.Fail(); } catch (Exception exception) { Assert.IsNotNull(exception); } }
/// <summary> /// Change this User's password without challenging the current password. /// </summary> /// <param name="password">The new Password</param> /// <returns>The new Password instance.</returns> public Password ChangePassword(string password) { // Make sure the Password is Valid var agencyPolicy = new AgencyPasswordPolicy(PrimaryAgency.Configuration.PasswordConfiguration); var violations = agencyPolicy.ValidatePasswordChange(this, password); if (violations.Any()) { throw new PasswordPolicyException(violations); } // Create and Set the New Password var newPassword = new Password(RMSSystemId, Id, password); SetPassword(newPassword); // Return the new Password Instance. return(newPassword); }
public void AgencyPasswordPolicy_ValidatePasswordForInvalidUser() { const string password = "******"; passwordConfiguration = new PasswordConfigurationNew(); passwordConfiguration.PasswordPolicy = true; passwordConfiguration.PasswordReuse = 2; passwordConfiguration.MaximumLength = 15; controllerInstance = new AgencyPasswordPolicy(passwordConfiguration); try { controllerInstance.ValidatePasswordChange(null, password); Assert.Fail(); } catch (Exception exception) { Assert.IsNotNull(exception); } }
public void AgencyPasswordPolicy_ValidatePasswordForInvalidReuseCount() { DeveloperIdentity.GetDeveloperIdentity(); const string password = "******"; Guid userId = Utils.CreateUser(password); UserNew userdetails = new UserNew() { PasswordHistory = new Collection <PasswordHistory>() { new PasswordHistory(new Password(new Guid(), userId, "abc")), new PasswordHistory(new Password(new Guid(), userId, "xyz")) } }; passwordConfiguration = new PasswordConfigurationNew(); passwordConfiguration.PasswordPolicy = true; passwordConfiguration.PasswordReuse = 5; passwordConfiguration.MaximumLength = 15; controllerInstance = new AgencyPasswordPolicy(passwordConfiguration); passwordViolations = controllerInstance.ValidatePasswordChange(userdetails, password); Assert.IsFalse(passwordViolations.Count > 0); }
public void IsPasswordPolicyDisabled() { _controllerInstance = new AgencyPasswordPolicy(_passwordConfiguration); _passwordViolations = _controllerInstance.ValidatePotentialPassword(UserName, "123"); Assert.IsFalse(_passwordViolations.Count > 0); }