Skip to content

Commit 358f583

Browse files
Reproducer test for JENKINS-76353
1 parent ce989fa commit 358f583

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ THE SOFTWARE.
132132
<artifactId>workflow-job</artifactId>
133133
<scope>test</scope>
134134
</dependency>
135+
<dependency>
136+
<groupId>org.wiremock</groupId>
137+
<artifactId>wiremock-standalone</artifactId>
138+
<version>3.13.1</version>
139+
</dependency>
135140
</dependencies>
136141

137142
<scm>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package jenkins.plugins.http_request;
2+
3+
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
4+
import static com.github.tomakehurst.wiremock.client.WireMock.get;
5+
import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching;
6+
7+
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
8+
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
9+
import org.junit.jupiter.api.BeforeEach;
10+
import org.junit.jupiter.api.Test;
11+
import org.junit.jupiter.api.extension.RegisterExtension;
12+
import org.jvnet.hudson.test.Issue;
13+
import org.jvnet.hudson.test.JenkinsRule;
14+
import org.jvnet.hudson.test.junit.jupiter.WithJenkins;
15+
16+
import com.github.tomakehurst.wiremock.junit5.WireMockExtension;
17+
18+
@WithJenkins
19+
class HttpRequestPluginTest {
20+
21+
@RegisterExtension
22+
private static final WireMockExtension WIRE_MOCK_EXTENSION = WireMockExtension.newInstance().build();
23+
24+
private JenkinsRule r;
25+
26+
@BeforeEach
27+
void beforeEach(JenkinsRule rule) {
28+
r = rule;
29+
}
30+
31+
@Test
32+
@Issue("JENKINS-76353")
33+
void test() throws Exception {
34+
String payload = "Some Random String";
35+
36+
WIRE_MOCK_EXTENSION.stubFor(get(urlMatching("/JENKINS-76353"))
37+
.willReturn(aResponse()
38+
.withStatus(200)
39+
.withStatusMessage("OK")
40+
.withHeader("date", "Fri, 23 Jan 2026 15:30:38 GMT")
41+
.withHeader("vary", "Accept-Encoding")
42+
.withHeader("content-disposition", "attachment; filename=\"file.txt\"; size=" + payload.length())
43+
.withHeader("etag", "\"a21bcba577f439d703fbe1561f77213bedf7a019616fae65d9a76d2b3687773b\"")
44+
.withHeader("content-encoding", "none")
45+
.withHeader("content-type", "application/octet-stream")
46+
.withHeader("cache-control", "no-store, no-cache")
47+
.withHeader("pragma", "no-cache")
48+
.withHeader("content-length", String.valueOf(payload.length()))
49+
.withHeader("strict-transport-security", "max-age=31536000;includeSubDomains")
50+
.withBody(payload)
51+
));
52+
53+
WorkflowJob project = r.createProject(WorkflowJob.class);
54+
project.setDefinition(new CpsFlowDefinition(
55+
"""
56+
httpRequest(
57+
url: "%s/JENKINS-76353"
58+
)
59+
""".formatted(WIRE_MOCK_EXTENSION.baseUrl()),
60+
true));
61+
r.assertBuildStatusSuccess(project.scheduleBuild2(0));
62+
}
63+
}

0 commit comments

Comments
 (0)