Search in sources :

Example 11 with SearchRequest

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

the class SampleTest method smallerClient.

// This tests assumes client_secret_basic for token endpoint authentication
@Test
@Parameters({ "domainURL", "OIDCMetadataUrl", "clientId", "clientSecret" })
public void smallerClient(String domainURL, String OIDCMetadataUrl, String clientId, String clientSecret) throws Exception {
    IUserWebService myclient = ScimClientFactory.getClient(IUserWebService.class, domainURL, OIDCMetadataUrl, clientId, clientSecret, false);
    SearchRequest sr = new SearchRequest();
    sr.setFilter("userName eq \"admin\"");
    Response response = myclient.searchUsersPost(sr);
    assertEquals(response.getStatus(), OK.getStatusCode());
    UserResource u = (UserResource) response.readEntity(ListResponse.class).getResources().get(0);
    logger.debug("Hello {}!", u.getDisplayName());
}
Also used : Response(javax.ws.rs.core.Response) IUserWebService(io.jans.scim.ws.rs.scim2.IUserWebService) UserResource(io.jans.scim.model.scim2.user.UserResource) Parameters(org.testng.annotations.Parameters) Test(org.testng.annotations.Test)

Example 12 with SearchRequest

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

the class SpecialCharsTest method NullChar.

// This test has been disabled as dealing with the NUL char in text editors and terminal consoles turned out to be troublesome
// However, in practice, translation of \0 into \00 is taking place in server side
// @Test
public void NullChar() {
    SearchRequest sr = new SearchRequest();
    sr.setFilter(String.format("displayName co \"%s\"", "\0"));
    sr.setAttributes("userName");
    Response response = client.searchUsersPost(sr);
    assertEquals(response.readEntity(ListResponse.class).getResources().size(), 1);
}
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)

Example 13 with SearchRequest

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

the class SpecialCharsTest method containabilityAllInGivenName.

@SkipTest(databases = { "spanner", "couchbase" })
@Test
public void containabilityAllInGivenName() {
    String filter = specialFilterLdapChars.stream().reduce("", (partial, next) -> partial + String.format(" and name.givenName co \"%s\"", next));
    SearchRequest sr = new SearchRequest();
    // Drop beginning (namely ' and ')
    sr.setFilter(filter.substring(5));
    sr.setAttributes("name");
    // Search users whose given names contain ALL the chars
    Response response = client.searchUsersPost(sr);
    assertEquals(response.getStatus(), OK.getStatusCode());
    List<UserResource> resources = response.readEntity(ListResponse.class).getResources().stream().map(UserResource.class::cast).collect(Collectors.toList());
    String givenName = resources.get(0).getName().getGivenName();
    assertEquals(resources.size(), 1);
    assertTrue(Stream.of(SPECIAL_CHARS).allMatch(givenName::contains));
}
Also used : Response(javax.ws.rs.core.Response) ListResponse(io.jans.scim.model.scim2.ListResponse) SearchRequest(io.jans.scim.model.scim2.SearchRequest) UserResource(io.jans.scim.model.scim2.user.UserResource) UserBaseTest(io.jans.scim2.client.UserBaseTest) Test(org.testng.annotations.Test) SkipTest(io.jans.scim2.listener.SkipTest) BeforeTest(org.testng.annotations.BeforeTest) SkipTest(io.jans.scim2.listener.SkipTest)

Example 14 with SearchRequest

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

the class SpecialCharsTest method containabilityAny.

@Test
public void containabilityAny() {
    // Builds a long "or" based clause
    String filter = specialFilterLdapChars.stream().reduce("", (partial, next) -> partial + String.format(" or userName co \"%s\"", next));
    SearchRequest sr = new SearchRequest();
    // Drop beginning (namely ' or ')
    sr.setFilter(filter.substring(4));
    sr.setAttributes("userName");
    // Search users whose usernames contain ANY of the chars
    Response response = client.searchUsersPost(sr);
    assertEquals(response.getStatus(), OK.getStatusCode());
    List<UserResource> resources = response.readEntity(ListResponse.class).getResources().stream().map(UserResource.class::cast).collect(Collectors.toList());
    assertTrue(resources.size() > 0);
    resources.forEach(user -> assertTrue(specialFilterLdapChars.stream().anyMatch(ch -> user.getUserName().contains(ch))));
    userNames = resources.stream().map(UserResource::getUserName).collect(Collectors.toList());
}
Also used : Response(javax.ws.rs.core.Response) ListResponse(io.jans.scim.model.scim2.ListResponse) SearchRequest(io.jans.scim.model.scim2.SearchRequest) UserResource(io.jans.scim.model.scim2.user.UserResource) UserBaseTest(io.jans.scim2.client.UserBaseTest) Test(org.testng.annotations.Test) SkipTest(io.jans.scim2.listener.SkipTest) BeforeTest(org.testng.annotations.BeforeTest)

Example 15 with SearchRequest

use of io.jans.scim.model.scim2.SearchRequest 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)

Aggregations

Response (javax.ws.rs.core.Response)31 SearchRequest (io.jans.scim.model.scim2.SearchRequest)23 ListResponse (io.jans.scim.model.scim2.ListResponse)21 Test (org.testng.annotations.Test)15 UserResource (io.jans.scim.model.scim2.user.UserResource)13 UserBaseTest (io.jans.scim2.client.UserBaseTest)13 SearchRequest (com.google.cloud.retail.v2.SearchRequest)7 SearchResponse (com.google.cloud.retail.v2.SearchResponse)7 SearchServiceClient (com.google.cloud.retail.v2.SearchServiceClient)7 URI (java.net.URI)6 SearchRequest (org.gluu.oxtrust.model.scim2.SearchRequest)6 BaseScimResource (io.jans.scim.model.scim2.BaseScimResource)5 SkipTest (io.jans.scim2.listener.SkipTest)5 SCIMException (io.jans.scim.model.exception.SCIMException)4 URISyntaxException (java.net.URISyntaxException)4 BeforeTest (org.testng.annotations.BeforeTest)4 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)3 DuplicateEntryException (io.jans.orm.exception.operation.DuplicateEntryException)2 GroupResource (io.jans.scim.model.scim2.group.GroupResource)2 Annotation (java.lang.annotation.Annotation)2