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);
}
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);
}
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()));
}
Aggregations