|
16 | 16 | import java.time.temporal.ChronoUnit;
|
17 | 17 | import java.util.List;
|
18 | 18 | import java.util.Map;
|
| 19 | +import java.util.UUID; |
19 | 20 | import java.util.stream.Collectors;
|
20 | 21 |
|
21 | 22 | import static access.teams.TeamsController.mapAuthority;
|
| 23 | +import static com.github.tomakehurst.wiremock.client.WireMock.*; |
| 24 | +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; |
22 | 25 | import static io.restassured.RestAssured.given;
|
23 | 26 | import static org.junit.jupiter.api.Assertions.*;
|
24 | 27 |
|
@@ -102,6 +105,42 @@ void migrateTeam() throws JsonProcessingException {
|
102 | 105 | assertEquals(team.getName(), group.get("name"));
|
103 | 106 | }
|
104 | 107 |
|
| 108 | + @Test |
| 109 | + void migrateTeamObjectOptimisticLockingFailureException() throws JsonProcessingException { |
| 110 | + List<Membership> memberships = getMemberships(); |
| 111 | + String manageId = UUID.randomUUID().toString(); |
| 112 | + Application application = new Application(manageId, EntityType.OIDC10_RP); |
| 113 | + application.setId(Long.MAX_VALUE - 1); |
| 114 | + |
| 115 | + List<Application> applications = List.of(application); |
| 116 | + Team team = new Team( |
| 117 | + "nl:surfnet:diensten:test", |
| 118 | + "test migration", |
| 119 | + "test migration", |
| 120 | + memberships, |
| 121 | + applications |
| 122 | + ); |
| 123 | + String path = String.format("/manage/api/internal/metadata/%s/%s", |
| 124 | + application.getManageType().name().toLowerCase(), manageId); |
| 125 | + String body = objectMapper.writeValueAsString(localManage.providerById(application.getManageType(), "7")); |
| 126 | + stubFor(get(urlPathMatching(path)).willReturn(aResponse() |
| 127 | + .withHeader("Content-Type", "application/json") |
| 128 | + .withBody(body))); |
| 129 | + |
| 130 | + super.stubForManageProvisioning(List.of()); |
| 131 | + |
| 132 | + given() |
| 133 | + .when() |
| 134 | + .auth().preemptive().basic("teams", "secret") |
| 135 | + .accept(ContentType.JSON) |
| 136 | + .contentType(ContentType.JSON) |
| 137 | + .body(team) |
| 138 | + .put("/api/external/v1/teams") |
| 139 | + .then() |
| 140 | + .statusCode(201); |
| 141 | + |
| 142 | + } |
| 143 | + |
105 | 144 | private List<Membership> getMemberships() {
|
106 | 145 | return userRoles.entrySet().stream()
|
107 | 146 | .map(entry -> new Membership(
|
|
0 commit comments