Search in sources :

Example 31 with WireMockTestClient

use of com.github.tomakehurst.wiremock.testsupport.WireMockTestClient in project wiremock by wiremock.

the class AlternativeServletContainerTest method init.

@BeforeEach
public void init() {
    client = new WireMockTestClient(wm.getPort());
    WireMock.configureFor(wm.getPort());
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 32 with WireMockTestClient

use of com.github.tomakehurst.wiremock.testsupport.WireMockTestClient in project wiremock by wiremock.

the class HttpsBrowserProxyAcceptanceTest method certificateAuthorityCertCanBeDownloaded.

@Test
@DisabledForJreRange(min = JRE.JAVA_17, disabledReason = "does not support generating certificates at runtime")
public void certificateAuthorityCertCanBeDownloaded() throws Exception {
    WireMockTestClient proxyTestClient = new WireMockTestClient(proxy.getPort());
    WireMockResponse certResponse = proxyTestClient.get("/__admin/certs/wiremock-ca.crt");
    assertEquals(200, certResponse.statusCode());
    assertEquals("application/x-pem-file", certResponse.firstHeader("Content-Type"));
    Certificate cert = decode(certResponse.content());
    X509KeyStore keyStore = new X509KeyStore(HttpsAcceptanceTest.readKeyStore(NO_PREEXISTING_KEYSTORE_PATH, "password"), "password".toCharArray());
    assertEquals(keyStore.getCertificateAuthority().certificateChain()[0], cert);
}
Also used : WireMockResponse(com.github.tomakehurst.wiremock.testsupport.WireMockResponse) WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) X509KeyStore(com.github.tomakehurst.wiremock.http.ssl.X509KeyStore) Certificate(java.security.cert.Certificate) Test(org.junit.jupiter.api.Test) DisabledForJreRange(org.junit.jupiter.api.condition.DisabledForJreRange)

Example 33 with WireMockTestClient

use of com.github.tomakehurst.wiremock.testsupport.WireMockTestClient in project wiremock by wiremock.

the class RequestFilterAcceptanceTest method initialise.

private void initialise(RequestFilter... filters) {
    wm = new WireMockServer(wireMockConfig().dynamicPort().extensions(filters));
    wm.start();
    client = new WireMockTestClient(wm.port());
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient)

Example 34 with WireMockTestClient

use of com.github.tomakehurst.wiremock.testsupport.WireMockTestClient 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"));
}
Also used : WireMockResponse(com.github.tomakehurst.wiremock.testsupport.WireMockResponse) WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) Test(org.junit.jupiter.api.Test)

Example 35 with WireMockTestClient

use of com.github.tomakehurst.wiremock.testsupport.WireMockTestClient in project wiremock by wiremock.

the class ResponseDefinitionTransformerAcceptanceTest method appliesNonGlobalExtensionsWhenSpecifiedByStub.

@Test
public void appliesNonGlobalExtensionsWhenSpecifiedByStub() {
    wm = new WireMockServer(wireMockConfig().dynamicPort().extensions(new NonGlobalTransformer()));
    wm.start();
    client = new WireMockTestClient(wm.port());
    wm.stubFor(get(urlEqualTo("/local-transform")).willReturn(aResponse().withStatus(200).withBody("Should not see this").withTransformers("local")));
    WireMockResponse response = client.get("/local-transform");
    assertThat(response.content(), is("Non-global transformed body"));
}
Also used : WireMockResponse(com.github.tomakehurst.wiremock.testsupport.WireMockResponse) WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) Test(org.junit.jupiter.api.Test)

Aggregations

WireMockTestClient (com.github.tomakehurst.wiremock.testsupport.WireMockTestClient)43 Test (org.junit.jupiter.api.Test)16 BeforeEach (org.junit.jupiter.api.BeforeEach)10 WireMockResponse (com.github.tomakehurst.wiremock.testsupport.WireMockResponse)9 WireMockServer (com.github.tomakehurst.wiremock.WireMockServer)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 BeforeAll (org.junit.jupiter.api.BeforeAll)3 SingleRootFileSource (com.github.tomakehurst.wiremock.common.SingleRootFileSource)2 WebAppContext (org.eclipse.jetty.webapp.WebAppContext)2 FileSource (com.github.tomakehurst.wiremock.common.FileSource)1 ProxySettings (com.github.tomakehurst.wiremock.common.ProxySettings)1 Request (com.github.tomakehurst.wiremock.http.Request)1 X509KeyStore (com.github.tomakehurst.wiremock.http.ssl.X509KeyStore)1 WireMockServerRunner (com.github.tomakehurst.wiremock.standalone.WireMockServerRunner)1 Stopwatch (com.google.common.base.Stopwatch)1 Certificate (java.security.cert.Certificate)1 Collections.singletonList (java.util.Collections.singletonList)1 List (java.util.List)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1