syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [1/2] syncope git commit: [SYNCOPE-152] Initial implementation as extension: user / group read and search (without filters, attributes or sort)
Date Fri, 27 Oct 2017 15:21:40 GMT
Repository: syncope
Updated Branches:
  refs/heads/2_0_X 59ad56b3e -> aa25af970


http://git-wip-us.apache.org/repos/asf/syncope/blob/aa25af97/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SAML2ITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SAML2ITCase.java
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SAML2ITCase.java
index bf947fc..d3bd925 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SAML2ITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SAML2ITCase.java
@@ -45,7 +45,6 @@ import java.util.Collections;
 import java.util.Date;
 import java.util.Arrays;
 import java.util.List;
-import java.util.regex.Pattern;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import javax.xml.namespace.QName;
@@ -335,7 +334,7 @@ public class SAML2ITCase extends AbstractITCase {
 
         org.opensaml.saml.saml2.core.Response samlResponse =
                 createResponse(inResponseTo, false, SAML2Constants.CONF_SENDER_VOUCHES,
-                               "urn:org:apache:cxf:fediz:idp:realm-A");
+                        "urn:org:apache:cxf:fediz:idp:realm-A");
 
         Document doc = DOMUtils.newDocument();
         Element responseElement = OpenSAMLUtil.toDom(samlResponse, doc);
@@ -425,7 +424,7 @@ public class SAML2ITCase extends AbstractITCase {
         response.setUrlContext("saml2sp");
 
         org.opensaml.saml.saml2.core.Response samlResponse =
-            createResponse(null, true, SAML2Constants.CONF_BEARER, "urn:org:apache:cxf:fediz:idp:realm-B");
+                createResponse(null, true, SAML2Constants.CONF_BEARER, "urn:org:apache:cxf:fediz:idp:realm-B");
 
         Document doc = DOMUtils.newDocument();
         Element responseElement = OpenSAMLUtil.toDom(samlResponse, doc);
@@ -435,7 +434,7 @@ public class SAML2ITCase extends AbstractITCase {
         response.setSamlResponse(Base64.encodeBase64String(responseStr.getBytes()));
         response.setRelayState("idpInitiated");
         SAML2LoginResponseTO loginResponse =
-            saml2Service.validateLoginResponse(response);
+                saml2Service.validateLoginResponse(response);
         assertNotNull(loginResponse.getAccessToken());
         assertEquals("puccini", loginResponse.getNameID());
     }
@@ -453,7 +452,7 @@ public class SAML2ITCase extends AbstractITCase {
         response.setUrlContext("saml2sp");
 
         org.opensaml.saml.saml2.core.Response samlResponse =
-            createResponse(null, true, SAML2Constants.CONF_BEARER, "urn:org:apache:cxf:fediz:idp:realm-A");
+                createResponse(null, true, SAML2Constants.CONF_BEARER, "urn:org:apache:cxf:fediz:idp:realm-A");
 
         Document doc = DOMUtils.newDocument();
         Element responseElement = OpenSAMLUtil.toDom(samlResponse, doc);

http://git-wip-us.apache.org/repos/asf/syncope/blob/aa25af97/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..381fc13
--- /dev/null
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/SCIMITCase.java
@@ -0,0 +1,96 @@
+/*
+ * 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.syncope.fit.core;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.io.InputStream;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.syncope.ext.scimv2.api.SCIMConstants;
+import org.apache.syncope.ext.scimv2.api.data.ListResponse;
+import org.apache.syncope.ext.scimv2.api.data.SCIMGroup;
+import org.apache.syncope.ext.scimv2.api.data.SCIMUser;
+import org.apache.syncope.fit.AbstractITCase;
+import org.apache.syncope.fit.SCIMDetector;
+import org.junit.Assume;
+import org.junit.Test;
+
+public class SCIMITCase extends AbstractITCase {
+
+    public static final String SCIM_ADDRESS = "http://localhost:9080/syncope/scim";
+
+    private static final ObjectMapper MAPPER = new ObjectMapper();
+
+    private WebClient webClient() {
+        return WebClient.create(SCIM_ADDRESS).
+                accept(SCIMConstants.APPLICATION_SCIM_JSON_TYPE).
+                header(HttpHeaders.AUTHORIZATION, "Bearer " + adminClient.getJWT());
+    }
+
+    @Test
+    public void read() throws IOException {
+        Assume.assumeTrue(SCIMDetector.isSCIMAvailable());
+
+        Response response = webClient().path("Users").path("1417acbe-cbf6-4277-9372-e75e04f97000").get();
+        assertEquals(200, response.getStatus());
+        assertEquals(
+                SCIMConstants.APPLICATION_SCIM_JSON,
+                StringUtils.substringBefore(response.getHeaderString(HttpHeaders.CONTENT_TYPE),
";"));
+
+        SCIMUser user = MAPPER.readValue((InputStream) response.getEntity(), SCIMUser.class);
+        assertNotNull(user);
+        assertEquals("1417acbe-cbf6-4277-9372-e75e04f97000", user.getId());
+        assertEquals("rossini", user.getUserName());
+        assertFalse(user.getGroups().isEmpty());
+        assertFalse(user.getRoles().isEmpty());
+    }
+
+    @Test
+    public void list() throws IOException {
+        Assume.assumeTrue(SCIMDetector.isSCIMAvailable());
+
+        Response response = webClient().path("Groups").get();
+        assertEquals(200, response.getStatus());
+        assertEquals(
+                SCIMConstants.APPLICATION_SCIM_JSON,
+                StringUtils.substringBefore(response.getHeaderString(HttpHeaders.CONTENT_TYPE),
";"));
+
+        ListResponse<SCIMGroup> result = MAPPER.readValue(
+                (InputStream) response.getEntity(),
+                new TypeReference<ListResponse<SCIMGroup>>() {
+        });
+        assertNotNull(result);
+        assertTrue(result.getTotalResults() > 0);
+        assertFalse(result.getResources().isEmpty());
+
+        for (SCIMGroup group : result.getResources()) {
+            assertNotNull(group.getId());
+            assertNotNull(group.getDisplayName());
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/aa25af97/fit/core-reference/src/test/resources/rebel.xml
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/resources/rebel.xml b/fit/core-reference/src/test/resources/rebel.xml
index 6cb85c4..a81d750 100644
--- a/fit/core-reference/src/test/resources/rebel.xml
+++ b/fit/core-reference/src/test/resources/rebel.xml
@@ -91,6 +91,10 @@ under the License.
     </dir>
     <dir name="${basedir}/../../ext/elasticsearch/persistence-jpa/target/classes">
     </dir>
+    <dir name="${basedir}/../../ext/scimv2/scim-rest-api/target/classes">
+    </dir>
+    <dir name="${basedir}/../../ext/scimv2/scim-rest-cxf/target/classes">
+    </dir>
   </classpath>
 
   <web>


Mime
View raw message