Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test for Weak password rule removal #1817

Merged
merged 1 commit into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/org/labkey/test/LabKeySiteWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import org.labkey.test.util.TestLogger;
import org.labkey.test.util.TextSearcher;
import org.labkey.test.util.Timer;
import org.labkey.test.util.core.login.DbLoginUtils;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebDriverException;
Expand Down Expand Up @@ -439,7 +440,7 @@ protected void resetPassword(String resetUrl, String username, String newPasswor

assertTextPresent(username,
"has been verified! Create an account password below.",
"Your password must be at least six characters and cannot contain spaces or match your email address."
DbLoginUtils.PasswordStrength.Good.getGuidance()
);

new SetPasswordForm(getDriver())
Expand Down
10 changes: 5 additions & 5 deletions src/org/labkey/test/tests/core/login/PasswordTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ public void testLoginConfigurationForm()
assertEquals("Login config", new DbLoginProperties(PasswordStrength.Good, PasswordExpiration.OneYear),
DbLoginUtils.getDbLoginConfig(connection));

DbLoginUtils.setDbLoginConfig(connection, PasswordStrength.Weak, PasswordExpiration.SixMonths);
DbLoginUtils.setDbLoginConfig(connection, PasswordStrength.Strong, PasswordExpiration.SixMonths);
DatabaseAuthConfigureDialog configDialog = configurePage
.getPrimaryConfigurationRow(dbAuth.getProviderDescription())
.clickEdit(dbAuth);

DbLoginProperties dbLoginConfig = configDialog.getDbLoginConfig();
assertEquals("Login config",
new DbLoginProperties(PasswordStrength.Weak, PasswordExpiration.SixMonths),
new DbLoginProperties(PasswordStrength.Strong, PasswordExpiration.SixMonths),
dbLoginConfig);
}

Expand Down Expand Up @@ -195,7 +195,7 @@ public void testReusePassword()
public void testPasswordReset()
{
DbLoginUtils.setDbLoginConfig(createDefaultConnection(),
PasswordStrength.Weak,
PasswordStrength.Good,
PasswordExpiration.Never);

//get user a password
Expand All @@ -210,7 +210,7 @@ public void testPasswordReset()

beginAt(resetUrl);

attemptSetInvalidPassword("fooba", "fooba", "Your password must be at least six characters and cannot contain spaces.");
attemptSetInvalidPassword("fooba", "fooba", "Your password must be at least eight characters and cannot contain spaces.");
attemptSetInvalidPassword("foobar", "foobar2", "Your password entries didn't match.");

resetPassword(resetUrl, USER, VERY_STRONG_PASSWORD);
Expand All @@ -221,7 +221,7 @@ public void testPasswordReset()
@Test
public void testPasswordParameter()
{
setInitialPassword(USER, VERY_WEAK_PASSWORD);
setInitialPassword(USER, WEAK_PASSWORD);

// 31000: fail login actions if parameters present on URL
SimplePostCommand command = new SimplePostCommand("login", "loginAPI");
Expand Down
8 changes: 4 additions & 4 deletions src/org/labkey/test/util/APIUserHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ public GetUsersResponse getUsers()
return getUsers(false);
}

public GetUsersResponse getUsers(boolean includeDeactivated)
public GetUsersResponse getUsers(boolean includeInactive)
{
GetUsersCommand command = new GetUsersCommand();
command.setIncludeDeactivated(includeDeactivated);
command.setIncludeInactive(includeInactive);
Connection connection = getWrapper().createDefaultConnection();
if (getWrapper().isImpersonating())
{
Expand All @@ -179,10 +179,10 @@ public Map<String, Integer> getUserIds(List<String> userEmails)
return getUserIds(userEmails, true);
}

public Map<String, Integer> getUserIds(List<String> userEmails, boolean includeDeactivated)
public Map<String, Integer> getUserIds(List<String> userEmails, boolean includeInactive)
{
Map<String, Integer> userIds = new HashMap<>();
List<UserInfo> usersInfo = getUsers(includeDeactivated).getUsersInfo();
List<UserInfo> usersInfo = getUsers(includeInactive).getUsersInfo();
for (UserInfo userInfo : usersInfo)
{
if (userEmails.contains(userInfo.getEmail()))
Expand Down
16 changes: 15 additions & 1 deletion src/org/labkey/test/util/core/login/DbLoginUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,27 @@ public static void resetDbLoginConfig(Connection connection)

public enum PasswordStrength implements OptionSelect.SelectOption
{
Weak, Good, Strong;
Good("Your password must be at least eight non-whitespace characters, include a mix of lowercase letters, uppercase letters, digits, and symbols, and cannot include portions of your personal information."),
Strong("Secure passwords are long and use multiple character types. The password strength gauge will turn green when your new password meets the complexity requirements.");

private final String _guidance;

PasswordStrength(String guidance)
{
_guidance = guidance;
}

@Override
public String getValue()
{
return name();
}

// General password guidance displayed on the set/change password page for this rule
public String getGuidance()
{
return _guidance;
}
}

public enum PasswordExpiration implements OptionSelect.SelectOption
Expand Down