Search in sources :

Example 6 with SCIMUser

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"));
}
Also used : ListResponse(org.apache.syncope.ext.scimv2.api.data.ListResponse) Response(javax.ws.rs.core.Response) SCIMUser(org.apache.syncope.ext.scimv2.api.data.SCIMUser) Test(org.junit.jupiter.api.Test)

Example 7 with SCIMUser

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;
}
Also used : SCIMUser(org.apache.syncope.ext.scimv2.api.data.SCIMUser) SCIMUserName(org.apache.syncope.ext.scimv2.api.data.SCIMUserName) SCIMComplexValue(org.apache.syncope.ext.scimv2.api.data.SCIMComplexValue)

Example 8 with SCIMUser

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());
}
Also used : ListResponse(org.apache.syncope.ext.scimv2.api.data.ListResponse) Response(javax.ws.rs.core.Response) Group(org.apache.syncope.ext.scimv2.api.data.Group) SCIMGroup(org.apache.syncope.ext.scimv2.api.data.SCIMGroup) SCIMUser(org.apache.syncope.ext.scimv2.api.data.SCIMUser) UserTO(org.apache.syncope.common.lib.to.UserTO) SCIMComplexValue(org.apache.syncope.ext.scimv2.api.data.SCIMComplexValue) Value(org.apache.syncope.ext.scimv2.api.data.Value) Test(org.junit.jupiter.api.Test)

Example 9 with SCIMUser

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());
}
Also used : ListResponse(org.apache.syncope.ext.scimv2.api.data.ListResponse) Response(javax.ws.rs.core.Response) SCIMUser(org.apache.syncope.ext.scimv2.api.data.SCIMUser) SCIMConf(org.apache.syncope.common.lib.scim.SCIMConf) Test(org.junit.jupiter.api.Test)

Example 10 with SCIMUser

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());
}
Also used : ListResponse(org.apache.syncope.ext.scimv2.api.data.ListResponse) Response(javax.ws.rs.core.Response) SCIMUser(org.apache.syncope.ext.scimv2.api.data.SCIMUser) Test(org.junit.jupiter.api.Test)

Aggregations

SCIMUser (org.apache.syncope.ext.scimv2.api.data.SCIMUser)10 Response (javax.ws.rs.core.Response)7 ListResponse (org.apache.syncope.ext.scimv2.api.data.ListResponse)7 Test (org.junit.jupiter.api.Test)7 UserTO (org.apache.syncope.common.lib.to.UserTO)5 SCIMGroup (org.apache.syncope.ext.scimv2.api.data.SCIMGroup)5 SCIMComplexValue (org.apache.syncope.ext.scimv2.api.data.SCIMComplexValue)4 SCIMConf (org.apache.syncope.common.lib.scim.SCIMConf)3 BadRequestException (org.apache.syncope.ext.scimv2.api.BadRequestException)3 Group (org.apache.syncope.ext.scimv2.api.data.Group)3 Member (org.apache.syncope.ext.scimv2.api.data.Member)3 SCIMError (org.apache.syncope.ext.scimv2.api.data.SCIMError)3 SCIMUserName (org.apache.syncope.ext.scimv2.api.data.SCIMUserName)3 Value (org.apache.syncope.ext.scimv2.api.data.Value)3 ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2