Search in sources :

Example 1 with CustomAttributes

use of io.jans.scim.model.scim2.CustomAttributes in project jans by JanssenProject.

the class PatchUserExtTest method patchJson.

@Parameters({ "user_patch_ext" })
@Test(dependsOnMethods = "create")
public void patchJson(String patchRequest) {
    Response response = client.patchUser(patchRequest, user.getId(), null, null);
    assertEquals(response.getStatus(), OK.getStatusCode());
    UserResource other = response.readEntity(usrClass);
    // For help on usage of io.jans.scim.model.scim2.CustomAttributes class, read its api docs (oxtrust-scim maven project)
    CustomAttributes custAttrs = other.getCustomAttributes(USER_EXT_SCHEMA_ID);
    // Verify new items appeared in scimCustomSecond
    List<Date> scimCustomSecond = custAttrs.getValues("scimCustomSecond", Date.class);
    assertEquals(scimCustomSecond.size(), 6);
    // Verify change in value of scimCustomThird
    int scimCustomThird = custAttrs.getValue("scimCustomThird", Integer.class);
    assertEquals(1, scimCustomThird);
    // Verify scimCustomFirst disappeared
    assertNull(custAttrs.getValue("scimCustomFirst", String.class));
    // Verify some others disappeared too
    assertNull(other.getAddresses().get(0).getType());
    assertNull(other.getName().getGivenName());
    Stream<String> types = other.getPhoneNumbers().stream().map(PhoneNumber::getType);
    assertTrue(types.map(Optional::ofNullable).noneMatch(Optional::isPresent));
}
Also used : Response(javax.ws.rs.core.Response) CustomAttributes(io.jans.scim.model.scim2.CustomAttributes) UserResource(io.jans.scim.model.scim2.user.UserResource) PhoneNumber(io.jans.scim.model.scim2.user.PhoneNumber) Parameters(org.testng.annotations.Parameters) UserBaseTest(io.jans.scim2.client.UserBaseTest) Test(org.testng.annotations.Test)

Example 2 with CustomAttributes

use of io.jans.scim.model.scim2.CustomAttributes in project jans by JanssenProject.

the class FullUserTest method update.

@Parameters("user_full_update")
@Test(dependsOnMethods = "createFull")
public void update(String json) {
    logger.debug("Updating user {} with json", user.getUserName());
    Response response = client.updateUser(json, user.getId(), null, null);
    assertEquals(response.getStatus(), OK.getStatusCode());
    UserResource other = response.readEntity(usrClass);
    CustomAttributes custAttrs1 = user.getCustomAttributes(USER_EXT_SCHEMA_ID);
    CustomAttributes custAttrs2 = other.getCustomAttributes(USER_EXT_SCHEMA_ID);
    // Verify scimCustomFirst changed
    assertNotEquals(custAttrs1.getValue("scimCustomFirst", String.class), custAttrs2.getValue("scimCustomFirst", String.class));
    // Verify a new scimCustomSecond value
    List<Date> col1 = custAttrs1.getValues("scimCustomSecond", Date.class);
    List<Date> col2 = custAttrs2.getValues("scimCustomSecond", Date.class);
    assertNotEquals(col1.size(), col2.size());
    // Verify scimCustomThird is the same
    assertEquals(custAttrs1.getValue("scimCustomThird", Integer.class), custAttrs2.getValue("scimCustomThird", Integer.class));
    // Verify change in emails, addresses and phoneNumbers
    assertNotEquals(user.getEmails().size(), other.getEmails().size());
    assertNotEquals(user.getAddresses().size(), other.getAddresses().size());
    assertNotEquals(user.getPhoneNumbers().size(), other.getPhoneNumbers().size());
    // Verify x509Certificates disappeared
    assertNull(other.getX509Certificates());
    // Verify no change in user type
    assertEquals(user.getUserType(), other.getUserType());
    user = other;
}
Also used : Response(javax.ws.rs.core.Response) ListResponse(io.jans.scim.model.scim2.ListResponse) CustomAttributes(io.jans.scim.model.scim2.CustomAttributes) UserResource(io.jans.scim.model.scim2.user.UserResource) Parameters(org.testng.annotations.Parameters) UserBaseTest(io.jans.scim2.client.UserBaseTest) Test(org.testng.annotations.Test) SkipTest(io.jans.scim2.listener.SkipTest)

Example 3 with CustomAttributes

use of io.jans.scim.model.scim2.CustomAttributes in project jans by JanssenProject.

the class FullUserTest method createFull.

