Skip to content
Permalink
Browse files

[JENKINS-34254] Add test

  • Loading branch information...
daniel-beck committed Dec 15, 2017
1 parent 3c695a3 commit f0efdbab087ea26342a034da198d055bd7141b8a
@@ -34,7 +34,7 @@ THE SOFTWARE.
</p>
<p><tt>${requestURL}</tt></p>
<p><strong>${%warning}</strong></p>
<f:form method="post">
<f:form method="post" name="retry">
<f:submit value="${%Retry using POST}"/>
</f:form>
</l:main-panel>
@@ -8,6 +8,8 @@

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 @@
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());
}

}

0 comments on commit f0efdba

Please sign in to comment.
You can’t perform that action at this time.