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));
}
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;
}
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);
}
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));
}
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());
}
Aggregations