mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-15 13:02:19 +00:00
Merge pull request #3187 from daniel-beck/JENKINS-34254-v2
[JENKINS-34254] Fix RequirePOST form
(cherry picked from commit 76c9f8beac)
This commit is contained in:
1 parent
e0ea7a648e
commit
bed6ccd719
5 files changed
+78
-1
No files matched your search
@@ -8,6 +8,8 @@ package hudson.security.csrf;
|
||||
|
||||
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
||||
import jenkins.model.Jenkins;
|
||||
import junit.framework.Assert;
|
||||
import net.sf.json.JSONObject;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
@@ -135,4 +137,19 @@ public class DefaultCrumbIssuerTest {
|
||||
wc.assertFails("crumbIssuer/api/json?jsonp=hack", HttpURLConnection.HTTP_FORBIDDEN);
|
||||
}
|
||||
|
||||
@Issue("JENKINS-34254")
|
||||
@Test public void testRequirePostErrorPageCrumb() throws Exception {
|
||||
Jenkins.getInstance().setCrumbIssuer(new DefaultCrumbIssuer(false));
|
||||
WebClient wc = r.createWebClient();
|
||||
try {
|
||||
wc.goTo("quietDown");
|
||||
fail("expected failure");
|
||||
} catch (FailingHttpStatusCodeException ex) {
|
||||
Assert.assertEquals("expect HTTP 405 method not allowed", 405, ex.getStatusCode());
|
||||
}
|
||||
HtmlPage retry = (HtmlPage) wc.getCurrentWindow().getEnclosedPage();
|
||||
HtmlPage success = r.submit(retry.getFormByName("retry"));
|
||||
Assert.assertTrue("quieting down", r.jenkins.isQuietingDown());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user