diff --git a/src/org/labkey/test/tests/AdminConsoleNavigationTest.java b/src/org/labkey/test/tests/AdminConsoleNavigationTest.java index 5e3e5e20cd..0becdfcc6f 100644 --- a/src/org/labkey/test/tests/AdminConsoleNavigationTest.java +++ b/src/org/labkey/test/tests/AdminConsoleNavigationTest.java @@ -1,5 +1,6 @@ package org.labkey.test.tests; +import org.assertj.core.api.Assertions; import org.jetbrains.annotations.Nullable; import org.junit.Assert; import org.junit.BeforeClass; @@ -86,6 +87,7 @@ public void testAdminNavTrails() { linkHrefs.put(link.getText(), link.getAttribute("href")); } + Assertions.assertThat(linkHrefs.keySet()).as("Expected links").containsAll(ignoredLinks); List pagesMissingNavTrail = new ArrayList<>(); @@ -121,6 +123,7 @@ public void testTroubleshooterLinkAccess() impersonate(TROUBLESHOOTER); Map linkHrefs = new LinkedHashMap<>(); List troubleshooterLinks = adminConsole.getAllAdminConsoleLinks(); + assertTrue(String.format("Failed sanity check. Only found %s admin links. There should be more.", troubleshooterLinks.size()), troubleshooterLinks.size() > 10); for (WebElement link : troubleshooterLinks) linkHrefs.put(link.getText(), link.getAttribute("href")); @@ -155,6 +158,7 @@ public void testAdminConsoleLinksForAdminAndNonAdmin() )); ShowAdminPage adminConsole = goToAdminConsole(); List adminLinks = adminConsole.getAllAdminConsoleLinks(); + assertTrue(String.format("Failed sanity check. Only found %s admin links. There should be more.", adminLinks.size()), adminLinks.size() > 10); Map linkHrefs = new LinkedHashMap<>(); for (WebElement link : adminLinks) linkHrefs.put(link.getText(), link.getAttribute("href")); diff --git a/src/org/labkey/test/tests/CrawlerTest.java b/src/org/labkey/test/tests/CrawlerTest.java index bc10407e81..520cd86a7a 100644 --- a/src/org/labkey/test/tests/CrawlerTest.java +++ b/src/org/labkey/test/tests/CrawlerTest.java @@ -1,11 +1,13 @@ package org.labkey.test.tests; +import org.assertj.core.api.Assertions; import org.junit.After; import org.junit.Assert; import org.junit.Assume; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.labkey.remoteapi.SimpleGetCommand; import org.labkey.test.BaseWebDriverTest; import org.labkey.test.Locator; import org.labkey.test.Locators; @@ -117,18 +119,25 @@ public void testEnforceCsp() throws Exception beginAt(getInjectUrl(Crawler.injectScriptBlock), 10_000); log("Verify that enforced CSP is also reported"); - CspLogUtil.checkNewCspWarnings(getArtifactCollector()); + CspLogUtil.checkNewCspWarnings(getArtifactCollector()); // throws CspWarningDetectedException } @Test (expected = CspLogUtil.CspWarningDetectedException.class) - public void testCspWarning() + public void testCspWarning() throws Exception { Assume.assumeFalse("Can't test for CSP report", TestProperties.isCspCheckSkipped()); _cspConfigHelper.setEnforceCsp(false); - beginAt(WebTestHelper.buildRelativeUrl(MODULE_NAME, getProjectName(), "cspWarning")); - CspLogUtil.checkNewCspWarnings(getArtifactCollector()); + int initialLength = getCspReportLog().length(); + + String cspWarningUrl = WebTestHelper.buildRelativeUrl(MODULE_NAME, getProjectName(), "cspWarning"); + beginAt(cspWarningUrl); + + // 53261: Provide visibility into CSP reports for cloud clients + Assertions.assertThat(getCspReportLog().substring(initialLength)).as("CSP warning").contains(cspWarningUrl); + + CspLogUtil.checkNewCspWarnings(getArtifactCollector()); // throws CspWarningDetectedException } // Crawler should flag external links without the correct 'rel' attribute @@ -188,6 +197,13 @@ protected boolean cspFailFast() return false; } + public String getCspReportLog() throws Exception + { + return new SimpleGetCommand("admin", "showCspReportLog") + .execute(createDefaultConnection(), null) + .getText(); + } + @After public void postTest() {