use of org.apache.syncope.ext.scimv2.api.data.SCIMGroup in project syncope by apache.
the class SCIMITCase method list.
@Test
public void list() throws IOException {
assumeTrue(SCIMDetector.isSCIMAvailable(webClient()));
Response response = webClient().path("Groups").query("count", 1100000).get();
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
SCIMError error = response.readEntity(SCIMError.class);
assertEquals(ErrorType.tooMany, error.getScimType());
response = webClient().path("Groups").query("sortBy", "displayName").query("count", 11).get();
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals(SCIMConstants.APPLICATION_SCIM_JSON, StringUtils.substringBefore(response.getHeaderString(HttpHeaders.CONTENT_TYPE), ";"));
ListResponse<SCIMGroup> result = response.readEntity(new GenericType<ListResponse<SCIMGroup>>() {
});
assertNotNull(result);
assertTrue(result.getTotalResults() > 0);
assertEquals(11, result.getItemsPerPage());
assertFalse(result.getResources().isEmpty());
result.getResources().forEach(group -> {
assertNotNull(group.getId());
assertNotNull(group.getDisplayName());
});
}
use of org.apache.syncope.ext.scimv2.api.data.SCIMGroup in project syncope by apache.
the class SCIMITCase method createGroup.
@Test
public void createGroup() {
assumeTrue(SCIMDetector.isSCIMAvailable(webClient()));
String displayName = UUID.randomUUID().toString();
SCIMGroup group = new SCIMGroup(null, null, displayName);
group.getMembers().add(new Member("1417acbe-cbf6-4277-9372-e75e04f97000", null, null));
assertNull(group.getId());
assertEquals(displayName, group.getDisplayName());
Response response = webClient().path("Groups").post(group);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
group = response.readEntity(SCIMGroup.class);
assertNotNull(group.getId());
assertTrue(response.getLocation().toASCIIString().endsWith(group.getId()));
assertEquals(1, group.getMembers().size());
assertEquals("1417acbe-cbf6-4277-9372-e75e04f97000", group.getMembers().get(0).getValue());
response = webClient().path("Users").path("1417acbe-cbf6-4277-9372-e75e04f97000").get();
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
SCIMUser user = response.readEntity(SCIMUser.class);
assertEquals("1417acbe-cbf6-4277-9372-e75e04f97000", user.getId());
response = webClient().path("Groups").post(group);
assertEquals(Response.Status.CONFLICT.getStatusCode(), response.getStatus());
SCIMError error = response.readEntity(SCIMError.class);
assertEquals(Response.Status.CONFLICT.getStatusCode(), error.getStatus());
assertEquals(ErrorType.uniqueness, error.getScimType());
}
use of org.apache.syncope.ext.scimv2.api.data.SCIMGroup in project syncope by apache.
the class SCIMITCase method deleteGroup.
@Test
public void deleteGroup() {
assumeTrue(SCIMDetector.isSCIMAvailable(webClient()));
SCIMGroup group = new SCIMGroup(null, null, UUID.randomUUID().toString());
Response response = webClient().path("Groups").post(group);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
group = response.readEntity(SCIMGroup.class);
assertNotNull(group.getId());
response = webClient().path("Groups").path(group.getId()).get();
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = webClient().path("Groups").path(group.getId()).delete();
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
response = webClient().path("Groups").path(group.getId()).get();
assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
}
use of org.apache.syncope.ext.scimv2.api.data.SCIMGroup in project syncope by apache.
the class SCIMITCase method search.
@Test
public void search() {
assumeTrue(SCIMDetector.isSCIMAvailable(webClient()));
// invalid filter
Response response = webClient().path("Groups").query("filter", "invalid").get();
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
SCIMError error = response.readEntity(SCIMError.class);
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), error.getStatus());
assertEquals(ErrorType.invalidFilter, error.getScimType());
// eq
response = webClient().path("Groups").query("filter", "displayName eq \"additional\"").get();
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals(SCIMConstants.APPLICATION_SCIM_JSON, StringUtils.substringBefore(response.getHeaderString(HttpHeaders.CONTENT_TYPE), ";"));
ListResponse<SCIMGroup> groups = response.readEntity(new GenericType<ListResponse<SCIMGroup>>() {
});
assertNotNull(groups);
assertEquals(1, groups.getTotalResults());
SCIMGroup additional = groups.getResources().get(0);
assertEquals("additional", additional.getDisplayName());
// eq via POST
SCIMSearchRequest request = new SCIMSearchRequest("displayName eq \"additional\"", null, null, null, null);
response = webClient().path("Groups").path("/.search").post(request);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals(SCIMConstants.APPLICATION_SCIM_JSON, StringUtils.substringBefore(response.getHeaderString(HttpHeaders.CONTENT_TYPE), ";"));
groups = response.readEntity(new GenericType<ListResponse<SCIMGroup>>() {
});
assertNotNull(groups);
assertEquals(1, groups.getTotalResults());
additional = groups.getResources().get(0);
assertEquals("additional", additional.getDisplayName());
// gt
UserTO newUser = userService.create(UserITCase.getUniqueSampleTO("scimsearch@syncope.apache.org"), true).readEntity(new GenericType<ProvisioningResult<UserTO>>() {
}).getEntity();
Date value = new Date(newUser.getCreationDate().getTime() - 1000);
response = webClient().path("Users").query("filter", "meta.created gt \"" + DATE_FORMAT.get().format(value) + "\"").get();
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals(SCIMConstants.APPLICATION_SCIM_JSON, StringUtils.substringBefore(response.getHeaderString(HttpHeaders.CONTENT_TYPE), ";"));
ListResponse<SCIMUser> users = response.readEntity(new GenericType<ListResponse<SCIMUser>>() {
});
assertNotNull(users);
assertEquals(1, users.getTotalResults());
SCIMUser newSCIMUser = users.getResources().get(0);
assertEquals(newUser.getUsername(), newSCIMUser.getUserName());
}
use of org.apache.syncope.ext.scimv2.api.data.SCIMGroup in project syncope by apache.
the class SCIMITCase method replaceGroup.
@Test
public void replaceGroup() {
assumeTrue(SCIMDetector.isSCIMAvailable(webClient()));
SCIMGroup group = new SCIMGroup(null, null, UUID.randomUUID().toString());
group.getMembers().add(new Member("b3cbc78d-32e6-4bd4-92e0-bbe07566a2ee", null, null));
Response response = webClient().path("Groups").post(group);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
group = response.readEntity(SCIMGroup.class);
assertNotNull(group.getId());
assertEquals(1, group.getMembers().size());
assertEquals("b3cbc78d-32e6-4bd4-92e0-bbe07566a2ee", group.getMembers().get(0).getValue());
group.setDisplayName("other" + group.getId());
group.getMembers().add(new Member("c9b2dec2-00a7-4855-97c0-d854842b4b24", null, null));
response = webClient().path("Groups").path(group.getId()).put(group);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
group = response.readEntity(SCIMGroup.class);
assertTrue(group.getDisplayName().startsWith("other"));
assertEquals(2, group.getMembers().size());
group.getMembers().clear();
group.getMembers().add(new Member("c9b2dec2-00a7-4855-97c0-d854842b4b24", null, null));
response = webClient().path("Groups").path(group.getId()).put(group);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
group = response.readEntity(SCIMGroup.class);
assertEquals(1, group.getMembers().size());
assertEquals("c9b2dec2-00a7-4855-97c0-d854842b4b24", group.getMembers().get(0).getValue());
}
Aggregations