File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
test/src/test/java/hudson/security/csrf Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 33import static org .hamcrest .MatcherAssert .assertThat ;
44import static org .hamcrest .Matchers .containsString ;
55
6+ import jakarta .servlet .ServletRequest ;
67import org .htmlunit .html .HtmlPage ;
78import org .junit .jupiter .api .BeforeEach ;
89import org .junit .jupiter .api .Test ;
910import org .jvnet .hudson .test .JenkinsRule ;
11+ import org .jvnet .hudson .test .TestExtension ;
1012import org .jvnet .hudson .test .junit .jupiter .WithJenkins ;
1113
1214@ WithJenkins
@@ -51,4 +53,33 @@ void csrfSectionShownWhenCsrfProtectionDisabled() throws Exception {
5153 GlobalCrumbIssuerConfiguration .DISABLE_CSRF_PROTECTION = original ;
5254 }
5355 }
56+
57+ @ TestExtension
58+ public static class DummyCrumbIssuer extends CrumbIssuer {
59+
60+ @ Override
61+ public String getCrumbRequestField () {
62+ return "dummy" ;
63+ }
64+
65+ @ Override
66+ public String issueCrumb (ServletRequest request , String salt ) {
67+ return "dummy-crumb" ;
68+ }
69+
70+ public static class DescriptorImpl extends CrumbIssuerDescriptor <DummyCrumbIssuer > {
71+
72+ DescriptorImpl () {
73+ super (
74+ DummyCrumbIssuer .class .getName (),
75+ "Dummy Crumb Issuer"
76+ );
77+ }
78+
79+ @ Override
80+ public String getDisplayName () {
81+ return "Dummy Crumb Issuer" ;
82+ }
83+ }
84+ }
5485}
You can’t perform that action at this time.
0 commit comments