22
33import static org .hamcrest .MatcherAssert .assertThat ;
44import static org .hamcrest .Matchers .containsString ;
5+ import static org .hamcrest .Matchers .not ;
56
67import jakarta .servlet .ServletRequest ;
78import org .htmlunit .html .HtmlPage ;
@@ -22,16 +23,16 @@ void setUp(JenkinsRule rule) {
2223 }
2324
2425 @ Test
25- void csrfSectionShownWhenOnlyDefaultIssuerAvailable () throws Exception {
26+ void csrfSectionHiddenWhenOnlyDefaultIssuerAvailable () throws Exception {
2627 // No @TestExtension here, so only DefaultCrumbIssuer is registered
2728 j .jenkins .setCrumbIssuer (new DefaultCrumbIssuer (false ));
2829
2930 JenkinsRule .WebClient wc = j .createWebClient ();
3031 HtmlPage page = wc .goTo ("configureSecurity" );
3132 String pageContent = page .asNormalizedText ();
3233
33- // When only DefaultCrumbIssuer exists, the CSRF section should still be visible
34- assertThat (pageContent , containsString ("Default Crumb Issuer" ));
34+ // When only DefaultCrumbIssuer exists, the CSRF section should be HIDDEN
35+ assertThat (pageContent , not ( containsString ("Dummy Crumb Issuer" ) ));
3536 }
3637
3738 @ Test
@@ -46,7 +47,7 @@ void csrfSectionShownWhenNonDefaultIssuerConfigured() throws Exception {
4647
4748 // With multiple CrumbIssuer descriptors available (from test extensions),
4849 // the CSRF Protection section should always be shown
49- assertThat (pageContent , containsString ("Default Crumb Issuer" ));
50+ assertThat (pageContent , containsString ("Crumb Issuer" ));
5051 }
5152
5253 @ Test
@@ -59,7 +60,7 @@ void csrfSectionShownWhenCsrfProtectionDisabled() throws Exception {
5960 HtmlPage page = wc .goTo ("configureSecurity" );
6061 String pageContent = page .asNormalizedText ();
6162
62- assertThat (pageContent , containsString ("This configuration is unavailable because the System property " ));
63+ assertThat (pageContent , containsString ("This configuration is unavailable because" ));
6364 } finally {
6465 GlobalCrumbIssuerConfiguration .DISABLE_CSRF_PROTECTION = original ;
6566 }
0 commit comments