|
75 | 75 | import static org.hamcrest.Matchers.anyOf; |
76 | 76 | import static org.hamcrest.Matchers.equalTo; |
77 | 77 | import static org.hamcrest.Matchers.notNullValue; |
| 78 | +import static org.hamcrest.Matchers.nullValue; |
78 | 79 | import static org.mockito.ArgumentMatchers.anyString; |
79 | 80 | import static org.mockito.ArgumentMatchers.argThat; |
80 | 81 | import static org.mockito.Mockito.mock; |
@@ -173,6 +174,34 @@ void createNewUser_principalIsSuperuser(IdentityHub identityHub, EventRouter rou |
173 | 174 | .allSatisfy(dd -> assertThat(dd.getVerificationMethod()).hasSize(1)); |
174 | 175 | } |
175 | 176 |
|
| 177 | + |
| 178 | + @Test |
| 179 | + void createNewUser_skipStsClientProvisioning(IdentityHub identityHub, EventRouter router) { |
| 180 | + var subscriber = mock(EventSubscriber.class); |
| 181 | + router.registerSync(ParticipantContextCreated.class, subscriber); |
| 182 | + |
| 183 | + var manifest = createNewParticipant().provisionStsAccount(false).build(); |
| 184 | + |
| 185 | + identityHub.getIdentityEndpoint().baseRequest() |
| 186 | + .header(authorizeUser(SUPER_USER, identityHub)) |
| 187 | + .contentType(ContentType.JSON) |
| 188 | + .body(manifest) |
| 189 | + .post("/v1beta/participants/") |
| 190 | + .then() |
| 191 | + .log().ifError() |
| 192 | + .statusCode(anyOf(equalTo(200), equalTo(204))) |
| 193 | + .body("clientId", nullValue()) |
| 194 | + .body("apiKey", notNullValue()) |
| 195 | + .body("clientSecret", nullValue()); |
| 196 | + |
| 197 | + verify(subscriber).on(argThat(env -> ((ParticipantContextCreated) env.getPayload()).getParticipantContextId().equals(manifest.getParticipantContextId()))); |
| 198 | + |
| 199 | + assertThat(identityHub.getKeyPairsForParticipant(manifest.getParticipantContextId())).hasSize(1); |
| 200 | + assertThat(identityHub.getDidForParticipant(manifest.getParticipantContextId())).hasSize(1) |
| 201 | + .allSatisfy(dd -> assertThat(dd.getVerificationMethod()).hasSize(1)); |
| 202 | + } |
| 203 | + |
| 204 | + |
176 | 205 | @Test |
177 | 206 | void createNewUser_whenKeyPairActive(IdentityHub identityHub, EventRouter router) { |
178 | 207 | var subscriber = mock(EventSubscriber.class); |
@@ -519,7 +548,7 @@ void updateScopes(IdentityHub identityHub) { |
519 | 548 | } |
520 | 549 |
|
521 | 550 | @ParameterizedTest(name = "Expect 403, role = {0}") |
522 | | - @ValueSource(strings = { "some-role", "admin" }) |
| 551 | + @ValueSource(strings = {"some-role", "admin"}) |
523 | 552 | void updateScopes_whenNotSuperuser(String role, IdentityHub identityHub) { |
524 | 553 | var participantContextId = "some-user"; |
525 | 554 | var userAuth = authorizeUser(participantContextId, identityHub); |
|
0 commit comments