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 bt...@apache.org on 2019/05/10 11:30:16 UTC

[james-project] 03/17: JAMES-2712 Add integration tests for Linshare download zip file

This is an automated email from the ASF dual-hosted git repository.

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

commit 8a6bcb372e02a9e2cddfbf2185c9c5075f864737
Author: Rene Cordier <rc...@linagora.com>
AuthorDate: Tue May 7 17:06:32 2019 +0700

    JAMES-2712 Add integration tests for Linshare download zip file
---
 ...LinshareBlobExportMechanismIntegrationTest.java | 53 +++++++++++++++++++++-
 1 file changed, 51 insertions(+), 2 deletions(-)

diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/LinshareBlobExportMechanismIntegrationTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/LinshareBlobExportMechanismIntegrationTest.java
index b5c0004..ef7239e 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/LinshareBlobExportMechanismIntegrationTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/LinshareBlobExportMechanismIntegrationTest.java
@@ -34,19 +34,23 @@ import static org.apache.james.jmap.TestingConstants.calmlyAwait;
 import static org.apache.james.jmap.TestingConstants.jmapRequestSpecBuilder;
 import static org.apache.james.linshare.LinshareFixture.MATCH_ALL_QUERY;
 import static org.apache.james.linshare.LinshareFixture.USER_1;
+import static org.apache.james.mailbox.backup.ZipAssert.assertThatZip;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.hamcrest.Matchers.containsString;
 import static org.hamcrest.Matchers.hasItem;
 import static org.hamcrest.Matchers.hasSize;
 
+import java.io.ByteArrayInputStream;
 import java.util.List;
 
 import org.apache.james.GuiceJamesServer;
 import org.apache.james.jmap.ExportRequest;
 import org.apache.james.jmap.api.access.AccessToken;
 import org.apache.james.linshare.LinshareExtension;
+import org.apache.james.linshare.client.Document;
 import org.apache.james.linshare.client.LinshareAPI;
 import org.apache.james.mailbox.DefaultMailboxes;
+import org.apache.james.mailbox.backup.ZipAssert;
 import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.probe.MailboxProbe;
 import org.apache.james.modules.MailboxProbeImpl;
@@ -78,6 +82,8 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
         .exportTo(USER_1.getUsername())
         .query(MATCH_ALL_QUERY);
 
+    private static LinshareExtension linshareExtension = new LinshareExtension();
+
     private AccessToken homerAccessToken;
     private AccessToken bartAccessToken;
     private GuiceJamesServer jmapServer;
@@ -110,9 +116,9 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
 
         homerAccessToken = authenticateJamesUser(baseUri(jmapServer), HOMER, HOMER_PASSWORD);
         bartAccessToken = authenticateJamesUser(baseUri(jmapServer), BART, BART_PASSWORD);
-        user1LinshareAPI = new LinshareExtension().getAPIFor(USER_1);
+        user1LinshareAPI = linshareExtension.getAPIFor(USER_1);
 
-        fakeSmtpRequestSpecification = given(new LinshareExtension().getLinshare().fakeSmtpRequestSpecification());
+        fakeSmtpRequestSpecification = given(linshareExtension.getLinshare().fakeSmtpRequestSpecification());
     }
 
     @Test
@@ -207,6 +213,49 @@ public abstract class LinshareBlobExportMechanismIntegrationTest {
             .body("[1].to", hasItem(USER_1.getUsername()));
     }
 
+    @Test
+    void exportShouldShareNonEmptyZipViaLinShareWhenJmapDelete() throws Exception {
+        bartSendMessageToHomer();
+
+        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1);
+
+        homerDeletesMessages(listMessageIdsForAccount(homerAccessToken));
+        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 0);
+
+        exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
+
+        Document sharedDoc = user1LinshareAPI.receivedShares().get(0).getDocument();
+        byte[] sharedFile =  linshareExtension.downloadSharedFile(USER_1, sharedDoc.getId(), sharedDoc.getName());
+
+        try (ZipAssert zipAssert = assertThatZip(new ByteArrayInputStream(sharedFile))) {
+            zipAssert.hasEntriesSize(1);
+        }
+    }
+
+    @Test
+    void exportShouldShareNonEmptyZipViaLinShareWhenImapDelete() throws Exception {
+        bartSendMessageToHomer();
+
+        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1);
+
+        imapMessageReader.connect(LOCALHOST_IP, jmapServer.getProbe(ImapGuiceProbe.class).getImapPort())
+            .login(HOMER, HOMER_PASSWORD)
+            .select(IMAPMessageReader.INBOX)
+            .setFlagsForAllMessagesInMailbox("\\Deleted");
+        imapMessageReader.expunge();
+
+        WAIT_TEN_SECONDS.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 0);
+
+        exportVaultContent(webAdminApi, EXPORT_ALL_HOMER_MESSAGES_TO_USER_1);
+
+        Document sharedDoc = user1LinshareAPI.receivedShares().get(0).getDocument();
+        byte[] sharedFile =  linshareExtension.downloadSharedFile(USER_1, sharedDoc.getId(), sharedDoc.getName());
+
+        try (ZipAssert zipAssert = assertThatZip(new ByteArrayInputStream(sharedFile))) {
+            zipAssert.hasEntriesSize(1);
+        }
+    }
+
     private void bartSendMessageToHomer() {
         String messageCreationId = "creationId";
         String outboxId = getOutboxId(bartAccessToken);


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