Search in sources :

Example 1 with AnythingPattern

use of com.github.tomakehurst.wiremock.matching.AnythingPattern in project java by kubernetes-client.

the class CopyTest method testUrl.

@Test
public void testUrl() throws IOException, ApiException, InterruptedException {
    Copy copy = new Copy(client);
    V1Pod pod = new V1Pod().metadata(new V1ObjectMeta().name(podName).namespace(namespace));
    wireMockRule.stubFor(get(urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/exec")).willReturn(aResponse().withStatus(404).withHeader("Content-Type", "application/json").withBody("{}")));
    try {
        InputStream inputStream = copy.copyFileFromPod(pod, "container", "/some/path/to/file");
        // block until the connection is established
        inputStream.read();
        inputStream.close();
    } catch (IOException | ApiException | IllegalStateException e) {
        e.printStackTrace();
    }
    wireMockRule.verify(getRequestedFor(urlPathEqualTo("/api/v1/namespaces/" + namespace + "/pods/" + podName + "/exec")).withQueryParam("stdin", equalTo("false")).withQueryParam("stdout", equalTo("true")).withQueryParam("stderr", equalTo("true")).withQueryParam("tty", equalTo("false")).withQueryParam("command", new AnythingPattern()));
}
Also used : V1ObjectMeta(io.kubernetes.client.openapi.models.V1ObjectMeta) InputStream(java.io.InputStream) AnythingPattern(com.github.tomakehurst.wiremock.matching.AnythingPattern) V1Pod(io.kubernetes.client.openapi.models.V1Pod) IOException(java.io.IOException) ApiException(io.kubernetes.client.openapi.ApiException) Test(org.junit.Test)

Aggregations

AnythingPattern (com.github.tomakehurst.wiremock.matching.AnythingPattern)1 ApiException (io.kubernetes.client.openapi.ApiException)1 V1ObjectMeta (io.kubernetes.client.openapi.models.V1ObjectMeta)1 V1Pod (io.kubernetes.client.openapi.models.V1Pod)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Test (org.junit.Test)1