|
18 | 18 | import com.github.tomakehurst.wiremock.WireMockServer; |
19 | 19 | import org.eclipse.dataplane.domain.Result; |
20 | 20 | import org.eclipse.dataplane.domain.dataflow.DataFlowPrepareMessage; |
| 21 | +import org.eclipse.dataplane.domain.registration.AuthorizationProfile; |
21 | 22 | import org.eclipse.dataplane.domain.registration.ControlPlaneRegistrationMessage; |
22 | 23 | import org.eclipse.dataplane.port.exception.DataFlowNotifyControlPlaneFailed; |
23 | 24 | import org.eclipse.dataplane.port.exception.DataplaneNotRegistered; |
|
35 | 36 | import static com.github.tomakehurst.wiremock.client.WireMock.and; |
36 | 37 | import static com.github.tomakehurst.wiremock.client.WireMock.anyUrl; |
37 | 38 | import static com.github.tomakehurst.wiremock.client.WireMock.equalTo; |
| 39 | +import static com.github.tomakehurst.wiremock.client.WireMock.equalToJson; |
38 | 40 | import static com.github.tomakehurst.wiremock.client.WireMock.matchingJsonPath; |
39 | 41 | import static com.github.tomakehurst.wiremock.client.WireMock.post; |
40 | 42 | import static com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor; |
@@ -177,6 +179,34 @@ void shouldRegisterOnTheControlPlane() { |
177 | 179 | ); |
178 | 180 | } |
179 | 181 |
|
| 182 | + @Test |
| 183 | + void shouldRegisterOnTheControlPlane_withAuthProfile() { |
| 184 | + controlPlane.stubFor(put(anyUrl()).willReturn(aResponse().withStatus(200))); |
| 185 | + |
| 186 | + var authProfile = new AuthorizationProfile("test") |
| 187 | + .withAttribute("key", "value"); |
| 188 | + |
| 189 | + var dataplane = Dataplane.newInstance() |
| 190 | + .id("dataplane-id") |
| 191 | + .endpoint(URI.create("http://localhost/dataplane")) |
| 192 | + .authorizationProfile(authProfile) |
| 193 | + .transferType("SupportedTransferType-PUSH") |
| 194 | + .label("label-one").label("label-two") |
| 195 | + .build(); |
| 196 | + |
| 197 | + var result = dataplane.registerOn(controlPlane.baseUrl()); |
| 198 | + |
| 199 | + assertThat(result.succeeded()).isTrue(); |
| 200 | + controlPlane.verify(putRequestedFor(urlPathEqualTo("/dataplanes")) |
| 201 | + .withRequestBody(and( |
| 202 | + matchingJsonPath("endpoint", equalTo("http://localhost/dataplane")), |
| 203 | + matchingJsonPath("authorization", equalToJson("{\"type\":\"test\",\"key\":\"value\"}")), |
| 204 | + matchingJsonPath("transferTypes[0]", equalTo("SupportedTransferType-PUSH")), |
| 205 | + matchingJsonPath("labels.size()", equalTo("2")) |
| 206 | + )) |
| 207 | + ); |
| 208 | + } |
| 209 | + |
180 | 210 | @Test |
181 | 211 | void shouldFail_whenStatusIsNot200() { |
182 | 212 | controlPlane.stubFor(post(anyUrl()).willReturn(aResponse().withStatus(409))); |
|
0 commit comments