Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[JENKINS-25637] test that a crumb is not required
  • Loading branch information
ydubreuil committed Apr 26, 2016
1 parent a0b99f9 commit a1a621d
Showing 1 changed file with 20 additions and 0 deletions.
Expand Up @@ -42,6 +42,8 @@
import java.util.logging.Logger;
import jenkins.model.ParameterizedJobMixIn;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.methods.PostMethod;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import static org.junit.Assert.*;
Expand Down Expand Up @@ -133,4 +135,22 @@ private void assertCreated(Page page) throws Exception {
// TODO test polling
// TODO test projects in folders

@Issue("JENKINS-25637")
@PresetData(PresetData.DataSet.NO_ANONYMOUS_READACCESS)
@Test public void testCrumbBypass() throws Exception {
FreeStyleProject p = j.createFreeStyleProject("p");
setAuthToken(p);

HttpClient client = new HttpClient();

PostMethod post = new PostMethod(j.jenkins.getRootUrl() + "buildByToken/build");
post.addParameter("job", p.getFullName());
post.addParameter("token", "secret");
post.addParameter("delay", "0sec");
client.executeMethod(post);
assertEquals(post.getStatusLine().getReasonPhrase(), 201, post.getStatusCode());

j.waitUntilNoActivity();
assertEquals(1, p.getBuilds().size());
}
}

0 comments on commit a1a621d

Please sign in to comment.