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());
}
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);
}
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));
}
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());
}
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);
}
Aggregations