james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [james-project] 11/11: JAMES-2713 Add integration test for Delete API
Date Thu, 18 Apr 2019 07:00:26 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 556071622272b41f6bdc5066d3720fa5cf87a1eb
Author: datph <dphamhoang@linagora.com>
AuthorDate: Wed Apr 17 15:15:40 2019 +0700

    JAMES-2713 Add integration test for Delete API
---
 .../integration/DeletedMessagesVaultTest.java      | 82 ++++++++++++++++++++++
 1 file changed, 82 insertions(+)

diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/DeletedMessagesVaultTest.java
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/DeletedMessagesVaultTest.java
index 7962379..8bf523f 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/DeletedMessagesVaultTest.java
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/DeletedMessagesVaultTest.java
@@ -688,6 +688,75 @@ public abstract class DeletedMessagesVaultTest {
             .hasSize(0);
     }
 
+    @Test
+    public void vaultDeleteShouldDeleteMessageThenExportWithNoEntry() throws Exception {
+        bartSendMessageToHomer();
+        WAIT_TWO_MINUTES.until(() -> listMessageIdsForAccount(homerAccessToken).size()
== 1);
+
+        String messageIdOfHomer = listMessageIdsForAccount(homerAccessToken).get(0);
+
+        homerDeletesMessages(listMessageIdsForAccount(homerAccessToken));
+        WAIT_TWO_MINUTES.until(() -> listMessageIdsForAccount(homerAccessToken).size()
== 0);
+
+        deleteVault(HOMER, messageIdOfHomer);
+
+        String fileLocation = exportAndGetFileLocationFromLastMail(EXPORT_ALL_HOMER_MESSAGES_TO_BART,
bartAccessToken);
+        try (ZipAssert zipAssert = assertThatZip(new FileInputStream(fileLocation))) {
+            zipAssert.hasNoEntry();
+        }
+    }
+
+    @Test
+    public void vaultDeleteShouldNotDeleteEmptyVaultThenExportNoEntry() throws Exception
{
+        bartSendMessageToHomer();
+        WAIT_TWO_MINUTES.until(() -> listMessageIdsForAccount(homerAccessToken).size()
== 1);
+
+        String messageIdOfHomer = listMessageIdsForAccount(homerAccessToken).get(0);
+
+        deleteVault(HOMER, messageIdOfHomer);
+
+        String fileLocation = exportAndGetFileLocationFromLastMail(EXPORT_ALL_HOMER_MESSAGES_TO_BART,
bartAccessToken);
+        try (ZipAssert zipAssert = assertThatZip(new FileInputStream(fileLocation))) {
+            zipAssert.hasNoEntry();
+        }
+    }
+
+    @Test
+    public void vaultDeleteShouldNotDeleteNotMatchedMessageInVaultThenExportAnEntry() throws
Exception {
+        bartSendMessageToHomer();
+        WAIT_TWO_MINUTES.until(() -> listMessageIdsForAccount(homerAccessToken).size()
== 1);
+
+        String messageIdOfBart = listMessageIdsForAccount(bartAccessToken).get(0);
+        String messageIdOfHomer = listMessageIdsForAccount(homerAccessToken).get(0);
+
+        homerDeletesMessages(listMessageIdsForAccount(homerAccessToken));
+        WAIT_TWO_MINUTES.until(() -> listMessageIdsForAccount(homerAccessToken).size()
== 0);
+
+        deleteVault(HOMER, messageIdOfBart);
+
+        String fileLocation = exportAndGetFileLocationFromLastMail(EXPORT_ALL_HOMER_MESSAGES_TO_BART,
bartAccessToken);
+        try (ZipAssert zipAssert = assertThatZip(new FileInputStream(fileLocation))) {
+            zipAssert.hasEntriesSize(1)
+                .allSatisfies(entry -> entry.hasName(messageIdOfHomer + ".eml"));
+        }
+    }
+
+    @Test
+    public void vaultDeleteShouldNotAppendMessageToTheUserMailbox() {
+        bartSendMessageToHomer();
+        WAIT_TWO_MINUTES.until(() -> listMessageIdsForAccount(homerAccessToken).size()
== 1);
+
+        String messageIdOfHomer = listMessageIdsForAccount(homerAccessToken).get(0);
+
+        homerDeletesMessages(listMessageIdsForAccount(homerAccessToken));
+        WAIT_TWO_MINUTES.until(() -> listMessageIdsForAccount(homerAccessToken).size()
== 0);
+
+        deleteVault(HOMER, messageIdOfHomer);
+
+        assertThat(listMessageIdsForAccount(homerAccessToken))
+            .hasSize(0);
+    }
+
     private String exportAndGetFileLocationFromLastMail(ExportRequest exportRequest, AccessToken
shareeAccessToken) {
         int currentNumberOfMessages = listMessageIdsForAccount(shareeAccessToken).size();
         exportVaultContent(exportRequest);
@@ -851,4 +920,17 @@ public abstract class DeletedMessagesVaultTest {
         .then()
             .body("status", is("completed"));
     }
+
+    private void deleteVault(String user, String messageId) {
+        String taskId =
+            webAdminApi.with()
+                .delete("/deletedMessages/users/" + user + "/messages/" + messageId)
+            .jsonPath()
+                .get("taskId");
+
+        webAdminApi.with()
+            .get("/tasks/" + taskId + "/await")
+        .then()
+            .body("status", is("completed"));
+    }
 }


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


Mime
View raw message