Search in sources :

Example 21 with ScimPerson

use of org.gluu.oxtrust.model.scim.ScimPerson in project oxTrust by GluuFederation.

the class CopyUtilsTestCreate method testCopyScim1EmptyCreate.

@Test
public void testCopyScim1EmptyCreate() throws Exception {
    GluuCustomPerson destination = new GluuCustomPerson();
    ScimPerson source = new ScimPerson();
    GluuCustomPerson copy = copyUtils.copy(source, destination, false);
    assertNull(copy);
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) ScimPerson(org.gluu.oxtrust.model.scim.ScimPerson) Test(org.testng.annotations.Test) ConfigurableTest(org.gluu.oxtrust.action.test.ConfigurableTest)

Example 22 with ScimPerson

use of org.gluu.oxtrust.model.scim.ScimPerson in project oxTrust by GluuFederation.

the class CopyUtilsTestCreate method testCopyScim1FilledMultipleAttributesCreate.

@Test
public void testCopyScim1FilledMultipleAttributesCreate() throws Exception {
    GluuCustomPerson destination = new GluuCustomPerson();
    ScimPerson source = new ScimPerson();
    source.setActive("true");
    ScimPersonAddresses address = new ScimPersonAddresses();
    address.setCountry("country");
    address.setFormatted("formatted");
    address.setLocality("locality");
    address.setPostalCode("postalCode");
    address.setPrimary("address_primary");
    address.setRegion("region");
    address.setStreetAddress("streetAddress");
    address.setType("address_type");
    List<ScimPersonAddresses> addresses = new ArrayList<ScimPersonAddresses>();
    addresses.add(address);
    source.setAddresses(addresses);
    List<ScimCustomAttributes> customAttributes = new ArrayList<ScimCustomAttributes>();
    ScimCustomAttributes customattribute = new ScimCustomAttributes();
    customattribute.setName("custom_name");
    List<String> values = new ArrayList<String>();
    values.add("value1");
    values.add("value3");
    values.add("value2");
    values.add("value4");
    customattribute.setValues(values);
    customAttributes.add(customattribute);
    source.setCustomAttributes(customAttributes);
    source.setDisplayName("displayName");
    ScimPersonEmails email = new ScimPersonEmails();
    email.setPrimary("email_primary");
    email.setType("email_type");
    email.setValue("email_value");
    List<ScimPersonEmails> emails = new ArrayList<ScimPersonEmails>();
    emails.add(email);
    source.setEmails(emails);
    ScimEntitlements entitlement = new ScimEntitlements();
    entitlement.setValue("entitlement_value");
    List<ScimEntitlements> entitlements = new ArrayList<ScimEntitlements>();
    entitlements.add(entitlement);
    source.setEntitlements(entitlements);
    source.setExternalId("externalId");
    ScimPersonGroups group1 = new ScimPersonGroups();
    group1.setDisplay("group_display");
    group1.setValue("group_value");
    ScimPersonGroups group2 = new ScimPersonGroups();
    group2.setDisplay("group_display1");
    group2.setValue("group_value1");
    List<ScimPersonGroups> groups = new ArrayList<ScimPersonGroups>();
    groups.add(group1);
    groups.add(group2);
    source.setGroups(groups);
    source.setId("id");
    ScimPersonIms personims = new ScimPersonIms();
    personims.setType("ims_type");
    personims.setValue("ims_value");
    List<ScimPersonIms> ims = new ArrayList<ScimPersonIms>();
    ims.add(personims);
    source.setIms(ims);
    source.setLocale("locale");
    PersonMeta meta = new PersonMeta();
    meta.setCreated("created");
    meta.setLastModified("lastModified");
    meta.setLocation("location");
    meta.setVersion("version");
    source.setMeta(meta);
    ScimName name = new ScimName();
    name.setFamilyName("familyName");
    name.setGivenName("givenName");
    name.setHonorificPrefix("honorificPrefix");
    name.setHonorificSuffix("honorificSuffix");
    name.setMiddleName("middleName");
    source.setName(name);
    source.setNickName("nickName");
    source.setPassword("password");
    ScimPersonPhones phonenumber = new ScimPersonPhones();
    phonenumber.setType("phone_type");
    phonenumber.setValue("phone_value");
    List<ScimPersonPhones> phoneNumbers = new ArrayList<ScimPersonPhones>();
    phoneNumbers.add(phonenumber);
    source.setPhoneNumbers(phoneNumbers);
    ScimPersonPhotos photo = new ScimPersonPhotos();
    photo.setType("photo_type");
    photo.setValue("photo_value");
    List<ScimPersonPhotos> photos = new ArrayList<ScimPersonPhotos>();
    photos.add(photo);
    source.setPhotos(photos);
    source.setPreferredLanguage("preferredLanguage");
    source.setProfileUrl("profileUrl");
    ScimRoles role = new ScimRoles();
    role.setValue("role_value");
    List<ScimRoles> roles = new ArrayList<ScimRoles>();
    roles.add(role);
    source.setRoles(roles);
    List<String> schemas = new ArrayList<String>();
    schemas.add("shema");
    source.setSchemas(schemas);
    source.setTimezone("timezone");
    source.setTitle("title");
    source.setUserName("userName");
    source.setUserType("userType");
    Scimx509Certificates cert = new Scimx509Certificates();
    cert.setValue("cert_value");
    List<Scimx509Certificates> x509Certificates = new ArrayList<Scimx509Certificates>();
    x509Certificates.add(cert);
    source.setX509Certificates(x509Certificates);
    GluuCustomPerson copy = copyUtils.copy(source, destination, false);
    assertNotNull(copy);
    assertEquals(copy.getUid(), "userName");
    assertEquals(copy.getGivenName(), "givenName");
    assertEquals(copy.getSurname(), "familyName");
    assertEquals(copy.getDisplayName(), "displayName");
    assertEquals(copy.getPreferredLanguage(), "preferredLanguage");
    assertEquals(copy.getTimezone(), "timezone");
    assertEquals(copy.getUserPassword(), "password");
    assertNotNull(copy.getMemberOf());
    assertEquals(copy.getMemberOf().size(), 2);
    assertEquals(copy.getMemberOf().get(0), "Mocked DN");
    assertEquals(copy.getMemberOf().get(1), "Mocked DN1");
    assertEquals(copy.getAttribute(GLUU_STATUS), "true");
    assertNull(copy.getAttribute(OX_TRUST_PHOTOS_TYPE));
    assertNull(copy.getAttribute(OX_TRUST_PHONE_TYPE));
    assertNull(copy.getAttribute(OX_TRUST_ADDRESS_PRIMARY));
    assertNull(copy.getAttribute(OX_TRUST_ADDRESS_TYPE));
    assertNull(copy.getAttribute(OX_TRUST_COUNTRY));
    assertNull(copy.getAttribute(OX_TRUST_POSTAL_CODE));
    assertNull(copy.getAttribute(OX_TRUST_REGION));
    assertNull(copy.getAttribute(OX_TRUST_LOCALITY));
    assertNull(copy.getAttribute(OX_TRUST_ADDRESS_FORMATTED));
    assertNull(copy.getAttribute(OX_TRUST_STREET));
    assertNull(copy.getAttribute(OX_TRUST_EMAIL_PRIMARY));
    assertNull(copy.getAttribute(OX_TRUST_EMAIL_TYPE));
    assertEquals(copy.getAttribute(OX_TRUST_META_LOCATION), "location");
    assertEquals(copy.getAttribute(OX_TRUST_META_VERSION), "version");
    assertEquals(copy.getAttribute(OX_TRUST_META_LAST_MODIFIED), "lastModified");
    assertEquals(copy.getAttribute(OX_TRUST_META_CREATED), "created");
    assertEquals(copy.getAttribute(OX_TRUSTX509_CERTIFICATE), "[{\"value\":\"cert_value\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_ENTITLEMENTS), "[{\"value\":\"entitlement_value\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_ROLE), "[{\"value\":\"role_value\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_ACTIVE), "true");
    assertEquals(copy.getAttribute(OX_TRUST_LOCALE), "locale");
    assertEquals(copy.getAttribute(OX_TRUST_TITLE), "title");
    assertEquals(copy.getAttribute(OX_TRUST_USER_TYPE), "userType");
    assertEquals(copy.getAttribute(OX_TRUST_PHOTOS), "[{\"value\":\"photo_value\",\"type\":\"photo_type\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_IMS_VALUE), "[{\"value\":\"ims_value\",\"type\":\"ims_type\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_PHONE_VALUE), "[{\"value\":\"phone_value\",\"type\":\"phone_type\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_ADDRESSES), "[{\"type\":\"address_type\",\"streetAddress\":\"streetAddress\",\"locality\":\"locality\",\"region\":\"region\",\"postalCode\":\"postalCode\",\"country\":\"country\",\"formatted\":\"formatted\",\"primary\":\"address_primary\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_EMAIL), "[{\"value\":\"email_value\",\"type\":\"email_type\",\"primary\":\"email_primary\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_PROFILE_URL), "profileUrl");
    assertEquals(copy.getAttribute(OX_TRUST_NICK_NAME), "nickName");
    assertEquals(copy.getAttribute(OX_TRUST_EXTERNAL_ID), "externalId");
    assertEquals(copy.getAttribute(OX_TRUSTHONORIFIC_SUFFIX), "honorificSuffix");
    assertEquals(copy.getAttribute(OX_TRUSTHONORIFIC_PREFIX), "honorificPrefix");
    assertEquals(copy.getAttribute(OX_TRUST_MIDDLE_NAME), "middleName");
}
Also used : ScimEntitlements(org.gluu.oxtrust.model.scim.ScimEntitlements) ArrayList(java.util.ArrayList) ScimPersonIms(org.gluu.oxtrust.model.scim.ScimPersonIms) GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) ScimPersonEmails(org.gluu.oxtrust.model.scim.ScimPersonEmails) PersonMeta(org.gluu.oxtrust.model.scim.PersonMeta) Scimx509Certificates(org.gluu.oxtrust.model.scim.Scimx509Certificates) ScimName(org.gluu.oxtrust.model.scim.ScimName) ScimRoles(org.gluu.oxtrust.model.scim.ScimRoles) ScimPersonAddresses(org.gluu.oxtrust.model.scim.ScimPersonAddresses) ScimPersonPhotos(org.gluu.oxtrust.model.scim.ScimPersonPhotos) ScimPersonGroups(org.gluu.oxtrust.model.scim.ScimPersonGroups) ScimPersonPhones(org.gluu.oxtrust.model.scim.ScimPersonPhones) ScimPerson(org.gluu.oxtrust.model.scim.ScimPerson) ScimCustomAttributes(org.gluu.oxtrust.model.scim.ScimCustomAttributes) Test(org.testng.annotations.Test) ConfigurableTest(org.gluu.oxtrust.action.test.ConfigurableTest)

Example 23 with ScimPerson

use of org.gluu.oxtrust.model.scim.ScimPerson in project oxTrust by GluuFederation.

the class CopyUtilsTestCreate method testCopyScim1FilledNullCustomAttributesCreate.

@Test
public void testCopyScim1FilledNullCustomAttributesCreate() throws Exception {
    GluuCustomPerson destination = new GluuCustomPerson();
    ScimPerson source = new ScimPerson();
    source.setActive("active");
    ScimPersonAddresses address = new ScimPersonAddresses();
    address.setCountry("country");
    address.setFormatted("formatted");
    address.setLocality("locality");
    address.setPostalCode("postalCode");
    address.setPrimary("address_primary");
    address.setRegion("region");
    address.setStreetAddress("streetAddress");
    address.setType("address_type");
    List<ScimPersonAddresses> addresses = new ArrayList<ScimPersonAddresses>();
    addresses.add(address);
    source.setAddresses(addresses);
    source.setCustomAttributes(null);
    source.setDisplayName("displayName");
    ScimPersonEmails email = new ScimPersonEmails();
    email.setPrimary("email_primary");
    email.setType("email_type");
    email.setValue("email_value");
    List<ScimPersonEmails> emails = new ArrayList<ScimPersonEmails>();
    emails.add(email);
    source.setEmails(emails);
    ScimEntitlements entitlement = new ScimEntitlements();
    entitlement.setValue("entitlement_value");
    List<ScimEntitlements> entitlements = new ArrayList<ScimEntitlements>();
    entitlements.add(entitlement);
    source.setEntitlements(entitlements);
    source.setExternalId("externalId");
    ScimPersonGroups group1 = new ScimPersonGroups();
    group1.setDisplay("group_display");
    group1.setValue("group_value");
    ScimPersonGroups group2 = new ScimPersonGroups();
    group2.setDisplay("group_display1");
    group2.setValue("group_value1");
    List<ScimPersonGroups> groups = new ArrayList<ScimPersonGroups>();
    groups.add(group1);
    groups.add(group2);
    source.setGroups(groups);
    source.setId("id");
    ScimPersonIms personims = new ScimPersonIms();
    personims.setType("ims_type");
    personims.setValue("ims_value");
    List<ScimPersonIms> ims = new ArrayList<ScimPersonIms>();
    ims.add(personims);
    source.setIms(ims);
    source.setLocale("locale");
    PersonMeta meta = new PersonMeta();
    meta.setCreated("created");
    meta.setLastModified("lastModified");
    meta.setLocation("location");
    meta.setVersion("version");
    source.setMeta(meta);
    ScimName name = new ScimName();
    name.setFamilyName("familyName");
    name.setGivenName("givenName");
    name.setHonorificPrefix("honorificPrefix");
    name.setHonorificSuffix("honorificSuffix");
    name.setMiddleName("middleName");
    source.setName(name);
    source.setNickName("nickName");
    source.setPassword("password");
    ScimPersonPhones phonenumber = new ScimPersonPhones();
    phonenumber.setType("phone_type");
    phonenumber.setValue("phone_value");
    List<ScimPersonPhones> phoneNumbers = new ArrayList<ScimPersonPhones>();
    phoneNumbers.add(phonenumber);
    source.setPhoneNumbers(phoneNumbers);
    ScimPersonPhotos photo = new ScimPersonPhotos();
    photo.setType("photo_type");
    photo.setValue("photo_value");
    List<ScimPersonPhotos> photos = new ArrayList<ScimPersonPhotos>();
    photos.add(photo);
    source.setPhotos(photos);
    source.setPreferredLanguage("preferredLanguage");
    source.setProfileUrl("profileUrl");
    ScimRoles role = new ScimRoles();
    role.setValue("role_value");
    List<ScimRoles> roles = new ArrayList<ScimRoles>();
    roles.add(role);
    source.setRoles(roles);
    List<String> schemas = new ArrayList<String>();
    schemas.add("shema");
    source.setSchemas(schemas);
    source.setTimezone("timezone");
    source.setTitle("title");
    source.setUserName("userName");
    source.setUserType("userType");
    Scimx509Certificates cert = new Scimx509Certificates();
    cert.setValue("cert_value");
    List<Scimx509Certificates> x509Certificates = new ArrayList<Scimx509Certificates>();
    x509Certificates.add(cert);
    source.setX509Certificates(x509Certificates);
    GluuCustomPerson copy = copyUtils.copy(source, destination, false);
    assertNotNull(copy);
    assertEquals(copy.getUid(), "userName");
    assertEquals(copy.getGivenName(), "givenName");
    assertEquals(copy.getSurname(), "familyName");
    assertEquals(copy.getDisplayName(), "displayName");
    assertEquals(copy.getPreferredLanguage(), "preferredLanguage");
    assertEquals(copy.getTimezone(), "timezone");
    assertEquals(copy.getUserPassword(), "password");
    assertNotNull(copy.getMemberOf());
    assertEquals(copy.getMemberOf().size(), 2);
    assertEquals(copy.getMemberOf().get(0), "Mocked DN");
    assertEquals(copy.getMemberOf().get(1), "Mocked DN1");
    assertNull(copy.getAttribute(GLUU_STATUS));
    assertNull(copy.getAttribute(OX_TRUST_PHOTOS_TYPE));
    assertNull(copy.getAttribute(OX_TRUST_PHONE_TYPE));
    assertNull(copy.getAttribute(OX_TRUST_ADDRESS_PRIMARY));
    assertNull(copy.getAttribute(OX_TRUST_ADDRESS_TYPE));
    assertNull(copy.getAttribute(OX_TRUST_COUNTRY));
    assertNull(copy.getAttribute(OX_TRUST_POSTAL_CODE));
    assertNull(copy.getAttribute(OX_TRUST_REGION));
    assertNull(copy.getAttribute(OX_TRUST_LOCALITY));
    assertNull(copy.getAttribute(OX_TRUST_ADDRESS_FORMATTED));
    assertNull(copy.getAttribute(OX_TRUST_STREET));
    assertNull(copy.getAttribute(OX_TRUST_EMAIL_PRIMARY));
    assertNull(copy.getAttribute(OX_TRUST_EMAIL_TYPE));
    assertEquals(copy.getAttribute(OX_TRUST_META_LOCATION), "location");
    assertEquals(copy.getAttribute(OX_TRUST_META_VERSION), "version");
    assertEquals(copy.getAttribute(OX_TRUST_META_LAST_MODIFIED), "lastModified");
    assertEquals(copy.getAttribute(OX_TRUST_META_CREATED), "created");
    assertEquals(copy.getAttribute(OX_TRUSTX509_CERTIFICATE), "[{\"value\":\"cert_value\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_ENTITLEMENTS), "[{\"value\":\"entitlement_value\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_ROLE), "[{\"value\":\"role_value\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_ACTIVE), "active");
    assertEquals(copy.getAttribute(OX_TRUST_LOCALE), "locale");
    assertEquals(copy.getAttribute(OX_TRUST_TITLE), "title");
    assertEquals(copy.getAttribute(OX_TRUST_USER_TYPE), "userType");
    assertEquals(copy.getAttribute(OX_TRUST_PHOTOS), "[{\"value\":\"photo_value\",\"type\":\"photo_type\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_IMS_VALUE), "[{\"value\":\"ims_value\",\"type\":\"ims_type\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_PHONE_VALUE), "[{\"value\":\"phone_value\",\"type\":\"phone_type\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_ADDRESSES), "[{\"type\":\"address_type\",\"streetAddress\":\"streetAddress\",\"locality\":\"locality\",\"region\":\"region\",\"postalCode\":\"postalCode\",\"country\":\"country\",\"formatted\":\"formatted\",\"primary\":\"address_primary\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_EMAIL), "[{\"value\":\"email_value\",\"type\":\"email_type\",\"primary\":\"email_primary\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_PROFILE_URL), "profileUrl");
    assertEquals(copy.getAttribute(OX_TRUST_NICK_NAME), "nickName");
    assertEquals(copy.getAttribute(OX_TRUST_EXTERNAL_ID), "externalId");
    assertEquals(copy.getAttribute(OX_TRUSTHONORIFIC_SUFFIX), "honorificSuffix");
    assertEquals(copy.getAttribute(OX_TRUSTHONORIFIC_PREFIX), "honorificPrefix");
    assertEquals(copy.getAttribute(OX_TRUST_MIDDLE_NAME), "middleName");
}
Also used : ScimEntitlements(org.gluu.oxtrust.model.scim.ScimEntitlements) ArrayList(java.util.ArrayList) ScimPersonIms(org.gluu.oxtrust.model.scim.ScimPersonIms) GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) ScimPersonEmails(org.gluu.oxtrust.model.scim.ScimPersonEmails) PersonMeta(org.gluu.oxtrust.model.scim.PersonMeta) Scimx509Certificates(org.gluu.oxtrust.model.scim.Scimx509Certificates) ScimName(org.gluu.oxtrust.model.scim.ScimName) ScimRoles(org.gluu.oxtrust.model.scim.ScimRoles) ScimPersonAddresses(org.gluu.oxtrust.model.scim.ScimPersonAddresses) ScimPersonPhotos(org.gluu.oxtrust.model.scim.ScimPersonPhotos) ScimPersonGroups(org.gluu.oxtrust.model.scim.ScimPersonGroups) ScimPersonPhones(org.gluu.oxtrust.model.scim.ScimPersonPhones) ScimPerson(org.gluu.oxtrust.model.scim.ScimPerson) Test(org.testng.annotations.Test) ConfigurableTest(org.gluu.oxtrust.action.test.ConfigurableTest)

Example 24 with ScimPerson

use of org.gluu.oxtrust.model.scim.ScimPerson in project oxTrust by GluuFederation.

the class CopyUtilsTestUpdate method testCopyScim1FilledUpdateExisting.

@Test
public void testCopyScim1FilledUpdateExisting() throws Exception {
    GluuCustomPerson destination = new GluuCustomPerson();
    destination.setAllowPublication(true);
    List<String> associatedClientDNs = new ArrayList<String>();
    associatedClientDNs.add("a");
    associatedClientDNs.add("b");
    associatedClientDNs.add("c");
    destination.setAssociatedClient(associatedClientDNs);
    destination.setBaseDn("dn");
    destination.setAttribute(OX_TRUST_NICK_NAME, "original nickname");
    destination.setAttribute(OX_TRUST_PROFILE_URL, "original url");
    destination.setCommonName("CN");
    destination.setGivenName("original givenname");
    destination.setPreferredLanguage("Nederlands");
    destination.setAttribute(OX_TRUST_ENTITLEMENTS, "[{\"value\":\"original entitlement_value\"}]");
    ScimPerson source = new ScimPerson();
    source.setActive("true");
    ScimPersonAddresses address = new ScimPersonAddresses();
    address.setCountry("country");
    address.setFormatted("formatted");
    address.setLocality("locality");
    address.setPostalCode("postalCode");
    address.setPrimary("address_primary");
    address.setRegion("region");
    address.setStreetAddress("streetAddress");
    address.setType("address_type");
    List<ScimPersonAddresses> addresses = new ArrayList<ScimPersonAddresses>();
    addresses.add(address);
    source.setAddresses(addresses);
    List<ScimCustomAttributes> customAttributes = new ArrayList<ScimCustomAttributes>();
    ScimCustomAttributes customattribute = new ScimCustomAttributes();
    customattribute.setName("custom_name");
    List<String> values = new ArrayList<String>();
    String value = "value";
    values.add(value);
    customattribute.setValues(values);
    customAttributes.add(customattribute);
    ScimCustomAttributes customattribute2 = new ScimCustomAttributes();
    customattribute2.setName("custom_name2");
    List<String> values2 = new ArrayList<String>();
    String value2 = "value";
    values2.add(value2);
    customattribute2.setValues(values2);
    customAttributes.add(customattribute2);
    source.setCustomAttributes(customAttributes);
    source.setDisplayName("displayName");
    ScimPersonEmails email = new ScimPersonEmails();
    email.setPrimary("email_primary");
    email.setType("email_type");
    email.setValue("email_value");
    List<ScimPersonEmails> emails = new ArrayList<ScimPersonEmails>();
    emails.add(email);
    source.setEmails(emails);
    ScimEntitlements entitlement = new ScimEntitlements();
    entitlement.setValue("entitlement_value");
    List<ScimEntitlements> entitlements = new ArrayList<ScimEntitlements>();
    entitlements.add(entitlement);
    source.setEntitlements(entitlements);
    source.setExternalId("externalId");
    ScimPersonGroups group = new ScimPersonGroups();
    group.setDisplay("group_display");
    group.setValue("group_value");
    List<ScimPersonGroups> groups = new ArrayList<ScimPersonGroups>();
    groups.add(group);
    source.setGroups(groups);
    source.setId("id");
    ScimPersonIms personims = new ScimPersonIms();
    personims.setType("ims_type");
    personims.setValue("ims_value");
    List<ScimPersonIms> ims = new ArrayList<ScimPersonIms>();
    ims.add(personims);
    source.setIms(ims);
    source.setLocale("locale");
    PersonMeta meta = new PersonMeta();
    meta.setCreated("created");
    meta.setLastModified("lastModified");
    meta.setLocation("location");
    meta.setVersion("version");
    source.setMeta(meta);
    ScimName name = new ScimName();
    name.setFamilyName("familyName");
    name.setGivenName("givenName");
    name.setHonorificPrefix("honorificPrefix");
    name.setHonorificSuffix("honorificSuffix");
    name.setMiddleName("middleName");
    source.setName(name);
    source.setNickName("nickName");
    source.setPassword("password");
    ScimPersonPhones phonenumber = new ScimPersonPhones();
    phonenumber.setType("phone_type");
    phonenumber.setValue("phone_value");
    List<ScimPersonPhones> phoneNumbers = new ArrayList<ScimPersonPhones>();
    phoneNumbers.add(phonenumber);
    source.setPhoneNumbers(phoneNumbers);
    ScimPersonPhotos photo = new ScimPersonPhotos();
    photo.setType("photo_type");
    photo.setValue("photo_value");
    List<ScimPersonPhotos> photos = new ArrayList<ScimPersonPhotos>();
    photos.add(photo);
    source.setPhotos(photos);
    source.setPreferredLanguage("preferredLanguage");
    source.setProfileUrl(null);
    ScimRoles role = new ScimRoles();
    role.setValue("role_value");
    List<ScimRoles> roles = new ArrayList<ScimRoles>();
    roles.add(role);
    source.setRoles(roles);
    List<String> schemas = new ArrayList<String>();
    schemas.add("shema");
    source.setSchemas(schemas);
    source.setTimezone("timezone");
    source.setTitle("title");
    source.setUserName("userName");
    source.setUserType("userType");
    Scimx509Certificates cert = new Scimx509Certificates();
    cert.setValue("cert_value");
    List<Scimx509Certificates> x509Certificates = new ArrayList<Scimx509Certificates>();
    x509Certificates.add(cert);
    source.setX509Certificates(x509Certificates);
    GluuCustomPerson copy = copyUtils.copy(source, destination, true);
    assertNotNull(copy);
    assertEquals(copy.getUid(), "userName");
    assertEquals(copy.getGivenName(), "givenName");
    assertEquals(copy.getSurname(), "familyName");
    assertEquals(copy.getDisplayName(), "displayName");
    assertEquals(copy.getPreferredLanguage(), "preferredLanguage");
    assertEquals(copy.getTimezone(), "timezone");
    assertEquals(copy.getUserPassword(), "password");
    assertNotNull(copy.getMemberOf());
    assertEquals(copy.getMemberOf().size(), 1);
    assertEquals(copy.getMemberOf().get(0), "Mocked DN");
    assertEquals(copy.getAttribute(GLUU_STATUS), "true");
    assertNull(copy.getAttribute(OX_TRUST_PHOTOS_TYPE));
    assertNull(copy.getAttribute(OX_TRUST_PHONE_TYPE));
    assertNull(copy.getAttribute(OX_TRUST_ADDRESS_PRIMARY));
    assertNull(copy.getAttribute(OX_TRUST_ADDRESS_TYPE));
    assertNull(copy.getAttribute(OX_TRUST_COUNTRY));
    assertNull(copy.getAttribute(OX_TRUST_POSTAL_CODE));
    assertNull(copy.getAttribute(OX_TRUST_REGION));
    assertNull(copy.getAttribute(OX_TRUST_LOCALITY));
    assertNull(copy.getAttribute(OX_TRUST_ADDRESS_FORMATTED));
    assertNull(copy.getAttribute(OX_TRUST_STREET));
    assertNull(copy.getAttribute(OX_TRUST_EMAIL_PRIMARY));
    assertNull(copy.getAttribute(OX_TRUST_EMAIL_TYPE));
    assertEquals(copy.getAttribute(OX_TRUST_META_LOCATION), "location");
    assertEquals(copy.getAttribute(OX_TRUST_META_VERSION), "version");
    assertEquals(copy.getAttribute(OX_TRUST_META_LAST_MODIFIED), "lastModified");
    assertEquals(copy.getAttribute(OX_TRUST_META_CREATED), "created");
    assertEquals(copy.getAttribute(OX_TRUSTX509_CERTIFICATE), "[{\"value\":\"cert_value\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_ENTITLEMENTS), "[{\"value\":\"entitlement_value\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_ROLE), "[{\"value\":\"role_value\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_ACTIVE), "true");
    assertEquals(copy.getAttribute(OX_TRUST_LOCALE), "locale");
    assertEquals(copy.getAttribute(OX_TRUST_TITLE), "title");
    assertEquals(copy.getAttribute(OX_TRUST_USER_TYPE), "userType");
    assertEquals(copy.getAttribute(OX_TRUST_PHOTOS), "[{\"value\":\"photo_value\",\"type\":\"photo_type\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_IMS_VALUE), "[{\"value\":\"ims_value\",\"type\":\"ims_type\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_PHONE_VALUE), "[{\"value\":\"phone_value\",\"type\":\"phone_type\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_ADDRESSES), "[{\"type\":\"address_type\",\"streetAddress\":\"streetAddress\",\"locality\":\"locality\",\"region\":\"region\",\"postalCode\":\"postalCode\",\"country\":\"country\",\"formatted\":\"formatted\",\"primary\":\"address_primary\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_EMAIL), "[{\"value\":\"email_value\",\"type\":\"email_type\",\"primary\":\"email_primary\"}]");
    assertNull(copy.getAttribute(OX_TRUST_PROFILE_URL));
    assertEquals(copy.getAttribute(OX_TRUST_NICK_NAME), "nickName");
    assertEquals(copy.getAttribute(OX_TRUST_EXTERNAL_ID), "externalId");
    assertEquals(copy.getAttribute(OX_TRUSTHONORIFIC_SUFFIX), "honorificSuffix");
    assertEquals(copy.getAttribute(OX_TRUSTHONORIFIC_PREFIX), "honorificPrefix");
    assertEquals(copy.getAttribute(OX_TRUST_MIDDLE_NAME), "middleName");
    assertEquals(copy.getAssociatedClient().size(), 3);
    assertEquals(copy.getBaseDn(), "dn");
    assertEquals(copy.getCommonName(), "CN");
    List<GluuCustomAttribute> customAttributes2 = copy.getCustomAttributes();
    assertNotNull(customAttributes2);
    assertEquals(customAttributes2.size(), 33);
    assertEquals(copy.getDisplayName(), "displayName");
    assertEquals(copy.getDn(), "dn");
    assertEquals(copy.getGivenName(), "givenName");
    assertEquals(copy.getGluuAllowPublication(), "true");
    GluuCustomAttribute gluuCustomAttribute = copy.getGluuCustomAttribute("custom_name");
    assertNotNull(gluuCustomAttribute);
    assertEquals(gluuCustomAttribute.getName(), "custom_name");
    assertEquals(gluuCustomAttribute.getValue(), "value");
    assertNull(gluuCustomAttribute.getDate());
    assertEquals(gluuCustomAttribute.getDisplayValue(), "value");
    assertNull(gluuCustomAttribute.getMetadata());
    assertEquals(gluuCustomAttribute.getValues()[0], "value");
    assertNull(copy.getGluuOptOuts());
    assertNull(copy.getIname());
    assertNull(copy.getMail());
    assertEquals(copy.getMemberOf().get(0), "Mocked DN");
    assertNull(copy.getNetworkPoken());
    assertNull(copy.getCreationDate());
    assertEquals(copy.getPreferredLanguage(), "preferredLanguage");
    assertNull(copy.getSLAManager());
    assertNull(copy.getSourceServerName());
    assertNull(copy.getStatus());
    assertEquals(copy.getSurname(), "familyName");
    assertEquals(copy.getTimezone(), "timezone");
    assertEquals(copy.getUid(), "userName");
    assertEquals(copy.getUserPassword(), "password");
}
Also used : ScimEntitlements(org.gluu.oxtrust.model.scim.ScimEntitlements) ArrayList(java.util.ArrayList) ScimPersonIms(org.gluu.oxtrust.model.scim.ScimPersonIms) GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) ScimPersonEmails(org.gluu.oxtrust.model.scim.ScimPersonEmails) PersonMeta(org.gluu.oxtrust.model.scim.PersonMeta) Scimx509Certificates(org.gluu.oxtrust.model.scim.Scimx509Certificates) GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) ScimName(org.gluu.oxtrust.model.scim.ScimName) ScimRoles(org.gluu.oxtrust.model.scim.ScimRoles) ScimPersonAddresses(org.gluu.oxtrust.model.scim.ScimPersonAddresses) ScimPersonPhotos(org.gluu.oxtrust.model.scim.ScimPersonPhotos) ScimPersonGroups(org.gluu.oxtrust.model.scim.ScimPersonGroups) ScimPersonPhones(org.gluu.oxtrust.model.scim.ScimPersonPhones) ScimPerson(org.gluu.oxtrust.model.scim.ScimPerson) ScimCustomAttributes(org.gluu.oxtrust.model.scim.ScimCustomAttributes) Test(org.testng.annotations.Test) ConfigurableTest(org.gluu.oxtrust.action.test.ConfigurableTest)

Example 25 with ScimPerson

use of org.gluu.oxtrust.model.scim.ScimPerson in project oxTrust by GluuFederation.

the class CopyUtilsTestUpdate method testCopyScim1FilledUpdate.

@Test
public void testCopyScim1FilledUpdate() throws Exception {
    GluuCustomPerson destination = new GluuCustomPerson();
    ScimPerson source = new ScimPerson();
    source.setActive("active");
    ScimPersonAddresses address = new ScimPersonAddresses();
    address.setCountry("country");
    address.setFormatted("formatted");
    address.setLocality("locality");
    address.setPostalCode("postalCode");
    address.setPrimary("address_primary");
    address.setRegion("region");
    address.setStreetAddress("streetAddress");
    address.setType("address_type");
    List<ScimPersonAddresses> addresses = new ArrayList<ScimPersonAddresses>();
    addresses.add(address);
    source.setAddresses(addresses);
    List<ScimCustomAttributes> customAttributes = new ArrayList<ScimCustomAttributes>();
    ScimCustomAttributes customattribute = new ScimCustomAttributes();
    customattribute.setName("custom_name");
    List<String> values = new ArrayList<String>();
    String value = "value";
    values.add(value);
    customattribute.setValues(values);
    customAttributes.add(customattribute);
    source.setCustomAttributes(customAttributes);
    source.setDisplayName("displayName");
    ScimPersonEmails email = new ScimPersonEmails();
    email.setPrimary("email_primary");
    email.setType("email_type");
    email.setValue("email_value");
    List<ScimPersonEmails> emails = new ArrayList<ScimPersonEmails>();
    emails.add(email);
    source.setEmails(emails);
    ScimEntitlements entitlement = new ScimEntitlements();
    entitlement.setValue("entitlement_value");
    List<ScimEntitlements> entitlements = new ArrayList<ScimEntitlements>();
    entitlements.add(entitlement);
    source.setEntitlements(entitlements);
    source.setExternalId("externalId");
    ScimPersonGroups group = new ScimPersonGroups();
    group.setDisplay("group_display");
    group.setValue("group_value");
    List<ScimPersonGroups> groups = new ArrayList<ScimPersonGroups>();
    groups.add(group);
    source.setGroups(groups);
    source.setId("id");
    ScimPersonIms personims = new ScimPersonIms();
    personims.setType("ims_type");
    personims.setValue("ims_value");
    List<ScimPersonIms> ims = new ArrayList<ScimPersonIms>();
    ims.add(personims);
    source.setIms(ims);
    source.setLocale("locale");
    PersonMeta meta = new PersonMeta();
    meta.setCreated("created");
    meta.setLastModified("lastModified");
    meta.setLocation("location");
    meta.setVersion("version");
    source.setMeta(meta);
    ScimName name = new ScimName();
    name.setFamilyName("familyName");
    name.setGivenName("givenName");
    name.setHonorificPrefix("honorificPrefix");
    name.setHonorificSuffix("honorificSuffix");
    name.setMiddleName("middleName");
    source.setName(name);
    source.setNickName("nickName");
    source.setPassword("password");
    ScimPersonPhones phonenumber = new ScimPersonPhones();
    phonenumber.setType("phone_type");
    phonenumber.setValue("phone_value");
    List<ScimPersonPhones> phoneNumbers = new ArrayList<ScimPersonPhones>();
    phoneNumbers.add(phonenumber);
    source.setPhoneNumbers(phoneNumbers);
    ScimPersonPhotos photo = new ScimPersonPhotos();
    photo.setType("photo_type");
    photo.setValue("photo_value");
    List<ScimPersonPhotos> photos = new ArrayList<ScimPersonPhotos>();
    photos.add(photo);
    source.setPhotos(photos);
    source.setPreferredLanguage("preferredLanguage");
    source.setProfileUrl("profileUrl");
    ScimRoles role = new ScimRoles();
    role.setValue("role_value");
    List<ScimRoles> roles = new ArrayList<ScimRoles>();
    roles.add(role);
    source.setRoles(roles);
    List<String> schemas = new ArrayList<String>();
    schemas.add("shema");
    source.setSchemas(schemas);
    source.setTimezone("timezone");
    source.setTitle("title");
    source.setUserName("userName");
    source.setUserType("userType");
    Scimx509Certificates cert = new Scimx509Certificates();
    cert.setValue("cert_value");
    List<Scimx509Certificates> x509Certificates = new ArrayList<Scimx509Certificates>();
    x509Certificates.add(cert);
    source.setX509Certificates(x509Certificates);
    GluuCustomPerson copy = copyUtils.copy(source, destination, true);
    assertNotNull(copy);
    assertEquals(copy.getUid(), "userName");
    assertEquals(copy.getGivenName(), "givenName");
    assertEquals(copy.getSurname(), "familyName");
    assertEquals(copy.getDisplayName(), "displayName");
    assertEquals(copy.getPreferredLanguage(), "preferredLanguage");
    assertEquals(copy.getTimezone(), "timezone");
    assertEquals(copy.getUserPassword(), "password");
    assertNotNull(copy.getMemberOf());
    assertEquals(copy.getMemberOf().size(), 1);
    assertEquals(copy.getMemberOf().get(0), "Mocked DN");
    assertNull(copy.getAttribute(GLUU_STATUS));
    assertNull(copy.getAttribute(OX_TRUST_PHOTOS_TYPE));
    assertNull(copy.getAttribute(OX_TRUST_PHONE_TYPE));
    assertNull(copy.getAttribute(OX_TRUST_ADDRESS_PRIMARY));
    assertNull(copy.getAttribute(OX_TRUST_ADDRESS_TYPE));
    assertNull(copy.getAttribute(OX_TRUST_COUNTRY));
    assertNull(copy.getAttribute(OX_TRUST_POSTAL_CODE));
    assertNull(copy.getAttribute(OX_TRUST_REGION));
    assertNull(copy.getAttribute(OX_TRUST_LOCALITY));
    assertNull(copy.getAttribute(OX_TRUST_ADDRESS_FORMATTED));
    assertNull(copy.getAttribute(OX_TRUST_STREET));
    assertNull(copy.getAttribute(OX_TRUST_EMAIL_PRIMARY));
    assertNull(copy.getAttribute(OX_TRUST_EMAIL_TYPE));
    assertEquals(copy.getAttribute(OX_TRUST_META_LOCATION), "location");
    assertEquals(copy.getAttribute(OX_TRUST_META_VERSION), "version");
    assertEquals(copy.getAttribute(OX_TRUST_META_LAST_MODIFIED), "lastModified");
    assertEquals(copy.getAttribute(OX_TRUST_META_CREATED), "created");
    assertEquals(copy.getAttribute(OX_TRUSTX509_CERTIFICATE), "[{\"value\":\"cert_value\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_ENTITLEMENTS), "[{\"value\":\"entitlement_value\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_ROLE), "[{\"value\":\"role_value\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_ACTIVE), "active");
    assertEquals(copy.getAttribute(OX_TRUST_LOCALE), "locale");
    assertEquals(copy.getAttribute(OX_TRUST_TITLE), "title");
    assertEquals(copy.getAttribute(OX_TRUST_USER_TYPE), "userType");
    assertEquals(copy.getAttribute(OX_TRUST_PHOTOS), "[{\"value\":\"photo_value\",\"type\":\"photo_type\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_IMS_VALUE), "[{\"value\":\"ims_value\",\"type\":\"ims_type\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_PHONE_VALUE), "[{\"value\":\"phone_value\",\"type\":\"phone_type\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_ADDRESSES), "[{\"type\":\"address_type\",\"streetAddress\":\"streetAddress\",\"locality\":\"locality\",\"region\":\"region\",\"postalCode\":\"postalCode\",\"country\":\"country\",\"formatted\":\"formatted\",\"primary\":\"address_primary\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_EMAIL), "[{\"value\":\"email_value\",\"type\":\"email_type\",\"primary\":\"email_primary\"}]");
    assertEquals(copy.getAttribute(OX_TRUST_PROFILE_URL), "profileUrl");
    assertEquals(copy.getAttribute(OX_TRUST_NICK_NAME), "nickName");
    assertEquals(copy.getAttribute(OX_TRUST_EXTERNAL_ID), "externalId");
    assertEquals(copy.getAttribute(OX_TRUSTHONORIFIC_SUFFIX), "honorificSuffix");
    assertEquals(copy.getAttribute(OX_TRUSTHONORIFIC_PREFIX), "honorificPrefix");
    assertEquals(copy.getAttribute(OX_TRUST_MIDDLE_NAME), "middleName");
    assertNull(copy.getAssociatedClient());
    assertNull(copy.getBaseDn());
    assertNull(copy.getCommonName());
    List<GluuCustomAttribute> customAttributes2 = copy.getCustomAttributes();
    assertNotNull(customAttributes2);
    assertEquals(customAttributes2.size(), 31);
    assertEquals(copy.getDisplayName(), "displayName");
    assertNull(copy.getDn());
    assertEquals(copy.getGivenName(), "givenName");
    assertNull(copy.getGluuAllowPublication());
    GluuCustomAttribute gluuCustomAttribute = copy.getGluuCustomAttribute("custom_name");
    assertNotNull(gluuCustomAttribute);
    assertEquals(gluuCustomAttribute.getName(), "custom_name");
    assertEquals(gluuCustomAttribute.getValue(), "value");
    assertNull(gluuCustomAttribute.getDate());
    assertEquals(gluuCustomAttribute.getDisplayValue(), "value");
    assertNull(gluuCustomAttribute.getMetadata());
    assertEquals(gluuCustomAttribute.getValues()[0], "value");
    assertNull(copy.getGluuOptOuts());
    assertNull(copy.getIname());
    assertNull(copy.getMail());
    assertEquals(copy.getMemberOf().get(0), "Mocked DN");
    assertNull(copy.getNetworkPoken());
    assertNull(copy.getCreationDate());
    assertEquals(copy.getPreferredLanguage(), "preferredLanguage");
    assertNull(copy.getSLAManager());
    assertNull(copy.getSourceServerName());
    assertNull(copy.getStatus());
    assertEquals(copy.getSurname(), "familyName");
    assertEquals(copy.getTimezone(), "timezone");
    assertEquals(copy.getUid(), "userName");
    assertEquals(copy.getUserPassword(), "password");
}
Also used : ScimEntitlements(org.gluu.oxtrust.model.scim.ScimEntitlements) ArrayList(java.util.ArrayList) ScimPersonIms(org.gluu.oxtrust.model.scim.ScimPersonIms) GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) ScimPersonEmails(org.gluu.oxtrust.model.scim.ScimPersonEmails) PersonMeta(org.gluu.oxtrust.model.scim.PersonMeta) Scimx509Certificates(org.gluu.oxtrust.model.scim.Scimx509Certificates) GluuCustomAttribute(org.gluu.oxtrust.model.GluuCustomAttribute) ScimName(org.gluu.oxtrust.model.scim.ScimName) ScimRoles(org.gluu.oxtrust.model.scim.ScimRoles) ScimPersonAddresses(org.gluu.oxtrust.model.scim.ScimPersonAddresses) ScimPersonPhotos(org.gluu.oxtrust.model.scim.ScimPersonPhotos) ScimPersonGroups(org.gluu.oxtrust.model.scim.ScimPersonGroups) ScimPersonPhones(org.gluu.oxtrust.model.scim.ScimPersonPhones) ScimPerson(org.gluu.oxtrust.model.scim.ScimPerson) ScimCustomAttributes(org.gluu.oxtrust.model.scim.ScimCustomAttributes) Test(org.testng.annotations.Test) ConfigurableTest(org.gluu.oxtrust.action.test.ConfigurableTest)

Aggregations

ScimPerson (org.gluu.oxtrust.model.scim.ScimPerson)27 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)26 ConfigurableTest (org.gluu.oxtrust.action.test.ConfigurableTest)18 Test (org.testng.annotations.Test)18 ArrayList (java.util.ArrayList)16 ScimPersonAddresses (org.gluu.oxtrust.model.scim.ScimPersonAddresses)14 ScimPersonEmails (org.gluu.oxtrust.model.scim.ScimPersonEmails)14 ScimPersonGroups (org.gluu.oxtrust.model.scim.ScimPersonGroups)14 ScimPersonIms (org.gluu.oxtrust.model.scim.ScimPersonIms)14 ScimPersonPhones (org.gluu.oxtrust.model.scim.ScimPersonPhones)14 ScimPersonPhotos (org.gluu.oxtrust.model.scim.ScimPersonPhotos)14 ScimRoles (org.gluu.oxtrust.model.scim.ScimRoles)14 PersonMeta (org.gluu.oxtrust.model.scim.PersonMeta)13 ScimEntitlements (org.gluu.oxtrust.model.scim.ScimEntitlements)13 ScimName (org.gluu.oxtrust.model.scim.ScimName)13 ScimCustomAttributes (org.gluu.oxtrust.model.scim.ScimCustomAttributes)12 Scimx509Certificates (org.gluu.oxtrust.model.scim.Scimx509Certificates)12 Produces (javax.ws.rs.Produces)8 Response (javax.ws.rs.core.Response)8 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)7