-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from lacostej/SECURITY-1025
Fix SECURITY-1025
- Loading branch information
Showing
6 changed files
with
55 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
src/main/resources/hudson/plugins/batch_task/BatchTask/delete.jelly
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package hudson.plugins.batch_task; | ||
|
||
import org.htmlunit.FailingHttpStatusCodeException; | ||
import org.htmlunit.HttpMethod; | ||
import org.htmlunit.WebRequest; | ||
import org.htmlunit.html.HtmlPage; | ||
import org.jvnet.hudson.test.JenkinsRule; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.is; | ||
import static org.junit.Assert.assertEquals; | ||
|
||
public class TestHelper { | ||
/** | ||
* Performs an HTTP POST request to the relative url. | ||
* | ||
* @param webClient the client | ||
* @param relative the url relative to the context path | ||
* @param expectedContentType if expecting specific content type or null if not | ||
* @param expectedStatus if expecting a http status code or null if not | ||
* @throws IOException if so | ||
*/ | ||
public static HtmlPage assertPost(JenkinsRule.WebClient webClient, String relative, | ||
String expectedContentType, Integer expectedStatus) throws IOException { | ||
WebRequest request = new WebRequest(webClient.createCrumbedUrl(relative), HttpMethod.POST); | ||
try { | ||
HtmlPage p = webClient.getPage(request); | ||
if (expectedContentType != null) { | ||
assertThat(p.getWebResponse().getContentType(), is(expectedContentType)); | ||
} | ||
if (expectedStatus != null) { | ||
assertEquals(expectedStatus.intValue(), p.getWebResponse().getStatusCode()); | ||
} | ||
return p; | ||
} catch (FailingHttpStatusCodeException e) { | ||
if (expectedStatus != null) { | ||
assertEquals(expectedStatus.intValue(), e.getStatusCode()); | ||
return null; | ||
} else { | ||
throw e; | ||
} | ||
} | ||
} | ||
} |