Search in sources :

Example 1 with PhoneNumber

use of io.jans.scim.model.scim2.user.PhoneNumber 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 PhoneNumber

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

the class PatchValueFilterUserTest method getDummyUser.

private UserResource getDummyUser() {
    user = new UserResource();
    user.setUserName("" + System.currentTimeMillis());
    user.setEmails(new ArrayList<>());
    user.setPhoneNumbers(new ArrayList<>());
    Email email = new Email();
    email.setValue("bjane@gluu.org");
    email.setDisplay("bjane");
    email.setPrimary(true);
    email.setType("work");
    user.getEmails().add(email);
    email = new Email();
    email.setValue("bjane@acme.org");
    email.setDisplay("bjane acme");
    email.setType("hobby");
    user.getEmails().add(email);
    PhoneNumber pn = new PhoneNumber();
    pn.setValue("+57 1234 56789");
    pn.setType("home");
    user.getPhoneNumbers().add(pn);
    pn = new PhoneNumber();
    pn.setValue("+1 1234 56789");
    pn.setType("work");
    pn.setPrimary(true);
    user.getPhoneNumbers().add(pn);
    Address address = new Address();
    address.setCountry("EG");
    address.setPrimary(false);
    address.setRegion("Somewhere");
    address.setStreetAddress("59 Acacia avenue");
    address.setLocality("Donington");
    user.setAddresses(Collections.singletonList(address));
    return user;
}
Also used : Email(io.jans.scim.model.scim2.user.Email) Address(io.jans.scim.model.scim2.user.Address) UserResource(io.jans.scim.model.scim2.user.UserResource) PhoneNumber(io.jans.scim.model.scim2.user.PhoneNumber)

Example 3 with PhoneNumber

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

the class PatchReplaceUserTest method jsonPathPatch2.

@Parameters({ "user_patchreplace_4" })
@Test(dependsOnMethods = "jsonPathPatch1")
public void jsonPathPatch2(String patchRequest) {
    Response response = client.patchUser(patchRequest, user.getId(), null, null);
    assertEquals(response.getStatus(), OK.getStatusCode());
    UserResource other = response.readEntity(usrClass);
    assertNotEquals(user.getName().getHonorificPrefix(), other.getName().getHonorificPrefix());
    assertNotEquals(user.getName().getHonorificSuffix(), other.getName().getHonorificSuffix());
    assertNotEquals(user.getName().getFormatted(), other.getName().getFormatted());
    // Verify change in the streetAddress
    Address adr = other.getAddresses().get(0);
    assertNotEquals(user.getAddresses().get(0).getStreetAddress(), adr.getStreetAddress());
    // Verify postal code is there
    assertNotNull(adr.getPostalCode());
    // Verify change in phone number values
    int num = user.getPhoneNumbers().size();
    assertEquals(num, other.getPhoneNumbers().size());
    Set<String> set1 = user.getPhoneNumbers().stream().map(PhoneNumber::getValue).collect(Collectors.toSet());
    Set<String> set2 = other.getPhoneNumbers().stream().map(PhoneNumber::getValue).collect(Collectors.toSet());
    assertFalse(set2.removeAll(set1));
    // Verify x509Certs disappeared
    assertNotNull(other.getX509Certificates());
    user = other;
}
Also used : Response(javax.ws.rs.core.Response) Address(io.jans.scim.model.scim2.user.Address) InstantMessagingAddress(io.jans.scim.model.scim2.user.InstantMessagingAddress) UserResource(io.jans.scim.model.scim2.user.UserResource) Parameters(org.testng.annotations.Parameters) UserBaseTest(io.jans.scim2.client.UserBaseTest) Test(org.testng.annotations.Test)

Example 4 with PhoneNumber

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

the class PatchReplaceUserTest method jsonNoPathPatch2.

