use of org.apache.syncope.ext.scimv2.api.data.SCIMUser in project syncope by apache.
the class SCIMITCase method replaceUser.
@Test
public void replaceUser() {
assumeTrue(SCIMDetector.isSCIMAvailable(webClient()));
scimConfService.set(CONF);
SCIMUser user = getSampleUser(UUID.randomUUID().toString());
Response response = webClient().path("Users").post(user);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
user = response.readEntity(SCIMUser.class);
assertNotNull(user.getId());
user.getName().setFormatted("new" + user.getUserName());
response = webClient().path("Users").path(user.getId()).put(user);
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
user = response.readEntity(SCIMUser.class);
assertTrue(user.getName().getFormatted().startsWith("new"));
}
use of org.apache.syncope.ext.scimv2.api.data.SCIMUser in project syncope by apache.
the class SCIMITCase method getSampleUser.
private SCIMUser getSampleUser(final String username) {
SCIMUser user = new SCIMUser(null, Collections.singletonList(Resource.User.schema()), null, username, true);
user.setPassword("password123");
SCIMUserName name = new SCIMUserName();
name.setGivenName(username);
name.setFamilyName("surname");
name.setFormatted(username);
user.setName(name);
SCIMComplexValue userId = new SCIMComplexValue();
userId.setType(EmailCanonicalType.work.name());
userId.setValue(username + "@syncope.apache.org");
user.getEmails().add(userId);
SCIMComplexValue email = new SCIMComplexValue();
email.setType(EmailCanonicalType.home.name());
email.setValue(username + "@syncope.apache.org");
user.getEmails().add(email);
return user;
}
use of org.apache.syncope.ext.scimv2.api.data.SCIMUser in project syncope by apache.
the class SCIMITCase method createUser.
@Test
public void createUser() throws JsonProcessingException {
assumeTrue(SCIMDetector.isSCIMAvailable(webClient()));
scimConfService.set(CONF);
SCIMUser user = getSampleUser(UUID.randomUUID().toString());
user.getRoles().add(new Value("User reviewer"));
user.getGroups().add(new Group("37d15e4c-cdc1-460b-a591-8505c8133806", null, null, null));
Response response = webClient().path("Users").post(user);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
user = response.readEntity(SCIMUser.class);
assertNotNull(user.getId());
assertTrue(response.getLocation().toASCIIString().endsWith(user.getId()));
UserTO userTO = userService.read(user.getId());
assertEquals(user.getUserName(), userTO.getUsername());
assertTrue(user.isActive());
assertEquals(user.getDisplayName(), userTO.getDerAttr("cn").get().getValues().get(0));
assertEquals(user.getName().getGivenName(), userTO.getPlainAttr("firstname").get().getValues().get(0));
assertEquals(user.getName().getFamilyName(), userTO.getPlainAttr("surname").get().getValues().get(0));
assertEquals(user.getName().getFormatted(), userTO.getPlainAttr("fullname").get().getValues().get(0));
assertEquals(user.getEmails().get(0).getValue(), userTO.getPlainAttr("userId").get().getValues().get(0));
assertEquals(user.getEmails().get(1).getValue(), userTO.getPlainAttr("email").get().getValues().get(0));
assertEquals(user.getRoles().get(0).getValue(), userTO.getRoles().get(0));
assertEquals(user.getGroups().get(0).getValue(), userTO.getMemberships().get(0).getGroupKey());
}
use of org.apache.syncope.ext.scimv2.api.data.SCIMUser in project syncope by apache.
the class SCIMITCase method conf.
@Test
public void conf() {
assumeTrue(SCIMDetector.isSCIMAvailable(webClient()));
SCIMConf conf = scimConfService.get();
assertNotNull(conf);
scimConfService.set(CONF);
Response response = webClient().path("Users").path("1417acbe-cbf6-4277-9372-e75e04f97000").get();
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
assertEquals(SCIMConstants.APPLICATION_SCIM_JSON, StringUtils.substringBefore(response.getHeaderString(HttpHeaders.CONTENT_TYPE), ";"));
SCIMUser user = response.readEntity(SCIMUser.class);
assertNotNull(user);
assertEquals("Rossini, Gioacchino", user.getDisplayName());
}
use of org.apache.syncope.ext.scimv2.api.data.SCIMUser in project syncope by apache.
the class SCIMITCase method deleteUser.
@Test
public void deleteUser() {
assumeTrue(SCIMDetector.isSCIMAvailable(webClient()));
scimConfService.set(CONF);
SCIMUser user = getSampleUser(UUID.randomUUID().toString());
Response response = webClient().path("Users").post(user);
assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
user = response.readEntity(SCIMUser.class);
assertNotNull(user.getId());
response = webClient().path("Users").path(user.getId()).get();
assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
response = webClient().path("Users").path(user.getId()).delete();
assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
response = webClient().path("Users").path(user.getId()).get();
assertEquals(Response.Status.NOT_FOUND.getStatusCode(), response.getStatus());
}
Aggregations