Search in sources :

Example 31 with ListResponse

use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.

the class MultipleResourcesSearchTest method search6.

@Test(dependsOnMethods = "search5")
public void search6() {
    // Irrelevant since no results will be returned
    sr.setStartIndex(5);
    // Returns no resources, only total
    sr.setCount(0);
    Response response = client.searchResourcesPost(sr);
    assertEquals(response.getStatus(), OK.getStatusCode());
    ListResponse anotherLR = response.readEntity(ListResponse.class);
    assertEquals(listResponse.getTotalResults(), anotherLR.getTotalResults());
    assertNull(anotherLR.getResources());
    // unassigned
    assertEquals(anotherLR.getItemsPerPage(), 0);
    // unassigned
    assertEquals(anotherLR.getStartIndex(), 0);
}
Also used : Response(javax.ws.rs.core.Response) ListResponse(io.jans.scim.model.scim2.ListResponse) ListResponse(io.jans.scim.model.scim2.ListResponse) Test(org.testng.annotations.Test) BaseTest(io.jans.scim2.client.BaseTest)

Example 32 with ListResponse

use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.

the class MultipleResourcesSearchTest method search2.

@Test(dependsOnMethods = "search1")
public void search2() {
    // Move forward the start index
    sr.setStartIndex(2);
    Response response = client.searchResourcesPost(sr);
    assertEquals(response.getStatus(), OK.getStatusCode());
    ListResponse anotherLR = response.readEntity(ListResponse.class);
    // Verify one result less was returned
    assertEquals(listResponse.getTotalResults(), anotherLR.getResources().size() + 1);
    assertEquals(anotherLR.getResources().size(), anotherLR.getItemsPerPage());
}
Also used : Response(javax.ws.rs.core.Response) ListResponse(io.jans.scim.model.scim2.ListResponse) ListResponse(io.jans.scim.model.scim2.ListResponse) Test(org.testng.annotations.Test) BaseTest(io.jans.scim2.client.BaseTest)

Example 33 with ListResponse

use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.

the class MultipleResourcesSearchTest method search4.

@Test(dependsOnMethods = "search3")
public void search4() {
    // Verify there are no results when start index is greater than the number of available results
    sr.setStartIndex(listResponse.getTotalResults() + 1);
    Response response = client.searchResourcesPost(sr);
    assertEquals(response.getStatus(), OK.getStatusCode());
    ListResponse anotherLR = response.readEntity(ListResponse.class);
    // unassigned
    assertEquals(anotherLR.getItemsPerPage(), 0);
    // unassigned
    assertEquals(anotherLR.getStartIndex(), 0);
}
Also used : Response(javax.ws.rs.core.Response) ListResponse(io.jans.scim.model.scim2.ListResponse) ListResponse(io.jans.scim.model.scim2.ListResponse) Test(org.testng.annotations.Test) BaseTest(io.jans.scim2.client.BaseTest)

Example 34 with ListResponse

use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.

the class SimpleSearchUserTest method searchComplexAttrPost.

@Test(dependsOnMethods = "create", groups = "search")
public void searchComplexAttrPost() {
    String givenName = user.getName().getGivenName();
    logger.debug("Searching user with attribute givenName = {} using POST verb", givenName);
    SearchRequest sr = new SearchRequest();
    sr.setFilter("name.givenName eq \"" + givenName + "\"");
    Response response = client.searchUsersPost(sr);
    assertEquals(response.getStatus(), OK.getStatusCode());
    ListResponse listResponse = response.readEntity(ListResponse.class);
    assertTrue(listResponse.getResources().size() > 0);
    // Retrieve first user in results
    UserResource other = listResponse.getResources().stream().map(usrClass::cast).findFirst().get();
    assertEquals(other.getName().getGivenName(), givenName);
}
Also used : Response(javax.ws.rs.core.Response) ListResponse(io.jans.scim.model.scim2.ListResponse) SearchRequest(io.jans.scim.model.scim2.SearchRequest) ListResponse(io.jans.scim.model.scim2.ListResponse) UserResource(io.jans.scim.model.scim2.user.UserResource) UserBaseTest(io.jans.scim2.client.UserBaseTest) Test(org.testng.annotations.Test)

