Skip to content

Commit 49f570b

Browse files
committed
Merge 25.7 to develop
2 parents b5d1aed + 99e7488 commit 49f570b

2 files changed

Lines changed: 49 additions & 10 deletions

File tree

src/org/labkey/test/tests/issues/IssuesTest.java

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ public class IssuesTest extends BaseWebDriverTest
8686
private static final String USER2 = "[email protected]";
8787
private static final String USER3 = "[email protected]";
8888
private static final String USER4 = "[email protected]";
89+
private static final String CLIENT_USER1 = "[email protected]";
8990
private static final String user = "[email protected]";
9091
private static final Map<String, String> ISSUE_0 = new HashMap<>(Maps.of("title", ISSUE_TITLE_0, "Priority", "2", "comment", "a bright flash of light"));
9192
private static final Map<String, String> ISSUE_1 = new HashMap<>(Maps.of("title", ISSUE_TITLE_1, "Priority", "1", "comment", "alien autopsy"));
9293
private static final String ISSUE_SUMMARY_WEBPART_NAME = "Issues Summary";
9394
private static final String ISSUE_LIST_REGION_NAME = "issues-issues";
9495
private static final String TEST_GROUP = "testers";
96+
private static final String CLIENT_GROUP = "clients";
9597
private static final String TEST_EMAIL_TEMPLATE =
9698
"You can review this issue here: ^detailsURL^\n" +
9799
"Modified by: ^user^\n" +
@@ -105,6 +107,7 @@ public class IssuesTest extends BaseWebDriverTest
105107
private static String NAME;
106108
protected IssuesHelper _issuesHelper;
107109
private final ApiPermissionsHelper _permissionsHelper = new ApiPermissionsHelper(this);
110+
private static String CLIENT_PORTAL = "Client Issues";
108111

109112
public IssuesTest()
110113
{
@@ -158,8 +161,9 @@ protected String getProjectName()
158161
@Override
159162
protected void doCleanup(boolean afterTest) throws TestTimeoutException
160163
{
161-
_userHelper.deleteUsers(false, USER1, USER2, USER3, USER4);
164+
_userHelper.deleteUsers(false, USER1, USER2, USER3, CLIENT_USER1);
162165
_containerHelper.deleteProject(getProjectName(), afterTest);
166+
_containerHelper.deleteProject(CLIENT_PORTAL, afterTest);
163167
}
164168

165169
public void doInit()
@@ -193,6 +197,15 @@ public void doInit()
193197
waitAndClickAndWait(Locator.linkContainingText(ISSUE_SUMMARY_WEBPART_NAME));
194198
_issuesHelper.addIssue(ISSUE_0);
195199
_issuesHelper.addIssue(ISSUE_1);
200+
201+
// Create a second project with different permissions
202+
_containerHelper.createProject(CLIENT_PORTAL);
203+
goToProjectHome(CLIENT_PORTAL);
204+
_userHelper.createUser(CLIENT_USER1);
205+
_permissionsHelper.createPermissionsGroup(CLIENT_GROUP);
206+
_permissionsHelper.setPermissions(CLIENT_GROUP, "Editor");
207+
_permissionsHelper.addUserToProjGroup(CLIENT_USER1, CLIENT_PORTAL, CLIENT_GROUP);
208+
_issuesHelper.createNewIssuesList("tickets", _containerHelper);
196209
}
197210

198211
@Before
@@ -834,7 +847,32 @@ public void relatedIssueTest()
834847
.clickSubMenu(false, "Hide related comments");
835848
assertElementNotVisible(related);
836849

