use of io.jans.scim2.listener.SkipTest in project jans by JanssenProject.
the class SpecialCharsTest method containabilityAll.
@SkipTest(databases = { "spanner", "couchbase" })
@Test
public void containabilityAll() {
// Builds a long "and" based clause
String filter = specialFilterLdapChars.stream().reduce("", (partial, next) -> partial + String.format(" and userName co \"%s\"", next));
SearchRequest sr = new SearchRequest();
// Drop beginning (namely " and ")
sr.setFilter(filter.substring(4));
sr.setAttributes("userName");
// Search users whose usernames 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 userName = resources.get(0).getUserName();
assertEquals(resources.size(), 1);
assertTrue(Stream.of(SPECIAL_CHARS).allMatch(userName::contains));
}
use of io.jans.scim2.listener.SkipTest 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.scim2.listener.SkipTest in project jans by JanssenProject.
the class FullUserTest method searchEscapingChars.
@SkipTest(databases = { "couchbase", "spanner" })
@Test(dependsOnMethods = "updateNonExisting", groups = "lastTests")
public void searchEscapingChars() {
char quote = '"', backslash = '\\';
String scapedQuote = String.valueOf(new char[] { backslash, quote });
String scapedBkSlash = String.valueOf(new char[] { backslash, backslash });
// Used to generate a random Unicode char
String rnd = UUID.randomUUID().toString().substring(0, 4);
String unicodeStr = String.valueOf(Character.toChars(Integer.parseInt(rnd, 16)));
Name name = user.getName();
name.setGivenName(String.format("with %cquotes%c", quote, quote));
name.setMiddleName(String.format("with backslash %c", backslash));
name.setFamilyName(String.format("%c %c %s", quote, backslash, unicodeStr));
CustomAttributes attrs = new CustomAttributes(USER_EXT_SCHEMA_ID);
attrs.setAttribute("scimCustomFirst", String.valueOf(quote));
user.addCustomAttributes(attrs);
Response response = client.updateUser(user, user.getId(), null, null);
assertEquals(response.getStatus(), OK.getStatusCode());
// => name.givenName co "\""
String filter = String.format("name.givenName co %c%s%c", quote, scapedQuote, quote);
// => and name.middleName ew "\\"
filter += String.format(" and name.middleName ew %c%s%c", quote, scapedBkSlash, quote);
String compValue = String.format("%s %s %cu%s", scapedQuote, scapedBkSlash, backslash, rnd);
// => and name.familyName eq ""\ \\ \\uWXYZ"
filter += String.format(" and name.familyName eq %c%s%c", quote, compValue, quote);
String customFirst = String.format("%s:%s", USER_EXT_SCHEMA_ID, "scimCustomFirst");
filter += String.format(" and %s eq %c%s%c", customFirst, quote, scapedQuote, quote);
SearchRequest sr = new SearchRequest();
sr.setFilter(filter);
sr.setCount(1);
sr.setAttributes("name, " + customFirst);
response = client.searchUsersPost(sr);
user = (UserResource) response.readEntity(ListResponse.class).getResources().get(0);
assertEquals(name.getGivenName(), user.getName().getGivenName());
assertEquals(name.getMiddleName(), user.getName().getMiddleName());
assertEquals(name.getFamilyName(), user.getName().getFamilyName());
// Verify the unicode character is intact
compValue = user.getName().getFamilyName();
// pick the last char
compValue = compValue.substring(compValue.length() - 1);
assertEquals(unicodeStr, compValue);
}
Aggregations