Search in sources :

Example 6 with EqualToPattern

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

the class KubectlRolloutTest method testKubectlRolloutHistoryStatefulSetWithRevisionShouldWork.

@Test
public void testKubectlRolloutHistoryStatefulSetWithRevisionShouldWork() throws KubectlException, IOException {
    wireMockRule.stubFor(get(urlPathEqualTo("/apis/apps/v1/namespaces/default/statefulsets/foo")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(STATEFUL_SET))))));
    wireMockRule.stubFor(get(urlPathEqualTo("/apis/apps/v1/namespaces/default/controllerrevisions")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(STATEFUL_SET_CONTROLLER_REVISION_LIST))))));
    wireMockRule.stubFor(patch(urlPathEqualTo("/apis/apps/v1/namespaces/default/statefulsets/foo")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(PATCHED_STATEFUL_SET))))));
    V1PodTemplateSpec template = Kubectl.rollout(V1StatefulSet.class).history().apiClient(apiClient).name("foo").namespace("default").revision(2).skipDiscovery().execute();
    wireMockRule.verify(1, getRequestedFor((urlPathEqualTo("/apis/apps/v1/namespaces/default/statefulsets/foo"))));
    wireMockRule.verify(1, getRequestedFor((urlPathEqualTo("/apis/apps/v1/namespaces/default/controllerrevisions"))).withQueryParam("labelSelector", new EqualToPattern("app = bar")));
    wireMockRule.verify(1, patchRequestedFor((urlPathEqualTo("/apis/apps/v1/namespaces/default/statefulsets/foo"))).withQueryParam("dryRun", new EqualToPattern("All")));
    Assert.assertNotNull(template);
}
Also used : V1StatefulSet(io.kubernetes.client.openapi.models.V1StatefulSet) EqualToPattern(com.github.tomakehurst.wiremock.matching.EqualToPattern) V1PodTemplateSpec(io.kubernetes.client.openapi.models.V1PodTemplateSpec) Test(org.junit.Test)

Example 7 with EqualToPattern

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

the class KubectlPatchTest method testPatchConfigMap.

@Test
public void testPatchConfigMap() throws KubectlException, IOException {
    wireMockRule.stubFor(patch(urlPathEqualTo("/api/v1/namespaces/foo/configmaps/bar")).withHeader("Content-Type", new EqualToPattern(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH)).willReturn(aResponse().withStatus(200).withBody("{\"metadata\":{\"name\":\"bar\",\"namespace\":\"foo\"}}")));
    wireMockRule.stubFor(get(urlPathEqualTo("/api")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(DISCOVERY_API))))));
    wireMockRule.stubFor(get(urlPathEqualTo("/apis")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(DISCOVERY_APIS))))));
    wireMockRule.stubFor(get(urlPathEqualTo("/api/v1")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(DISCOVERY_APIV1))))));
    V1ConfigMap configMap = Kubectl.patch(V1ConfigMap.class).namespace("foo").name("bar").patchType(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH).patchContent(new V1Patch("{\"data\":{\"key\":\"value\"}}")).apiClient(apiClient).execute();
    wireMockRule.verify(1, patchRequestedFor(urlPathEqualTo("/api/v1/namespaces/foo/configmaps/bar")));
    assertNotNull(configMap);
}
Also used : V1Patch(io.kubernetes.client.custom.V1Patch) EqualToPattern(com.github.tomakehurst.wiremock.matching.EqualToPattern) V1ConfigMap(io.kubernetes.client.openapi.models.V1ConfigMap) Test(org.junit.Test)

Example 8 with EqualToPattern

use of com.github.tomakehurst.wiremock.matching.EqualToPattern in project codekvast by crispab.

the class HerokuApiWrapperImplTest method should_get_app_details.

@Test
void should_get_app_details() throws IOException {
    // given
    givenThat(get("/addons/some-external-id").withHeader("Authorization", new EqualToPattern("Bearer some-access-token")).withHeader("Accept", new EqualToPattern("application/vnd.heroku+json; version=3")).willReturn(okJson(readResource("/heroku/sample-heroku-addons-response.json"))));
    givenThat(get("/apps/some-app-id").withHeader("Authorization", new EqualToPattern("Bearer some-access-token")).withHeader("Accept", new EqualToPattern("application/vnd.heroku+json; version=3")).willReturn(okJson(readResource("/heroku/sample-heroku-apps-response.json"))));
    // when
    HerokuAppDetails appDetails = herokuApiWrapper.getAppDetails("some-external-id", "some-access-token");
    // then
    assertThat(appDetails, is(HerokuAppDetails.builder().appName("some-app-name").ownerEmail("some-owner-email").build()));
}
Also used : EqualToPattern(com.github.tomakehurst.wiremock.matching.EqualToPattern) HerokuAppDetails(io.codekvast.login.heroku.model.HerokuAppDetails) Test(org.junit.jupiter.api.Test) WireMockTest(com.github.tomakehurst.wiremock.junit5.WireMockTest)

Aggregations

EqualToPattern (com.github.tomakehurst.wiremock.matching.EqualToPattern)8 Test (org.junit.Test)6 V1PodTemplateSpec (io.kubernetes.client.openapi.models.V1PodTemplateSpec)3 V1ConfigMap (io.kubernetes.client.openapi.models.V1ConfigMap)2 V1Deployment (io.kubernetes.client.openapi.models.V1Deployment)2 Test (org.junit.jupiter.api.Test)2 WireMockTest (com.github.tomakehurst.wiremock.junit5.WireMockTest)1 HerokuAppDetails (io.codekvast.login.heroku.model.HerokuAppDetails)1 V1Patch (io.kubernetes.client.custom.V1Patch)1 JSON (io.kubernetes.client.openapi.JSON)1 AppsV1Api (io.kubernetes.client.openapi.apis.AppsV1Api)1 V1DaemonSet (io.kubernetes.client.openapi.models.V1DaemonSet)1 V1ObjectMeta (io.kubernetes.client.openapi.models.V1ObjectMeta)1 V1ReplicaSet (io.kubernetes.client.openapi.models.V1ReplicaSet)1 V1StatefulSet (io.kubernetes.client.openapi.models.V1StatefulSet)1 ArrayList (java.util.ArrayList)1 AbstractServerTest (org.ligoj.app.AbstractServerTest)1