837-
// NOTE: still need to test for case where user doesn't have permission to related issue...
850+
// related issue permission tests
851+
Locator commentLocator = Locator.name("related");
852+
goToProjectHome(CLIENT_PORTAL);
853+
waitAndClickAndWait(Locator.linkContainingText(ISSUE_SUMMARY_WEBPART_NAME));
854+
String clientIssueId = _issuesHelper.addIssue(Maps.of("assignedTo", NAME, "title", "Client ticket", "priority", "3", "related", issueIdA)).getIssueId();
855+
856+
// impersonate a user without permissions to the related issues
857+
impersonate(CLIENT_USER1);
858+
clickAndWait(Locator.linkWithText("Issues List"));
859+
clickAndWait(Locator.linkWithText(clientIssueId));
860+
updateIssue();
861+
setFormElement(Locator.name("comment"), "This should work");
862+
clickButton("Save");
863+
864+
// try to add related issue they don't have permission to see
865+
updateIssue();
866+
setFormElement(relatedLocator, String.format("%s,%s", issueIdA, issueIdB));
867+
clickButton("Save");
868+
assertTextPresent("User does not have Read Permission for related issue");
869+
870+
// Issue 53820 try to remove a related issue they don't have permission to see
871+
setFormElement(relatedLocator, "");
872+
clickButton("Save");
873+
assertTextPresent(String.format("User does not have Read Permission for related issue '%s'", issueIdA));
874+
clickButton("Cancel");
875+
stopImpersonating();
838876
}
839877

840878
@Test

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
import static org.apache.commons.lang3.StringUtils.trimToNull;
2525

2626
/**
27-
* Base test class for tests that setup data and configure a server then verify the persistence or modification of those
28-
* data and configurations after upgrading to a newer version of LabKey.<br>
29-
* The {@code EariestVersion} and {@code LatestVersion} annotations can be used to skip particular tests when they are
27+
* Base test class for tests that set up data and configure a server, then verify the persistence or modification of
28+
* those data and configurations after upgrading to a newer version of LabKey.<br>
29+
* The {@link EarliestVersion} and {@link LatestVersion} annotations can be used to skip particular tests when they are
3030
* not relevant to the version of LabKey being upgraded from (specified in the {@code webtest.upgradePreviousVersion}
3131
* system property).<br>
3232
* The setup steps will be skipped if the {@code webtest.upgradeSetup} system property is set to {@code false}.
@@ -77,7 +77,8 @@ public List<String> getAssociatedModules()
7777
*/
7878
@Retention(RetentionPolicy.RUNTIME)
7979
@Target({ElementType.METHOD})
80-
protected @interface EariestVersion {
80+
protected @interface EarliestVersion
81+
{
8182
String value();
8283
}
8384

@@ -98,12 +99,12 @@ private static class UpgradeVersionCheck implements TestRule
9899
@Override
99100
public @NotNull Statement apply(Statement base, Description description)
100101
{
101-
String eariestVersion = Optional.ofNullable(description.getAnnotation(EariestVersion.class))
102-
.map(EariestVersion::value).orElse(null);
102+
String earliestVersion = Optional.ofNullable(description.getAnnotation(EarliestVersion.class))
103+
.map(EarliestVersion::value).orElse(null);
103104
String latestVersion = Optional.ofNullable(description.getAnnotation(LatestVersion.class))
104105
.map(LatestVersion::value).orElse(null);
105106

106-
if (isUpgradeSetupPhase || previousVersion == null || (eariestVersion == null && latestVersion == null))
107+
if (isUpgradeSetupPhase || previousVersion == null || (earliestVersion == null && latestVersion == null))
107108
{
108109
return base; // Run the test normally
109110
}
@@ -114,7 +115,7 @@ private static class UpgradeVersionCheck implements TestRule
114115
public void evaluate() throws Throwable
115116
{
116117
Assume.assumeTrue("Test doesn't support upgrading from version: " + previousVersion,
117-
VersionRange.versionRange(eariestVersion, latestVersion).contains(previousVersion)
118+
VersionRange.versionRange(earliestVersion, latestVersion).contains(previousVersion)
118119
);
119120
base.evaluate();
120121
}

0 commit comments

Comments
 (0)