Merge pull request #147 from apache/tests-and-tweaks
tests and tweaks
diff --git a/pom.xml b/pom.xml
index 1d2d502..085c94d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -230,10 +230,12 @@
<artifactId>guava</artifactId>
<version>31.1-android</version>
</dependency>
+ <!-- later version of logback and other deps in the examples don't play well together,
+ this version works seems to work with Spring, Jersey, and embedded examples -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
- <version>1.4.0</version>
+ <version>1.2.11</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git a/scim-compliance-tests/src/main/java/org/apache/directory/scim/compliance/tests/ScimpleITSupport.java b/scim-compliance-tests/src/main/java/org/apache/directory/scim/compliance/tests/ScimpleITSupport.java
index 999608c..d28b2f0 100644
--- a/scim-compliance-tests/src/main/java/org/apache/directory/scim/compliance/tests/ScimpleITSupport.java
+++ b/scim-compliance-tests/src/main/java/org/apache/directory/scim/compliance/tests/ScimpleITSupport.java
@@ -92,13 +92,14 @@
.when()
.filter(logging(loggingEnabled))
.get(uri(path, query))
- .then()
- .contentType(SCIM_MEDIA_TYPE);
+ .then();
if (loggingEnabled) {
responseSpec.log().everything();
}
- return responseSpec;
+
+ return responseSpec
+ .contentType(SCIM_MEDIA_TYPE);
}
protected ValidatableResponse post(String path, String body) {
diff --git a/scim-compliance-tests/src/main/java/org/apache/directory/scim/compliance/tests/UsersIT.java b/scim-compliance-tests/src/main/java/org/apache/directory/scim/compliance/tests/UsersIT.java
index ff97a47..34e05ee 100644
--- a/scim-compliance-tests/src/main/java/org/apache/directory/scim/compliance/tests/UsersIT.java
+++ b/scim-compliance-tests/src/main/java/org/apache/directory/scim/compliance/tests/UsersIT.java
@@ -62,6 +62,7 @@
@DisplayName("Get Users/{{id}}")
public void userById() {
String id = get("/Users", Map.of("count", "1","startIndex", "1"))
+ .statusCode(200)
.extract().jsonPath().get("Resources[0].id");
get("/Users/" + id)
@@ -129,7 +130,7 @@
"id", not(emptyString()),
"name.givenName", is(givenName),
"name.familyName", is(familyName),
- "userName", is(email)
+ "userName", equalToIgnoringCase(email)
)
.extract().jsonPath().get("id");
@@ -142,7 +143,7 @@
"id", not(emptyString()),
"name.givenName", is(givenName),
"name.familyName", is(familyName),
- "userName", is(email)
+ "userName", equalToIgnoringCase(email)
);
// posting same content again should return a conflict (409)
diff --git a/scim-server/src/main/java/org/apache/directory/scim/server/exception/UnsupportedFilterExceptionMapper.java b/scim-server/src/main/java/org/apache/directory/scim/server/exception/UnsupportedFilterExceptionMapper.java
new file mode 100644
index 0000000..ff76502
--- /dev/null
+++ b/scim-server/src/main/java/org/apache/directory/scim/server/exception/UnsupportedFilterExceptionMapper.java
@@ -0,0 +1,37 @@
+/*
+* 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.
+*/
+
+package org.apache.directory.scim.server.exception;
+
+import jakarta.ws.rs.core.Response;
+import jakarta.ws.rs.core.Response.Status;
+import jakarta.ws.rs.ext.ExceptionMapper;
+import org.apache.directory.scim.protocol.ErrorMessageType;
+import org.apache.directory.scim.protocol.data.ErrorResponse;
+import org.apache.directory.scim.spec.exception.UnsupportedFilterException;
+
+public class UnsupportedFilterExceptionMapper implements ExceptionMapper<UnsupportedFilterException> {
+
+ @Override
+ public Response toResponse(UnsupportedFilterException exception) {
+ ErrorResponse error = new ErrorResponse(Response.Status.BAD_REQUEST, ErrorMessageType.INVALID_FILTER.getDetail())
+ .setScimType(ErrorMessageType.INVALID_FILTER);
+ return error.toResponse();
+ }
+}
diff --git a/scim-server/src/main/java/org/apache/directory/scim/server/rest/BaseResourceTypeResourceImpl.java b/scim-server/src/main/java/org/apache/directory/scim/server/rest/BaseResourceTypeResourceImpl.java
index 21ff426..da459c8 100644
--- a/scim-server/src/main/java/org/apache/directory/scim/server/rest/BaseResourceTypeResourceImpl.java
+++ b/scim-server/src/main/java/org/apache/directory/scim/server/rest/BaseResourceTypeResourceImpl.java
@@ -233,7 +233,7 @@
.isEmpty()) {
listResponse.setTotalResults(0);
} else {
- log.info("Find returned " + filterResp.getResources()
+ log.debug("Find returned " + filterResp.getResources()
.size());
listResponse.setItemsPerPage(filterResp.getResources()
.size());
diff --git a/scim-server/src/main/java/org/apache/directory/scim/server/rest/ScimResourceHelper.java b/scim-server/src/main/java/org/apache/directory/scim/server/rest/ScimResourceHelper.java
index ee4e0b6..164f211 100644
--- a/scim-server/src/main/java/org/apache/directory/scim/server/rest/ScimResourceHelper.java
+++ b/scim-server/src/main/java/org/apache/directory/scim/server/rest/ScimResourceHelper.java
@@ -56,6 +56,7 @@
UserResourceImpl.class,
// exception mappers
+ UnsupportedFilterExceptionMapper.class,
ResourceExceptionMapper.class,
ScimExceptionMapper.class,
FilterParseExceptionMapper.class,
diff --git a/scim-spec/scim-spec-schema/src/main/java/org/apache/directory/scim/spec/exception/UnsupportedFilterException.java b/scim-spec/scim-spec-schema/src/main/java/org/apache/directory/scim/spec/exception/UnsupportedFilterException.java
new file mode 100644
index 0000000..0a3b56e
--- /dev/null
+++ b/scim-spec/scim-spec-schema/src/main/java/org/apache/directory/scim/spec/exception/UnsupportedFilterException.java
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+package org.apache.directory.scim.spec.exception;
+
+public class UnsupportedFilterException extends RuntimeException {
+
+ public UnsupportedFilterException(String message) {
+ super(message);
+ }
+
+ public UnsupportedFilterException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/scim-spec/scim-spec-schema/src/main/java/org/apache/directory/scim/spec/resources/ScimGroup.java b/scim-spec/scim-spec-schema/src/main/java/org/apache/directory/scim/spec/resources/ScimGroup.java
index cfef250..8734f45 100644
--- a/scim-spec/scim-spec-schema/src/main/java/org/apache/directory/scim/spec/resources/ScimGroup.java
+++ b/scim-spec/scim-spec-schema/src/main/java/org/apache/directory/scim/spec/resources/ScimGroup.java
@@ -20,6 +20,7 @@
package org.apache.directory.scim.spec.resources;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.List;
import jakarta.xml.bind.annotation.XmlAccessType;
@@ -52,6 +53,15 @@
@ScimAttribute(description = "A list of members of the Group.")
List<ResourceReference> members;
+ public ScimGroup addMember(ResourceReference resourceReference) {
+ if (members == null) {
+ members = new ArrayList<>();
+ }
+ members.add(resourceReference);
+
+ return this;
+ }
+
public ScimGroup() {
super(SCHEMA_URI);
}