use of com.github.tomakehurst.wiremock.matching.EqualToPattern in project java by kubernetes-client.
the class KubectlRolloutTest method testKubectlRolloutHistoryDeploymentWithRevisionShouldWork.
@Test
public void testKubectlRolloutHistoryDeploymentWithRevisionShouldWork() throws KubectlException, IOException {
wireMockRule.stubFor(get(urlPathEqualTo("/apis/apps/v1/namespaces/default/deployments/foo")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(DEPLOYMENT))))));
wireMockRule.stubFor(get(urlPathEqualTo("/apis/apps/v1/namespaces/default/replicasets")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(REPLICASET_LIST))))));
V1PodTemplateSpec template = Kubectl.rollout(V1Deployment.class).history().apiClient(apiClient).name("foo").namespace("default").revision(3).skipDiscovery().execute();
wireMockRule.verify(1, getRequestedFor((urlPathEqualTo("/apis/apps/v1/namespaces/default/deployments/foo"))));
wireMockRule.verify(1, getRequestedFor((urlPathEqualTo("/apis/apps/v1/namespaces/default/replicasets"))).withQueryParam("labelSelector", new EqualToPattern("app = bar")));
Assert.assertNotNull(template);
}
use of com.github.tomakehurst.wiremock.matching.EqualToPattern in project java by kubernetes-client.
the class KubectlRolloutTest method testKubectlRolloutHistoryDaemonSetWithRevisionShouldWork.
@Test
public void testKubectlRolloutHistoryDaemonSetWithRevisionShouldWork() throws KubectlException, IOException {
wireMockRule.stubFor(get(urlPathEqualTo("/apis/apps/v1/namespaces/default/daemonsets/foo")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(DAEMON_SET))))));
wireMockRule.stubFor(get(urlPathEqualTo("/apis/apps/v1/namespaces/default/controllerrevisions")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(DAEMON_SET_CONTROLLER_REVISION_LIST))))));
wireMockRule.stubFor(patch(urlPathEqualTo("/apis/apps/v1/namespaces/default/daemonsets/foo")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(PATCHED_DAEMON_SET))))));
V1PodTemplateSpec template = Kubectl.rollout(V1DaemonSet.class).history().apiClient(apiClient).name("foo").namespace("default").revision(2).skipDiscovery().execute();
wireMockRule.verify(1, getRequestedFor((urlPathEqualTo("/apis/apps/v1/namespaces/default/daemonsets/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/daemonsets/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 DeploymentHelperTest method testGetAllReplicaSetsShouldWork.
@Test
public void testGetAllReplicaSetsShouldWork() throws IOException, ApiException {
wireMockRule.stubFor(get(urlPathEqualTo("/apis/apps/v1/namespaces/default/replicasets")).willReturn(aResponse().withStatus(200).withBody(new String(Files.readAllBytes(Paths.get(REPLICASET_LIST))))));
AppsV1Api api = new AppsV1Api(this.apiClient);
V1Deployment deployment = new JSON().deserialize(new String(Files.readAllBytes(Paths.get(DEPLOYMENT))), V1Deployment.class);
List<V1ReplicaSet> oldRSes = new ArrayList<>();
List<V1ReplicaSet> allOldRSes = new ArrayList<>();
V1ReplicaSet newRs = DeploymentHelper.getAllReplicaSets(deployment, api, oldRSes, allOldRSes);
wireMockRule.verify(1, getRequestedFor((urlPathEqualTo("/apis/apps/v1/namespaces/default/replicasets"))).withQueryParam("labelSelector", new EqualToPattern("app = bar")));
Assert.assertNotNull(newRs);
Assert.assertEquals(1, oldRSes.size());
Assert.assertEquals(2, allOldRSes.size());
}
use of com.github.tomakehurst.wiremock.matching.EqualToPattern in project ligoj-api by ligoj.
the class CurlProcessorTest method testHeadersOverrideDefault.
@Test
public void testHeadersOverrideDefault() {
httpServer.stubFor(get(urlPathEqualTo("/")).withHeader("ACCEPT-charset", new EqualToPattern("utf-8")).willReturn(aResponse().withStatus(HttpStatus.SC_OK).withBody("CONTENT")));
httpServer.start();
final CurlProcessor processor = new CurlProcessor();
Assertions.assertEquals("CONTENT", processor.get("http://localhost:" + MOCK_PORT, "ACCEPT-charset:utf-8"));
}
use of com.github.tomakehurst.wiremock.matching.EqualToPattern in project java by kubernetes-client.
the class KubectlApplyTest method testApplyConfigMap.
@Test
public void testApplyConfigMap() throws KubectlException, IOException {
wireMockRule.stubFor(patch(urlPathEqualTo("/api/v1/namespaces/foo/configmaps/bar")).withHeader("Content-Type", new EqualToPattern(V1Patch.PATCH_FORMAT_APPLY_YAML)).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.apply(V1ConfigMap.class).apiClient(apiClient).resource(new V1ConfigMap().apiVersion("v1").metadata(new V1ObjectMeta().namespace("foo").name("bar")).data(new HashMap<String, String>() {
{
put("key1", "value1");
}
})).execute();
wireMockRule.verify(1, patchRequestedFor(urlPathEqualTo("/api/v1/namespaces/foo/configmaps/bar")));
assertNotNull(configMap);
}
Aggregations