Search in sources :

Example 11 with ListResponse

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

the class MultipleResourcesSearchTest method search1.

@Test(dependsOnMethods = "searchJson")
public void search1() {
    // Build up a request
    sr = new SearchRequest();
    // return a few attributes
    sr.setAttributes("id");
    sr.setStartIndex(1);
    // Aimed at having both users and groups
    sr.setFilter("displayName co \"1111\" or displayName co \"Group\"");
    Response response = client.searchResourcesPost(sr);
    assertEquals(response.getStatus(), OK.getStatusCode());
    listResponse = response.readEntity(ListResponse.class);
    // Verify it has results
    assertTrue(listResponse.getTotalResults() > 0);
}
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) Test(org.testng.annotations.Test) BaseTest(io.jans.scim2.client.BaseTest)

Example 12 with ListResponse

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

the class MultipleResourcesSearchTest method searchJson.

@Parameters({ "search_multiple_1", "search_multiple_2" })
@Test
public void searchJson(String json1, String json2) {
    Response response = client.searchResourcesPost(json1);
    assertEquals(response.getStatus(), OK.getStatusCode());
    ListResponse anotherLR = response.readEntity(ListResponse.class);
    // Verify it has results
    assertTrue(anotherLR.getTotalResults() > 0);
    response = client.searchResourcesPost(json2);
    assertEquals(response.getStatus(), OK.getStatusCode());
    ListResponse anotherLR2 = response.readEntity(ListResponse.class);
    assertEquals(anotherLR.getTotalResults(), anotherLR2.getTotalResults());
    assertNull(anotherLR2.getResources());
    // unassigned
    assertEquals(anotherLR2.getItemsPerPage(), 0);
    // unassigned
    assertEquals(anotherLR2.getStartIndex(), 0);
}
Also used : Response(javax.ws.rs.core.Response) ListResponse(io.jans.scim.model.scim2.ListResponse) ListResponse(io.jans.scim.model.scim2.ListResponse) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test) BaseTest(io.jans.scim2.client.BaseTest)

Example 13 with ListResponse

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

the class SimpleSearchUserTest method searchNoMatches.

@Test(dependsOnMethods = "create", groups = "search")
public void searchNoMatches() {
    String nowIsoDateTimeString = Instant.ofEpochMilli(System.currentTimeMillis()).toString();
    SearchRequest sr = new SearchRequest();
    sr.setFilter(String.format("urn:ietf:params:scim:schemas:extension:gluu:2.0:User:scimCustomThird eq 1 and displayName eq \"%s\" " + "and addresses[postalCode ne null or type eq null] and meta.lastModified gt \"%s\"", "test", nowIsoDateTimeString));
    Response response = client.searchUsersPost(sr);
    assertEquals(response.getStatus(), OK.getStatusCode());
    ListResponse listResponse = response.readEntity(ListResponse.class);
    assertNull(listResponse.getResources());
}
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) UserBaseTest(io.jans.scim2.client.UserBaseTest) Test(org.testng.annotations.Test)

Example 14 with ListResponse

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

the class SimpleSearchUserTest method searchSimpleAttrGet.

@Test(dependsOnMethods = "create", groups = "search")
public void searchSimpleAttrGet() {
    String isoDateString = user.getMeta().getCreated();
    String locale = user.getLocale();
    logger.debug("Searching user with attribute locale = {} and created date >= {} using GET verb", locale, isoDateString);
    Response response = client.searchUsers(String.format("locale eq \"%s\" and meta.created ge \"%s\"", locale, isoDateString), null, null, null, null, null, null);
    assertEquals(response.getStatus(), OK.getStatusCode());
    ListResponse listResponse = response.readEntity(ListResponse.class);
    assertTrue(listResponse.getResources().size() > 0);
    // Retrieve first user in results
    UserResource same = listResponse.getResources().stream().map(usrClass::cast).findFirst().get();
    assertEquals(same.getLocale(), locale);
}
Also used : Response(javax.ws.rs.core.Response) ListResponse(io.jans.scim.model.scim2.ListResponse) 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 15 with ListResponse

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

the class SimpleSearchUserTest method searchNoResults.

@Test(dependsOnMethods = "create", groups = "search")
public void searchNoResults() {
    logger.debug("Calculating the total number of users");
    // Pass count=0 so no results are retrieved (only total)
    Response response = client.searchUsers("userName pr", null, 0, null, null, null, null);
    assertEquals(response.getStatus(), OK.getStatusCode());
    ListResponse listResponse = response.readEntity(ListResponse.class);
    assertNull(listResponse.getResources());
    assertTrue(listResponse.getTotalResults() > 0);
    logger.debug("There are {} users!", listResponse.getTotalResults());
}
Also used : Response(javax.ws.rs.core.Response) ListResponse(io.jans.scim.model.scim2.ListResponse) ListResponse(io.jans.scim.model.scim2.ListResponse) 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