1313package io .kubernetes .client .extended .kubectl ;
1414
1515import static com .github .tomakehurst .wiremock .client .WireMock .aResponse ;
16+ import static com .github .tomakehurst .wiremock .client .WireMock .equalToJson ;
1617import static com .github .tomakehurst .wiremock .client .WireMock .get ;
1718import static com .github .tomakehurst .wiremock .client .WireMock .getRequestedFor ;
19+ import static com .github .tomakehurst .wiremock .client .WireMock .matchingJsonPath ;
1820import static com .github .tomakehurst .wiremock .client .WireMock .put ;
1921import static com .github .tomakehurst .wiremock .client .WireMock .putRequestedFor ;
2022import static com .github .tomakehurst .wiremock .client .WireMock .urlPathEqualTo ;
@@ -56,6 +58,9 @@ public void testKubectlLabelNamespacedResourceShouldWork() throws KubectlExcepti
5658 .withBody ("{\" metadata\" :{\" name\" :\" foo\" ,\" namespace\" :\" default\" }}" )));
5759 wireMockRule .stubFor (
5860 put (urlPathEqualTo ("/api/v1/namespaces/default/pods/foo" ))
61+ .withRequestBody (
62+ matchingJsonPath (
63+ "$.metadata.labels" , equalToJson ("{ \" k1\" : \" v1\" , \" k2\" : \" v2\" }" )))
5964 .willReturn (
6065 aResponse ()
6166 .withStatus (200 )
@@ -85,6 +90,9 @@ public void testKubectlLabelNamespacedResourceReceiveForbiddenShouldThrowExcepti
8590 .withBody ("{\" metadata\" :{\" name\" :\" foo\" ,\" namespace\" :\" default\" }}" )));
8691 wireMockRule .stubFor (
8792 put (urlPathEqualTo ("/api/v1/namespaces/default/pods/foo" ))
93+ .withRequestBody (
94+ matchingJsonPath (
95+ "$.metadata.labels" , equalToJson ("{ \" k1\" : \" v1\" , \" k2\" : \" v2\" }" )))
8896 .willReturn (aResponse ().withStatus (403 ).withBody ("{\" metadata\" :{}}" )));
8997 assertThrows (
9098 KubectlException .class ,
@@ -109,6 +117,9 @@ public void testKubectlLabelClusterResourceShouldWork() throws KubectlException
109117 .willReturn (aResponse ().withStatus (200 ).withBody ("{\" metadata\" :{\" name\" :\" foo\" }}" )));
110118 wireMockRule .stubFor (
111119 put (urlPathEqualTo ("/api/v1/nodes/foo" ))
120+ .withRequestBody (
121+ matchingJsonPath (
122+ "$.metadata.labels" , equalToJson ("{ \" k1\" : \" v1\" , \" k2\" : \" v2\" }" )))
112123 .willReturn (aResponse ().withStatus (200 ).withBody ("{\" metadata\" :{\" name\" :\" foo\" }}" )));
113124 V1Node labelledNode =
114125 Kubectl .label (V1Node .class )
@@ -131,6 +142,9 @@ public void testKubectlLabelClusterResourceReceiveForbiddenShouldThrowException(
131142 .willReturn (aResponse ().withStatus (200 ).withBody ("{\" metadata\" :{\" name\" :\" foo\" }}" )));
132143 wireMockRule .stubFor (
133144 put (urlPathEqualTo ("/api/v1/nodes/foo" ))
145+ .withRequestBody (
146+ matchingJsonPath (
147+ "$.metadata.labels" , equalToJson ("{ \" k1\" : \" v1\" , \" k2\" : \" v2\" }" )))
134148 .willReturn (aResponse ().withStatus (403 ).withBody ("{\" metadata\" :{\" name\" :\" foo\" }}" )));
135149 assertThrows (
136150 KubectlException .class ,
0 commit comments