syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject [syncope] branch master updated: [SYNCOPE-1458] Changing Zookeeper-based Keymaster client to run tests without do DockeDocker, and moving Docker-based tests to a profile
Date Sat, 20 Apr 2019 17:10:05 GMT
This is an automated email from the ASF dual-hosted git repository.

ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git


The following commit(s) were added to refs/heads/master by this push:
     new e526bb1  [SYNCOPE-1458] Changing Zookeeper-based Keymaster client to run tests without
do DockeDocker, and moving Docker-based tests to a profile
e526bb1 is described below

commit e526bb1058df45298e3d60681a3132d997003559
Author: Francesco Chicchiriccò <ilgrosso@apache.org>
AuthorDate: Sat Apr 20 19:09:52 2019 +0200

    [SYNCOPE-1458] Changing Zookeeper-based Keymaster client to run tests without do DockeDocker,
and moving Docker-based tests to a profile
---
 common/keymaster/client-zookeeper/pom.xml          | 109 +++++++++++++--------
 .../client/zookeper/ZookeeperConfParamOpsTest.java |  80 +++++++++++++++
 .../zookeper/ZookeeperTestContentLoader.java       |   2 +-
 3 files changed, 147 insertions(+), 44 deletions(-)

diff --git a/common/keymaster/client-zookeeper/pom.xml b/common/keymaster/client-zookeeper/pom.xml
index d3883e4..01acda0 100644
--- a/common/keymaster/client-zookeeper/pom.xml
+++ b/common/keymaster/client-zookeeper/pom.xml
@@ -64,6 +64,12 @@ under the License.
     </dependency>
 
     <dependency>
+      <groupId>org.apache.curator</groupId>
+      <artifactId>curator-test</artifactId>
+      <version>2.13.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-simple</artifactId>
       <scope>test</scope>
@@ -88,50 +94,8 @@ under the License.
       </plugin>
       
       <plugin>
-        <groupId>io.fabric8</groupId>
-        <artifactId>docker-maven-plugin</artifactId>
-        <configuration>
-          <images>
-            <image>
-              <name>zookeeper:${zookeeper.version}</name>
-              <run>
-                <ports>
-                  <port>2181:2181</port>
-                </ports>
-                <volumes>
-                  <bind>
-                    <volume>${project.build.outputDirectory}/zoo.cfg:/conf/zoo.cfg</volume>
-                    <volume>${project.build.outputDirectory}/java.env:/conf/java.env</volume>
-                    <volume>${project.build.outputDirectory}/server-jaas.conf:/conf/server-jaas.conf</volume>
-                    <volume>${project.build.outputDirectory}/client-jaas.conf:/conf/client-jaas.conf</volume>
-                  </bind>
-                </volumes>
-              </run>
-            </image>
-          </images>
-        </configuration>
-        <executions>
-          <execution>
-            <id>start-zookeeper</id>
-            <phase>pre-integration-test</phase>
-            <goals>
-              <goal>start</goal>
-            </goals>
-          </execution>
-          <execution>
-            <id>stop-zookeeper</id>
-            <phase>post-integration-test</phase>
-            <goals>
-              <goal>stop</goal>
-              <goal>remove</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-      
-      <plugin>
         <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-failsafe-plugin</artifactId>
+        <artifactId>maven-surefire-plugin</artifactId>
         <inherited>true</inherited>
       </plugin>
     </plugins>
@@ -143,4 +107,63 @@ under the License.
       </resource>
     </resources>
   </build>
+  
+  <profiles>
+    <profile>
+      <id>zookeeper-it</id>
+
+      <build>
+        <plugins>
+
+          <plugin>
+            <groupId>io.fabric8</groupId>
+            <artifactId>docker-maven-plugin</artifactId>
+            <configuration>
+              <images>
+                <image>
+                  <name>zookeeper:${zookeeper.version}</name>
+                  <run>
+                    <ports>
+                      <port>2181:2181</port>
+                    </ports>
+                    <volumes>
+                      <bind>
+                        <volume>${project.build.outputDirectory}/zoo.cfg:/conf/zoo.cfg</volume>
+                        <volume>${project.build.outputDirectory}/java.env:/conf/java.env</volume>
+                        <volume>${project.build.outputDirectory}/server-jaas.conf:/conf/server-jaas.conf</volume>
+                        <volume>${project.build.outputDirectory}/client-jaas.conf:/conf/client-jaas.conf</volume>
+                      </bind>
+                    </volumes>
+                  </run>
+                </image>
+              </images>
+            </configuration>
+            <executions>
+              <execution>
+                <id>start-zookeeper</id>
+                <phase>pre-integration-test</phase>
+                <goals>
+                  <goal>start</goal>
+                </goals>
+              </execution>
+              <execution>
+                <id>stop-zookeeper</id>
+                <phase>post-integration-test</phase>
+                <goals>
+                  <goal>stop</goal>
+                  <goal>remove</goal>
+                </goals>
+              </execution>
+            </executions>
+          </plugin>
+      
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-failsafe-plugin</artifactId>
+            <inherited>true</inherited>
+          </plugin>          
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
 </project>
