Search in sources :

Example 26 with WireMockTestClient

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

the class XmlHandlingAcceptanceTest method init.

@BeforeEach
public void init() {
    client = new WireMockTestClient(wm.getPort());
    externalDtdServer.stubFor(get("/dodgy.dtd").willReturn(ok("<!ELEMENT shiftydata (#PCDATA)>").withHeader("Content-Type", "application/xml-dtd")));
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 27 with WireMockTestClient

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

the class ClientAuthenticationAcceptanceTest method supportsTokenAuthenticatorViaStaticDsl.

@Test
public void supportsTokenAuthenticatorViaStaticDsl() {
    final String TOKEN = "my_token_123";
    initialise(new TokenAuthenticator(TOKEN), new ClientTokenAuthenticator(TOKEN));
    WireMockTestClient client = new WireMockTestClient(server.port());
    WireMock.configureFor(goodClient);
    // Expect no exception thrown
    WireMock.getAllServeEvents();
    assertThat(client.get("/__admin/requests").statusCode(), is(401));
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.jupiter.api.Test)

Example 28 with WireMockTestClient

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

the class ClientAuthenticationAcceptanceTest method supportsBasicAuthenticatorViaStaticDsl.

@Test
public void supportsBasicAuthenticatorViaStaticDsl() {
    initialise(new BasicAuthenticator(new BasicCredentials("user1", "password1"), new BasicCredentials("user2", "password2")), new ClientBasicAuthenticator("user2", "password2"));
    WireMockTestClient client = new WireMockTestClient(server.port());
    WireMock.configureFor(goodClient);
    // Expect no exception thrown
    WireMock.getAllServeEvents();
    assertThat(client.get("/__admin/requests").statusCode(), is(401));
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) Test(org.junit.jupiter.api.Test)

Example 29 with WireMockTestClient

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

the class WireMockClientAcceptanceTest method init.

@BeforeEach
public void init() {
    wireMockServer = new WireMockServer(Options.DYNAMIC_PORT);
    wireMockServer.start();
    WireMock.configureFor(wireMockServer.port());
    testClient = new WireMockTestClient(wireMockServer.port());
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) WireMockServer(com.github.tomakehurst.wiremock.WireMockServer) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 30 with WireMockTestClient

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

the class WireMockClientWithProxyAcceptanceTest method init.

@BeforeAll
public static void init() {
    wireMockServer = new WireMockServer(DYNAMIC_PORT);
    wireMockServer.start();
    proxyServer = DefaultHttpProxyServer.bootstrap().withPort(0).start();
    testClient = new WireMockTestClient(wireMockServer.port());
}
Also used : WireMockTestClient(com.github.tomakehurst.wiremock.testsupport.WireMockTestClient) WireMockServer(com.github.tomakehurst.wiremock.WireMockServer) BeforeAll(org.junit.jupiter.api.BeforeAll)

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