Example 35 with ListResponse

use of io.jans.scim.model.scim2.ListResponse in project jans by JanssenProject.

the class SimpleSearchUserTest method searchComplexMultivaluedPost.

@Test(dependsOnMethods = "create", groups = "search")
public void searchComplexMultivaluedPost() {
    String ghost = user.getEmails().get(0).getValue();
    final String host = ghost.substring(ghost.indexOf("@") + 1);
    logger.debug("Searching user with attribute emails.value like {} or phone numbers with type unassigned or value containing '+' using POST verb", host);
    SearchRequest sr = new SearchRequest();
    sr.setFilter("emails[value ew \"" + host + "\"] or urn:ietf:params:scim:schemas:core:2.0:User:phoneNumbers[value co \"+\" or type eq null]");
    Response response = client.searchUsersPost(sr);
    assertEquals(response.getStatus(), OK.getStatusCode());
    ListResponse listResponse = response.readEntity(ListResponse.class);
    assertTrue(listResponse.getResources().size() > 0);
    // Retrieve first user in results
    UserResource other = listResponse.getResources().stream().map(usrClass::cast).findFirst().get();
    boolean cond1 = false, cond2 = false, cond3 = false;
    if (other.getEmails() != null) {
        cond1 = other.getEmails().stream().anyMatch(mail -> mail.getValue().endsWith(host));
    }
    if (other.getPhoneNumbers() != null) {
        cond2 = other.getPhoneNumbers().stream().anyMatch(phone -> phone.getValue().contains("+"));
        cond3 = other.getPhoneNumbers().stream().anyMatch(phone -> phone.getType() == null);
    }
    assertTrue(cond1 || cond2 || cond3);
}
Also used : Response(javax.ws.rs.core.Response) ListResponse(io.jans.scim.model.scim2.ListResponse) UserBaseTest(io.jans.scim2.client.UserBaseTest) UserResource(io.jans.scim.model.scim2.user.UserResource) SearchRequest(io.jans.scim.model.scim2.SearchRequest) Response(javax.ws.rs.core.Response) Assert(org.testng.Assert) ListResponse(io.jans.scim.model.scim2.ListResponse) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) Instant(java.time.Instant) Status(javax.ws.rs.core.Response.Status) SearchRequest(io.jans.scim.model.scim2.SearchRequest) ListResponse(io.jans.scim.model.scim2.ListResponse) UserResource(io.jans.scim.model.scim2.user.UserResource) UserBaseTest(io.jans.scim2.client.UserBaseTest) Test(org.testng.annotations.Test)

Aggregations

Response (javax.ws.rs.core.Response)38 ListResponse (io.jans.scim.model.scim2.ListResponse)36 Test (org.testng.annotations.Test)26 UserBaseTest (io.jans.scim2.client.UserBaseTest)16 SearchRequest (io.jans.scim.model.scim2.SearchRequest)12 UserResource (io.jans.scim.model.scim2.user.UserResource)11 URI (java.net.URI)11 BaseTest (io.jans.scim2.client.BaseTest)10 ListResponse (org.gluu.oxtrust.model.scim2.ListResponse)9 DefaultValue (javax.ws.rs.DefaultValue)8 HeaderParam (javax.ws.rs.HeaderParam)8 Produces (javax.ws.rs.Produces)8 ArrayList (java.util.ArrayList)7 GET (javax.ws.rs.GET)7 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)4 BaseScimResource (io.jans.scim.model.scim2.BaseScimResource)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)2 RejectFilterParam (io.jans.scim.service.scim2.interceptor.RejectFilterParam)2