james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [james-project] 06/12: JAMES-2709 Integration test for LinShare Blob Export Mechanism provisioning
Date Fri, 19 Apr 2019 07:42:59 GMT
This is an automated email from the ASF dual-hosted git repository.

aduprat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 7bc454914ffc826922e768b65a43f95516372537
Author: Benoit Tellier <btellier@linagora.com>
AuthorDate: Thu Apr 11 11:27:15 2019 +0700

    JAMES-2709 Integration test for LinShare Blob Export Mechanism provisioning
---
 pom.xml                                            | 12 +++++
 server/container/guice/blob-export-guice/pom.xml   |  6 +++
 .../james/modules/LinshareGuiceExtension.java      | 58 ++++++++++++++++++++++
 server/container/guice/memory-guice/pom.xml        | 22 ++++++++
 .../LinshareBlobExportMechanismProvidingTest.java  | 42 ++++++++++++++++
 .../java/org/apache/james/linshare/Linshare.java   |  2 +-
 .../apache/james/linshare/LinshareExtension.java   | 18 +++----
 .../resources/backend/conf/{id_rsa => id_rsa.pri}  |  0
 8 files changed, 150 insertions(+), 10 deletions(-)

diff --git a/pom.xml b/pom.xml
index 1acee52..7100134 100644
--- a/pom.xml
+++ b/pom.xml
@@ -725,6 +725,12 @@
             </dependency>
             <dependency>
                 <groupId>${james.groupId}</groupId>
+                <artifactId>apache-james-linshare</artifactId>
+                <version>${project.version}</version>
+                <type>test-jar</type>
+            </dependency>
+            <dependency>
+                <groupId>${james.groupId}</groupId>
                 <artifactId>apache-james-spamassassin</artifactId>
                 <version>${project.version}</version>
             </dependency>
@@ -1120,6 +1126,12 @@
             </dependency>
             <dependency>
                 <groupId>${james.groupId}</groupId>
+                <artifactId>blob-export-guice</artifactId>
+                <version>${project.version}</version>
+                <type>test-jar</type>
+            </dependency>
+            <dependency>
+                <groupId>${james.groupId}</groupId>
                 <artifactId>blob-memory</artifactId>
                 <version>${project.version}</version>
             </dependency>
