use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class AdminApiTest method returnsBadEntityStatusWhenInvalidRegexUsedInHeader.
@Test
public void returnsBadEntityStatusWhenInvalidRegexUsedInHeader() {
WireMockResponse response = testClient.postJson("/__admin/mappings", "{\n" + " \"request\": {\n" + " \"headers\": {\n" + " \"Accept\": {\n" + " \"matches\": \"%[[json[[\"\n" + " }\n" + " }\n" + " }\n" + "}");
assertThat(response.statusCode(), is(422));
Errors errors = Json.read(response.content(), Errors.class);
assertThat(errors.first().getDetail(), equalsMultiLine("Unclosed character class near index 8\n" + "%[[json[[\n" + " ^"));
assertThat(errors.first().getSource().getPointer(), is("/request/headers/Accept"));
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class BasicAuthAcceptanceTest method doesNotMatchPreemptiveBasicAuthWhenCredentialsAreIncorrect.
@Test
public void doesNotMatchPreemptiveBasicAuthWhenCredentialsAreIncorrect() {
stubFor(get(urlEqualTo("/basic/auth/preemptive")).withBasicAuth("the-username", "thepassword").willReturn(aResponse().withStatus(200)));
WireMockResponse response = testClient.getWithPreemptiveCredentials("/basic/auth/preemptive", wireMockServer.port(), "the-username", "WRONG!!!");
assertThat(response.statusCode(), is(404));
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class CookieMatchingAcceptanceTest method matchesOnWellFormedCookie.
@Test
public void matchesOnWellFormedCookie() {
stubFor(get(urlEqualTo("/good/cookie")).withCookie("my_cookie", containing("mycookievalue")).willReturn(aResponse().withStatus(200)));
WireMockResponse response = testClient.get("/good/cookie", withHeader(COOKIE, "my_cookie=xxx-mycookievalue-xxx"));
assertThat(response.statusCode(), is(200));
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class CookieMatchingAcceptanceTest method doesNotMatchWhenExpectedCookieHasTheWrongValue.
@Test
public void doesNotMatchWhenExpectedCookieHasTheWrongValue() {
stubFor(get(urlEqualTo("/bad/cookie")).withCookie("my_cookie", containing("mycookievalue")).willReturn(aResponse().withStatus(200)));
WireMockResponse response = testClient.get("/bad/cookie", withHeader(COOKIE, "my_cookie=youwontfindthis"));
assertThat(response.statusCode(), is(404));
}
use of com.github.tomakehurst.wiremock.testsupport.WireMockResponse in project wiremock by wiremock.
the class CookieMatchingAcceptanceTest method doesNotMatchWhenExpectedCookieIsAbsent.
@Test
public void doesNotMatchWhenExpectedCookieIsAbsent() {
stubFor(get(urlEqualTo("/missing/cookie")).withCookie("my_cookie", containing("mycookievalue")).willReturn(aResponse().withStatus(200)));
WireMockResponse response = testClient.get("/missing/cookie", withHeader(COOKIE, "the_wrong_cookie=xxx-mycookievalue-xxx"));
assertThat(response.statusCode(), is(404));
}
Aggregations