use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.
the class SchemasTest method init.
@BeforeTest
public void init() throws Exception {
Response response = client.getSchemas();
listResponse = response.readEntity(ListResponse.class);
assertTrue(listResponse.getTotalResults() > 0);
}
use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.
the class FidoU2fDeviceTest method search.
@Test
public void search() {
logger.debug("Searching all fido u2f devices");
Response response = client.searchDevices(null, "application pr", null, null, null, null, null, null);
assertEquals(response.getStatus(), OK.getStatusCode());
ListResponse listResponse = response.readEntity(ListResponse.class);
// Work upon the first device whose deviceData is empty
Optional<FidoDeviceResource> opt = listResponse.getResources().stream().map(FidoDeviceResource.class::cast).filter(dev -> dev.getDeviceData() == null).findAny();
assertTrue(opt.isPresent());
device = opt.get();
logger.debug("First device {} picked", device.getId());
}
use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.
the class ComplexSearchUserTest method searchExcludedAttributesParam.
@Test
public void searchExcludedAttributesParam() {
int count = 3;
List<String> attrList = Arrays.asList("x509Certificates", "entitlements", "roles", "ims", "phoneNumbers", "addresses", "emails", "groups");
logger.debug("Searching at most {} users using POST verb", count);
logger.debug("Sorted by displayName ascending");
logger.debug("Excluding the attributes {}", attrList);
SearchRequest sr = new SearchRequest();
sr.setFilter("displayName pr");
sr.setSortBy("displayName");
sr.setSortOrder("descending");
// Generate a string with the attributes to exclude
sr.setExcludedAttributes(attrList.toString().replaceFirst("\\[", "").replaceFirst("]", ""));
sr.setCount(count);
Response response = client.searchUsersPost(sr);
assertEquals(response.getStatus(), OK.getStatusCode());
ListResponse listResponse = response.readEntity(ListResponse.class);
if (listResponse.getResources().size() < count)
logger.warn("Less than {} users satisfying the criteria. TESTER please check manually", count);
else {
// Obtain an array of results
UserResource[] users = listResponse.getResources().stream().map(usrClass::cast).collect(Collectors.toList()).toArray(new UserResource[0]);
assertEquals(users.length, count);
// Verify attributes were excluded
for (UserResource u : users) {
assertNull(u.getX509Certificates());
assertNull(u.getEntitlements());
assertNull(u.getRoles());
assertNull(u.getIms());
assertNull(u.getPhoneNumbers());
assertNull(u.getAddresses());
assertNull(u.getEmails());
}
boolean correctSorting = true;
for (int i = 1; i < users.length && correctSorting; i++) {
String displayName = users[i - 1].getDisplayName();
String displayName2 = users[i].getDisplayName();
// Check if second string is less or equal than first
correctSorting = displayName.compareTo(displayName2) >= 0;
}
if (!correctSorting) {
// LDAP may ignore case sensitivity, try again using lowercasing
correctSorting = true;
for (int i = 1; i < users.length && correctSorting; i++) {
String displayName = users[i - 1].getDisplayName().toLowerCase();
String displayName2 = users[i].getDisplayName().toLowerCase();
// Check if second string is less or equal than first
correctSorting = displayName.compareTo(displayName2) >= 0;
}
}
assertTrue(correctSorting);
}
}
use of io.jans.scim.model.scim2.ListResponse 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.ListResponse in project jans by JanssenProject.
the class PaginationUserSearchTest method search5.
@Test(dependsOnMethods = "search4")
public void search5() {
// Request more resources than existing
int existing = listResponse.getTotalResults();
sr.setStartIndex(null);
sr.setCount(1 + existing);
Response response = client.searchUsersPost(sr);
assertEquals(response.getStatus(), OK.getStatusCode());
ListResponse anotherLR = response.readEntity(ListResponse.class);
assertEquals(anotherLR.getTotalResults(), existing);
assertEquals(anotherLR.getItemsPerPage(), existing);
assertEquals(anotherLR.getStartIndex(), 1);
}
Aggregations