diff --git a/server/container/guice/blob-export-guice/pom.xml b/server/container/guice/blob-export-guice/pom.xml
index b55785d..4aaf28e 100644
--- a/server/container/guice/blob-export-guice/pom.xml
+++ b/server/container/guice/blob-export-guice/pom.xml
@@ -37,6 +37,12 @@
         <dependency>
             <groupId>${james.groupId}</groupId>
             <artifactId>apache-james-linshare</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>apache-james-linshare</artifactId>
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
diff --git a/server/container/guice/blob-export-guice/src/test/java/org/apache/james/modules/LinshareGuiceExtension.java
b/server/container/guice/blob-export-guice/src/test/java/org/apache/james/modules/LinshareGuiceExtension.java
new file mode 100644
index 0000000..090395f
--- /dev/null
+++ b/server/container/guice/blob-export-guice/src/test/java/org/apache/james/modules/LinshareGuiceExtension.java
@@ -0,0 +1,58 @@
+/****************************************************************
+ * 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.james.modules;
+
+import org.apache.james.GuiceModuleTestExtension;
+import org.apache.james.linshare.LinshareConfiguration;
+import org.apache.james.linshare.LinshareExtension;
+import org.apache.james.linshare.LinshareFixture;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+import com.google.inject.Module;
+import com.google.inject.util.Modules;
+
+public class LinshareGuiceExtension implements GuiceModuleTestExtension {
+    private final LinshareExtension linshareExtension;
+
+    public LinshareGuiceExtension() {
+        linshareExtension = new LinshareExtension();
+    }
+
+    @Override
+    public void beforeEach(ExtensionContext extensionContext) throws Exception {
+        linshareExtension.beforeEach(extensionContext);
+    }
+
+    @Override
+    public Module getModule() {
+        return Modules.combine(
+            binder -> binder.bind(BlobExportImplChoice.class)
+                .toInstance(BlobExportImplChoice.LINSHARE),
+            binder -> {
+                try {
+                    binder.bind(LinshareConfiguration.class)
+                        .toInstance(linshareExtension.configurationWithJwtFor(LinshareFixture.USER_1));
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        );
+    }
+}
diff --git a/server/container/guice/memory-guice/pom.xml b/server/container/guice/memory-guice/pom.xml
index b322d03..af5ca6c 100644
--- a/server/container/guice/memory-guice/pom.xml
+++ b/server/container/guice/memory-guice/pom.xml
@@ -37,6 +37,12 @@
     <dependencies>
         <dependency>
             <groupId>${james.groupId}</groupId>
+            <artifactId>apache-james-linshare</artifactId>
+            <scope>test</scope>
+            <type>test-jar</type>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
             <artifactId>apache-james-mailbox-memory</artifactId>
         </dependency>
         <dependency>
@@ -69,6 +75,12 @@
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
+            <artifactId>blob-export-guice</artifactId>
+            <type>test-jar</type>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
             <artifactId>blob-memory-guice</artifactId>
         </dependency>
         <dependency>
@@ -168,6 +180,11 @@
             <artifactId>james-server-queue-memory</artifactId>
         </dependency>
         <dependency>
+            <groupId>${james.groupId}</groupId>
+            <artifactId>james-server-testing</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
             <groupId>ch.qos.logback</groupId>
             <artifactId>logback-classic</artifactId>
             <scope>test</scope>
@@ -197,6 +214,11 @@
             <artifactId>assertj-core</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.testcontainers</groupId>
+            <artifactId>testcontainers</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
diff --git a/server/container/guice/memory-guice/src/test/java/org/apache/james/LinshareBlobExportMechanismProvidingTest.java
b/server/container/guice/memory-guice/src/test/java/org/apache/james/LinshareBlobExportMechanismProvidingTest.java
new file mode 100644
index 0000000..a6e022b
--- /dev/null
+++ b/server/container/guice/memory-guice/src/test/java/org/apache/james/LinshareBlobExportMechanismProvidingTest.java
@@ -0,0 +1,42 @@
+/****************************************************************
+ * 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.james;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.james.modules.LinshareGuiceExtension;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+class LinshareBlobExportMechanismProvidingTest {
+    private static final LinshareGuiceExtension linshareGuiceExtension = new LinshareGuiceExtension();
+
+    @RegisterExtension
+    static JamesServerExtension jamesServerExtension = new JamesServerBuilder()
+        .extension(linshareGuiceExtension)
+        .server(configuration -> GuiceJamesServer.forConfiguration(configuration)
+            .combineWith(MemoryJamesServerMain.IN_MEMORY_SERVER_AGGREGATE_MODULE))
+        .build();
+
+    @Test
+    void memoryJamesServerShouldStartWithLinShareBlobExportMechanism(GuiceJamesServer server)
{
+        assertThat(server.isStarted()).isTrue();
+    }
+}
diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/Linshare.java b/third-party/linshare/src/test/java/org/apache/james/linshare/Linshare.java
index 4112f75..694a4c3 100644
--- a/third-party/linshare/src/test/java/org/apache/james/linshare/Linshare.java
+++ b/third-party/linshare/src/test/java/org/apache/james/linshare/Linshare.java
@@ -115,7 +115,7 @@ public class Linshare {
             new ImageFromDockerfile()
                 .withFileFromClasspath("conf/log4j.properties", "backend/conf/log4j.properties")
                 .withFileFromClasspath("conf/catalina.properties", "backend/conf/catalina.properties")
-                .withFileFromClasspath("conf/id_rsa", "backend/conf/id_rsa")
+                .withFileFromClasspath("conf/id_rsa", "backend/conf/id_rsa.pri")
                 .withFileFromClasspath("conf/id_rsa.pub", "backend/conf/id_rsa.pub")
                 .withFileFromClasspath("Dockerfile", "backend/Dockerfile"))
             .withNetworkAliases("backend")
diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareExtension.java
b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareExtension.java
index 29895cc..6a5ec9b 100644
--- a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareExtension.java
+++ b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareExtension.java
@@ -81,6 +81,15 @@ public class LinshareExtension implements BeforeEachCallback {
         return LinshareAPI.from(configurationWithJwtFor(credential));
     }
 
+    public LinshareConfiguration configurationWithJwtFor(LinshareFixture.Credential credential)
throws Exception {
+        AuthorizationToken token = LinshareAPIForTesting.from(credential, linshare).jwt();
+
+        return LinshareConfiguration.builder()
+            .urlAsString(linshare.getUrl())
+            .authorizationToken(token)
+            .build();
+    }
+
     private void deleteAllUsersDocuments() {
         LinshareAPIForTesting.from(USER_1, linshare)
             .allUsers()
@@ -95,13 +104,4 @@ public class LinshareExtension implements BeforeEachCallback {
         return Optional.ofNullable(USER_CREDENTIAL_MAP.get(user.getMail()))
             .orElseThrow(() -> new RuntimeException("cannot get token of user " + user.getMail()));
     }
-
-    private LinshareConfiguration configurationWithJwtFor(LinshareFixture.Credential credential)
throws Exception {
-        AuthorizationToken token = LinshareAPIForTesting.from(credential, linshare).jwt();
-
-        return LinshareConfiguration.builder()
-            .urlAsString(linshare.getUrl())
-            .authorizationToken(token)
-            .build();
-    }
 }
diff --git a/third-party/linshare/src/test/resources/backend/conf/id_rsa b/third-party/linshare/src/test/resources/backend/conf/id_rsa.pri
similarity index 100%
rename from third-party/linshare/src/test/resources/backend/conf/id_rsa
rename to third-party/linshare/src/test/resources/backend/conf/id_rsa.pri


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message