Skip to content

Commit 3248934

Browse files
authored
Upgrade test for "limit unsuccessful logins" settings (#2991)
- Upgrade test for "limit unsuccessful logins" settings - Update `BaseUpgradeTest` annotations to work at the class level
1 parent fa99193 commit 3248934

3 files changed

Lines changed: 37 additions & 9 deletions

File tree

src/org/labkey/test/pages/compliance/ComplianceLoginSettingsPage.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ public void disableLoginControls()
3535
shortWait().until(wd -> !elementCache().loginAttemptCountCombo.isEnabled());
3636
}
3737

38+
public boolean isLoginLimitEnabled()
39+
{
40+
return elementCache().enableLoginChk.isSelected();
41+
}
42+
3843
public void setLoginAttemptCount(String count)
3944
{
4045
setFormElement(elementCache().loginAttemptCountInput, count);
@@ -45,6 +50,21 @@ public void selectLoginAttemptCount(String count)
4550
elementCache().loginAttemptCountCombo.selectComboBoxItem(count);
4651
}
4752

53+
public String getLoginAttemptCount()
54+
{
55+
return getFormElement(elementCache().loginAttemptCountInput);
56+
}
57+
58+
public String getLoginAttemptPeriod()
59+
{
60+
return getFormElement(elementCache().loginAttemptPeriodInput);
61+
}
62+
63+
public String getLoginAttemptRecoveryTime()
64+
{
65+
return getFormElement(elementCache().loginAttemptRecoveryTimeInput);
66+
}
67+
4868
public void selectLoginAttemptPeriod(String period)
4969
{
5070
elementCache().loginAttemptPeriodCombo.selectComboBoxItem(period);

src/org/labkey/test/tests/upgrade/BaseUpgradeTest.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,23 @@ public static void setupProject() throws Exception
5050
{
5151
BaseUpgradeTest currentTest = BaseWebDriverTest.getCurrentTest();
5252

53+
Class<?> testClass = currentTest.getClass();
54+
String earliestVersion = Optional.ofNullable(testClass.getAnnotation(EarliestVersion.class))
55+
.map(EarliestVersion::value).orElse(null);
56+
String latestVersion = Optional.ofNullable(testClass.getAnnotation(LatestVersion.class))
57+
.map(LatestVersion::value).orElse(null);
58+
59+
Assume.assumeTrue("Test class not valid when upgrading from version: " + setupVersion,
60+
VersionRange.versionRange(earliestVersion, latestVersion).contains(setupVersion)
61+
);
62+
5363
if (isUpgradeSetupPhase)
5464
{
5565
currentTest.doSetup();
5666
}
5767
else
5868
{
59-
TestLogger.info("Skipping setup for %s. Verifying upgrade.". formatted(currentTest.getClass().getSimpleName()));
69+
TestLogger.info("Skipping setup for %s. Verifying upgrade.". formatted(testClass.getSimpleName()));
6070
}
6171
}
6272

@@ -100,19 +110,19 @@ protected boolean wasSetupWithin(String earliestVersion, String latestVersion)
100110
* Specifies the earliest version of the test class that performed the required setup for the annotated method.
101111
*/
102112
@Retention(RetentionPolicy.RUNTIME)
103-
@Target({ElementType.METHOD})
113+
@Target({ElementType.METHOD, ElementType.TYPE})
104114
protected @interface EarliestVersion
105115
{
106116
String value();
107117
}
108118

109119
/**
110-
* Annotates test methods that should only run when upgrading from particular LabKey versions, as specified in
111-
* {@code webtest.upgradePreviousVersion}.<br>
112-
* Specifies the latest version of the test class that performed the required setup for the annotated method.
120+
* Annotates test methods or classes that should only run when upgrading from particular LabKey versions, as
121+
* specified in {@code webtest.upgradePreviousVersion}.<br>
122+
* Specifies the latest version of the test class that performed the required setup for the annotated method or class.
113123
*/
114124
@Retention(RetentionPolicy.RUNTIME)
115-
@Target({ElementType.METHOD})
125+
@Target({ElementType.METHOD, ElementType.TYPE})
116126
protected @interface LatestVersion {
117127
String value();
118128
}

src/org/labkey/test/util/VersionRange.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ public class VersionRange
1414
*
1515
* @param earliestVersion The earliest version in the range (inclusive). If null, there is no lower bound.
1616
* @param latestVersion The latest version in the range (inclusive). If null, there is no upper bound.
17-
* @throws IllegalArgumentException if both versions are null, or if earliestVersion is after latestVersion.
17+
* @throws IllegalArgumentException if earliestVersion is after latestVersion.
1818
*/
1919
public VersionRange(Version earliestVersion, Version latestVersion)
2020
{
2121
this.earliestVersion = earliestVersion;
2222
this.latestVersion = latestVersion;
2323

24-
if (earliestVersion == null && latestVersion == null)
25-
throw new IllegalArgumentException("Version range requires at least one version");
2624
if (earliestVersion != null && latestVersion != null && earliestVersion.compareTo(latestVersion) > 0)
2725
throw new IllegalArgumentException("%s is after %s".formatted(earliestVersion, latestVersion));
2826

0 commit comments

Comments
 (0)