From 4a2f35ed556f867bc6800ebda8bcefe6a020cbcb Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Tue, 23 Jan 2024 10:01:30 -0800 Subject: [PATCH 1/2] Fix container path mismatches --- .../security/GetReadableContainersAPITest.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/org/labkey/test/tests/core/security/GetReadableContainersAPITest.java b/src/org/labkey/test/tests/core/security/GetReadableContainersAPITest.java index 59018784dc..3532340428 100644 --- a/src/org/labkey/test/tests/core/security/GetReadableContainersAPITest.java +++ b/src/org/labkey/test/tests/core/security/GetReadableContainersAPITest.java @@ -95,8 +95,8 @@ public void testUnreadableStartingContainer() public void testUnlimitedDepth() { impersonate(USER); - Set expectedFolders = getExpectedFolders("/", 10, false); - Set readableContainers = getReadableContainers(true, -1, "/"); + Set expectedFolders = getExpectedFolders("", 10, false); + Set readableContainers = getReadableContainers(true, -1, ""); assertEquals("Depth '-1' should be treated as unlimited'", expectedFolders, readableContainers); } @@ -105,8 +105,8 @@ public void testUnlimitedDepth() public void testCustomDepth() { impersonate(USER); - Set expectedFolders = getExpectedFolders("/", 2, false); - Set readableContainers = getReadableContainers(true, 2, "/"); + Set expectedFolders = getExpectedFolders("", 2, false); + Set readableContainers = getReadableContainers(true, 2, ""); assertEquals("Custom listing depth should be respected", expectedFolders, readableContainers); } @@ -138,8 +138,8 @@ public void testStartingContainerById() throws Exception @Test public void testSiteAdminSeesAll() { - Set expectedFolders = getExpectedFolders("/", 10, true); - Set readableContainers = getReadableContainers(true, -1, "/"); + Set expectedFolders = getExpectedFolders("", 10, true); + Set readableContainers = getReadableContainers(true, -1, ""); assertEquals("Site admin should see all containers", expectedFolders, readableContainers); } @@ -151,7 +151,7 @@ private Set getExpectedFolders(String container, int absoluteDepth, bool (info.isReadable() || includeUnreadable) && info.getAbsoluteDepth() <= absoluteDepth && info.getPath().startsWith(container)) - .map(ContainerInfo::getPath) + .map(containerInfo -> "/" + containerInfo.getPath()) .collect(Collectors.toSet()); } From 13cd028e34ffc62793a8fd6ba6af538e6cc7e5a6 Mon Sep 17 00:00:00 2001 From: labkey-tchad Date: Tue, 23 Jan 2024 10:38:04 -0800 Subject: [PATCH 2/2] Fix container path mismatches (better) --- .../GetReadableContainersAPITest.java | 20 +++++++++---------- .../labkey/test/util/APIContainerHelper.java | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/org/labkey/test/tests/core/security/GetReadableContainersAPITest.java b/src/org/labkey/test/tests/core/security/GetReadableContainersAPITest.java index 3532340428..c3ebebd47b 100644 --- a/src/org/labkey/test/tests/core/security/GetReadableContainersAPITest.java +++ b/src/org/labkey/test/tests/core/security/GetReadableContainersAPITest.java @@ -23,7 +23,7 @@ @Category({Daily.class}) public class GetReadableContainersAPITest extends BaseWebDriverTest { - private static final String PROJECT_PREFIX = "GetReadableContainersAPITest"; + private static final String PROJECT_PREFIX = "/GetReadableContainersAPITest"; private static final String READABLE_PROJECT = PROJECT_PREFIX + " Readable"; private static final String UNREADABLE_PROJECT = PROJECT_PREFIX + " Unreadable"; private static final String USER = "reader@containersapi.test"; @@ -95,8 +95,8 @@ public void testUnreadableStartingContainer() public void testUnlimitedDepth() { impersonate(USER); - Set expectedFolders = getExpectedFolders("", 10, false); - Set readableContainers = getReadableContainers(true, -1, ""); + Set expectedFolders = getExpectedFolders("/", 10, false); + Set readableContainers = getReadableContainers(true, -1, "/"); assertEquals("Depth '-1' should be treated as unlimited'", expectedFolders, readableContainers); } @@ -105,8 +105,8 @@ public void testUnlimitedDepth() public void testCustomDepth() { impersonate(USER); - Set expectedFolders = getExpectedFolders("", 2, false); - Set readableContainers = getReadableContainers(true, 2, ""); + Set expectedFolders = getExpectedFolders("/", 2, false); + Set readableContainers = getReadableContainers(true, 2, "/"); assertEquals("Custom listing depth should be respected", expectedFolders, readableContainers); } @@ -138,8 +138,8 @@ public void testStartingContainerById() throws Exception @Test public void testSiteAdminSeesAll() { - Set expectedFolders = getExpectedFolders("", 10, true); - Set readableContainers = getReadableContainers(true, -1, ""); + Set expectedFolders = getExpectedFolders("/", 10, true); + Set readableContainers = getReadableContainers(true, -1, "/"); assertEquals("Site admin should see all containers", expectedFolders, readableContainers); } @@ -151,7 +151,7 @@ private Set getExpectedFolders(String container, int absoluteDepth, bool (info.isReadable() || includeUnreadable) && info.getAbsoluteDepth() <= absoluteDepth && info.getPath().startsWith(container)) - .map(containerInfo -> "/" + containerInfo.getPath()) + .map(ContainerInfo::getPath) .collect(Collectors.toSet()); } @@ -190,7 +190,7 @@ private String getPathToFolder(boolean projectReadable, boolean... foldersReadab private Set getReadableContainers(Boolean includeSubfolders, Integer depth, Object container) { List response = executeGetReadableContainers(includeSubfolders, depth, container, List.class); - return response.stream().filter(path -> path.startsWith("/" + PROJECT_PREFIX)).collect(Collectors.toSet()); + return response.stream().filter(path -> path.startsWith(PROJECT_PREFIX)).collect(Collectors.toSet()); } private List> getReadableContainersErrors(Boolean includeSubfolders, Integer depth, Object container) @@ -214,7 +214,7 @@ private T executeGetReadableContainers(Boolean includeSubfolders, Integer de if (depth != null) config.put("depth", depth); if (container != null) - config.put("container", "/" + container); + config.put("container", container); String script = "var config = arguments[0];\n" + "config.success = callback;\n" + diff --git a/src/org/labkey/test/util/APIContainerHelper.java b/src/org/labkey/test/util/APIContainerHelper.java index dce63e831d..676e4b4cc9 100644 --- a/src/org/labkey/test/util/APIContainerHelper.java +++ b/src/org/labkey/test/util/APIContainerHelper.java @@ -126,7 +126,7 @@ else if (parentPath.equals("/")) @Override protected void doDeleteProject(String projectName, boolean failIfNotFound, int wait) throws TestTimeoutException { - deleteContainer("/" + projectName, failIfNotFound, wait); + deleteContainer(projectName, failIfNotFound, wait); } @Override