Hide CSRF configuration UI when only DefaultCrumbIssuer is available#26057
Hide CSRF configuration UI when only DefaultCrumbIssuer is available#26057AmoghParmar wants to merge 8 commits intojenkinsci:masterfrom
Conversation
|
Yay, your first pull request towards Jenkins core was created successfully! Thank you so much! |
|
Kinda rude to just take an already assigned issue.
Time to add a new test then. Also, please add screenshots of steps 3 and 4. We've recently had an influx of PRs whose submitters made claims that were untrue, so evidence that you actually did these steps would be nice. |
|
@daniel-beck @MarkEWaite |
This change looks reasonable as implemented. Otherwise I'm still waiting for
|
Thanks for the review and confirmation that the change itself looks good. I did attempt to add automated coverage, but I’m running into non-trivial Jenkins core test harness issues for this UI/DOM-behavior change (locale-dependent, generated IDs). Before continuing further, could you please advise what kind of automated coverage would be preferred here? For example, would a focused unit test around ID generation be sufficient, or is a higher-level UI test expected? Happy to follow the recommended approach. |
|
JenkinsRule tests are always the same locale, so whatever you're doing is probably wrong. |
|
Hello @daniel-beck |
72fa34f to
25af895
Compare
…criptor in test environment
Thanks a lot, @daniel-beck. I had forgotten to include the @TestExtension class in the previous revision. I’ve now added the DummyCrumbIssuer test extension so that an additional CrumbIssuer descriptor is available during the test execution, and confirmed that the test passes locally. Apologies as well for the rebase/force push. I understand that it makes the review history harder to follow. I won’t rewrite history on this PR further and will keep future updates incremental. Please let me know if anything else should be adjusted. |
| } | ||
| } | ||
|
|
||
| @TestExtension |
There was a problem hiding this comment.
Limit to #csrfSectionShownWhenNonDefaultIssuerConfigured otherwise #csrfSectionShownWhenCsrfProtectionDisabled is unconvincing. I expect that would pass even if you never set the flag.
| assertThat("CSRF section should be shown when CSRF protection is disabled", | ||
| pageContent, containsString("CSRF Protection")); |
There was a problem hiding this comment.
Should specifically assert the placeholder message, see other comment.
| } | ||
| } | ||
| } | ||
| } No newline at end of file |
daniel-beck
left a comment
There was a problem hiding this comment.
Please also add a test for the default case to ensure that behavior doesn't regress.
| HtmlPage page = wc.goTo("configureSecurity"); | ||
| String pageContent = page.asNormalizedText(); | ||
|
|
||
| // When only DefaultCrumbIssuer exists, the CSRF section should still be visible |
There was a problem hiding this comment.
Sorry @daniel-beck for the confusion.. The comment was misleading ..
I'm fixing the test now to correctly assert that the CSRF section
is hidden when only DefaultCrumbIssuer is available.



Fixes #26012
Testing done
This change was manually verified by running Jenkins locally from source.
Steps:
fix-26012-hide-csrf-uibranch.DefaultCrumbIssueris available, the CSRF Protection section is not rendered.No automated test was added because this change affects a Groovy UI configuration file, and existing test coverage for this specific UI condition is not present.
Screenshots (UI changes only)
Before
CSRF Protection section was always visible even when only DefaultCrumbIssuer was available.

After
CSRF Protection section is hidden when only DefaultCrumbIssuer is available.

Proposed changelog entries
Proposed changelog category
/label rfe,web-ui
Proposed upgrade guidelines
N/A
Submitter checklist
@Restrictedor have@sinceJavadocs, as appropriate.Desired reviewers
@jenkinsci/core-pr-reviewers