|
15 | 15 | import io.restassured.http.ContentType; |
16 | 16 | import jakarta.mail.Address; |
17 | 17 | import org.junit.jupiter.api.Test; |
18 | | -import org.springframework.http.HttpStatus; |
19 | 18 |
|
20 | 19 | import java.util.List; |
21 | 20 | import java.util.Optional; |
@@ -198,7 +197,8 @@ void contactInviteNewUserSuppressEmail() throws Exception { |
198 | 197 | List<MimeMessageParser> allMailMessages = allMailMessages(0); |
199 | 198 | assertEquals(0, allMailMessages.size()); |
200 | 199 | } |
201 | | - @Test |
| 200 | + |
| 201 | + @Test |
202 | 202 | void contactProvisioningRemoveScimRole() throws JsonProcessingException { |
203 | 203 | CRMRole crmRoleResearch = new CRMRole("5e17b508-08e4-e811-8100-005056956c1a", "CONBEH", "SURFconextbeheerder"); |
204 | 204 | CRMRole crmRoleCloud = new CRMRole("cf652619-08e4-e811-8100-005056956c1a", "CONVER", "SURFconextverantwoordelijke"); |
@@ -247,6 +247,67 @@ void contactProvisioningRemoveScimRole() throws JsonProcessingException { |
247 | 247 | assertEquals(3, user.getUserRoles().size()); |
248 | 248 | } |
249 | 249 |
|
| 250 | + @Test |
| 251 | + void contactProvisioningRoleEmptyApplications() { |
| 252 | + CRMRole crmRoleResearch = new CRMRole("ea61793b-c4a9-47a0-9558-40e684ded3be", "EMPTY", "Deprecated"); |
| 253 | + String crmContactID = UUID.randomUUID().toString(); |
| 254 | + String crmOrganisationID = UUID.randomUUID().toString(); |
| 255 | + CRMContact crmContact = createCrmContact(crmContactID, crmOrganisationID, crmRoleResearch, "steven", "nope.com", true); |
| 256 | + String sub = "urn:collab:person:nope.com:steven"; |
| 257 | + Optional<User> userOptional = userRepository.findBySubIgnoreCase(sub); |
| 258 | + assertTrue(userOptional.isEmpty()); |
| 259 | + |
| 260 | + String response = given() |
| 261 | + .when() |
| 262 | + .accept(ContentType.JSON) |
| 263 | + .header(API_KEY_HEADER, "secret") |
| 264 | + .contentType(ContentType.JSON) |
| 265 | + .body(crmContact) |
| 266 | + .post("/api/internal/v1/crm") |
| 267 | + .then() |
| 268 | + .extract() |
| 269 | + .asString(); |
| 270 | + assertEquals("created", response); |
| 271 | + |
| 272 | + userOptional = userRepository.findBySubIgnoreCase(sub); |
| 273 | + assertTrue(userOptional.isPresent()); |
| 274 | + assertEquals(0, userOptional.get().getUserRoles().size()); |
| 275 | + } |
| 276 | + |
| 277 | + @Test |
| 278 | + void contactInviteNoInvitationWithNoRoles() throws Exception { |
| 279 | + CRMRole crmRoleResearch = new CRMRole("ea61793b-c4a9-47a0-9558-40e684ded3be", "EMPTY", "Deprecated"); |
| 280 | + String crmContactID = UUID.randomUUID().toString(); |
| 281 | + String crmOrganisationID = UUID.randomUUID().toString(); |
| 282 | + CRMContact crmContact = createCrmContact(crmContactID, crmOrganisationID, crmRoleResearch, null, null, false); |
| 283 | + String sub = "urn:collab:person:nope.com:steven"; |
| 284 | + Optional<User> userOptional = userRepository.findBySubIgnoreCase(sub); |
| 285 | + assertTrue(userOptional.isEmpty()); |
| 286 | + |
| 287 | + String response = given() |
| 288 | + .when() |
| 289 | + .accept(ContentType.JSON) |
| 290 | + .header(API_KEY_HEADER, "secret") |
| 291 | + .contentType(ContentType.JSON) |
| 292 | + .body(crmContact) |
| 293 | + .post("/api/internal/v1/crm") |
| 294 | + .then() |
| 295 | + .extract() |
| 296 | + .asString(); |
| 297 | + assertEquals("created", response); |
| 298 | + |
| 299 | + Optional<User> optionalUser = userRepository.findByCrmContactIdAndCrmOrganisationId(crmContactID, |
| 300 | + crmOrganisationID); |
| 301 | + assertTrue(optionalUser.isEmpty()); |
| 302 | + |
| 303 | + List<Invitation> invitations = invitationRepository.findByCrmContactIdAndCrmOrganisationId( |
| 304 | + crmContactID, crmOrganisationID); |
| 305 | + assertEquals(0, invitations.size()); |
| 306 | + |
| 307 | + List<MimeMessageParser> allMailMessages = allMailMessages(0); |
| 308 | + assertEquals(0, allMailMessages.size()); |
| 309 | + } |
| 310 | + |
250 | 311 | @Test |
251 | 312 | void deleteUser() throws JsonProcessingException { |
252 | 313 | CRMContact crmContact = new CRMContact(); |
@@ -313,7 +374,7 @@ void scopeInviteRoleToUniqueCRMRoleIdAndOrganizationId() throws JsonProcessingEx |
313 | 374 | assertEquals(1, user.getUserRoles().size()); |
314 | 375 | //Now post the same CRMContact for a different user, but the same role. Enusure the role is not re-used |
315 | 376 | String newOrganisationID = UUID.randomUUID().toString(); |
316 | | - crmContact.setOrganisation(new CRMOrganisation(newOrganisationID,"abbrev","name")); |
| 377 | + crmContact.setOrganisation(new CRMOrganisation(newOrganisationID, "abbrev", "name")); |
317 | 378 | crmContact.setUid("second_user"); |
318 | 379 | response = given() |
319 | 380 | .when() |
|
0 commit comments