@Parameters({ "user_patchreplace_2" })
@Test(dependsOnMethods = "jsonNoPathPatch1")
public void jsonNoPathPatch2(String patchRequest) {
    Response response = client.patchUser(patchRequest, user.getId(), null, null);
    assertEquals(response.getStatus(), OK.getStatusCode());
    UserResource other = response.readEntity(usrClass);
    assertNotEquals(user.getName().getHonorificPrefix(), other.getName().getHonorificPrefix());
    assertNotEquals(user.getName().getHonorificSuffix(), other.getName().getHonorificSuffix());
    assertNotEquals(user.getName().getFormatted(), other.getName().getFormatted());
    // Verify change in the streetAddress
    Address adr = other.getAddresses().get(0);
    assertNotEquals(user.getAddresses().get(0).getStreetAddress(), adr.getStreetAddress());
    // Verify other attributes were nulled
    assertNull(adr.getPostalCode());
    assertNull(adr.getRegion());
    // Verify change in number of phone numbers
    assertNotEquals(user.getPhoneNumbers().size(), other.getPhoneNumbers().size());
    // Verify new user has different phone numbers
    String phone = user.getPhoneNumbers().get(0).getValue();
    assertTrue(other.getPhoneNumbers().stream().map(PhoneNumber::getValue).noneMatch(phone::equals));
    // Verify x509Certs disappeared
    assertNull(other.getX509Certificates());
    // Verify "roles" are still there intact
    assertEquals(user.getRoles().size(), other.getRoles().size());
    assertEquals(user.getRoles().get(0).getValue(), other.getRoles().get(0).getValue());
    user = other;
}
Also used : Response(javax.ws.rs.core.Response) Address(io.jans.scim.model.scim2.user.Address) InstantMessagingAddress(io.jans.scim.model.scim2.user.InstantMessagingAddress) 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 5 with PhoneNumber

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

the class AverageUserTest method updateWithObject2.

@Test(dependsOnMethods = "updateWithObject1")
public void updateWithObject2() {
    UserResource aUser = new UserResource();
    aUser.setEmails(user.getEmails());
    aUser.setPhoneNumbers(user.getPhoneNumbers());
    // Change some canonical values
    aUser.getEmails().get(0).setType(Email.Type.HOME);
    aUser.getPhoneNumbers().get(0).setType("fax");
    PhoneNumber pager = new PhoneNumber();
    pager.setValue("+1 234 566 9999");
    pager.setType(PhoneNumber.Type.PAGER);
    aUser.getPhoneNumbers().add(pager);
    Response response = client.updateUser(aUser, user.getId(), "emails, addresses, phoneNumbers, userName", null);
    user = response.readEntity(UserResource.class);
    assertEquals(user.getEmails().get(0).getType(), Email.Type.HOME.name().toLowerCase());
    assertEquals(user.getPhoneNumbers().get(0).getType(), PhoneNumber.Type.FAX.name().toLowerCase());
    assertEquals(user.getPhoneNumbers().get(1).getType(), PhoneNumber.Type.PAGER.name().toLowerCase());
    assertNull(user.getPreferredLanguage());
    logger.debug("Updated user {}", user.getUserName());
}
Also used : Response(javax.ws.rs.core.Response) UserResource(io.jans.scim.model.scim2.user.UserResource) PhoneNumber(io.jans.scim.model.scim2.user.PhoneNumber) UserBaseTest(io.jans.scim2.client.UserBaseTest) Test(org.testng.annotations.Test)

Aggregations

UserResource (io.jans.scim.model.scim2.user.UserResource)5 PhoneNumber (io.jans.scim.model.scim2.user.PhoneNumber)4 UserBaseTest (io.jans.scim2.client.UserBaseTest)4 Response (javax.ws.rs.core.Response)4 Test (org.testng.annotations.Test)4 Address (io.jans.scim.model.scim2.user.Address)3 Parameters (org.testng.annotations.Parameters)3 InstantMessagingAddress (io.jans.scim.model.scim2.user.InstantMessagingAddress)2 CustomAttributes (io.jans.scim.model.scim2.CustomAttributes)1 Email (io.jans.scim.model.scim2.user.Email)1