This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a commit to branch 3_0_X
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/3_0_X by this push:
new e716cfbdb9 [SYNCOPE-1823] Polishing and adding more tests
e716cfbdb9 is described below
commit e716cfbdb940ddefc9144dbbe3693c55c47b4103
Author: Francesco Chicchiriccò <[email protected]>
AuthorDate: Tue Jul 16 16:02:28 2024 +0200
[SYNCOPE-1823] Polishing and adding more tests
---
ext/scimv2/logic/pom.xml | 5 +
.../syncope/core/logic/scim/SearchCondVisitor.java | 218 ++++++++++-----------
.../syncope/core/logic/scim/SCIMFilterTest.java | 140 +++++++------
.../src/test/resources/simplelogger.properties | 21 ++
.../org/apache/syncope/fit/core/SCIMITCase.java | 52 +++++
5 files changed, 266 insertions(+), 170 deletions(-)
diff --git a/ext/scimv2/logic/pom.xml b/ext/scimv2/logic/pom.xml
index 7663e0bbee..36165dd9b6 100644
--- a/ext/scimv2/logic/pom.xml
+++ b/ext/scimv2/logic/pom.xml
@@ -62,6 +62,11 @@ under the License.
<artifactId>antlr4-runtime</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
diff --git
a/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/scim/SearchCondVisitor.java
b/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/scim/SearchCondVisitor.java
index 4fa1c4f6e1..fba72c8bef 100644
---
a/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/scim/SearchCondVisitor.java
+++
b/ext/scimv2/logic/src/main/java/org/apache/syncope/core/logic/scim/SearchCondVisitor.java
@@ -40,20 +40,6 @@ public class SearchCondVisitor extends
SCIMFilterBaseVisitor<SearchCond> {
private static final List<String> MULTIVALUE = List.of(
"emails", "phoneNumbers", "ims", "photos", "addresses");
- private final Resource resource;
-
- private final SCIMConf conf;
-
- public SearchCondVisitor(final Resource resource, final SCIMConf conf) {
- this.resource = resource;
- this.conf = conf;
- }
-
- @Override
- public SearchCond visitScimFilter(final SCIMFilterParser.ScimFilterContext
ctx) {
- return visit(ctx.expression(0));
- }
-
private static boolean schemaEquals(final Resource resource, final String
value, final String schema) {
return resource == null
? value.contains(":")
@@ -62,99 +48,6 @@ public class SearchCondVisitor extends
SCIMFilterBaseVisitor<SearchCond> {
: value.equalsIgnoreCase(schema) || (resource.schema() + ":" +
value).equalsIgnoreCase(schema);
}
- public AttrCond createAttrCond(final String schema) {
- AttrCond attrCond = null;
-
- if (schemaEquals(Resource.User, "userName", schema)) {
- attrCond = new AnyCond();
- attrCond.setSchema("username");
- } else if (resource == Resource.Group && schemaEquals(Resource.Group,
"displayName", schema)) {
- attrCond = new AnyCond();
- attrCond.setSchema("name");
- } else if (schemaEquals(null, "meta.created", schema)) {
- attrCond = new AnyCond();
- attrCond.setSchema("creationDate");
- } else if (schemaEquals(null, "meta.lastModified", schema)) {
- attrCond = new AnyCond();
- attrCond.setSchema("lastChangeDate");
- }
-
- switch (resource) {
- case User:
- if (conf.getUserConf() != null) {
- if (conf.getUserConf().getName() != null) {
- for (Map.Entry<String, String> entry :
conf.getUserConf().getName().asMap().entrySet()) {
- if (schemaEquals(Resource.User, "name." +
entry.getKey(), schema)) {
- attrCond = new AttrCond();
- attrCond.setSchema(entry.getValue());
- }
- }
- }
-
- for (Map.Entry<String, String> entry :
conf.getUserConf().asMap().entrySet()) {
- if (schemaEquals(Resource.User, entry.getKey(),
schema)) {
- attrCond = new AttrCond();
- attrCond.setSchema(entry.getValue());
- }
- }
-
- for (SCIMUserAddressConf address :
conf.getUserConf().getAddresses()) {
- for (Map.Entry<String, String> entry :
address.asMap().entrySet()) {
- if (schemaEquals(Resource.User, "addresses." +
entry.getKey(), schema)) {
- attrCond = new AttrCond();
- attrCond.setSchema(entry.getValue());
- }
- }
- }
- }
-
- if (conf.getEnterpriseUserConf() != null) {
- for (Map.Entry<String, String> entry :
conf.getEnterpriseUserConf().asMap().entrySet()) {
- if (schemaEquals(Resource.EnterpriseUser,
entry.getKey(), schema)) {
- attrCond = new AttrCond();
- attrCond.setSchema(entry.getValue());
- }
- }
-
- if (conf.getEnterpriseUserConf().getManager() != null
- &&
conf.getEnterpriseUserConf().getManager().getKey() != null) {
-
- attrCond = new AttrCond();
-
attrCond.setSchema(conf.getEnterpriseUserConf().getManager().getKey());
- }
- }
-
- if (conf.getExtensionUserConf() != null) {
- for (Map.Entry<String, String> entry :
conf.getExtensionUserConf().asMap().entrySet()) {
- if (schemaEquals(Resource.ExtensionUser,
entry.getKey(), schema)) {
- attrCond = new AttrCond();
- attrCond.setSchema(entry.getValue());
- }
- }
- }
- break;
-
- case Group:
- if (conf.getGroupConf() != null) {
- for (Map.Entry<String, String> entry :
conf.getGroupConf().asMap().entrySet()) {
- if (schemaEquals(Resource.Group, entry.getKey(),
schema)) {
- attrCond = new AttrCond();
- attrCond.setSchema(entry.getValue());
- }
- }
- }
- break;
-
- default:
- }
-
- if (attrCond == null) {
- throw new IllegalArgumentException("Could not match " + schema + "
for " + resource);
- }
-
- return attrCond;
- }
-
private static SearchCond setOperator(final AttrCond attrCond, final
String operator) {
switch (operator) {
case "eq":
@@ -203,7 +96,7 @@ public class SearchCondVisitor extends
SCIMFilterBaseVisitor<SearchCond> {
: SearchCond.getLeaf(attrCond);
}
- private <E extends Enum<?>> SearchCond complex(
+ private static <E extends Enum<?>> SearchCond complex(
final String operator, final String left, final String right,
final List<SCIMComplexConf<E>> items) {
if (left.endsWith(".type") && "eq".equals(operator)) {
@@ -232,7 +125,7 @@ public class SearchCondVisitor extends
SCIMFilterBaseVisitor<SearchCond> {
return null;
}
- private SearchCond addresses(
+ private static SearchCond addresses(
final String operator, final String left, final String right,
final List<SCIMUserAddressConf> items) {
if (left.endsWith(".type") && "eq".equals(operator)) {
@@ -261,6 +154,113 @@ public class SearchCondVisitor extends
SCIMFilterBaseVisitor<SearchCond> {
return null;
}
+ private final Resource resource;
+
+ private final SCIMConf conf;
+
+ public SearchCondVisitor(final Resource resource, final SCIMConf conf) {
+ this.resource = resource;
+ this.conf = conf;
+ }
+
+ @Override
+ public SearchCond visitScimFilter(final SCIMFilterParser.ScimFilterContext
ctx) {
+ return visit(ctx.expression(0));
+ }
+
+ public AttrCond createAttrCond(final String schema) {
+ AttrCond attrCond = null;
+
+ if (schemaEquals(Resource.User, "userName", schema)) {
+ attrCond = new AnyCond();
+ attrCond.setSchema("username");
+ } else if (resource == Resource.Group && schemaEquals(Resource.Group,
"displayName", schema)) {
+ attrCond = new AnyCond();
+ attrCond.setSchema("name");
+ } else if (schemaEquals(null, "meta.created", schema)) {
+ attrCond = new AnyCond();
+ attrCond.setSchema("creationDate");
+ } else if (schemaEquals(null, "meta.lastModified", schema)) {
+ attrCond = new AnyCond();
+ attrCond.setSchema("lastChangeDate");
+ }
+
+ switch (resource) {
+ case User:
+ if (conf.getUserConf() != null) {
+ if (conf.getUserConf().getName() != null) {
+ for (Map.Entry<String, String> entry :
conf.getUserConf().getName().asMap().entrySet()) {
+ if (schemaEquals(Resource.User, "name." +
entry.getKey(), schema)) {
+ attrCond = new AttrCond();
+ attrCond.setSchema(entry.getValue());
+ }
+ }
+ }
+
+ for (Map.Entry<String, String> entry :
conf.getUserConf().asMap().entrySet()) {
+ if (schemaEquals(Resource.User, entry.getKey(),
schema)) {
+ attrCond = new AttrCond();
+ attrCond.setSchema(entry.getValue());
+ }
+ }
+
+ for (SCIMUserAddressConf address :
conf.getUserConf().getAddresses()) {
+ for (Map.Entry<String, String> entry :
address.asMap().entrySet()) {
+ if (schemaEquals(Resource.User, "addresses." +
entry.getKey(), schema)) {
+ attrCond = new AttrCond();
+ attrCond.setSchema(entry.getValue());
+ }
+ }
+ }
+ }
+
+ if (conf.getEnterpriseUserConf() != null) {
+ for (Map.Entry<String, String> entry :
conf.getEnterpriseUserConf().asMap().entrySet()) {
+ if (schemaEquals(Resource.EnterpriseUser,
entry.getKey(), schema)) {
+ attrCond = new AttrCond();
+ attrCond.setSchema(entry.getValue());
+ }
+ }
+
+ if (conf.getEnterpriseUserConf().getManager() != null
+ &&
conf.getEnterpriseUserConf().getManager().getKey() != null) {
+
+ attrCond = new AttrCond();
+
attrCond.setSchema(conf.getEnterpriseUserConf().getManager().getKey());
+ }
+ }
+
+ if (conf.getExtensionUserConf() != null) {
+ for (Map.Entry<String, String> entry :
conf.getExtensionUserConf().asMap().entrySet()) {
+ if (schemaEquals(Resource.ExtensionUser,
entry.getKey(), schema)) {
+ attrCond = new AttrCond();
+ attrCond.setSchema(entry.getValue());
+ }
+ }
+ }
+ break;
+
+ case Group:
+ if (conf.getGroupConf() != null) {
+ for (Map.Entry<String, String> entry :
conf.getGroupConf().asMap().entrySet()) {
+ if (schemaEquals(Resource.Group, entry.getKey(),
schema)) {
+ attrCond = new AttrCond();
+ attrCond.setSchema(entry.getValue());
+ }
+ }
+ }
+ break;
+
+ default:
+ }
+
+ if (attrCond == null) {
+ throw new IllegalArgumentException("Could not match " + schema + "
for " + resource);
+ }
+
+ return attrCond;
+ }
+
private SearchCond transform(final String operator, final String left,
final String right) {
SearchCond result = null;
diff --git
a/ext/scimv2/logic/src/test/java/org/apache/syncope/core/logic/scim/SCIMFilterTest.java
b/ext/scimv2/logic/src/test/java/org/apache/syncope/core/logic/scim/SCIMFilterTest.java
index 7c7816d48d..5e62a41252 100644
---
a/ext/scimv2/logic/src/test/java/org/apache/syncope/core/logic/scim/SCIMFilterTest.java
+++
b/ext/scimv2/logic/src/test/java/org/apache/syncope/core/logic/scim/SCIMFilterTest.java
@@ -21,10 +21,12 @@ package org.apache.syncope.core.logic.scim;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.syncope.common.lib.scim.SCIMComplexConf;
import org.apache.syncope.common.lib.scim.SCIMConf;
+import org.apache.syncope.common.lib.scim.SCIMEnterpriseUserConf;
+import org.apache.syncope.common.lib.scim.SCIMExtensionUserConf;
+import org.apache.syncope.common.lib.scim.SCIMItem;
import org.apache.syncope.common.lib.scim.SCIMUserConf;
import org.apache.syncope.common.lib.scim.SCIMUserNameConf;
import org.apache.syncope.common.lib.scim.types.EmailCanonicalType;
@@ -59,6 +61,17 @@ public class SCIMFilterTest {
email.setType(EmailCanonicalType.home);
conf.getUserConf().getEmails().add(email);
+ SCIMEnterpriseUserConf entConf = new SCIMEnterpriseUserConf();
+ entConf.setOrganization("org");
+ conf.setEnterpriseUserConf(entConf);
+
+ SCIMExtensionUserConf extConf = new SCIMExtensionUserConf();
+ SCIMItem item = new SCIMItem();
+ item.setIntAttrName("realm");
+ item.setExtAttrName("realm");
+ extConf.add(item);
+ conf.setExtensionUserConf(extConf);
+
VISITOR = new SearchCondVisitor(Resource.User, conf);
}
@@ -66,20 +79,18 @@ public class SCIMFilterTest {
public void eq() {
SearchCond cond = SearchCondConverter.convert(VISITOR, "userName eq
\"bjensen\"");
assertNotNull(cond);
- assertTrue(cond.getLeaf(AnyCond.class).isPresent());
- assertEquals("username",
cond.getLeaf(AnyCond.class).get().getSchema());
- assertEquals(AttrCond.Type.IEQ,
cond.getLeaf(AnyCond.class).get().getType());
- assertEquals("bjensen",
cond.getLeaf(AnyCond.class).get().getExpression());
+ assertEquals("username",
cond.getLeaf(AnyCond.class).orElseThrow().getSchema());
+ assertEquals(AttrCond.Type.IEQ,
cond.getLeaf(AnyCond.class).orElseThrow().getType());
+ assertEquals("bjensen",
cond.getLeaf(AnyCond.class).orElseThrow().getExpression());
}
@Test
public void sw() {
SearchCond cond = SearchCondConverter.convert(VISITOR, "userName sw
\"J\"");
assertNotNull(cond);
- assertTrue(cond.getLeaf(AnyCond.class).isPresent());
- assertEquals("username",
cond.getLeaf(AnyCond.class).get().getSchema());
- assertEquals(AttrCond.Type.ILIKE,
cond.getLeaf(AnyCond.class).get().getType());
- assertEquals("J%", cond.getLeaf(AnyCond.class).get().getExpression());
+ assertEquals("username",
cond.getLeaf(AnyCond.class).orElseThrow().getSchema());
+ assertEquals(AttrCond.Type.ILIKE,
cond.getLeaf(AnyCond.class).orElseThrow().getType());
+ assertEquals("J%",
cond.getLeaf(AnyCond.class).orElseThrow().getExpression());
SearchCond fqn = SearchCondConverter.convert(
VISITOR, "urn:ietf:params:scim:schemas:core:2.0:User:userName
sw \"J\"");
@@ -90,30 +101,27 @@ public class SCIMFilterTest {
public void pr() {
SearchCond cond = SearchCondConverter.convert(VISITOR, "title pr");
assertNotNull(cond);
- assertTrue(cond.getLeaf(AttrCond.class).isPresent());
- assertEquals("title", cond.getLeaf(AttrCond.class).get().getSchema());
- assertEquals(AttrCond.Type.ISNOTNULL,
cond.getLeaf(AttrCond.class).get().getType());
- assertNull(cond.getLeaf(AttrCond.class).get().getExpression());
+ assertEquals("title",
cond.getLeaf(AttrCond.class).orElseThrow().getSchema());
+ assertEquals(AttrCond.Type.ISNOTNULL,
cond.getLeaf(AttrCond.class).orElseThrow().getType());
+ assertNull(cond.getLeaf(AttrCond.class).orElseThrow().getExpression());
}
@Test
public void gt() {
SearchCond cond = SearchCondConverter.convert(VISITOR,
"meta.lastModified gt \"2011-05-13T04:42:34Z\"");
assertNotNull(cond);
- assertTrue(cond.getLeaf(AnyCond.class).isPresent());
- assertEquals("lastChangeDate",
cond.getLeaf(AnyCond.class).get().getSchema());
- assertEquals(AttrCond.Type.GT,
cond.getLeaf(AnyCond.class).get().getType());
- assertEquals("2011-05-13T04:42:34Z",
cond.getLeaf(AnyCond.class).get().getExpression());
+ assertEquals("lastChangeDate",
cond.getLeaf(AnyCond.class).orElseThrow().getSchema());
+ assertEquals(AttrCond.Type.GT,
cond.getLeaf(AnyCond.class).orElseThrow().getType());
+ assertEquals("2011-05-13T04:42:34Z",
cond.getLeaf(AnyCond.class).orElseThrow().getExpression());
}
@Test
public void not() {
SearchCond cond = SearchCondConverter.convert(VISITOR, "not (title
pr)");
assertNotNull(cond);
- assertTrue(cond.getLeaf(AttrCond.class).isPresent());
- assertEquals("title", cond.getLeaf(AttrCond.class).get().getSchema());
- assertEquals(AttrCond.Type.ISNULL,
cond.getLeaf(AttrCond.class).get().getType());
- assertNull(cond.getLeaf(AttrCond.class).get().getExpression());
+ assertEquals("title",
cond.getLeaf(AttrCond.class).orElseThrow().getSchema());
+ assertEquals(AttrCond.Type.ISNULL,
cond.getLeaf(AttrCond.class).orElseThrow().getType());
+ assertNull(cond.getLeaf(AttrCond.class).orElseThrow().getExpression());
}
@Test
@@ -124,17 +132,15 @@ public class SCIMFilterTest {
SearchCond left = cond.getLeft();
assertNotNull(left);
- assertTrue(left.getLeaf(AttrCond.class).isPresent());
- assertEquals("title", left.getLeaf(AttrCond.class).get().getSchema());
- assertEquals(AttrCond.Type.ISNOTNULL,
left.getLeaf(AttrCond.class).get().getType());
- assertNull(left.getLeaf(AttrCond.class).get().getExpression());
+ assertEquals("title",
left.getLeaf(AttrCond.class).orElseThrow().getSchema());
+ assertEquals(AttrCond.Type.ISNOTNULL,
left.getLeaf(AttrCond.class).orElseThrow().getType());
+ assertNull(left.getLeaf(AttrCond.class).orElseThrow().getExpression());
SearchCond right = cond.getRight();
assertNotNull(right);
- assertTrue(right.getLeaf(AnyCond.class).isPresent());
- assertEquals("username",
right.getLeaf(AnyCond.class).get().getSchema());
- assertEquals(AttrCond.Type.ILIKE,
right.getLeaf(AnyCond.class).get().getType());
- assertEquals("J%", right.getLeaf(AnyCond.class).get().getExpression());
+ assertEquals("username",
right.getLeaf(AnyCond.class).orElseThrow().getSchema());
+ assertEquals(AttrCond.Type.ILIKE,
right.getLeaf(AnyCond.class).orElseThrow().getType());
+ assertEquals("J%",
right.getLeaf(AnyCond.class).orElseThrow().getExpression());
}
@Test
@@ -145,17 +151,15 @@ public class SCIMFilterTest {
SearchCond left = cond.getLeft();
assertNotNull(left);
- assertTrue(left.getLeaf(AttrCond.class).isPresent());
- assertEquals("title", left.getLeaf(AttrCond.class).get().getSchema());
- assertEquals(AttrCond.Type.ISNOTNULL,
left.getLeaf(AttrCond.class).get().getType());
- assertNull(left.getLeaf(AttrCond.class).get().getExpression());
+ assertEquals("title",
left.getLeaf(AttrCond.class).orElseThrow().getSchema());
+ assertEquals(AttrCond.Type.ISNOTNULL,
left.getLeaf(AttrCond.class).orElseThrow().getType());
+ assertNull(left.getLeaf(AttrCond.class).orElseThrow().getExpression());
SearchCond right = cond.getRight();
assertNotNull(right);
- assertTrue(right.getLeaf(AttrCond.class).isPresent());
- assertEquals("cn", right.getLeaf(AttrCond.class).get().getSchema());
- assertEquals(AttrCond.Type.IEQ,
right.getLeaf(AttrCond.class).get().getType());
- assertEquals("Other",
right.getLeaf(AttrCond.class).get().getExpression());
+ assertEquals("cn",
right.getLeaf(AttrCond.class).orElseThrow().getSchema());
+ assertEquals(AttrCond.Type.IEQ,
right.getLeaf(AttrCond.class).orElseThrow().getType());
+ assertEquals("Other",
right.getLeaf(AttrCond.class).orElseThrow().getExpression());
}
@Test
@@ -167,16 +171,14 @@ public class SCIMFilterTest {
SearchCond left = cond.getLeft();
assertNotNull(left);
- assertTrue(left.getLeaf(AttrCond.class).isPresent());
- assertEquals("userType",
left.getLeaf(AttrCond.class).get().getSchema());
- assertEquals(AttrCond.Type.IEQ,
left.getLeaf(AttrCond.class).get().getType());
- assertEquals("Employee",
left.getLeaf(AttrCond.class).get().getExpression());
+ assertEquals("userType",
left.getLeaf(AttrCond.class).orElseThrow().getSchema());
+ assertEquals(AttrCond.Type.IEQ,
left.getLeaf(AttrCond.class).orElseThrow().getType());
+ assertEquals("Employee",
left.getLeaf(AttrCond.class).orElseThrow().getExpression());
SearchCond right = cond.getRight();
assertNotNull(right);
- assertTrue(right.getLeaf(AttrCond.class).isPresent());
- assertEquals("email", right.getLeaf(AttrCond.class).get().getSchema());
- assertEquals(AttrCond.Type.ISNOTNULL,
right.getLeaf(AttrCond.class).get().getType());
+ assertEquals("email",
right.getLeaf(AttrCond.class).orElseThrow().getSchema());
+ assertEquals(AttrCond.Type.ISNOTNULL,
right.getLeaf(AttrCond.class).orElseThrow().getType());
}
@Test
@@ -185,7 +187,7 @@ public class SCIMFilterTest {
assertNotNull(cond);
assertEquals(SearchCond.Type.LEAF, cond.getType());
- AttrCond leaf = cond.getLeaf(AttrCond.class).get();
+ AttrCond leaf = cond.getLeaf(AttrCond.class).orElseThrow();
assertNotNull(leaf);
assertEquals("surname", leaf.getSchema());
assertEquals(AttrCond.Type.ILIKE, leaf.getType());
@@ -205,17 +207,15 @@ public class SCIMFilterTest {
SearchCond left1 = left.getLeft();
assertNotNull(left1);
- assertTrue(left1.getLeaf(AttrCond.class).isPresent());
- assertEquals("email", left1.getLeaf(AttrCond.class).get().getSchema());
- assertEquals(AttrCond.Type.ILIKE,
left1.getLeaf(AttrCond.class).get().getType());
- assertEquals("%example.com%",
left1.getLeaf(AttrCond.class).get().getExpression());
+ assertEquals("email",
left1.getLeaf(AttrCond.class).orElseThrow().getSchema());
+ assertEquals(AttrCond.Type.ILIKE,
left1.getLeaf(AttrCond.class).orElseThrow().getType());
+ assertEquals("%example.com%",
left1.getLeaf(AttrCond.class).orElseThrow().getExpression());
SearchCond left2 = left.getRight();
assertNotNull(left2);
- assertTrue(left2.getLeaf(AttrCond.class).isPresent());
- assertEquals("gmail", left2.getLeaf(AttrCond.class).get().getSchema());
- assertEquals(AttrCond.Type.ILIKE,
left2.getLeaf(AttrCond.class).get().getType());
- assertEquals("%example.com%",
left2.getLeaf(AttrCond.class).get().getExpression());
+ assertEquals("gmail",
left2.getLeaf(AttrCond.class).orElseThrow().getSchema());
+ assertEquals(AttrCond.Type.ILIKE,
left2.getLeaf(AttrCond.class).orElseThrow().getType());
+ assertEquals("%example.com%",
left2.getLeaf(AttrCond.class).orElseThrow().getExpression());
SearchCond right = cond.getRight();
assertNotNull(right);
@@ -223,16 +223,34 @@ public class SCIMFilterTest {
SearchCond right1 = right.getLeft();
assertNotNull(right1);
- assertTrue(right1.getLeaf(AttrCond.class).isPresent());
- assertEquals("email",
right1.getLeaf(AttrCond.class).get().getSchema());
- assertEquals(AttrCond.Type.ILIKE,
right1.getLeaf(AttrCond.class).get().getType());
- assertEquals("%example.org%",
right1.getLeaf(AttrCond.class).get().getExpression());
+ assertEquals("email",
right1.getLeaf(AttrCond.class).orElseThrow().getSchema());
+ assertEquals(AttrCond.Type.ILIKE,
right1.getLeaf(AttrCond.class).orElseThrow().getType());
+ assertEquals("%example.org%",
right1.getLeaf(AttrCond.class).orElseThrow().getExpression());
SearchCond right2 = right.getRight();
assertNotNull(right2);
- assertTrue(right2.getLeaf(AttrCond.class).isPresent());
- assertEquals("gmail",
right2.getLeaf(AttrCond.class).get().getSchema());
- assertEquals(AttrCond.Type.ILIKE,
right2.getLeaf(AttrCond.class).get().getType());
- assertEquals("%example.org%",
right2.getLeaf(AttrCond.class).get().getExpression());
+ assertEquals("gmail",
right2.getLeaf(AttrCond.class).orElseThrow().getSchema());
+ assertEquals(AttrCond.Type.ILIKE,
right2.getLeaf(AttrCond.class).orElseThrow().getType());
+ assertEquals("%example.org%",
right2.getLeaf(AttrCond.class).orElseThrow().getExpression());
+ }
+
+ @Test
+ public void enterpriseUserAttr() {
+ SearchCond cond = SearchCondConverter.convert(VISITOR,
+
"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:organization eq
\"The ASF\"");
+ assertNotNull(cond);
+ assertEquals("org",
cond.getLeaf(AttrCond.class).orElseThrow().getSchema());
+ assertEquals(AttrCond.Type.IEQ,
cond.getLeaf(AttrCond.class).orElseThrow().getType());
+ assertEquals("The ASF",
cond.getLeaf(AttrCond.class).orElseThrow().getExpression());
+ }
+
+ @Test
+ public void extensionUserAttr() {
+ SearchCond cond = SearchCondConverter.convert(VISITOR,
+ "urn:ietf:params:scim:schemas:extension:syncope:2.0:User:realm
sw \"/\"");
+ assertNotNull(cond);
+ assertEquals("realm",
cond.getLeaf(AttrCond.class).orElseThrow().getSchema());
+ assertEquals(AttrCond.Type.ILIKE,
cond.getLeaf(AttrCond.class).orElseThrow().getType());
+ assertEquals("/%",
cond.getLeaf(AttrCond.class).orElseThrow().getExpression());
}
}
diff --git a/ext/scimv2/logic/src/test/resources/simplelogger.properties
b/ext/scimv2/logic/src/test/resources/simplelogger.properties
new file mode 100644
index 0000000000..973e0096ff
--- /dev/null
+++ b/ext/scimv2/logic/src/test/resources/simplelogger.properties
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# See http://www.slf4j.org/api/org/slf4j/impl/SimpleLogger.html
+# Possible values: "trace", "debug", "info", "warn", or "error"
+org.slf4j.simpleLogger.defaultLogLevel=debug
+
diff --git
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java
index 9d9b091a57..b8e21880eb 100644
---
a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java
+++
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java
@@ -47,6 +47,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.syncope.common.lib.scim.SCIMComplexConf;
import org.apache.syncope.common.lib.scim.SCIMConf;
+import org.apache.syncope.common.lib.scim.SCIMEnterpriseUserConf;
import org.apache.syncope.common.lib.scim.SCIMExtensionUserConf;
import org.apache.syncope.common.lib.scim.SCIMGroupConf;
import org.apache.syncope.common.lib.scim.SCIMItem;
@@ -414,6 +415,57 @@ public class SCIMITCase extends AbstractITCase {
SCIMUser newSCIMUser = users.getResources().get(0);
assertEquals(newUser.getUsername(), newSCIMUser.getUserName());
+
+ SCIMEnterpriseUserConf beforeEntConf = CONF.getEnterpriseUserConf();
+ SCIMExtensionUserConf beforeExtConf = CONF.getExtensionUserConf();
+ try {
+ SCIMEnterpriseUserConf entConf = new SCIMEnterpriseUserConf();
+ entConf.setOrganization("userId");
+ CONF.setEnterpriseUserConf(entConf);
+
+ SCIMExtensionUserConf extConf = new SCIMExtensionUserConf();
+ SCIMItem item = new SCIMItem();
+ item.setIntAttrName("email");
+ item.setExtAttrName("email");
+ extConf.add(item);
+ CONF.setExtensionUserConf(extConf);
+
+ SCIM_CONF_SERVICE.set(CONF);
+
+ // Enterprise User
+ response = webClient().path("Users").query(
+ "filter",
+
"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User:organization eq
\"[email protected]\"").
+ get();
+ assertEquals(Response.Status.OK.getStatusCode(),
response.getStatus());
+ assertEquals(
+ SCIMConstants.APPLICATION_SCIM_JSON,
+
StringUtils.substringBefore(response.getHeaderString(HttpHeaders.CONTENT_TYPE),
";"));
+
+ users = response.readEntity(new GenericType<>() {
+ });
+ assertNotNull(users);
+ assertEquals(1, users.getTotalResults());
+
+ // Extension User
+ response = webClient().path("Users").query(
+ "filter",
+
"urn:ietf:params:scim:schemas:extension:syncope:2.0:User:email sw \"verdi\"").
+ get();
+ assertEquals(Response.Status.OK.getStatusCode(),
response.getStatus());
+ assertEquals(
+ SCIMConstants.APPLICATION_SCIM_JSON,
+
StringUtils.substringBefore(response.getHeaderString(HttpHeaders.CONTENT_TYPE),
";"));
+
+ users = response.readEntity(new GenericType<>() {
+ });
+ assertNotNull(users);
+ assertEquals(1, users.getTotalResults());
+ } finally {
+ CONF.setEnterpriseUserConf(beforeEntConf);
+ CONF.setExtensionUserConf(beforeExtConf);
+ SCIM_CONF_SERVICE.set(CONF);
+ }
}
@Test