use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class RequestFilterAcceptanceTest method filterCanStopWithResponse.
@Test
public void filterCanStopWithResponse() {
initialise(new StubAuthenticatingFilter());
wm.stubFor(get(url).willReturn(ok()));
WireMockResponse good = client.get(url, withHeader("Authorization", "Token 123"));
assertThat(good.statusCode(), is(200));
WireMockResponse bad = client.get(url);
assertThat(bad.statusCode(), is(401));
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class RequestFilterAcceptanceTest method filterCanContinueWithModifiedRequest.
@Test
public void filterCanContinueWithModifiedRequest() {
initialise(new RequestHeaderModifyingFilter());
wm.stubFor(get(url).withHeader("X-Modify-Me", equalTo("modified")).willReturn(ok()));
WireMockResponse response = client.get(url, withHeader("X-Modify-Me", "original"));
assertThat(response.statusCode(), is(200));
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class RequestFilterAcceptanceTest method filterCanBeAppliedToStubsAndAdmin.
@Test
public void filterCanBeAppliedToStubsAndAdmin() {
initialise(new BothAuthenticatingFilter());
wm.stubFor(get(url).willReturn(ok()));
String adminUrl = "/__admin/mappings";
WireMockResponse stub = client.get(url);
assertThat(stub.statusCode(), is(401));
WireMockResponse admin = client.get(adminUrl);
assertThat(admin.statusCode(), is(401));
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class RequestFilterAcceptanceTest method filtersAreChained.
@Test
public void filtersAreChained() {
initialise(new RequestHeaderAppendingFilter("A"), new RequestHeaderAppendingFilter("B"), new RequestHeaderAppendingFilter("C"));
wm.stubFor(get(url).withHeader("X-Modify-Me", matching("_[ABC]{3}")).willReturn(ok()));
WireMockResponse response = client.get(url, withHeader("X-Modify-Me", "_"));
assertThat(response.statusCode(), is(200));
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class ResponseDefinitionTransformerAcceptanceTest method doesNotApplyNonGlobalExtensionsWhenNotExplicitlySpecfiedByStub.
@Test
public void doesNotApplyNonGlobalExtensionsWhenNotExplicitlySpecfiedByStub() {
wm = new WireMockServer(wireMockConfig().dynamicPort().extensions(new ExampleTransformer(), new NonGlobalTransformer()));
wm.start();
client = new WireMockTestClient(wm.port());
createStub("/non-global-transform");
WireMockResponse response = client.get("/non-global-transform");
assertThat(response.content(), is("Transformed body"));
}
Aggregations