Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static org.junit.jupiter.api.Assertions.assertEquals;

import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
Expand Down Expand Up @@ -44,7 +44,7 @@ void exactUrlOnly() throws ApiException {
V1Namespace ns1 = new V1Namespace().metadata(new V1ObjectMeta().name("name"));

apiServer.stubFor(
get(urlEqualTo("/api/v1/namespaces/name"))
get(urlPathEqualTo("/api/v1/namespaces/name"))
.willReturn(
aResponse()
.withHeader("Content-Type", "application/json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ static void setupApiServer() throws Exception {
apiServer.resetScenarios();
apiServer.resetRequests();
apiServer.stubFor(
post(urlEqualTo("/api/v1/namespaces"))
post(urlPathEqualTo("/api/v1/namespaces"))
.willReturn(
aResponse()
.withHeader("Content-Type", "application/json")
Expand All @@ -146,7 +146,7 @@ static void setupApiServer() throws Exception {
.getJSON()
.serialize(returningCreatedNamespace))));
apiServer.stubFor(
post(urlEqualTo("/api/v1/namespaces/spring-boot-test-namespace/serviceaccounts"))
post(urlPathEqualTo("/api/v1/namespaces/spring-boot-test-namespace/serviceaccounts"))
.willReturn(
aResponse()
.withHeader("Content-Type", "application/json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.put;
import static com.github.tomakehurst.wiremock.client.WireMock.putRequestedFor;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -87,7 +86,7 @@ void setup() {
void deleteNamespacedPodReturningStatus() {
V1Status status = new V1Status().kind("Status").code(200).message("good!");
apiServer.stubFor(
delete(urlEqualTo("/api/v1/namespaces/default/pods/foo1"))
delete(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1"))
.willReturn(aResponse().withStatus(200).withBody(json.serialize(status))));

KubernetesApiResponse<V1Pod> deletePodResp = podClient.delete("default", "foo1", null);
Expand All @@ -101,7 +100,7 @@ void deleteNamespacedPodReturningStatus() {
void deleteNamespacedPodAsyncReturningStatus() throws InterruptedException {
V1Status status = new V1Status().kind("Status").code(200).message("good!");
apiServer.stubFor(
delete(urlEqualTo("/api/v1/namespaces/default/pods/foo1"))
delete(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1"))
.willReturn(aResponse().withStatus(200).withBody(json.serialize(status))));
TestCallback<V1Pod> callback = new TestCallback<>(podClient.getApiClient());

Expand All @@ -123,7 +122,7 @@ void deleteNamespacedPodReturningDeletedObject() {
new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));

apiServer.stubFor(
delete(urlEqualTo("/api/v1/namespaces/default/pods/foo1"))
delete(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1"))
.willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));

KubernetesApiResponse<V1Pod> deletePodResp = podClient.delete("default", "foo1");
Expand All @@ -139,7 +138,7 @@ void deleteNamespacedPodAsyncReturningDeletedObject() throws InterruptedExceptio
new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));

apiServer.stubFor(
delete(urlEqualTo("/api/v1/namespaces/default/pods/foo1"))
delete(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1"))
.willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
TestCallback<V1Pod> callback = new TestCallback<>(podClient.getApiClient());

Expand All @@ -159,7 +158,7 @@ void deleteNamespacedPodReturningForbiddenStatus() {
V1Status status = new V1Status().kind("Status").code(403).message("good!");

apiServer.stubFor(
delete(urlEqualTo("/api/v1/namespaces/default/pods/foo1"))
delete(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1"))
.willReturn(aResponse().withStatus(403).withBody(json.serialize(status))));

KubernetesApiResponse<V1Pod> deletePodResp = podClient.delete("default", "foo1");
Expand All @@ -174,7 +173,7 @@ void deleteNamespacedPodAsyncReturningForbiddenStatus() throws InterruptedExcept
V1Status status = new V1Status().kind("Status").code(403).message("good!");

apiServer.stubFor(
delete(urlEqualTo("/api/v1/namespaces/default/pods/foo1"))
delete(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1"))
.willReturn(aResponse().withStatus(403).withBody(json.serialize(status))));
TestCallback<V1Pod> callback = new TestCallback<>(podClient.getApiClient());

Expand Down Expand Up @@ -316,7 +315,7 @@ void createNamespacedPodReturningObject() {
new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));

apiServer.stubFor(
post(urlEqualTo("/api/v1/namespaces/default/pods"))
post(urlPathEqualTo("/api/v1/namespaces/default/pods"))
.willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
KubernetesApiResponse<V1Pod> podListResp = podClient.create(foo1);
assertThat(podListResp.isSuccess()).isTrue();
Expand All @@ -331,7 +330,7 @@ void createNamespacedPodAsyncReturningObject() throws InterruptedException {
new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));

apiServer.stubFor(
post(urlEqualTo("/api/v1/namespaces/default/pods"))
post(urlPathEqualTo("/api/v1/namespaces/default/pods"))
.willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
TestCallback<V1Pod> callback = new TestCallback<>(podClient.getApiClient());

Expand All @@ -351,7 +350,7 @@ void updateNamespacedPodReturningObject() {
new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));

apiServer.stubFor(
put(urlEqualTo("/api/v1/namespaces/default/pods/foo1"))
put(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1"))
.willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
KubernetesApiResponse<V1Pod> podListResp = podClient.update(foo1);
assertThat(podListResp.isSuccess()).isTrue();
Expand All @@ -366,7 +365,7 @@ void updateNamespacedPodAsyncReturningObject() throws InterruptedException {
new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));

apiServer.stubFor(
put(urlEqualTo("/api/v1/namespaces/default/pods/foo1"))
put(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1"))
.willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
TestCallback<V1Pod> callback = new TestCallback<>(podClient.getApiClient());

Expand All @@ -386,7 +385,7 @@ void patchNamespacedPodReturningObject() {
V1Pod foo1 =
new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));
apiServer.stubFor(
patch(urlEqualTo("/api/v1/namespaces/default/pods/foo1"))
patch(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1"))
.withHeader("Content-Type", containing(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH))
.willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
KubernetesApiResponse<V1Pod> podPatchResp =
Expand All @@ -404,7 +403,7 @@ void patchNamespacedPodAsyncReturningObject() throws InterruptedException {
V1Pod foo1 =
new V1Pod().kind("Pod").metadata(new V1ObjectMeta().namespace("default").name("foo1"));
apiServer.stubFor(
patch(urlEqualTo("/api/v1/namespaces/default/pods/foo1"))
patch(urlPathEqualTo("/api/v1/namespaces/default/pods/foo1"))
.withHeader("Content-Type", containing(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH))
.willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
TestCallback<V1Pod> callback = new TestCallback<>(podClient.getApiClient());
Expand All @@ -430,7 +429,7 @@ void patchNamespacedPodWithApiPrefix() {
// add api prefix
String prefix = "/k8s/clusters/c-7q988";
apiServer.stubFor(
patch(urlEqualTo(prefix + "/api/v1/namespaces/default/pods/foo1"))
patch(urlPathEqualTo(prefix + "/api/v1/namespaces/default/pods/foo1"))
.withHeader("Content-Type", containing(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH))
.willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));

Expand Down Expand Up @@ -462,7 +461,7 @@ void patchNamespacedPodAsyncWithApiPrefix() throws InterruptedException {
// add api prefix
String prefix = "/k8s/clusters/c-7q988";
apiServer.stubFor(
patch(urlEqualTo(prefix + "/api/v1/namespaces/default/pods/foo1"))
patch(urlPathEqualTo(prefix + "/api/v1/namespaces/default/pods/foo1"))
.withHeader("Content-Type", containing(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH))
.willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
TestCallback<V1Pod> callback = new TestCallback<>(podClient.getApiClient());
Expand Down Expand Up @@ -501,7 +500,7 @@ void readTimeoutShouldThrowException() {
.readTimeout(1, TimeUnit.MILLISECONDS) // timeout everytime
.build());
apiServer.stubFor(
get(urlEqualTo("/api/v1/namespaces/foo/pods/test"))
get(urlPathEqualTo("/api/v1/namespaces/foo/pods/test"))
.willReturn(aResponse().withFixedDelay(99999).withStatus(200).withBody("")));
podClient =
new GenericKubernetesApi<>(V1Pod.class, V1PodList.class, "", "v1", "pods", apiClient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void setup() {
void deleteNamespacedJobReturningStatus() {
V1Status status = new V1Status().kind("Status").code(200).message("good!");
apiServer.stubFor(
delete(urlEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1"))
delete(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1"))
.willReturn(aResponse().withStatus(200).withBody(json.serialize(status))));

KubernetesApiResponse<V1Job> deleteJobResp = jobClient.delete("default", "foo1", null);
Expand All @@ -76,7 +76,7 @@ void deleteNamespacedJobReturningDeletedObject() {
new V1Job().kind("Job").metadata(new V1ObjectMeta().namespace("default").name("foo1"));

apiServer.stubFor(
delete(urlEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1"))
delete(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1"))
.willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));

KubernetesApiResponse<V1Job> deleteJobResp = jobClient.delete("default", "foo1");
Expand All @@ -91,7 +91,7 @@ void deleteNamespacedJobReturningForbiddenStatus() {
V1Status status = new V1Status().kind("Status").code(403).message("good!");

apiServer.stubFor(
delete(urlEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1"))
delete(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1"))
.willReturn(aResponse().withStatus(403).withBody(json.serialize(status))));

KubernetesApiResponse<V1Job> deleteJobResp = jobClient.delete("default", "foo1");
Expand Down Expand Up @@ -188,7 +188,7 @@ void createNamespacedJobReturningObject() {
new V1Job().kind("Job").metadata(new V1ObjectMeta().namespace("default").name("foo1"));

apiServer.stubFor(
post(urlEqualTo("/apis/batch/v1/namespaces/default/jobs"))
post(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs"))
.willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
KubernetesApiResponse<V1Job> jobListResp = jobClient.create(foo1);
assertThat(jobListResp.isSuccess()).isTrue();
Expand All @@ -203,7 +203,7 @@ void updateNamespacedJobReturningObject() {
new V1Job().kind("Job").metadata(new V1ObjectMeta().namespace("default").name("foo1"));

apiServer.stubFor(
put(urlEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1"))
put(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1"))
.willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
KubernetesApiResponse<V1Job> jobListResp = jobClient.update(foo1);
assertThat(jobListResp.isSuccess()).isTrue();
Expand All @@ -219,7 +219,7 @@ void updateStatusNamespacedJobReturningObject() {
foo1.setStatus(new V1JobStatus().failed(1));

apiServer.stubFor(
patch(urlEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1/status"))
patch(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1/status"))
.willReturn(aResponse().withStatus(200).withBody(new JSON().serialize(foo1))));
KubernetesApiResponse<V1Job> jobListResp = jobClient.updateStatus(foo1, t -> t.getStatus());
assertThat(jobListResp.isSuccess()).isTrue();
Expand All @@ -235,7 +235,7 @@ void patchNamespacedJobReturningObject() {
V1Job foo1 =
new V1Job().kind("Job").metadata(new V1ObjectMeta().namespace("default").name("foo1"));
apiServer.stubFor(
patch(urlEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1"))
patch(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1"))
.withHeader("Content-Type", containing(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH))
.willReturn(aResponse().withStatus(200).withBody(json.serialize(foo1))));
KubernetesApiResponse<V1Job> jobPatchResp =
Expand All @@ -251,7 +251,7 @@ void patchNamespacedJobReturningObject() {
void patchNamespacedJobReturningEmpty() {
V1Patch v1Patch = new V1Patch("{}");
apiServer.stubFor(
patch(urlEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1"))
patch(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs/foo1"))
.withHeader("Content-Type", containing(V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH))
.willReturn(aResponse().withStatus(200).withBody("")));
KubernetesApiResponse<V1Job> jobPatchResp =
Expand Down Expand Up @@ -289,7 +289,7 @@ void readTimeoutShouldThrowException() {
.readTimeout(1, TimeUnit.MILLISECONDS) // timeout everytime
.build());
apiServer.stubFor(
get(urlEqualTo("/apis/batch/v1/namespaces/foo/jobs/test"))
get(urlPathEqualTo("/apis/batch/v1/namespaces/foo/jobs/test"))
.willReturn(aResponse().withFixedDelay(99999).withStatus(200).withBody("")));
jobClient =
new GenericKubernetesApi<>(V1Job.class, V1JobList.class, "batch", "v1", "jobs", apiClient);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ void returningNormalObjectShouldWork() {
FooCustomResource foo = new FooCustomResource();

apiServer.stubFor(
get(urlEqualTo("/apis/batch/v1/namespaces/default/jobs/noxu"))
get(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs/noxu"))
.willReturn(aResponse().withStatus(200).withBody(JSON.serialize(job))));
apiServer.stubFor(
get(urlEqualTo("/apis/example.io/v1/namespaces/default/foos/noxu"))
get(urlPathEqualTo("/apis/example.io/v1/namespaces/default/foos/noxu"))
.willReturn(aResponse().withStatus(200).withBody(JSON.serialize(foo))));

KubernetesApiResponse<V1Job> jobResp = jobClient.get("default", "noxu");
Expand All @@ -79,10 +79,10 @@ void returningStatusShouldWork() {
V1Status forbiddenStatus = new V1Status().kind("Status");

apiServer.stubFor(
get(urlEqualTo("/apis/batch/v1/namespaces/default/jobs/noxu"))
get(urlPathEqualTo("/apis/batch/v1/namespaces/default/jobs/noxu"))
.willReturn(aResponse().withStatus(403).withBody(JSON.serialize(forbiddenStatus))));
apiServer.stubFor(
get(urlEqualTo("/apis/example.io/v1/namespaces/default/foos/noxu"))
get(urlPathEqualTo("/apis/example.io/v1/namespaces/default/foos/noxu"))
.willReturn(aResponse().withStatus(403).withBody(JSON.serialize(forbiddenStatus))));

KubernetesApiResponse<V1Job> jobResp = jobClient.get("default", "noxu");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
import static com.github.tomakehurst.wiremock.client.WireMock.delete;
import static com.github.tomakehurst.wiremock.client.WireMock.get;
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -51,7 +51,7 @@ void setup() {
void errorStatusHandler() throws ApiException {
V1Status forbiddenStatus = new V1Status().code(403).message("Forbidden");
apiServer.stubFor(
delete(urlEqualTo("/api/v1/namespaces/default/pods/foo"))
delete(urlPathEqualTo("/api/v1/namespaces/default/pods/foo"))
.willReturn(aResponse().withStatus(403).withBody(new Gson().toJson(forbiddenStatus))));
AtomicBoolean catched = new AtomicBoolean(false);
assertThat(
Expand All @@ -69,7 +69,7 @@ void errorStatusHandler() throws ApiException {
void notDeserializableResponse() {
String message = "-foobar";
apiServer.stubFor(
get(urlEqualTo("/api/v1/namespaces/default/pods/foo"))
get(urlPathEqualTo("/api/v1/namespaces/default/pods/foo"))
.willReturn(aResponse().withStatus(403).withBody(message)));
KubernetesApiResponse response = podClient.get("default", "foo");
assertThat(response.isSuccess()).isFalse();
Expand Down
Loading