use of io.jans.scim.model.scim2.user.UserResource in project jans by JanssenProject.
the class ComplexSearchUserTest method searchSortByDate.
// This test is disabled to avoid problems in attribute excludeMetaLastMod being inconsistent with updatedAt in testing server
// @Test
public void searchSortByDate() {
SearchRequest sr = new SearchRequest();
sr.setFilter("userName pr");
sr.setSortBy("meta.lastModified");
sr.setAttributes(Collections.singletonList(sr.getSortBy()));
Response response = client.searchUsersPost(sr);
assertEquals(response.getStatus(), OK.getStatusCode());
ListResponse listResponse = response.readEntity(ListResponse.class);
UserResource[] users = listResponse.getResources().stream().map(usrClass::cast).collect(Collectors.toList()).toArray(new UserResource[0]);
for (int i = 1; i < users.length; i++) {
String lastMod1 = users[i - 1].getMeta() == null ? null : users[i - 1].getMeta().getLastModified();
String lastMod2 = users[i].getMeta() == null ? null : users[i].getMeta().getLastModified();
if (// Both being non null is OK
lastMod1 != null)
assertNotNull(lastMod2);
if (// If second is null, first must be
lastMod2 == null)
assertNull(lastMod1);
if (lastMod1 != null && lastMod2 != null) {
ZonedDateTime dt1 = ZonedDateTime.parse(lastMod1);
ZonedDateTime dt2 = ZonedDateTime.parse(lastMod2);
assertTrue(dt1.isEqual(dt2) || dt1.isBefore(dt2));
}
}
}
use of io.jans.scim.model.scim2.user.UserResource in project jans by JanssenProject.
the class PatchDeleteUserTest method delete1.
@Parameters({ "user_patchdelete" })
@Test(dependsOnMethods = "createForDel")
public void delete1(String patchRequest) {
Response response = client.patchUser(patchRequest, user.getId(), null, null);
assertEquals(response.getStatus(), OK.getStatusCode());
UserResource other = response.readEntity(usrClass);
for (int i = 0; i < 2; i++) {
assertNull(other.getName().getMiddleName());
assertNull(other.getNickName());
assertNull(other.getEntitlements());
assertNull(other.getAddresses().get(0).getPostalCode());
assertNull(other.getAddresses().get(0).getLocality());
assertNotNull(other.getAddresses().get(0).getStreetAddress());
// Double check
response = client.getUserById(user.getId(), null, null);
other = response.readEntity(usrClass);
}
}
use of io.jans.scim.model.scim2.user.UserResource in project jans by JanssenProject.
the class PatchReplaceUserTest method jsonPathPatch1.
@Parameters({ "user_patchreplace_3" })
@Test(dependsOnMethods = "jsonNoPathPatch2")
public void jsonPathPatch1(String patchRequest) {
Response response = client.patchUser(patchRequest, user.getId(), null, null);
assertEquals(response.getStatus(), OK.getStatusCode());
UserResource other = response.readEntity(usrClass);
// Verify display name changed
assertNotEquals(user.getDisplayName(), other.getDisplayName());
// Verify some name components changed
assertNotEquals(user.getName().getFamilyName(), other.getName().getFamilyName());
assertNotEquals(user.getName().getMiddleName(), other.getName().getMiddleName());
assertNotEquals(user.getName().getGivenName(), other.getName().getGivenName());
assertEquals(user.getName().getHonorificPrefix(), other.getName().getHonorificPrefix());
assertEquals(user.getName().getHonorificSuffix(), other.getName().getHonorificSuffix());
// Verify is now active
assertTrue(other.getActive());
user = other;
}
use of io.jans.scim.model.scim2.user.UserResource 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;
}
use of io.jans.scim.model.scim2.user.UserResource 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;
}
Aggregations