Skip to content

Commit

Permalink
[FIXED JENKINS-16918] Use HTTP 405 when POST is required.
Browse files Browse the repository at this point in the history
(cherry picked from commit ec9d809)

Conflicts:
	changelog.html
  • Loading branch information
jglick authored and olivergondza committed Sep 16, 2013
1 parent f664639 commit d7e3702
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions core/src/main/java/hudson/model/BuildAuthorizationToken.java
Expand Up @@ -31,6 +31,7 @@
import org.kohsuke.stapler.StaplerResponse;

import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import jenkins.security.ApiTokenProperty;
import org.acegisecurity.AccessDeniedException;
import org.kohsuke.stapler.HttpResponses;
Expand Down Expand Up @@ -84,6 +85,8 @@ public static void checkPermission(AbstractProject project, BuildAuthorizationTo
return;
}

rsp.setStatus(HttpServletResponse.SC_METHOD_NOT_ALLOWED);
rsp.addHeader("Allow", "POST");
throw HttpResponses.forwardToView(project, "requirePOST.jelly");
}

Expand Down
2 changes: 1 addition & 1 deletion test/src/test/java/jenkins/model/JenkinsTest.java
Expand Up @@ -262,7 +262,7 @@ public void testDoEval() throws Exception {
jenkins.setCrumbIssuer(null);
WebClient wc = createWebClient();
wc.login("alice");
wc.assertFails("eval", HttpURLConnection.HTTP_INTERNAL_ERROR);
wc.assertFails("eval", HttpURLConnection.HTTP_BAD_METHOD);
assertEquals("3", eval(wc));
wc.login("bob");
try {
Expand Down

0 comments on commit d7e3702

Please sign in to comment.