Skip to content

Commit

Permalink
Fix container path mismatches (better)
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-tchad committed Jan 23, 2024
1 parent 4a2f35e commit 13cd028
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "[email protected]";
Expand Down Expand Up @@ -95,8 +95,8 @@ public void testUnreadableStartingContainer()
public void testUnlimitedDepth()
{
impersonate(USER);
Set<String> expectedFolders = getExpectedFolders("", 10, false);
Set<String> readableContainers = getReadableContainers(true, -1, "");
Set<String> expectedFolders = getExpectedFolders("/", 10, false);
Set<String> readableContainers = getReadableContainers(true, -1, "/");

assertEquals("Depth '-1' should be treated as unlimited'", expectedFolders, readableContainers);
}
Expand All @@ -105,8 +105,8 @@ public void testUnlimitedDepth()
public void testCustomDepth()
{
impersonate(USER);
Set<String> expectedFolders = getExpectedFolders("", 2, false);
Set<String> readableContainers = getReadableContainers(true, 2, "");
Set<String> expectedFolders = getExpectedFolders("/", 2, false);
Set<String> readableContainers = getReadableContainers(true, 2, "/");

assertEquals("Custom listing depth should be respected", expectedFolders, readableContainers);
}
Expand Down Expand Up @@ -138,8 +138,8 @@ public void testStartingContainerById() throws Exception
@Test
public void testSiteAdminSeesAll()
{
Set<String> expectedFolders = getExpectedFolders("", 10, true);
Set<String> readableContainers = getReadableContainers(true, -1, "");
Set<String> expectedFolders = getExpectedFolders("/", 10, true);
Set<String> readableContainers = getReadableContainers(true, -1, "/");

assertEquals("Site admin should see all containers", expectedFolders, readableContainers);
}
Expand All @@ -151,7 +151,7 @@ private Set<String> 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());
}

Expand Down Expand Up @@ -190,7 +190,7 @@ private String getPathToFolder(boolean projectReadable, boolean... foldersReadab
private Set<String> getReadableContainers(Boolean includeSubfolders, Integer depth, Object container)
{
List<String> 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<Map<String, String>> getReadableContainersErrors(Boolean includeSubfolders, Integer depth, Object container)
Expand All @@ -214,7 +214,7 @@ private <T> 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" +
Expand Down
2 changes: 1 addition & 1 deletion src/org/labkey/test/util/APIContainerHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 13cd028

Please sign in to comment.