diff --git a/common/keymaster/client-zookeeper/src/test/java/org/apache/syncope/common/keymaster/client/zookeper/ZookeeperConfParamOpsTest.java
b/common/keymaster/client-zookeeper/src/test/java/org/apache/syncope/common/keymaster/client/zookeper/ZookeeperConfParamOpsTest.java
new file mode 100644
index 0000000..19f5ebc
--- /dev/null
+++ b/common/keymaster/client-zookeeper/src/test/java/org/apache/syncope/common/keymaster/client/zookeper/ZookeeperConfParamOpsTest.java
@@ -0,0 +1,80 @@
+/*
+ * 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.common.keymaster.client.zookeper;
+
+import static org.junit.jupiter.api.Assertions.fail;
+
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicReference;
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.Configuration;
+import org.apache.curator.test.InstanceSpec;
+import org.apache.curator.test.TestingServer;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+
+public class ZookeeperConfParamOpsTest extends ZookeeperConfParamOpsITCase {
+
+    private static TestingServer ZK_SERVER;
+
+    @BeforeAll
+    public static void setUp() throws Exception {
+        AtomicReference<String> username = new AtomicReference<>();
+        AtomicReference<String> password = new AtomicReference<>();
+        try (InputStream propStream = ZookeeperConfParamOpsTest.class.getResourceAsStream("/keymaster.properties"))
{
+            Properties props = new Properties();
+            props.load(propStream);
+
+            username.set(props.getProperty("keymaster.username"));
+            password.set(props.getProperty("keymaster.password"));
+        } catch (Exception e) {
+            fail("Could not load /keymaster.properties", e);
+        }
+
+        Configuration.setConfiguration(new Configuration() {
+
+            private final AppConfigurationEntry[] entries = {
+                new AppConfigurationEntry(
+                "org.apache.zookeeper.server.auth.DigestLoginModule",
+                AppConfigurationEntry.LoginModuleControlFlag.REQUIRED,
+                Map.of(
+                "user_" + username.get(), password.get()
+                ))
+            };
+
+            @Override
+            public AppConfigurationEntry[] getAppConfigurationEntry(final String name) {
+                return entries;
+            }
+        });
+
+        Map<String, Object> customProperties = new HashMap<>();
+        customProperties.put("authProvider.1", "org.apache.zookeeper.server.auth.SASLAuthenticationProvider");
+        InstanceSpec spec = new InstanceSpec(null, 2181, -1, -1, true, 1, -1, -1, customProperties);
+        ZK_SERVER = new TestingServer(spec, true);
+    }
+
+    @AfterAll
+    public static void tearDown() throws Exception {
+        ZK_SERVER.stop();
+    }
+}
diff --git a/common/keymaster/client-zookeeper/src/test/java/org/apache/syncope/common/keymaster/client/zookeper/ZookeeperTestContentLoader.java
b/common/keymaster/client-zookeeper/src/test/java/org/apache/syncope/common/keymaster/client/zookeper/ZookeeperTestContentLoader.java
index b54fab7..f3b7169 100644
--- a/common/keymaster/client-zookeeper/src/test/java/org/apache/syncope/common/keymaster/client/zookeper/ZookeeperTestContentLoader.java
+++ b/common/keymaster/client-zookeeper/src/test/java/org/apache/syncope/common/keymaster/client/zookeper/ZookeeperTestContentLoader.java
@@ -40,7 +40,7 @@ public class ZookeeperTestContentLoader implements InitializingBean {
             Map.Entry<String, JsonNode> param = itor.next();
             Object value = MAPPER.treeToValue(param.getValue(), Object.class);
             if (value != null) {
-                confParamOps.set(ZookeeperConfParamOpsITCase.DOMAIN, param.getKey(), value);
+                confParamOps.set(ZookeeperConfParamOpsTest.DOMAIN, param.getKey(), value);
             }
         }
     }


Mime
View raw message