use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.
the class PaginationUserSearchTest method search1.
@Test
public void search1() {
// Issue a default request except for a filter and reducing the attributes returned
sr = new SearchRequest();
sr.setFilter("name.familyName co \"Filter\"");
// Couchbase result set order is not deterministic, requires ORDER BY to workaround it
sr.setSortBy("id");
sr.setAttributes("meta.location");
Response response = client.searchUsersPost(sr);
assertEquals(response.getStatus(), OK.getStatusCode());
// Store for further comparison
listResponse = response.readEntity(ListResponse.class);
assertEquals(listResponse.getResources().size(), listResponse.getTotalResults());
}
use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.
the class PaginationUserSearchTest method search2.
@Test(dependsOnMethods = "search1")
public void search2() {
// Issue the request specifiying index and count
sr.setStartIndex(1);
sr.setCount(listResponse.getTotalResults());
Response response = client.searchUsersPost(sr);
assertEquals(response.getStatus(), OK.getStatusCode());
ListResponse anotherLR = response.readEntity(ListResponse.class);
// number of results should be the same as in original listResponse (first test)
assertEquals(listResponse.getTotalResults(), anotherLR.getTotalResults());
// The page return should contain all results
assertEquals(listResponse.getTotalResults(), anotherLR.getItemsPerPage());
assertEquals(anotherLR.getStartIndex(), 1);
}
use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.
the class PaginationUserSearchTest method search4.
@Test(dependsOnMethods = "search3")
public void search4() {
// Issue a request disregarding resources (only total is of interest)
sr.setStartIndex(null);
sr.setCount(0);
Response response = client.searchUsersPost(sr);
assertEquals(response.getStatus(), OK.getStatusCode());
ListResponse anotherLR = response.readEntity(ListResponse.class);
// means no existing
assertEquals(anotherLR.getItemsPerPage(), 0);
assertEquals(anotherLR.getTotalResults(), listResponse.getTotalResults());
// Verify resources weren't serialized
assertNull(anotherLR.getResources());
}
use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.
the class PaginationUserSearchTest method search3.
@Test(dependsOnMethods = "search2")
public void search3() {
int rounds = 3;
int ipp = listResponse.getTotalResults() / 3;
// Make several requests changing start index, leaving count to be fixed valued
for (int i = 0; i < rounds; i++) {
int startIndex = rounds * (1 + i) + 1;
sr.setStartIndex(startIndex);
sr.setCount(ipp);
Response response = client.searchUsersPost(sr);
assertEquals(response.getStatus(), OK.getStatusCode());
ListResponse anotherLR = response.readEntity(ListResponse.class);
// Items per page should be the same as count supplied above
assertEquals(anotherLR.getItemsPerPage(), ipp);
assertEquals(anotherLR.getStartIndex(), startIndex);
// Determine if current results contain the same elements as in original listResponse
Set<String> ids = new LinkedHashSet<>();
Set<String> ids2 = new LinkedHashSet<>();
for (int j = 0; j < ipp; j++) {
ids.add(listResponse.getResources().get(j + startIndex - 1).getId());
ids2.add(anotherLR.getResources().get(j).getId());
assertNotNull(anotherLR.getResources().get(j).getMeta().getLocation());
}
assertTrue(ids.containsAll(ids2));
}
}
use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.
the class PairwiseIdentifiersTest method queryAndRemoval.
@Test
public void queryAndRemoval() throws Exception {
// Get a list (of at most 1 user) who has a persisted pairwise identifier
Response response = client.searchUsers("pairwiseIdentifiers pr", null, 1, null, null, "pairwiseIdentifiers, id", null);
assertEquals(response.getStatus(), OK.getStatusCode());
ListResponse lr = response.readEntity(ListResponse.class);
// If the list is empty do nothing (successful test)
if (lr.getItemsPerPage() > 0) {
UserResource user = (UserResource) lr.getResources().get(0);
assertNotNull(user.getPairwiseIdentifiers());
// Prepare the removal of the user's PPIDs
PatchOperation operation = new PatchOperation();
operation.setOperation("remove");
operation.setPath("pairwiseIdentitifers");
PatchRequest pr = new PatchRequest();
pr.setOperations(Collections.singletonList(operation));
response = client.patchUser(pr, user.getId(), "pairwiseIdentifiers", null);
assertEquals(response.getStatus(), OK.getStatusCode());
// Ensure they are not there anymore.
user = response.readEntity(UserResource.class);
assertNull(user.getPairwiseIdentifiers());
// This test does not guarantee the ou=pairwiseIdentifiers sub-branch disappears... only the jsPPID LDAP attribute
}
}
Aggregations