@Parameters("user_full_create")
@Test(dependsOnGroups = "avgTestFinished")
public void createFull(String json) {
    logger.debug("Creating user from json...");
    user = createUserFromJson(json);
    // Confirm extended attrs info is there
    // For help on usage of io.jans.scim.model.scim2.CustomAttributes class, read its api docs (oxtrust-scim maven project)
    CustomAttributes custAttrs = user.getCustomAttributes(USER_EXT_SCHEMA_ID);
    assertNotNull(custAttrs.getValue("scimCustomFirst", String.class));
    assertNotNull(custAttrs.getValues("scimCustomSecond", Date.class));
    assertNotNull(custAttrs.getValue("scimCustomThird", Integer.class));
    assertEquals(custAttrs.getValues("scimCustomSecond", Date.class).size(), 1);
}
Also used : CustomAttributes(io.jans.scim.model.scim2.CustomAttributes) Parameters(org.testng.annotations.Parameters) UserBaseTest(io.jans.scim2.client.UserBaseTest) Test(org.testng.annotations.Test) SkipTest(io.jans.scim2.listener.SkipTest)

Example 4 with CustomAttributes

use of io.jans.scim.model.scim2.CustomAttributes in project jans by JanssenProject.

the class QueryParamCreateUpdateTest method execAssertions.

private void execAssertions(UserResource user) {
    // Verify "ALWAYS" attribs were retrieved
    assertNotNull(user.getSchemas());
    assertNotNull(user.getId());
    // Verify no password was retrieved
    assertNull(user.getPassword());
    // Verify preferredLanguage is null (not provided in Json originally)
    assertNull(user.getPreferredLanguage());
    // Verify all others are present
    assertNotNull(user.getUserName());
    assertNotNull(user.getDisplayName());
    assertNotNull(user.getNickName());
    assertNotNull(user.getName().getGivenName());
    // Verify cust attrs are there
    CustomAttributes custAttrs = user.getCustomAttributes(USER_EXT_SCHEMA_ID);
    assertNotNull(custAttrs.getValues("scimCustomSecond", Date.class));
    assertNotNull(custAttrs.getValue("scimCustomThird", Integer.class));
    // Verify e-mails were retrieved
    assertNotNull(user.getEmails());
    assertTrue(user.getEmails().stream().map(Email::getValue).map(Optional::ofNullable).allMatch(Optional::isPresent));
}
Also used : CustomAttributes(io.jans.scim.model.scim2.CustomAttributes) Optional(java.util.Optional) Date(java.util.Date)

Example 5 with CustomAttributes

use of io.jans.scim.model.scim2.CustomAttributes in project jans by JanssenProject.

the class PatchUserExtTest method patchObject.

@Test(dependsOnMethods = "patchJson")
public void patchObject() {
    PatchOperation operation = new PatchOperation();
    operation.setOperation("replace");
    operation.setPath("urn:ietf:params:scim:schemas:extension:gluu:2.0:User:scimCustomSecond");
    long now = System.currentTimeMillis();
    List<String> someDates = Arrays.asList(now, now + 1000, now + 2000, now + 3000).stream().map(DateUtil::millisToISOString).collect(Collectors.toList());
    operation.setValue(someDates);
    PatchRequest pr = new PatchRequest();
    pr.setOperations(Collections.singletonList(operation));
    Response response = client.patchUser(pr, user.getId(), null, null);
    assertEquals(response.getStatus(), OK.getStatusCode());
    UserResource other = response.readEntity(usrClass);
    CustomAttributes custAttrs = other.getCustomAttributes(USER_EXT_SCHEMA_ID);
    // Verify different dates appeared in scimCustomSecond
    List<Date> scimCustomSecond = custAttrs.getValues("scimCustomSecond", Date.class);
    assertEquals(scimCustomSecond.size(), someDates.size());
    assertEquals(now, scimCustomSecond.get(0).getTime());
}
Also used : Response(javax.ws.rs.core.Response) CustomAttributes(io.jans.scim.model.scim2.CustomAttributes) PatchOperation(io.jans.scim.model.scim2.patch.PatchOperation) UserResource(io.jans.scim.model.scim2.user.UserResource) PatchRequest(io.jans.scim.model.scim2.patch.PatchRequest) UserBaseTest(io.jans.scim2.client.UserBaseTest) Test(org.testng.annotations.Test)

Aggregations

CustomAttributes (io.jans.scim.model.scim2.CustomAttributes)7 UserBaseTest (io.jans.scim2.client.UserBaseTest)6 Test (org.testng.annotations.Test)6 Response (javax.ws.rs.core.Response)5 UserResource (io.jans.scim.model.scim2.user.UserResource)4 SkipTest (io.jans.scim2.listener.SkipTest)3 Parameters (org.testng.annotations.Parameters)3 ListResponse (io.jans.scim.model.scim2.ListResponse)2 Date (java.util.Date)2 SearchRequest (io.jans.scim.model.scim2.SearchRequest)1 PatchOperation (io.jans.scim.model.scim2.patch.PatchOperation)1 PatchRequest (io.jans.scim.model.scim2.patch.PatchRequest)1 Name (io.jans.scim.model.scim2.user.Name)1 PhoneNumber (io.jans.scim.model.scim2.user.PhoneNumber)1 Optional (java.util.Optional)1