You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ad...@apache.org on 2019/04/19 07:42:53 UTC
[james-project] branch master updated (6fb06d5 -> 1155f53)
This is an automated email from the ASF dual-hosted git repository.
aduprat pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git.
from 6fb06d5 JAMES-2721 provide a builder-like API for allowing Cassandra restart between tests
new ce1e202 JAMES-2709 FileExtension::asFileSuffix
new c2c74cf JAMES-2709 Contribute a LinShare Blob Export Mechanism
new 3d69d90 JAMES-2709 Fasten LinShare test by reusing surefire forks
new 82305ca JAMES-2709 Parse LinShareConfiguration from .properties
new fe0a43d JAMES-2709 Provide the LinShare BlobExport mechanism as a viable choice
new 7bc4549 JAMES-2709 Integration test for LinShare Blob Export Mechanism provisioning
new 08d7775 JAMES-2709 Fix POMs issues
new f0b00ef JAMES-2709 Add name and description to Third Party POM
new e4fd6d6 JAMES-2709 Use FakeSmtp to check mails sent by LinShare
new 86159d1 JAMES-2709 Position explanation on the share
new 9dd2923 JAMES-2709 little cleanup of dockerized Linshare
new 1155f53 Merge remote-tracking branch 'btellier/JAMES-2709'
The 12 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
pom.xml | 17 +++
.../james/blob/export/api/FileExtension.java | 9 +-
.../james/blob/export/api/FileExtensionTest.java | 40 +++++--
server/container/cli-integration/pom.xml | 6 +
server/container/guice/blob-export-guice/pom.xml | 11 ++
.../apache/james/modules/BlobExportImplChoice.java | 3 +-
.../james/modules/BlobExportMechanismModule.java | 8 +-
.../LinshareBlobExportMechanismModule.java} | 37 +++---
.../modules/BlobExportMechanismModuleTest.java | 11 +-
.../james/modules/LinshareGuiceExtension.java} | 43 ++++---
server/container/guice/memory-guice/pom.xml | 23 ++++
... LinshareBlobExportMechanismProvidingTest.java} | 22 ++--
.../memory-jmap-integration-testing/pom.xml | 6 +
.../main/java/org/apache/james/utils/FakeSmtp.java | 23 ++--
third-party/linshare/pom.xml | 33 ++++++
.../linshare/LinshareBlobExportMechanism.java | 82 +++++++++++++
.../james/linshare/LinshareConfiguration.java | 17 ++-
.../james/linshare/client/ReceivedShare.java | 2 +-
.../apache/james/linshare/client/ShareRequest.java | 39 +++++--
.../java/org/apache/james/linshare/Linshare.java | 27 ++++-
.../linshare/LinshareBlobExportMechanismTest.java | 127 +++++++++++++++++++++
.../james/linshare/LinshareConfigurationTest.java | 58 ++++++++--
.../apache/james/linshare/LinshareExtension.java | 22 ++--
.../james/linshare/client/LinshareAPITest.java | 46 +++++++-
.../james/linshare/client/ShareRequestTest.java | 20 +++-
.../src/test/resources/backend/conf/id_rsa | 27 -----
.../{ssl/id_rsa => backend/conf/id_rsa.pri} | 0
.../linshare/src/test/resources/smtp/Dockerfile | 3 -
.../src/test/resources/smtp/conf/smtpd.conf | 14 ---
third-party/linshare/src/test/resources/ssl/ca.pem | 28 -----
.../linshare/src/test/resources/ssl/id_rsa.pub | 1 -
.../linshare/src/test/resources/ssl/linshare.key | 28 -----
.../linshare/src/test/resources/ssl/linshare.pem | 97 ----------------
third-party/spamassassin/pom.xml | 3 +
34 files changed, 613 insertions(+), 320 deletions(-)
copy server/container/guice/{mailbox-plugin-spamassassin/src/main/java/org/apache/james/modules/spamassassin/SpamAssassinListenerModule.java => blob-export-guice/src/main/java/org/apache/james/modules/LinshareBlobExportMechanismModule.java} (60%)
copy server/container/guice/{cassandra-rabbitmq-guice/src/test/java/org/apache/james/modules/SwiftBlobStoreExtension.java => blob-export-guice/src/test/java/org/apache/james/modules/LinshareGuiceExtension.java} (59%)
copy server/container/guice/memory-guice/src/test/java/org/apache/james/{MemoryJamesServerTest.java => LinshareBlobExportMechanismProvidingTest.java} (74%)
create mode 100644 third-party/linshare/src/main/java/org/apache/james/linshare/LinshareBlobExportMechanism.java
create mode 100644 third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java
delete mode 100644 third-party/linshare/src/test/resources/backend/conf/id_rsa
rename third-party/linshare/src/test/resources/{ssl/id_rsa => backend/conf/id_rsa.pri} (100%)
delete mode 100644 third-party/linshare/src/test/resources/smtp/Dockerfile
delete mode 100644 third-party/linshare/src/test/resources/smtp/conf/smtpd.conf
delete mode 100644 third-party/linshare/src/test/resources/ssl/ca.pem
delete mode 100644 third-party/linshare/src/test/resources/ssl/id_rsa.pub
delete mode 100644 third-party/linshare/src/test/resources/ssl/linshare.key
delete mode 100644 third-party/linshare/src/test/resources/ssl/linshare.pem
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 03/12: JAMES-2709 Fasten LinShare test by reusing
surefire forks
Posted by ad...@apache.org.
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 3d69d9088f331d1f4c69e6f185a080cc118171da
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Apr 11 10:24:43 2019 +0700
JAMES-2709 Fasten LinShare test by reusing surefire forks
- We initialise testcontainer only once
- LinShare singleton is initialized only once hence dockers are started only once
---
third-party/linshare/pom.xml | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/third-party/linshare/pom.xml b/third-party/linshare/pom.xml
index 4a41a92..8a7917a 100644
--- a/third-party/linshare/pom.xml
+++ b/third-party/linshare/pom.xml
@@ -111,4 +111,16 @@
<scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <reuseForks>true</reuseForks>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 02/12: JAMES-2709 Contribute a LinShare Blob Export
Mechanism
Posted by ad...@apache.org.
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 c2c74cf9609227c8f21dd192f38bc1639aa92f16
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Apr 9 15:37:13 2019 +0700
JAMES-2709 Contribute a LinShare Blob Export Mechanism
---
third-party/linshare/pom.xml | 9 +++
.../linshare/LinshareBlobExportMechanism.java | 78 +++++++++++++++++++
.../james/linshare/client/ReceivedShare.java | 2 +-
.../apache/james/linshare/client/ShareRequest.java | 12 +--
.../linshare/LinshareBlobExportMechanismTest.java | 91 ++++++++++++++++++++++
5 files changed, 185 insertions(+), 7 deletions(-)
diff --git a/third-party/linshare/pom.xml b/third-party/linshare/pom.xml
index 576c3ee..4a41a92 100644
--- a/third-party/linshare/pom.xml
+++ b/third-party/linshare/pom.xml
@@ -34,6 +34,15 @@
<artifactId>james-core</artifactId>
</dependency>
<dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>blob-export-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
+ <artifactId>blob-memory</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
diff --git a/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareBlobExportMechanism.java b/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareBlobExportMechanism.java
new file mode 100644
index 0000000..b5b7db4
--- /dev/null
+++ b/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareBlobExportMechanism.java
@@ -0,0 +1,78 @@
+/****************************************************************
+ * 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.linshare;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Optional;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.james.blob.api.BlobId;
+import org.apache.james.blob.api.BlobStore;
+import org.apache.james.blob.export.api.BlobExportMechanism;
+import org.apache.james.blob.export.api.FileExtension;
+import org.apache.james.core.MailAddress;
+import org.apache.james.linshare.client.Document;
+import org.apache.james.linshare.client.LinshareAPI;
+import org.apache.james.linshare.client.ShareRequest;
+
+public class LinshareBlobExportMechanism implements BlobExportMechanism {
+ private final LinshareAPI linshareAPI;
+ private final BlobStore blobStore;
+
+ public LinshareBlobExportMechanism(LinshareAPI linshareAPI, BlobStore blobStore) {
+ this.linshareAPI = linshareAPI;
+ this.blobStore = blobStore;
+ }
+
+ @Override
+ public ShareeStage blobId(BlobId blobId) {
+ return mailAddress -> explanation -> fileExtension -> () -> {
+ try {
+ exportBlob(blobId, mailAddress, fileExtension);
+ } catch (Exception e) {
+ throw new BlobExportException("Error while exporting blob " + blobId.asString() + " to " + mailAddress.asString(), e);
+ }
+ };
+ }
+
+ private void exportBlob(BlobId blobId, MailAddress mailAddress, Optional<FileExtension> fileExtension) throws IOException {
+ File tempFile = createTempFile(blobId, fileExtension);
+ try {
+ FileUtils.copyInputStreamToFile(blobStore.read(blobId), tempFile);
+ uploadAndShare(mailAddress, tempFile);
+ } finally {
+ FileUtils.forceDelete(tempFile);
+ }
+ }
+
+ private void uploadAndShare(MailAddress mailAddress, File tempFile) {
+ Document document = linshareAPI.uploadDocument(tempFile);
+ linshareAPI.share(ShareRequest.builder()
+ .addDocumentId(document.getId())
+ .addRecipient(mailAddress)
+ .build());
+ }
+
+ private File createTempFile(BlobId blobId, Optional<FileExtension> fileExtension) throws IOException {
+ String suffix = fileExtension.map(FileExtension::asFileSuffix).orElse("");
+ return File.createTempFile(blobId.asString() + "_", suffix);
+ }
+}
diff --git a/third-party/linshare/src/main/java/org/apache/james/linshare/client/ReceivedShare.java b/third-party/linshare/src/main/java/org/apache/james/linshare/client/ReceivedShare.java
index 7d21962..cf11766 100644
--- a/third-party/linshare/src/main/java/org/apache/james/linshare/client/ReceivedShare.java
+++ b/third-party/linshare/src/main/java/org/apache/james/linshare/client/ReceivedShare.java
@@ -24,7 +24,7 @@ import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.annotations.VisibleForTesting;
-class ReceivedShare {
+public class ReceivedShare {
private final User sender;
private final Document document;
diff --git a/third-party/linshare/src/main/java/org/apache/james/linshare/client/ShareRequest.java b/third-party/linshare/src/main/java/org/apache/james/linshare/client/ShareRequest.java
index c0a95bb..61a2d8b 100644
--- a/third-party/linshare/src/main/java/org/apache/james/linshare/client/ShareRequest.java
+++ b/third-party/linshare/src/main/java/org/apache/james/linshare/client/ShareRequest.java
@@ -31,7 +31,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
-class ShareRequest {
+public class ShareRequest {
static class Recipient {
private final MailAddress mail;
@@ -64,7 +64,7 @@ class ShareRequest {
}
}
- static class Builder {
+ public static class Builder {
private final ImmutableList.Builder<Recipient> recipientsBuilder;
private final ImmutableList.Builder<DocumentId> documentIdsBuilder;
@@ -73,22 +73,22 @@ class ShareRequest {
this.documentIdsBuilder = new ImmutableList.Builder<>();
}
- Builder addRecipient(MailAddress recipient) {
+ public Builder addRecipient(MailAddress recipient) {
recipientsBuilder.add(new Recipient(recipient));
return this;
}
- Builder addDocumentId(DocumentId documentId) {
+ public Builder addDocumentId(DocumentId documentId) {
documentIdsBuilder.add(documentId);
return this;
}
- ShareRequest build() {
+ public ShareRequest build() {
return new ShareRequest(recipientsBuilder.build(), documentIdsBuilder.build());
}
}
- static Builder builder() {
+ public static Builder builder() {
return new Builder();
}
diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java
new file mode 100644
index 0000000..e693cd5
--- /dev/null
+++ b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java
@@ -0,0 +1,91 @@
+/****************************************************************
+ * 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.linshare;
+
+import static org.apache.james.linshare.LinshareFixture.USER_1;
+import static org.apache.james.linshare.LinshareFixture.USER_2;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+
+import java.nio.charset.StandardCharsets;
+
+import org.apache.james.blob.api.BlobId;
+import org.apache.james.blob.api.HashBlobId;
+import org.apache.james.blob.export.api.BlobExportMechanism;
+import org.apache.james.blob.export.api.FileExtension;
+import org.apache.james.blob.memory.MemoryBlobStore;
+import org.apache.james.core.MailAddress;
+import org.apache.james.linshare.client.LinshareAPI;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+class LinshareBlobExportMechanismTest {
+ private static final String EXPLANATION = "Explanation about the file being shared";
+
+ @RegisterExtension
+ static LinshareExtension linshareExtension = new LinshareExtension();
+
+ private MemoryBlobStore blobStore;
+ private LinshareBlobExportMechanism testee;
+ private HashBlobId.Factory blobIdFactory;
+
+ @BeforeEach
+ void setUp() throws Exception {
+ blobIdFactory = new HashBlobId.Factory();
+ blobStore = new MemoryBlobStore(blobIdFactory);
+
+ testee = new LinshareBlobExportMechanism(
+ linshareExtension.getAPIFor(USER_1),
+ blobStore);
+ }
+
+ @Test
+ void exportShouldShareTheDocumentViaLinShare() throws Exception {
+ BlobId blobId = blobStore.save("content".getBytes(StandardCharsets.UTF_8)).block();
+
+ testee.blobId(blobId)
+ .with(new MailAddress(USER_2.getUsername()))
+ .explanation(EXPLANATION)
+ .fileExtension(FileExtension.of("txt"))
+ .export();
+
+ LinshareAPI user2API = linshareExtension.getAPIFor(USER_2);
+
+ assertThat(user2API.receivedShares())
+ .hasSize(1)
+ .allSatisfy(receivedShare -> assertThat(receivedShare.getDocument().getName()).endsWith(".txt"))
+ .allSatisfy(receivedShare -> assertThat(receivedShare.getDocument().getName()).startsWith(blobId.asString()))
+ .allSatisfy(receivedShare -> assertThat(receivedShare.getSender().getMail()).isEqualTo(USER_1.getUsername()));
+ }
+
+ @Test
+ void exportShouldFailWhenBlobDoesNotExist() {
+ BlobId blobId = blobIdFactory.randomId();
+
+ assertThatThrownBy(
+ () -> testee.blobId(blobId)
+ .with(new MailAddress(USER_2.getUsername()))
+ .explanation(EXPLANATION)
+ .fileExtension(FileExtension.of("txt"))
+ .export())
+ .isInstanceOf(BlobExportMechanism.BlobExportException.class);
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 08/12: JAMES-2709 Add name and description to Third
Party POM
Posted by ad...@apache.org.
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 f0b00ef25ea1e224806865689ce34c1c1c7f1f0b
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Apr 11 14:04:47 2019 +0700
JAMES-2709 Add name and description to Third Party POM
---
third-party/linshare/pom.xml | 3 +++
third-party/spamassassin/pom.xml | 3 +++
2 files changed, 6 insertions(+)
diff --git a/third-party/linshare/pom.xml b/third-party/linshare/pom.xml
index fe07bbd..e243509 100644
--- a/third-party/linshare/pom.xml
+++ b/third-party/linshare/pom.xml
@@ -28,6 +28,9 @@
<artifactId>apache-james-linshare</artifactId>
+ <name>Apache James :: Third Party :: LinShare</name>
+ <description>LinShare Java client, blob export mechanism and test utilities</description>
+
<dependencies>
<dependency>
<groupId>${james.groupId}</groupId>
diff --git a/third-party/spamassassin/pom.xml b/third-party/spamassassin/pom.xml
index 0d70747..0a7a181 100644
--- a/third-party/spamassassin/pom.xml
+++ b/third-party/spamassassin/pom.xml
@@ -28,6 +28,9 @@
<artifactId>apache-james-spamassassin</artifactId>
+ <name>Apache James :: Third Party :: SpamAssassin</name>
+ <description>SpamAssassin Java client and testing utilities</description>
+
<dependencies>
<dependency>
<groupId>${james.groupId}</groupId>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 07/12: JAMES-2709 Fix POMs issues
Posted by ad...@apache.org.
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 08d77750c4a56c5499255bd8399e4d19c5f2c49e
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Apr 11 11:37:24 2019 +0700
JAMES-2709 Fix POMs issues
---
server/container/cli-integration/pom.xml | 6 ++++++
server/container/guice/blob-export-guice/pom.xml | 1 +
server/container/guice/memory-guice/pom.xml | 1 +
.../memory-jmap-integration-testing/pom.xml | 6 ++++++
4 files changed, 14 insertions(+)
diff --git a/server/container/cli-integration/pom.xml b/server/container/cli-integration/pom.xml
index 3742426..7f64b2f 100644
--- a/server/container/cli-integration/pom.xml
+++ b/server/container/cli-integration/pom.xml
@@ -33,6 +33,12 @@
<dependencies>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-mailbox-scanning-search</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>james-server-cli</artifactId>
<scope>test</scope>
</dependency>
diff --git a/server/container/guice/blob-export-guice/pom.xml b/server/container/guice/blob-export-guice/pom.xml
index 4aaf28e..79ac090 100644
--- a/server/container/guice/blob-export-guice/pom.xml
+++ b/server/container/guice/blob-export-guice/pom.xml
@@ -64,6 +64,7 @@
<groupId>${james.groupId}</groupId>
<artifactId>james-server-guice-common</artifactId>
<type>test-jar</type>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
diff --git a/server/container/guice/memory-guice/pom.xml b/server/container/guice/memory-guice/pom.xml
index af5ca6c..c69c31f 100644
--- a/server/container/guice/memory-guice/pom.xml
+++ b/server/container/guice/memory-guice/pom.xml
@@ -53,6 +53,7 @@
<groupId>${james.groupId}</groupId>
<artifactId>apache-james-mailbox-scanning-search</artifactId>
<type>test-jar</type>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
index e90ba7e..2cf9aab 100644
--- a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
@@ -41,6 +41,12 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-mailbox-scanning-search</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>apache-james-mailbox-spamassassin</artifactId>
<scope>test</scope>
</dependency>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 09/12: JAMES-2709 Use FakeSmtp to check mails sent
by LinShare
Posted by ad...@apache.org.
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 e4fd6d64a4d349d8f8f04bfd536612e046030284
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Apr 11 15:49:26 2019 +0700
JAMES-2709 Use FakeSmtp to check mails sent by LinShare
---
.../main/java/org/apache/james/utils/FakeSmtp.java | 23 ++++++++++++---------
third-party/linshare/pom.xml | 5 +++++
.../java/org/apache/james/linshare/Linshare.java | 24 ++++++++++++++++++----
.../apache/james/linshare/LinshareExtension.java | 4 +++-
.../linshare/src/test/resources/smtp/Dockerfile | 3 ---
.../src/test/resources/smtp/conf/smtpd.conf | 14 -------------
6 files changed, 41 insertions(+), 32 deletions(-)
diff --git a/server/testing/src/main/java/org/apache/james/utils/FakeSmtp.java b/server/testing/src/main/java/org/apache/james/utils/FakeSmtp.java
index c94e742..3215f23 100644
--- a/server/testing/src/main/java/org/apache/james/utils/FakeSmtp.java
+++ b/server/testing/src/main/java/org/apache/james/utils/FakeSmtp.java
@@ -43,6 +43,17 @@ import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;
public class FakeSmtp implements TestRule {
+ public static void clean(RequestSpecification requestSpecification) {
+ given(requestSpecification, RESPONSE_SPECIFICATION)
+ .get("/api/email")
+ .jsonPath()
+ .getList("id", String.class)
+ .stream()
+ .mapToInt(Integer::valueOf)
+ .max()
+ .ifPresent(id -> given(requestSpecification, RESPONSE_SPECIFICATION)
+ .get("/api/email/purge/" + id));
+ }
public static FakeSmtp withSmtpPort(Integer smtpPort) {
DockerGenericContainer container = fakeSmtpContainer()
@@ -59,7 +70,7 @@ public class FakeSmtp implements TestRule {
}
private static final int SMTP_PORT = 25;
- private static final ResponseSpecification RESPONSE_SPECIFICATION = new ResponseSpecBuilder().build();
+ public static final ResponseSpecification RESPONSE_SPECIFICATION = new ResponseSpecBuilder().build();
private final DockerGenericContainer container;
private final Integer smtpPort;
@@ -104,14 +115,6 @@ public class FakeSmtp implements TestRule {
}
public void clean() {
- given(requestSpecification(), RESPONSE_SPECIFICATION)
- .get("/api/email")
- .jsonPath()
- .getList("id", String.class)
- .stream()
- .mapToInt(Integer::valueOf)
- .max()
- .ifPresent(id -> given(requestSpecification(), RESPONSE_SPECIFICATION)
- .get("/api/email/purge/" + id));
+ clean(requestSpecification());
}
}
diff --git a/third-party/linshare/pom.xml b/third-party/linshare/pom.xml
index e243509..fdb3266 100644
--- a/third-party/linshare/pom.xml
+++ b/third-party/linshare/pom.xml
@@ -38,6 +38,11 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>james-server-testing</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>blob-export-api</artifactId>
</dependency>
<dependency>
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 694a4c3..4dec0f7 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
@@ -19,13 +19,22 @@
package org.apache.james.linshare;
+import static io.restassured.config.EncoderConfig.encoderConfig;
+import static io.restassured.config.RestAssuredConfig.newConfig;
+
+import java.nio.charset.StandardCharsets;
import java.time.Duration;
+import org.apache.james.util.docker.Images;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.images.builder.ImageFromDockerfile;
+import io.restassured.builder.RequestSpecBuilder;
+import io.restassured.http.ContentType;
+import io.restassured.specification.RequestSpecification;
+
public class Linshare {
private static final String WAIT_FOR_BACKEND_INIT_LOG = ".*Server startup.*";
private static final String WAIT_FOR_DB_INIT_LOG = ".*/linshare/webservice/rest/admin/authentication/change_password.*";
@@ -102,10 +111,7 @@ public class Linshare {
}
private GenericContainer createDockerSmtp() {
- return new GenericContainer<>(
- new ImageFromDockerfile()
- .withFileFromClasspath("conf/smtpd.conf", "smtp/conf/smtpd.conf")
- .withFileFromClasspath("Dockerfile", "smtp/Dockerfile"))
+ return new GenericContainer<>(Images.FAKE_SMTP)
.withNetworkAliases("smtp", "linshare_smtp")
.withNetwork(network);
}
@@ -133,4 +139,14 @@ public class Linshare {
.withStartupTimeout(Duration.ofMinutes(10)))
.withNetwork(network);
}
+
+ public RequestSpecification fakeSmtpRequestSpecification() {
+ return new RequestSpecBuilder()
+ .setContentType(ContentType.JSON)
+ .setAccept(ContentType.JSON)
+ .setConfig(newConfig().encoderConfig(encoderConfig().defaultContentCharset(StandardCharsets.UTF_8)))
+ .setPort(linshareSmtp.getMappedPort(80))
+ .setBaseUri("http://" + linshareSmtp.getContainerIpAddress())
+ .build();
+ }
}
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 6a5ec9b..620d8ee 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
@@ -27,6 +27,7 @@ import java.util.Optional;
import org.apache.james.linshare.client.LinshareAPI;
import org.apache.james.linshare.client.User;
+import org.apache.james.utils.FakeSmtp;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
@@ -69,8 +70,9 @@ public class LinshareExtension implements BeforeEachCallback {
private final Linshare linshare = LinshareSingleton.singleton;
@Override
- public void beforeEach(ExtensionContext context) throws Exception {
+ public void beforeEach(ExtensionContext context) {
deleteAllUsersDocuments();
+ FakeSmtp.clean(linshare.fakeSmtpRequestSpecification());
}
public Linshare getLinshare() {
diff --git a/third-party/linshare/src/test/resources/smtp/Dockerfile b/third-party/linshare/src/test/resources/smtp/Dockerfile
deleted file mode 100644
index 3b4b81a..0000000
--- a/third-party/linshare/src/test/resources/smtp/Dockerfile
+++ /dev/null
@@ -1,3 +0,0 @@
-FROM linagora/opensmtpd
-
-COPY conf/smtpd.conf /etc/smtpd/smtpd.conf
diff --git a/third-party/linshare/src/test/resources/smtp/conf/smtpd.conf b/third-party/linshare/src/test/resources/smtp/conf/smtpd.conf
deleted file mode 100644
index f6afe25..0000000
--- a/third-party/linshare/src/test/resources/smtp/conf/smtpd.conf
+++ /dev/null
@@ -1,14 +0,0 @@
-# This is the smtpd server system-wide configuration file.
-# See smtpd.conf(5) for more information.
-
-# To accept external mail, replace with: listen on all
-listen on 0.0.0.0
-
-# If you edit the file, you have to run "smtpctl update table aliases"
-table aliases file:/etc/smtpd/aliases
-
-# Uncomment the following to accept external mail for domain "example.org"
-#accept from any for domain "example.org" alias <aliases> deliver to mbox
-
-#accept for local alias <aliases> deliver to mbox
-accept from any for any relay
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 04/12: JAMES-2709 Parse LinShareConfiguration from
.properties
Posted by ad...@apache.org.
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 82305ca960e11608a384e341d6553c7b6519f5bd
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Apr 11 11:07:10 2019 +0700
JAMES-2709 Parse LinShareConfiguration from .properties
---
third-party/linshare/pom.xml | 4 ++
.../james/linshare/LinshareConfiguration.java | 17 +++++--
.../james/linshare/LinshareConfigurationTest.java | 58 ++++++++++++++++++----
3 files changed, 66 insertions(+), 13 deletions(-)
diff --git a/third-party/linshare/pom.xml b/third-party/linshare/pom.xml
index 8a7917a..fe07bbd 100644
--- a/third-party/linshare/pom.xml
+++ b/third-party/linshare/pom.xml
@@ -56,6 +56,10 @@
<artifactId>guava</artifactId>
</dependency>
<dependency>
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ </dependency>
+ <dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-core</artifactId>
</dependency>
diff --git a/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareConfiguration.java b/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareConfiguration.java
index d2ca31b..6957bb3 100644
--- a/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareConfiguration.java
+++ b/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareConfiguration.java
@@ -23,13 +23,17 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.Objects;
+import org.apache.commons.configuration.Configuration;
+
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
public class LinshareConfiguration {
- public static class Builder {
+ public static final String URL = "blob.export.linshare.url";
+ public static final String TOKEN = "blob.export.linshare.token";
+ public static class Builder {
@FunctionalInterface
public interface RequireUrl {
RequireAuthorizationToken url(URL url);
@@ -62,13 +66,20 @@ public class LinshareConfiguration {
return url -> credential -> new Builder.ReadyToBuild(url, credential);
}
+ public static LinshareConfiguration from(Configuration configuration) throws MalformedURLException {
+ return builder()
+ .urlAsString(configuration.getString(URL, null))
+ .authorizationToken(new AuthorizationToken(configuration.getString(TOKEN, null)))
+ .build();
+ }
+
private final URL url;
private final AuthorizationToken token;
@VisibleForTesting
LinshareConfiguration(URL url, AuthorizationToken token) {
- Preconditions.checkNotNull(url);
- Preconditions.checkNotNull(token);
+ Preconditions.checkNotNull(url, "'" + URL + "' can not be null");
+ Preconditions.checkNotNull(token, "'" + TOKEN + "' can not be null");
this.url = url;
this.token = token;
diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareConfigurationTest.java b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareConfigurationTest.java
index 6b9316b..59d237e 100644
--- a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareConfigurationTest.java
+++ b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareConfigurationTest.java
@@ -19,16 +19,18 @@
package org.apache.james.linshare;
+import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import java.net.MalformedURLException;
import java.net.URL;
+import org.apache.commons.configuration.PropertiesConfiguration;
import org.junit.jupiter.api.Test;
import nl.jqno.equalsverifier.EqualsVerifier;
class LinshareConfigurationTest {
-
@Test
void shouldMatchBeanContract() {
EqualsVerifier.forClass(LinshareConfiguration.class)
@@ -36,17 +38,53 @@ class LinshareConfigurationTest {
}
@Test
- void constructorShouldThrowWhenPassingNullCredential() {
- AuthorizationToken nullToken = null;
- assertThatThrownBy(() -> new LinshareConfiguration(new URL("https://linshare.linagora.com"), nullToken))
- .isInstanceOf(NullPointerException.class);
+ void fromShouldThrowWhenUrlIsNull() {
+ PropertiesConfiguration configuration = new PropertiesConfiguration();
+ configuration.addProperty("blob.export.linshare.token", "token");
+ configuration.addProperty("blob.export.linshare.url", null);
+
+ assertThatThrownBy(() -> LinshareConfiguration.from(configuration)).isInstanceOf(MalformedURLException.class);
+ }
+
+ @Test
+ void fromShouldThrowWhenTokenIsNull() {
+ PropertiesConfiguration configuration = new PropertiesConfiguration();
+ configuration.addProperty("blob.export.linshare.token", null);
+ configuration.addProperty("blob.export.linshare.url", "http://127.0.0.1:8080");
+
+ assertThatThrownBy(() -> LinshareConfiguration.from(configuration)).isInstanceOf(IllegalArgumentException.class);
+ }
+
+ @Test
+ void fromShouldThrowWhenURLIsInvalid() {
+ PropertiesConfiguration configuration = new PropertiesConfiguration();
+ configuration.addProperty("blob.export.linshare.token", "token");
+ configuration.addProperty("blob.export.linshare.url", "invalid");
+
+ assertThatThrownBy(() -> LinshareConfiguration.from(configuration)).isInstanceOf(MalformedURLException.class);
+ }
+
+ @Test
+ void fromShouldThrowWhenTokenIsEmpty() {
+ PropertiesConfiguration configuration = new PropertiesConfiguration();
+ configuration.addProperty("blob.export.linshare.token", "");
+ configuration.addProperty("blob.export.linshare.url", "http://127.0.0.1:8080");
+
+ assertThatThrownBy(() -> LinshareConfiguration.from(configuration)).isInstanceOf(IllegalArgumentException.class);
}
@Test
- void constructorShouldThrowWhenPassingNullUrl() {
- AuthorizationToken token = new AuthorizationToken("jwt-token-at-here");
- URL nullUrl = null;
- assertThatThrownBy(() -> new LinshareConfiguration(nullUrl, token))
- .isInstanceOf(NullPointerException.class);
+ void fromShouldReturnProvidedConfiguration() throws Exception {
+ String token = "token";
+ String url = "http://127.0.0.1:8080";
+
+ PropertiesConfiguration configuration = new PropertiesConfiguration();
+ configuration.addProperty("blob.export.linshare.token", token);
+ configuration.addProperty("blob.export.linshare.url", url);
+
+ assertThat(LinshareConfiguration.from(configuration)).isEqualTo(LinshareConfiguration.builder()
+ .url(new URL(url))
+ .authorizationToken(new AuthorizationToken(token))
+ .build());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 05/12: JAMES-2709 Provide the LinShare BlobExport
mechanism as a viable choice
Posted by ad...@apache.org.
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 fe0a43d1b17c9ff34d6a3965e6691991bfc590a7
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Apr 11 11:08:39 2019 +0700
JAMES-2709 Provide the LinShare BlobExport mechanism as a viable choice
---
pom.xml | 5 ++
server/container/guice/blob-export-guice/pom.xml | 4 ++
.../apache/james/modules/BlobExportImplChoice.java | 3 +-
.../james/modules/BlobExportMechanismModule.java | 8 +++-
.../modules/LinshareBlobExportMechanismModule.java | 53 ++++++++++++++++++++++
.../modules/BlobExportMechanismModuleTest.java | 11 ++++-
.../linshare/LinshareBlobExportMechanism.java | 5 +-
7 files changed, 85 insertions(+), 4 deletions(-)
diff --git a/pom.xml b/pom.xml
index 3110ef9..1acee52 100644
--- a/pom.xml
+++ b/pom.xml
@@ -720,6 +720,11 @@
</dependency>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-linshare</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>apache-james-spamassassin</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 c465ffc..b55785d 100644
--- a/server/container/guice/blob-export-guice/pom.xml
+++ b/server/container/guice/blob-export-guice/pom.xml
@@ -36,6 +36,10 @@
<dependencies>
<dependency>
<groupId>${james.groupId}</groupId>
+ <artifactId>apache-james-linshare</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${james.groupId}</groupId>
<artifactId>blob-api-guice</artifactId>
</dependency>
<dependency>
diff --git a/server/container/guice/blob-export-guice/src/main/java/org/apache/james/modules/BlobExportImplChoice.java b/server/container/guice/blob-export-guice/src/main/java/org/apache/james/modules/BlobExportImplChoice.java
index a00eb78..8f4f201 100644
--- a/server/container/guice/blob-export-guice/src/main/java/org/apache/james/modules/BlobExportImplChoice.java
+++ b/server/container/guice/blob-export-guice/src/main/java/org/apache/james/modules/BlobExportImplChoice.java
@@ -30,7 +30,8 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
enum BlobExportImplChoice {
- LOCAL_FILE("localFile");
+ LOCAL_FILE("localFile"),
+ LINSHARE("linshare");
private static Optional<BlobExportImplChoice> from(String implNameString) {
Preconditions.checkNotNull(implNameString);
diff --git a/server/container/guice/blob-export-guice/src/main/java/org/apache/james/modules/BlobExportMechanismModule.java b/server/container/guice/blob-export-guice/src/main/java/org/apache/james/modules/BlobExportMechanismModule.java
index ae1d6c3..6e258c9 100644
--- a/server/container/guice/blob-export-guice/src/main/java/org/apache/james/modules/BlobExportMechanismModule.java
+++ b/server/container/guice/blob-export-guice/src/main/java/org/apache/james/modules/BlobExportMechanismModule.java
@@ -27,6 +27,7 @@ import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.james.blob.export.api.BlobExportMechanism;
import org.apache.james.blob.export.file.LocalFileBlobExportMechanism;
+import org.apache.james.linshare.LinshareBlobExportMechanism;
import org.apache.james.modules.mailbox.ConfigurationComponent;
import org.apache.james.utils.PropertiesProvider;
import org.slf4j.Logger;
@@ -44,6 +45,7 @@ public class BlobExportMechanismModule extends AbstractModule {
@Override
protected void configure() {
install(new LocalFileBlobExportMechanismModule());
+ install(new LinshareBlobExportMechanismModule());
}
@VisibleForTesting
@@ -66,10 +68,14 @@ public class BlobExportMechanismModule extends AbstractModule {
@VisibleForTesting
@Provides
@Singleton
- BlobExportMechanism provideMechanism(BlobExportImplChoice implChoice, Provider<LocalFileBlobExportMechanism> localFileMechanismProvider) {
+ BlobExportMechanism provideMechanism(BlobExportImplChoice implChoice,
+ Provider<LocalFileBlobExportMechanism> localFileMechanismProvider,
+ Provider<LinshareBlobExportMechanism> linshareMechanismProvider) {
switch (implChoice) {
case LOCAL_FILE:
return localFileMechanismProvider.get();
+ case LINSHARE:
+ return linshareMechanismProvider.get();
default:
throw new RuntimeException("blobExportMechanism '" + implChoice.getImplName() + "' is not supported yet");
}
diff --git a/server/container/guice/blob-export-guice/src/main/java/org/apache/james/modules/LinshareBlobExportMechanismModule.java b/server/container/guice/blob-export-guice/src/main/java/org/apache/james/modules/LinshareBlobExportMechanismModule.java
new file mode 100644
index 0000000..b154cb6
--- /dev/null
+++ b/server/container/guice/blob-export-guice/src/main/java/org/apache/james/modules/LinshareBlobExportMechanismModule.java
@@ -0,0 +1,53 @@
+/****************************************************************
+ * 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 java.io.FileNotFoundException;
+import java.net.MalformedURLException;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.james.linshare.LinshareConfiguration;
+import org.apache.james.linshare.client.LinshareAPI;
+import org.apache.james.modules.mailbox.ConfigurationComponent;
+import org.apache.james.utils.PropertiesProvider;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+
+public class LinshareBlobExportMechanismModule extends AbstractModule {
+ @Override
+ protected void configure() {
+ }
+
+ @Singleton
+ @Provides
+ LinshareConfiguration linshareConfiguration(PropertiesProvider propertiesProvider) throws ConfigurationException, FileNotFoundException, MalformedURLException {
+ Configuration configuration = propertiesProvider.getConfigurations(ConfigurationComponent.NAMES);
+ return LinshareConfiguration.from(configuration);
+ }
+
+ @Singleton
+ @Provides
+ LinshareAPI linshare(LinshareConfiguration configuration) {
+ return LinshareAPI.from(configuration);
+ }
+}
diff --git a/server/container/guice/blob-export-guice/src/test/java/org/apache/james/modules/BlobExportMechanismModuleTest.java b/server/container/guice/blob-export-guice/src/test/java/org/apache/james/modules/BlobExportMechanismModuleTest.java
index e011a90..f615527 100644
--- a/server/container/guice/blob-export-guice/src/test/java/org/apache/james/modules/BlobExportMechanismModuleTest.java
+++ b/server/container/guice/blob-export-guice/src/test/java/org/apache/james/modules/BlobExportMechanismModuleTest.java
@@ -27,6 +27,7 @@ import static org.mockito.Mockito.mock;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.james.FakePropertiesProvider;
import org.apache.james.blob.export.file.LocalFileBlobExportMechanism;
+import org.apache.james.linshare.LinshareBlobExportMechanism;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -35,7 +36,9 @@ import com.google.inject.Provider;
class BlobExportMechanismModuleTest {
private static LocalFileBlobExportMechanism LOCAL_FILE_EXPORT = mock(LocalFileBlobExportMechanism.class);
+ private static LinshareBlobExportMechanism LINSHARE_EXPORT = mock(LinshareBlobExportMechanism.class);
private static Provider<LocalFileBlobExportMechanism> LOCAL_FILE_EXPORT_PROVIDER = () -> LOCAL_FILE_EXPORT;
+ private static Provider<LinshareBlobExportMechanism> LINSHARE_FILE_EXPORT_PROVIDER = () -> LINSHARE_EXPORT;
private BlobExportMechanismModule module;
@@ -91,7 +94,13 @@ class BlobExportMechanismModuleTest {
@Test
void provideMechanismShouldProvideFileExportWhenPassingLocalFileChoice() {
- assertThat(module.provideMechanism(BlobExportImplChoice.LOCAL_FILE, LOCAL_FILE_EXPORT_PROVIDER))
+ assertThat(module.provideMechanism(BlobExportImplChoice.LOCAL_FILE, LOCAL_FILE_EXPORT_PROVIDER, LINSHARE_FILE_EXPORT_PROVIDER))
.isEqualTo(LOCAL_FILE_EXPORT);
}
+
+ @Test
+ void provideMechanismShouldProvideLinshareExportWhenPassingLinshareChoice() {
+ assertThat(module.provideMechanism(BlobExportImplChoice.LINSHARE, LOCAL_FILE_EXPORT_PROVIDER, LINSHARE_FILE_EXPORT_PROVIDER))
+ .isEqualTo(LINSHARE_EXPORT);
+ }
}
\ No newline at end of file
diff --git a/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareBlobExportMechanism.java b/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareBlobExportMechanism.java
index b5b7db4..042c966 100644
--- a/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareBlobExportMechanism.java
+++ b/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareBlobExportMechanism.java
@@ -23,6 +23,8 @@ import java.io.File;
import java.io.IOException;
import java.util.Optional;
+import javax.inject.Inject;
+
import org.apache.commons.io.FileUtils;
import org.apache.james.blob.api.BlobId;
import org.apache.james.blob.api.BlobStore;
@@ -37,7 +39,8 @@ public class LinshareBlobExportMechanism implements BlobExportMechanism {
private final LinshareAPI linshareAPI;
private final BlobStore blobStore;
- public LinshareBlobExportMechanism(LinshareAPI linshareAPI, BlobStore blobStore) {
+ @Inject
+ LinshareBlobExportMechanism(LinshareAPI linshareAPI, BlobStore blobStore) {
this.linshareAPI = linshareAPI;
this.blobStore = blobStore;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 12/12: Merge remote-tracking branch
'btellier/JAMES-2709'
Posted by ad...@apache.org.
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 1155f53813e44b59e89095835f43ae42310dbdcc
Merge: 6fb06d5 9dd2923
Author: Antoine Duprat <ad...@linagora.com>
AuthorDate: Fri Apr 19 09:42:44 2019 +0200
Merge remote-tracking branch 'btellier/JAMES-2709'
pom.xml | 17 +++
.../james/blob/export/api/FileExtension.java | 9 +-
.../james/blob/export/api/FileExtensionTest.java | 40 +++++--
server/container/cli-integration/pom.xml | 6 +
server/container/guice/blob-export-guice/pom.xml | 11 ++
.../apache/james/modules/BlobExportImplChoice.java | 3 +-
.../james/modules/BlobExportMechanismModule.java | 8 +-
.../modules/LinshareBlobExportMechanismModule.java | 47 ++++----
.../modules/BlobExportMechanismModuleTest.java | 11 +-
.../james/modules/LinshareGuiceExtension.java | 58 ++++++++++
server/container/guice/memory-guice/pom.xml | 23 ++++
.../LinshareBlobExportMechanismProvidingTest.java | 38 +++---
.../memory-jmap-integration-testing/pom.xml | 6 +
.../main/java/org/apache/james/utils/FakeSmtp.java | 23 ++--
third-party/linshare/pom.xml | 33 ++++++
.../linshare/LinshareBlobExportMechanism.java | 82 +++++++++++++
.../james/linshare/LinshareConfiguration.java | 17 ++-
.../james/linshare/client/ReceivedShare.java | 2 +-
.../apache/james/linshare/client/ShareRequest.java | 39 +++++--
.../java/org/apache/james/linshare/Linshare.java | 27 ++++-
.../linshare/LinshareBlobExportMechanismTest.java | 127 +++++++++++++++++++++
.../james/linshare/LinshareConfigurationTest.java | 58 ++++++++--
.../apache/james/linshare/LinshareExtension.java | 22 ++--
.../james/linshare/client/LinshareAPITest.java | 46 +++++++-
.../james/linshare/client/ShareRequestTest.java | 20 +++-
.../src/test/resources/backend/conf/id_rsa | 27 -----
.../{ssl/id_rsa => backend/conf/id_rsa.pri} | 0
.../linshare/src/test/resources/smtp/Dockerfile | 3 -
.../src/test/resources/smtp/conf/smtpd.conf | 14 ---
third-party/linshare/src/test/resources/ssl/ca.pem | 28 -----
.../linshare/src/test/resources/ssl/id_rsa.pub | 1 -
.../linshare/src/test/resources/ssl/linshare.key | 28 -----
.../linshare/src/test/resources/ssl/linshare.pem | 97 ----------------
third-party/spamassassin/pom.xml | 3 +
34 files changed, 659 insertions(+), 315 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 01/12: JAMES-2709 FileExtension::asFileSuffix
Posted by ad...@apache.org.
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 ce1e2028153bd11467bda128594b7bc00f1d92bd
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Apr 11 10:42:57 2019 +0700
JAMES-2709 FileExtension::asFileSuffix
---
.../james/blob/export/api/FileExtension.java | 9 ++++-
.../james/blob/export/api/FileExtensionTest.java | 40 +++++++++++++++++-----
2 files changed, 39 insertions(+), 10 deletions(-)
diff --git a/server/blob/blob-export-api/src/main/java/org/apache/james/blob/export/api/FileExtension.java b/server/blob/blob-export-api/src/main/java/org/apache/james/blob/export/api/FileExtension.java
index b0c3000..1faebe6 100644
--- a/server/blob/blob-export-api/src/main/java/org/apache/james/blob/export/api/FileExtension.java
+++ b/server/blob/blob-export-api/src/main/java/org/apache/james/blob/export/api/FileExtension.java
@@ -39,13 +39,20 @@ public class FileExtension {
@VisibleForTesting
FileExtension(String extension) {
+ Preconditions.checkNotNull(extension, "'extension' can not be null");
+ Preconditions.checkArgument(StringUtils.isNotBlank(extension), "'extension' can not be blank");
+
this.extension = extension;
}
public String appendExtension(String filePath) {
Preconditions.checkArgument(StringUtils.isNotBlank(filePath), "filePath cannot be null or blank");
- return filePath + EXTENSION_SEPARATOR + extension;
+ return filePath + asFileSuffix();
+ }
+
+ public String asFileSuffix() {
+ return EXTENSION_SEPARATOR + extension;
}
public String getExtension() {
diff --git a/server/blob/blob-export-api/src/test/java/org/apache/james/blob/export/api/FileExtensionTest.java b/server/blob/blob-export-api/src/test/java/org/apache/james/blob/export/api/FileExtensionTest.java
index 6c0823b..d2642e2 100644
--- a/server/blob/blob-export-api/src/test/java/org/apache/james/blob/export/api/FileExtensionTest.java
+++ b/server/blob/blob-export-api/src/test/java/org/apache/james/blob/export/api/FileExtensionTest.java
@@ -23,42 +23,64 @@ import static org.apache.james.blob.export.api.FileExtension.ZIP_EXTENSION_STRIN
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import nl.jqno.equalsverifier.EqualsVerifier;
class FileExtensionTest {
+ @Test
+ void shouldMatchBeanContract() {
+ EqualsVerifier.forClass(FileExtension.class)
+ .verify();
+ }
- private FileExtension fileExtension;
+ @Test
+ void constructorShouldThrowOnNull() {
+ assertThatThrownBy(() -> new FileExtension(null))
+ .isInstanceOf(NullPointerException.class);
+ }
- @BeforeEach
- void beforeEach() {
- fileExtension = new FileExtension(ZIP_EXTENSION_STRING);
+ @Test
+ void constructorShouldThrowOnEmpty() {
+ assertThatThrownBy(() -> new FileExtension(""))
+ .isInstanceOf(IllegalArgumentException.class);
}
@Test
- void shouldMatchBeanContract() {
- EqualsVerifier.forClass(FileExtension.class)
- .verify();
+ void constructorShouldThrowOnBlank() {
+ assertThatThrownBy(() -> new FileExtension(" "))
+ .isInstanceOf(IllegalArgumentException.class);
}
@Test
void appendExtensionShouldThrowWhenPassingNullValue() {
+ FileExtension fileExtension = new FileExtension(ZIP_EXTENSION_STRING);
+
assertThatThrownBy(() -> fileExtension.appendExtension(null))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
void appendExtensionShouldThrowWhenPassingEmptyStringValue() {
+ FileExtension fileExtension = new FileExtension(ZIP_EXTENSION_STRING);
+
assertThatThrownBy(() -> fileExtension.appendExtension(""))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
void appendExtensionShouldReturnValueEndsWithExtension() {
- fileExtension = new FileExtension("tar.gz");
+ FileExtension fileExtension = new FileExtension("tar.gz");
+
assertThat(fileExtension.appendExtension("/local/james"))
.endsWith(".tar.gz");
}
+
+ @Test
+ void asFileSuffixShouldReturnDotAndExtension() {
+ FileExtension fileExtension = new FileExtension("tar.gz");
+
+ assertThat(fileExtension.asFileSuffix())
+ .isEqualTo(".tar.gz");
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 11/12: JAMES-2709 little cleanup of dockerized
Linshare
Posted by ad...@apache.org.
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 9dd292325e1a5572405bb3568b9a8c94363f825a
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Fri Apr 12 14:43:08 2019 +0700
JAMES-2709 little cleanup of dockerized Linshare
---
.../java/org/apache/james/linshare/Linshare.java | 1 -
third-party/linshare/src/test/resources/ssl/ca.pem | 28 -------
third-party/linshare/src/test/resources/ssl/id_rsa | 27 ------
.../linshare/src/test/resources/ssl/id_rsa.pub | 1 -
.../linshare/src/test/resources/ssl/linshare.key | 28 -------
.../linshare/src/test/resources/ssl/linshare.pem | 97 ----------------------
6 files changed, 182 deletions(-)
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 4dec0f7..9986bd7 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
@@ -37,7 +37,6 @@ import io.restassured.specification.RequestSpecification;
public class Linshare {
private static final String WAIT_FOR_BACKEND_INIT_LOG = ".*Server startup.*";
- private static final String WAIT_FOR_DB_INIT_LOG = ".*/linshare/webservice/rest/admin/authentication/change_password.*";
private static final int LINSHARE_BACKEND_PORT = 8080;
private final GenericContainer<?> linshareBackend;
diff --git a/third-party/linshare/src/test/resources/ssl/ca.pem b/third-party/linshare/src/test/resources/ssl/ca.pem
deleted file mode 100644
index 208dd8d..0000000
--- a/third-party/linshare/src/test/resources/ssl/ca.pem
+++ /dev/null
@@ -1,28 +0,0 @@
------BEGIN CERTIFICATE-----
-MIIEzTCCA7WgAwIBAgIJAMikNamqqRPjMA0GCSqGSIb3DQEBCwUAMIGfMQswCQYD
-VQQGEwJGUjEMMAoGA1UECBMDSWRGMQ4wDAYDVQQHEwVQYXJpczERMA8GA1UEChMI
-TGluYWdvcmExETAPBgNVBAsUCFImRCBTYWFzMRQwEgYDVQQDEwtMaW5hZ29yYSBD
-QTEQMA4GA1UEKRMHRWFzeVJTQTEkMCIGCSqGSIb3DQEJARYVdHNhcmJvbmlAbGlu
-YWdvcmEuY29tMB4XDTE1MDkxNDA4NTAxOVoXDTI1MDkxMTA4NTAxOVowgZ8xCzAJ
-BgNVBAYTAkZSMQwwCgYDVQQIEwNJZEYxDjAMBgNVBAcTBVBhcmlzMREwDwYDVQQK
-EwhMaW5hZ29yYTERMA8GA1UECxQIUiZEIFNhYXMxFDASBgNVBAMTC0xpbmFnb3Jh
-IENBMRAwDgYDVQQpEwdFYXN5UlNBMSQwIgYJKoZIhvcNAQkBFhV0c2FyYm9uaUBs
-aW5hZ29yYS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDnX76W
-/7NAsYW9SvK/jPCY3QlpL5lNtiN99OV2hD/Hk1PSG34rwe9GyFCL/4YikcHTnWuk
-vizK1/IDGhi482FlljecWH5UxMlHG8yxUG9ahs86pNjcsyUafDAryXC3ocFtGk4v
-e2kAOatGlqlV7EH2rKi0t5jnMXdV2stMeitUNSFs8+iyDQK4V3T6n/hXpxO8VXsB
-wF7vd/4+idyAcC1YwUKiB+PAbUvpot+hJ8OaM1q5i3CXEFEbUCrJLh/oC2srOdhr
-7Rk4YK6oz+Pw3NQTvVZBByfziE2H6YRHWdRDVcOfWh2L0z42C5tCr23LDAray/9d
-uOYKl+cLKdvv4ymHAgMBAAGjggEIMIIBBDAdBgNVHQ4EFgQUnLuJzgwZk9X8Rgb0
-QUyYz6zdILQwgdQGA1UdIwSBzDCByYAUnLuJzgwZk9X8Rgb0QUyYz6zdILShgaWk
-gaIwgZ8xCzAJBgNVBAYTAkZSMQwwCgYDVQQIEwNJZEYxDjAMBgNVBAcTBVBhcmlz
-MREwDwYDVQQKEwhMaW5hZ29yYTERMA8GA1UECxQIUiZEIFNhYXMxFDASBgNVBAMT
-C0xpbmFnb3JhIENBMRAwDgYDVQQpEwdFYXN5UlNBMSQwIgYJKoZIhvcNAQkBFhV0
-c2FyYm9uaUBsaW5hZ29yYS5jb22CCQDIpDWpqqkT4zAMBgNVHRMEBTADAQH/MA0G
-CSqGSIb3DQEBCwUAA4IBAQCiEAmG+czlm/HT0s1ahWTtqcbzGl0+j3Io/JtyVNWW
-ALmmYid3VejcHYDbKd0rN+yFJtI+p6CMjpRVZCDEJo8eLZr9P7YZa+jKc0OhjSgr
-mD7FVwyZePid33VuKzWaMLbKiNVIcXroKkm2pEvENdibMZWBuhgrs6Pa00iYH68g
-s5Y1glQV7IeCmHkwNmHtgkiLDIzJYYukxAQSnaz7su8wnGtEJS6iz8+iCtEJm8XR
-FoUzfMS1/TI+C2tU80qfkc7D4kL7eEDob0zfdlZlqMKEWen47EuVuB+4DdImaI1P
-i+10msgMl2o6K4tNYVlfcM3qkHSXFfwEwvWtIqvRYsx4
------END CERTIFICATE-----
diff --git a/third-party/linshare/src/test/resources/ssl/id_rsa b/third-party/linshare/src/test/resources/ssl/id_rsa
deleted file mode 100644
index 24dd555..0000000
--- a/third-party/linshare/src/test/resources/ssl/id_rsa
+++ /dev/null
@@ -1,27 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-MIIEowIBAAKCAQEA18mc6QTlSdwFqVUzLPr4h9Wpw8qOQ+MhU0fzNIqKHFZ5zwP+
-TEi5iqAoj8tSkBG5SeQFMNzYo/Botd2JkOO6rGaIaNZzTZXg9kjZ9YxtZoM+LX0f
-Jm5Ts9bLWgA3rRTK1NDhpCKkUoHIfelqjOCVuCBkmL7s9UwRmAdZ9YI4jw6HOLT1
-72QhOj4Z21iD1F3JAKy4gs0H7vGQZBYxWE3NqUGlx0pb6v7N5qh4DkIKulo+QJDz
-AHQeiOgCm0ZcZUu7kcVU+GbCgPyjk0l6McIG55/G8t672Krrc5HiRqvSIxqsOYt+
-NR0HBo51mXVitS+tAyFMGhGk2Z9S/mCmNeKNPQIDAQABAoIBAA9Va0n/qA9sjBZx
-UHakyt5UJ4EbNqrKTAbv+O9F3PSQjI1SWlKvZEfeg6NcLlzAdaszgc7sEpTrs3Ug
-7fKWzCAOFSll+8GKofa+TIavWOLM9rEi0ADaHCaOX9rgYxRwgs1GnpIcSBL41/di
-i8jA+MKhwqQ8BPiVVDa6ZwEUJNK9cxPlenwSZOl12/aAPW6DATftdL7xv+fjw9Bz
-BexEPHklbphHGwoTxvQfiCmTN96CGn1/W99xABKTH70tprAFgOZ78klQjXYwtxVW
-rQiXmvgOTEhbrqBMxpRIzFgP+ryrEgcn02jbaq8Aa4BNbD96PJsMIo0psuTHSsnZ
-Tcqe2MECgYEA+nVL50qSGlXSvPNTrnjYJHt6mkifke5clmLgX4HegjQqi2+wBjlR
-QM1M+1neqB53ueJrlxS8+fZR00SyaUg7ANub5jkqiK5YsVUJk9CvlhUfDlXEW1Ce
-quYvuYWr2LX7K8sh+mXDCwttDms/aaJASSvTExMV/GeWFeJpsBs8QJECgYEA3I/t
-S+gAbGByUirMKXoP2sfIl3inApU93SIXgpvFnRF87GcC30bE95VYZJ8X8MdsYmro
-UiWbWq/8P7PzxYFukbQw+etUs0SV6eJ2FLR7n9dTWfj2Juw86HxERoA57L9Qt6os
-d0tEBWm5+ZVlRdGoavi+ADnRRbD3ugzz2QdR1+0CgYEAhxBmRG6UZ5tMsBTQVdBZ
-TyM/tJ/hXYMbbwYXVanlYnXbU6KBXHngdX/BOfL2/dagXh/aQXkvh+Trr3DmfZw0
-JXxIkFjXtSnALrFbHtl1Nwxg2Qwrfcr2JddIeVW6nH1W3AEJa80g533b6+CuK7sR
-y+PUSf8K5ji+WULmF9A4J+ECgYBEurzROHxZSTyWiiuQiS7DmBnTyY8RaPwcGnGF
-C5FqvnZVHExy0xSxqeIfiMvnBd2qVXILlxhwDALovuSpmQmhcasJVeHQ8wBcH2t4
-TD1xs6GPmdrqihb4wzBrX62tLniyot60VcneffGr6nfiZ9C5dMWQQHQL6XdojHy4
-FmXUiQKBgBk1nTlnmeS2CRbKakc1IqVqGeyZDbEpYG7pc79T1/5Hdw/TOfH36W7H
-5OapRlEgny+snw8UmkeWghg3+QgfMDY+d6iXaBcTr0tGlqEinff81EyJfuWNCUQJ
-a5XfnKtGwsEEOLyD3qEK2QABKvML1BgzGOJFENDeQ8euHMIy9SF4
------END RSA PRIVATE KEY-----
diff --git a/third-party/linshare/src/test/resources/ssl/id_rsa.pub b/third-party/linshare/src/test/resources/ssl/id_rsa.pub
deleted file mode 100644
index 98eae24..0000000
--- a/third-party/linshare/src/test/resources/ssl/id_rsa.pub
+++ /dev/null
@@ -1 +0,0 @@
-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXyZzpBOVJ3AWpVTMs+viH1anDyo5D4yFTR/M0ioocVnnPA/5MSLmKoCiPy1KQEblJ5AUw3Nij8Gi13YmQ47qsZoho1nNNleD2SNn1jG1mgz4tfR8mblOz1staADetFMrU0OGkIqRSgch96WqM4JW4IGSYvuz1TBGYB1n1gjiPDoc4tPXvZCE6PhnbWIPUXckArLiCzQfu8ZBkFjFYTc2pQaXHSlvq/s3mqHgOQgq6Wj5AkPMAdB6I6AKbRlxlS7uRxVT4ZsKA/KOTSXoxwgbnn8by3rvYqutzkeJGq9IjGqw5i341HQcGjnWZdWK1L60DIUwaEaTZn1L+YKY14o09 duc@duc-HP-ProBook-450-G4
diff --git a/third-party/linshare/src/test/resources/ssl/linshare.key b/third-party/linshare/src/test/resources/ssl/linshare.key
deleted file mode 100644
index 58380e0..0000000
--- a/third-party/linshare/src/test/resources/ssl/linshare.key
+++ /dev/null
@@ -1,28 +0,0 @@
------BEGIN PRIVATE KEY-----
-MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDfj54Mfv8DEqLv
-AUpPAp+S2jI2I/DjBBzbvuqlsPGN4Qqlt8XPwBl8MEu4DDwingJHvK64jZ7hT3+K
-3Zk/T2HGRYq1eJYAU0CLj6pAhh3kzxadxtTZHcpDZslSeFzq5bog1LKk/d5xv9we
-Qu4xDxUU4a5A9jM9SyP+6YVjih5SebLRhUq2iUPmoQLvLqGz2YVq+keAbpzFcfOX
-7SEfXb1le9HUxrtpVE1svtaaoZziHQYmwTLEb9yq1UWyu+LXSk/gnsnt9Iy19P4I
-V2TuoaiDIXkw1HEzD+fRom38I7Wzf9t+pLuJbGrY2Az0k7NdO/Ri0G5fex3Hvc+o
-+euNEa1xAgMBAAECggEBAJFzcEHzEllec7GKpl0XeNjjq417/srErz3tTd81a0OC
-6hl9om6TLkGVbn41P57KLPOdeBPM2FUBExs3J/B/5j5ImoGNDhLyF2l1tDA80hA/
-CBjo9yy3bBREOLG2a8XMZzfbCsu7/FEHod/ybeRvSqkGWAgd5qJ3U9kS990WTLod
-Clx2rYb6ewOhyn0ij9HcyQnPnjetGmvTeBlkIxoz3qjUg7vpxwdj4WQoSUvyTu+c
-YBbLjCKWY7UIlr8EimnPFYl87IMnl6Awj9+iwLTkg3vw83pqsxepllbVpJZh55Vi
-qmIBb0RtPT5mloT4AmeRERpjKFRPfoEc6U18JHCXypECgYEA9wwNviF3NQJtqlV/
-DLxgsWzPiqwT/2KqzcPzRJrKFMf4nMZFTIonXWAkIPGu6bFnsz9mfwgxZjhRMfoW
-amm9NUym0So61joCkCTg08LHUYnFFKFLzesEqiMumq/FDDGMPIG7eNRVw+Pwtd3+
-h2UqcGBjtwzb4mHo8aG7SdrhXtUCgYEA56msu1ALMh2WQm81QLrBybqF7LDWyWab
-65Es356ukBv0FszsCFYW1SngEFjsrcNjNdyjuMu5khxYpW0V7T/lBEnB/BcZ0xBi
-2IQ4OgJH1iPJrd2yhh/U7gHbz26BRM7/hCJuO7CNcPEZJJkfRu3Vv7cohozg+1Uk
-6ipxW+V4+i0CgYEA14SvdH/Tc+5DZ4agiKbKH96SDCLkazZTVaCtV9tFke2GCJa7
-m/MmNkKKIidVdU+r7ObRbt7h4ZAd3WCUL49BXf8ZxH13yK3g0IkrjfFtWse6o622
-6NQvRJHetVnDqEiNU7fFqbpre7IdqzsYMlviMxkTxHw2Uv8hbbKvJdYKKGUCgYAE
-66WvlNOoDNjUMGiBJ3ZWQo/1pwvo2zUUm9DILyamCPH2SgP5aVqyzGDl9/2O80d4
-LWeM1Ubrw45edSKyF1lV7fsgz5zMztxKnQRUtxevhLMT7lGMZ8CuDXwNu9sjCwKC
-W/jba7SVYYmXLWlsqECSAeHqebONoxFVp/Egco9PQQKBgE1iQ30yPc6EaYnVoXGe
-j5BQw80T1yc5ePX5aixZkS0YRywb5YjR6lg6/tSqCSFsvUs7ysj9etXfMLP2JDns
-7LFzDEhPP71uQASe729JCBcK92pQOmbJZO2yxFp06P6y8eMNb+giefWybRe2CTt2
-rE8Xi7dsol9Ev4pYqI4DZF9l
------END PRIVATE KEY-----
diff --git a/third-party/linshare/src/test/resources/ssl/linshare.pem b/third-party/linshare/src/test/resources/ssl/linshare.pem
deleted file mode 100644
index d38eea4..0000000
--- a/third-party/linshare/src/test/resources/ssl/linshare.pem
+++ /dev/null
@@ -1,97 +0,0 @@
-Certificate:
- Data:
- Version: 3 (0x2)
- Serial Number: 1 (0x1)
- Signature Algorithm: sha256WithRSAEncryption
- Issuer: C=FR, ST=IdF, L=Paris, O=Linagora, OU=R&D Saas, CN=Linagora CA/name=EasyRSA/emailAddress=tsarboni@linagora.com
- Validity
- Not Before: Sep 14 08:53:06 2015 GMT
- Not After : Sep 11 08:53:06 2025 GMT
- Subject: C=FR, ST=IdF, L=Paris, O=Linagora, OU=R&D Saas, CN=*.linshare.local/name=EasyRSA/emailAddress=tsarboni@linagora.com
- Subject Public Key Info:
- Public Key Algorithm: rsaEncryption
- Public-Key: (2048 bit)
- Modulus:
- 00:df:8f:9e:0c:7e:ff:03:12:a2:ef:01:4a:4f:02:
- 9f:92:da:32:36:23:f0:e3:04:1c:db:be:ea:a5:b0:
- f1:8d:e1:0a:a5:b7:c5:cf:c0:19:7c:30:4b:b8:0c:
- 3c:22:9e:02:47:bc:ae:b8:8d:9e:e1:4f:7f:8a:dd:
- 99:3f:4f:61:c6:45:8a:b5:78:96:00:53:40:8b:8f:
- aa:40:86:1d:e4:cf:16:9d:c6:d4:d9:1d:ca:43:66:
- c9:52:78:5c:ea:e5:ba:20:d4:b2:a4:fd:de:71:bf:
- dc:1e:42:ee:31:0f:15:14:e1:ae:40:f6:33:3d:4b:
- 23:fe:e9:85:63:8a:1e:52:79:b2:d1:85:4a:b6:89:
- 43:e6:a1:02:ef:2e:a1:b3:d9:85:6a:fa:47:80:6e:
- 9c:c5:71:f3:97:ed:21:1f:5d:bd:65:7b:d1:d4:c6:
- bb:69:54:4d:6c:be:d6:9a:a1:9c:e2:1d:06:26:c1:
- 32:c4:6f:dc:aa:d5:45:b2:bb:e2:d7:4a:4f:e0:9e:
- c9:ed:f4:8c:b5:f4:fe:08:57:64:ee:a1:a8:83:21:
- 79:30:d4:71:33:0f:e7:d1:a2:6d:fc:23:b5:b3:7f:
- db:7e:a4:bb:89:6c:6a:d8:d8:0c:f4:93:b3:5d:3b:
- f4:62:d0:6e:5f:7b:1d:c7:bd:cf:a8:f9:eb:8d:11:
- ad:71
- Exponent: 65537 (0x10001)
- X509v3 extensions:
- X509v3 Basic Constraints:
- CA:FALSE
- Netscape Cert Type:
- SSL Server
- Netscape Comment:
- Easy-RSA Generated Server Certificate
- X509v3 Subject Key Identifier:
- 28:DD:B4:92:F2:8C:CB:0F:42:2A:CE:1F:0B:7C:02:76:D9:A4:E9:D3
- X509v3 Authority Key Identifier:
- keyid:9C:BB:89:CE:0C:19:93:D5:FC:46:06:F4:41:4C:98:CF:AC:DD:20:B4
- DirName:/C=FR/ST=IdF/L=Paris/O=Linagora/OU=R&D Saas/CN=Linagora CA/name=EasyRSA/emailAddress=tsarboni@linagora.com
- serial:C8:A4:35:A9:AA:A9:13:E3
-
- X509v3 Extended Key Usage:
- TLS Web Server Authentication
- X509v3 Key Usage:
- Digital Signature, Key Encipherment
- Signature Algorithm: sha256WithRSAEncryption
- 99:8d:66:fc:73:b4:04:ae:d1:04:5e:80:73:a5:6c:54:f3:bd:
- a4:51:1a:6f:90:11:32:f4:e4:c1:f2:9d:e0:aa:fe:c6:c5:02:
- 68:a1:f9:fa:8d:88:d2:62:db:6c:9d:78:dc:6a:e2:89:3f:cf:
- 3f:3a:8a:89:56:b3:70:f2:db:32:da:08:07:06:11:33:05:60:
- d7:31:f3:21:3f:f5:11:21:59:5e:8e:8a:ad:1d:2f:c8:88:54:
- 42:90:bc:2a:fd:42:26:99:b3:45:ac:4a:98:2d:2f:51:ee:8d:
- 1e:3e:01:40:b1:f2:a1:45:e3:8b:f1:91:97:e8:f8:9c:45:fe:
- c2:42:2e:8f:f1:7e:24:3d:73:ad:c0:7b:6d:3e:e7:5e:c5:36:
- 70:e3:32:ee:8e:d0:47:46:d6:63:5e:8d:5c:e3:ee:08:3e:56:
- 53:3f:ca:39:02:23:1d:d5:fd:90:20:cd:37:a5:4f:83:21:c9:
- 5b:41:cc:cb:57:51:9c:b9:a6:31:1c:74:fa:24:a4:84:a0:98:
- a0:69:3e:b1:eb:a5:1c:84:ac:9d:4d:e0:37:e9:a0:f2:e6:9d:
- ca:7b:26:0a:66:d9:91:f8:b0:f3:49:4f:85:59:cf:58:b5:b5:
- 15:7c:86:0b:c0:a8:42:4b:bd:3c:90:54:70:8b:dd:c1:bd:cb:
- ba:67:13:a9
------BEGIN CERTIFICATE-----
-MIIFMjCCBBqgAwIBAgIBATANBgkqhkiG9w0BAQsFADCBnzELMAkGA1UEBhMCRlIx
-DDAKBgNVBAgTA0lkRjEOMAwGA1UEBxMFUGFyaXMxETAPBgNVBAoTCExpbmFnb3Jh
-MREwDwYDVQQLFAhSJkQgU2FhczEUMBIGA1UEAxMLTGluYWdvcmEgQ0ExEDAOBgNV
-BCkTB0Vhc3lSU0ExJDAiBgkqhkiG9w0BCQEWFXRzYXJib25pQGxpbmFnb3JhLmNv
-bTAeFw0xNTA5MTQwODUzMDZaFw0yNTA5MTEwODUzMDZaMIGkMQswCQYDVQQGEwJG
-UjEMMAoGA1UECBMDSWRGMQ4wDAYDVQQHEwVQYXJpczERMA8GA1UEChMITGluYWdv
-cmExETAPBgNVBAsUCFImRCBTYWFzMRkwFwYDVQQDFBAqLmxpbnNoYXJlLmxvY2Fs
-MRAwDgYDVQQpEwdFYXN5UlNBMSQwIgYJKoZIhvcNAQkBFhV0c2FyYm9uaUBsaW5h
-Z29yYS5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDfj54Mfv8D
-EqLvAUpPAp+S2jI2I/DjBBzbvuqlsPGN4Qqlt8XPwBl8MEu4DDwingJHvK64jZ7h
-T3+K3Zk/T2HGRYq1eJYAU0CLj6pAhh3kzxadxtTZHcpDZslSeFzq5bog1LKk/d5x
-v9weQu4xDxUU4a5A9jM9SyP+6YVjih5SebLRhUq2iUPmoQLvLqGz2YVq+keAbpzF
-cfOX7SEfXb1le9HUxrtpVE1svtaaoZziHQYmwTLEb9yq1UWyu+LXSk/gnsnt9Iy1
-9P4IV2TuoaiDIXkw1HEzD+fRom38I7Wzf9t+pLuJbGrY2Az0k7NdO/Ri0G5fex3H
-vc+o+euNEa1xAgMBAAGjggFwMIIBbDAJBgNVHRMEAjAAMBEGCWCGSAGG+EIBAQQE
-AwIGQDA0BglghkgBhvhCAQ0EJxYlRWFzeS1SU0EgR2VuZXJhdGVkIFNlcnZlciBD
-ZXJ0aWZpY2F0ZTAdBgNVHQ4EFgQUKN20kvKMyw9CKs4fC3wCdtmk6dMwgdQGA1Ud
-IwSBzDCByYAUnLuJzgwZk9X8Rgb0QUyYz6zdILShgaWkgaIwgZ8xCzAJBgNVBAYT
-AkZSMQwwCgYDVQQIEwNJZEYxDjAMBgNVBAcTBVBhcmlzMREwDwYDVQQKEwhMaW5h
-Z29yYTERMA8GA1UECxQIUiZEIFNhYXMxFDASBgNVBAMTC0xpbmFnb3JhIENBMRAw
-DgYDVQQpEwdFYXN5UlNBMSQwIgYJKoZIhvcNAQkBFhV0c2FyYm9uaUBsaW5hZ29y
-YS5jb22CCQDIpDWpqqkT4zATBgNVHSUEDDAKBggrBgEFBQcDATALBgNVHQ8EBAMC
-BaAwDQYJKoZIhvcNAQELBQADggEBAJmNZvxztASu0QRegHOlbFTzvaRRGm+QETL0
-5MHyneCq/sbFAmih+fqNiNJi22ydeNxq4ok/zz86iolWs3Dy2zLaCAcGETMFYNcx
-8yE/9REhWV6Oiq0dL8iIVEKQvCr9QiaZs0WsSpgtL1HujR4+AUCx8qFF44vxkZfo
-+JxF/sJCLo/xfiQ9c63Ae20+517FNnDjMu6O0EdG1mNejVzj7gg+VlM/yjkCIx3V
-/ZAgzTelT4MhyVtBzMtXUZy5pjEcdPokpISgmKBpPrHrpRyErJ1N4DfpoPLmncp7
-Jgpm2ZH4sPNJT4VZz1i1tRV8hgvAqEJLvTyQVHCL3cG9y7pnE6k=
------END CERTIFICATE-----
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 10/12: JAMES-2709 Position explanation on the share
Posted by ad...@apache.org.
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 86159d10c3656a636b0080b78c1019e67675af6f
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Apr 11 15:50:15 2019 +0700
JAMES-2709 Position explanation on the share
---
.../linshare/LinshareBlobExportMechanism.java | 9 +++--
.../apache/james/linshare/client/ShareRequest.java | 29 ++++++++++----
.../linshare/LinshareBlobExportMechanismTest.java | 36 +++++++++++++++++
.../james/linshare/client/LinshareAPITest.java | 46 ++++++++++++++++++++--
.../james/linshare/client/ShareRequestTest.java | 20 +++++++++-
5 files changed, 124 insertions(+), 16 deletions(-)
diff --git a/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareBlobExportMechanism.java b/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareBlobExportMechanism.java
index 042c966..3af2261 100644
--- a/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareBlobExportMechanism.java
+++ b/third-party/linshare/src/main/java/org/apache/james/linshare/LinshareBlobExportMechanism.java
@@ -49,26 +49,27 @@ public class LinshareBlobExportMechanism implements BlobExportMechanism {
public ShareeStage blobId(BlobId blobId) {
return mailAddress -> explanation -> fileExtension -> () -> {
try {
- exportBlob(blobId, mailAddress, fileExtension);
+ exportBlob(blobId, mailAddress, fileExtension, explanation);
} catch (Exception e) {
throw new BlobExportException("Error while exporting blob " + blobId.asString() + " to " + mailAddress.asString(), e);
}
};
}
- private void exportBlob(BlobId blobId, MailAddress mailAddress, Optional<FileExtension> fileExtension) throws IOException {
+ private void exportBlob(BlobId blobId, MailAddress mailAddress, Optional<FileExtension> fileExtension, String explanation) throws IOException {
File tempFile = createTempFile(blobId, fileExtension);
try {
FileUtils.copyInputStreamToFile(blobStore.read(blobId), tempFile);
- uploadAndShare(mailAddress, tempFile);
+ uploadAndShare(mailAddress, tempFile, explanation);
} finally {
FileUtils.forceDelete(tempFile);
}
}
- private void uploadAndShare(MailAddress mailAddress, File tempFile) {
+ private void uploadAndShare(MailAddress mailAddress, File tempFile, String explanation) {
Document document = linshareAPI.uploadDocument(tempFile);
linshareAPI.share(ShareRequest.builder()
+ .message(explanation)
.addDocumentId(document.getId())
.addRecipient(mailAddress)
.build());
diff --git a/third-party/linshare/src/main/java/org/apache/james/linshare/client/ShareRequest.java b/third-party/linshare/src/main/java/org/apache/james/linshare/client/ShareRequest.java
index 61a2d8b..beb6892 100644
--- a/third-party/linshare/src/main/java/org/apache/james/linshare/client/ShareRequest.java
+++ b/third-party/linshare/src/main/java/org/apache/james/linshare/client/ShareRequest.java
@@ -63,12 +63,19 @@ public class ShareRequest {
return Objects.hash(mail);
}
}
+
+ @FunctionalInterface
+ public interface RequireMessage {
+ Builder message(String message);
+ }
public static class Builder {
private final ImmutableList.Builder<Recipient> recipientsBuilder;
private final ImmutableList.Builder<DocumentId> documentIdsBuilder;
+ private final String message;
- Builder() {
+ Builder(String message) {
+ this.message = message;
this.recipientsBuilder = new ImmutableList.Builder<>();
this.documentIdsBuilder = new ImmutableList.Builder<>();
}
@@ -84,27 +91,34 @@ public class ShareRequest {
}
public ShareRequest build() {
- return new ShareRequest(recipientsBuilder.build(), documentIdsBuilder.build());
+ return new ShareRequest(recipientsBuilder.build(), documentIdsBuilder.build(), message);
}
}
- public static Builder builder() {
- return new Builder();
+ public static RequireMessage builder() {
+ return Builder::new;
}
private final List<Recipient> recipients;
private final List<DocumentId> documentIds;
+ private final String message;
- private ShareRequest(List<Recipient> recipients, List<DocumentId> documentIds) {
+ private ShareRequest(List<Recipient> recipients, List<DocumentId> documentIds, String message) {
+ Preconditions.checkNotNull(message);
Preconditions.checkNotNull(recipients);
Preconditions.checkNotNull(documentIds);
Preconditions.checkArgument(!recipients.isEmpty(), "recipients cannot be empty");
Preconditions.checkArgument(!documentIds.isEmpty(), "documents cannot be empty");
+ this.message = message;
this.recipients = recipients;
this.documentIds = documentIds;
}
+ public String getMessage() {
+ return message;
+ }
+
public List<Recipient> getRecipients() {
return recipients;
}
@@ -123,13 +137,14 @@ public class ShareRequest {
ShareRequest that = (ShareRequest) o;
return Objects.equals(this.recipients, that.recipients)
- && Objects.equals(this.documentIds, that.documentIds);
+ && Objects.equals(this.documentIds, that.documentIds)
+ && Objects.equals(this.message, that.message);
}
return false;
}
@Override
public final int hashCode() {
- return Objects.hash(recipients, documentIds);
+ return Objects.hash(recipients, documentIds, message);
}
}
diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java
index e693cd5..569cde9 100644
--- a/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java
+++ b/third-party/linshare/src/test/java/org/apache/james/linshare/LinshareBlobExportMechanismTest.java
@@ -19,10 +19,14 @@
package org.apache.james.linshare;
+import static io.restassured.RestAssured.given;
import static org.apache.james.linshare.LinshareFixture.USER_1;
import static org.apache.james.linshare.LinshareFixture.USER_2;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.hasItem;
+import static org.hamcrest.Matchers.hasSize;
import java.nio.charset.StandardCharsets;
@@ -33,10 +37,14 @@ import org.apache.james.blob.export.api.FileExtension;
import org.apache.james.blob.memory.MemoryBlobStore;
import org.apache.james.core.MailAddress;
import org.apache.james.linshare.client.LinshareAPI;
+import org.awaitility.Awaitility;
+import org.awaitility.Duration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
+import io.restassured.specification.RequestSpecification;
+
class LinshareBlobExportMechanismTest {
private static final String EXPLANATION = "Explanation about the file being shared";
@@ -77,6 +85,34 @@ class LinshareBlobExportMechanismTest {
}
@Test
+ void exportShouldSendAnEmailToSharee() throws Exception {
+ BlobId blobId = blobStore.save("content".getBytes(StandardCharsets.UTF_8)).block();
+
+ testee.blobId(blobId)
+ .with(new MailAddress(USER_2.getUsername()))
+ .explanation(EXPLANATION)
+ .fileExtension(FileExtension.of("txt"))
+ .export();
+
+ RequestSpecification request = given(linshareExtension.getLinshare().fakeSmtpRequestSpecification());
+
+ Awaitility.waitAtMost(Duration.TEN_SECONDS)
+ .pollInterval(Duration.ONE_SECOND)
+ .untilAsserted(
+ () -> request
+ .get("/api/email")
+ .then()
+ .body("", hasSize(2)));
+
+ request
+ .get("/api/email")
+ .then()
+ .body("[1].subject", containsString("John Doe has shared a file with you"))
+ .body("[1].to", hasItem(USER_2.getUsername()))
+ .body("[1].html", containsString(EXPLANATION));
+ }
+
+ @Test
void exportShouldFailWhenBlobDoesNotExist() {
BlobId blobId = blobIdFactory.randomId();
diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/client/LinshareAPITest.java b/third-party/linshare/src/test/java/org/apache/james/linshare/client/LinshareAPITest.java
index 1991514..d765379 100644
--- a/third-party/linshare/src/test/java/org/apache/james/linshare/client/LinshareAPITest.java
+++ b/third-party/linshare/src/test/java/org/apache/james/linshare/client/LinshareAPITest.java
@@ -19,12 +19,15 @@
package org.apache.james.linshare.client;
+import static io.restassured.RestAssured.given;
import static org.apache.james.linshare.LinshareFixture.USER_1;
import static org.apache.james.linshare.LinshareFixture.USER_2;
import static org.apache.james.linshare.LinshareFixture.USER_3;
import static org.apache.james.linshare.LinshareFixture.USER_4;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.hasSize;
import java.io.File;
import java.nio.file.Files;
@@ -34,6 +37,8 @@ import java.util.List;
import org.apache.james.core.MailAddress;
import org.apache.james.linshare.LinshareExtension;
import org.assertj.core.api.SoftAssertions;
+import org.awaitility.Awaitility;
+import org.awaitility.Duration;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -42,8 +47,10 @@ import org.testcontainers.shaded.com.google.common.collect.ImmutableList;
import com.github.steveash.guavate.Guavate;
import feign.FeignException;
+import io.restassured.specification.RequestSpecification;
class LinshareAPITest {
+ private static final String MESSAGE = "message";
@RegisterExtension
static LinshareExtension linshareExtension = new LinshareExtension();
@@ -101,7 +108,7 @@ class LinshareAPITest {
Document firstDocument = user1LinshareAPI.uploadDocument(templateFile());
Document secondDocument = user1LinshareAPI.uploadDocument(templateFile());
- Document user2Document = user2LinshareAPI.uploadDocument(templateFile());
+ user2LinshareAPI.uploadDocument(templateFile());
assertThat(user1LinshareAPI.listAllDocuments())
.containsExactly(firstDocument, secondDocument);
@@ -136,8 +143,8 @@ class LinshareAPITest {
@Test
void deleteAllShouldClearAllDocumentsOfAnUser() throws Exception {
- Document user1Document1 = user1LinshareAPI.uploadDocument(templateFile());
- Document user1Document2 = user1LinshareAPI.uploadDocument(templateFile());
+ user1LinshareAPI.uploadDocument(templateFile());
+ user1LinshareAPI.uploadDocument(templateFile());
user1LinshareAPI.deleteAllDocuments();
@@ -146,10 +153,42 @@ class LinshareAPITest {
}
@Test
+ void shareShouldTriggerAnEmail() throws Exception {
+ Document user1Document = user1LinshareAPI.uploadDocument(templateFile());
+
+ String message = "Very specific message";
+ ShareRequest shareRequest = ShareRequest.builder()
+ .message(message)
+ .addDocumentId(user1Document.getId())
+ .addRecipient(new MailAddress(USER_2.getUsername()))
+ .build();
+
+ user1LinshareAPI.share(shareRequest);
+
+ RequestSpecification request = given(linshareExtension.getLinshare().fakeSmtpRequestSpecification());
+
+ Awaitility.waitAtMost(Duration.TEN_SECONDS)
+ .pollInterval(Duration.ONE_SECOND)
+ .untilAsserted(
+ () -> request
+ .get("/api/email")
+ .then()
+ .body("", hasSize(2)));
+
+ request
+ .get("/api/email")
+ .then()
+ .body("[1].subject", containsString("John Doe has shared a file with you"))
+ .body("[1].html", containsString(message));
+ }
+
+
+ @Test
void shareShouldShareToTargetedRecipient() throws Exception {
Document user1Document = user1LinshareAPI.uploadDocument(templateFile());
ShareRequest shareRequest = ShareRequest.builder()
+ .message(MESSAGE)
.addDocumentId(user1Document.getId())
.addRecipient(new MailAddress(USER_2.getUsername()))
.build();
@@ -169,6 +208,7 @@ class LinshareAPITest {
Document user1Document = user1LinshareAPI.uploadDocument(templateFile());
ShareRequest shareRequest = ShareRequest.builder()
+ .message(MESSAGE)
.addDocumentId(user1Document.getId())
.addRecipient(new MailAddress(USER_2.getUsername()))
.addRecipient(new MailAddress(USER_3.getUsername()))
diff --git a/third-party/linshare/src/test/java/org/apache/james/linshare/client/ShareRequestTest.java b/third-party/linshare/src/test/java/org/apache/james/linshare/client/ShareRequestTest.java
index 7e648bd..bb6567f 100644
--- a/third-party/linshare/src/test/java/org/apache/james/linshare/client/ShareRequestTest.java
+++ b/third-party/linshare/src/test/java/org/apache/james/linshare/client/ShareRequestTest.java
@@ -31,6 +31,8 @@ import nl.jqno.equalsverifier.EqualsVerifier;
class ShareRequestTest {
+ private static final String MESSAGE = "message";
+
@Test
void shouldMatchBeanContract() {
EqualsVerifier.forClass(ShareRequest.class)
@@ -40,6 +42,7 @@ class ShareRequestTest {
@Test
void builderShouldThrowWhenPassingNullRecipient() {
assertThatThrownBy(() -> ShareRequest.builder()
+ .message(MESSAGE)
.addDocumentId(new Document.DocumentId(UUID.fromString("89bc2e3b-e07e-405f-9520-2de33a0a836c")))
.addRecipient(null)
.build())
@@ -47,8 +50,19 @@ class ShareRequestTest {
}
@Test
+ void builderShouldThrowWhenPassingNullMessage() {
+ assertThatThrownBy(() -> ShareRequest.builder()
+ .message(null)
+ .addDocumentId(new Document.DocumentId(UUID.fromString("89bc2e3b-e07e-405f-9520-2de33a0a836c")))
+ .addRecipient(new MailAddress("user@james.org"))
+ .build())
+ .isInstanceOf(NullPointerException.class);
+ }
+
+ @Test
void builderShouldThrowWhenPassingNullDocumentId() {
assertThatThrownBy(() -> ShareRequest.builder()
+ .message(MESSAGE)
.addDocumentId(null)
.addRecipient(new MailAddress("user@james.org"))
.build())
@@ -56,16 +70,18 @@ class ShareRequestTest {
}
@Test
- void builderShouldThrowWhenNoRecipient() {
+ void builderShouldThrowWhenNoDocumentId() {
assertThatThrownBy(() -> ShareRequest.builder()
+ .message(MESSAGE)
.addRecipient(new MailAddress("user@james.org"))
.build())
.isInstanceOf(IllegalArgumentException.class);
}
@Test
- void builderShouldThrowWhenNoDocumentId() {
+ void builderShouldThrowWhenNoRecipient() {
assertThatThrownBy(() -> ShareRequest.builder()
+ .message(MESSAGE)
.addDocumentId(new Document.DocumentId(UUID.fromString("89bc2e3b-e07e-405f-9520-2de33a0a836c")))
.build())
.isInstanceOf(IllegalArgumentException.class);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[james-project] 06/12: JAMES-2709 Integration test for LinShare
Blob Export Mechanism provisioning
Posted by ad...@apache.org.
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 <bt...@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