13
13
package io .kubernetes .client .extended .kubectl ;
14
14
15
15
import static com .github .tomakehurst .wiremock .client .WireMock .aResponse ;
16
+ import static com .github .tomakehurst .wiremock .client .WireMock .equalToJson ;
16
17
import static com .github .tomakehurst .wiremock .client .WireMock .get ;
17
18
import static com .github .tomakehurst .wiremock .client .WireMock .getRequestedFor ;
19
+ import static com .github .tomakehurst .wiremock .client .WireMock .matchingJsonPath ;
18
20
import static com .github .tomakehurst .wiremock .client .WireMock .put ;
19
21
import static com .github .tomakehurst .wiremock .client .WireMock .putRequestedFor ;
20
22
import static com .github .tomakehurst .wiremock .client .WireMock .urlPathEqualTo ;
@@ -56,6 +58,9 @@ public void testKubectlLabelNamespacedResourceShouldWork() throws KubectlExcepti
56
58
.withBody ("{\" metadata\" :{\" name\" :\" foo\" ,\" namespace\" :\" default\" }}" )));
57
59
wireMockRule .stubFor (
58
60
put (urlPathEqualTo ("/api/v1/namespaces/default/pods/foo" ))
61
+ .withRequestBody (
62
+ matchingJsonPath (
63
+ "$.metadata.labels" , equalToJson ("{ \" k1\" : \" v1\" , \" k2\" : \" v2\" }" )))
59
64
.willReturn (
60
65
aResponse ()
61
66
.withStatus (200 )
@@ -85,6 +90,9 @@ public void testKubectlLabelNamespacedResourceReceiveForbiddenShouldThrowExcepti
85
90
.withBody ("{\" metadata\" :{\" name\" :\" foo\" ,\" namespace\" :\" default\" }}" )));
86
91
wireMockRule .stubFor (
87
92
put (urlPathEqualTo ("/api/v1/namespaces/default/pods/foo" ))
93
+ .withRequestBody (
94
+ matchingJsonPath (
95
+ "$.metadata.labels" , equalToJson ("{ \" k1\" : \" v1\" , \" k2\" : \" v2\" }" )))
88
96
.willReturn (aResponse ().withStatus (403 ).withBody ("{\" metadata\" :{}}" )));
89
97
assertThrows (
90
98
KubectlException .class ,
@@ -109,6 +117,9 @@ public void testKubectlLabelClusterResourceShouldWork() throws KubectlException
109
117
.willReturn (aResponse ().withStatus (200 ).withBody ("{\" metadata\" :{\" name\" :\" foo\" }}" )));
110
118
wireMockRule .stubFor (
111
119
put (urlPathEqualTo ("/api/v1/nodes/foo" ))
120
+ .withRequestBody (
121
+ matchingJsonPath (
122
+ "$.metadata.labels" , equalToJson ("{ \" k1\" : \" v1\" , \" k2\" : \" v2\" }" )))
112
123
.willReturn (aResponse ().withStatus (200 ).withBody ("{\" metadata\" :{\" name\" :\" foo\" }}" )));
113
124
V1Node labelledNode =
114
125
Kubectl .label (V1Node .class )
@@ -131,6 +142,9 @@ public void testKubectlLabelClusterResourceReceiveForbiddenShouldThrowException(
131
142
.willReturn (aResponse ().withStatus (200 ).withBody ("{\" metadata\" :{\" name\" :\" foo\" }}" )));
132
143
wireMockRule .stubFor (
133
144
put (urlPathEqualTo ("/api/v1/nodes/foo" ))
145
+ .withRequestBody (
146
+ matchingJsonPath (
147
+ "$.metadata.labels" , equalToJson ("{ \" k1\" : \" v1\" , \" k2\" : \" v2\" }" )))
134
148
.willReturn (aResponse ().withStatus (403 ).withBody ("{\" metadata\" :{\" name\" :\" foo\" }}" )));
135
149
assertThrows (
136
150
KubectlException .class ,
0 commit comments