1313import org .labkey .test .util .CspLogUtil ;
1414import org .labkey .test .util .TextSearcher ;
1515import org .labkey .test .util .WikiHelper ;
16+ import org .labkey .test .util .core .admin .CspConfigHelper ;
1617
1718import java .util .Arrays ;
1819import java .util .List ;
2122@ BaseWebDriverTest .ClassTimeout (minutes = 2 )
2223public class WikiCspTest extends BaseWebDriverTest
2324{
24- private static final String PROJECT_NAME = TRICKY_CHARACTERS_FOR_PROJECT_NAMES + "WikiCspTest" ;
25+ private static final String PROJECT_NAME = TRICKY_CHARACTERS_FOR_PROJECT_NAMES ;
2526 private static final String WIKI_PAGE_TITLE = "TOC_with_inline" ;
2627 private static final String WIKI_PAGE_BODY =
2728 // Issue 52483: HTML substitution patterns can throw errors during wiki validation
@@ -53,6 +54,17 @@ private void doSetup()
5354 _containerHelper .createProject (PROJECT_NAME , null );
5455 _containerHelper .enableModules (Arrays .asList ("Wiki" ));
5556 goToProjectHome ();
57+ CspConfigHelper .debugCspWarnings (); // Ensure that CSP violation logs aren't suppressed by de-duping efforts
58+ }
59+
60+ @ Override
61+ protected void doCleanup (boolean afterTest )
62+ {
63+ super .doCleanup (afterTest );
64+ if (afterTest )
65+ {
66+ CspConfigHelper .infoCspWarnings ();
67+ }
5668 }
5769
5870 @ Override
@@ -76,13 +88,18 @@ public void testCspChecks()
7688
7789 waitForText ("Click me" );
7890
79- try
91+ waitFor (() ->
8092 {
81- CspLogUtil .checkNewCspWarnings (getArtifactCollector ());
82- }
83- catch (CspLogUtil .CspWarningDetectedException ignore ) {}
84-
85- goToAdminConsole ().goToSettingsSection ();
93+ try
94+ {
95+ CspLogUtil .checkNewCspWarnings (getArtifactCollector ());
96+ return false ;
97+ }
98+ catch (CspLogUtil .CspWarningDetectedException ignore )
99+ {
100+ return true ;
101+ }
102+ }, "Should have triggered a CSP error" , WAIT_FOR_PAGE );
86103
87104 SiteValidationPage validationPage = goToAdminConsole ().clickSiteValidation ();
88105 validationPage .setAllValidators (false );
0 commit comments