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 88102e590dc31b573983ddbb8f5b0117e660d796 Author: Benoit Tellier <btell...@linagora.com> AuthorDate: Wed Mar 6 10:43:24 2019 +0700 JAMES-2665 Moved messages should not end up in the vault --- .../integration/DeletedMessagesVaultTest.java | 61 +++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) 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 3620607..e986f8c 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 @@ -42,6 +42,7 @@ import org.apache.james.GuiceJamesServer; import org.apache.james.jmap.api.access.AccessToken; import org.apache.james.jmap.categories.BasicFeature; import org.apache.james.mailbox.DefaultMailboxes; +import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.probe.MailboxProbe; import org.apache.james.modules.MailboxProbeImpl; import org.apache.james.modules.protocols.ImapGuiceProbe; @@ -74,6 +75,7 @@ public abstract class DeletedMessagesVaultTest { private static final ConditionFactory WAIT_TWO_MINUTES = calmlyAwait.atMost(Duration.TWO_MINUTES); private static final String SUBJECT = "This mail will be restored from the vault!!"; private static final String MAILBOX_NAME = "toBeDeleted"; + private MailboxId otherMailboxId; protected abstract GuiceJamesServer createJmapServer() throws IOException; @@ -101,7 +103,7 @@ public abstract class DeletedMessagesVaultTest { dataProbe.addUser(HOMER, PASSWORD); dataProbe.addUser(BART, BOB_PASSWORD); mailboxProbe.createMailbox("#private", HOMER, DefaultMailboxes.INBOX); - mailboxProbe.createMailbox("#private", HOMER, MAILBOX_NAME); + otherMailboxId = mailboxProbe.createMailbox("#private", HOMER, MAILBOX_NAME); homerAccessToken = authenticateJamesUser(baseUri(jmapServer), HOMER, PASSWORD); bartAccessToken = authenticateJamesUser(baseUri(jmapServer), BART, BOB_PASSWORD); @@ -204,6 +206,43 @@ public abstract class DeletedMessagesVaultTest { } @Test + public void imapMovedMessageShouldNotEndUpInTheVault() throws Exception { + bartSendMessageToHomer(); + WAIT_TWO_MINUTES.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1); + + imapMessageReader.connect(LOCALHOST_IP, jmapServer.getProbe(ImapGuiceProbe.class).getImapPort()) + .login(HOMER, PASSWORD) + .select(IMAPMessageReader.INBOX); + + imapMessageReader.moveFirstMessage(MAILBOX_NAME); + + //Moved messages should not be moved to the vault + restoreAllMessagesOfHomer(); + WAIT_TWO_MINUTES.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1); + + + // No messages restored for bart + assertThat(listMessageIdsForAccount(bartAccessToken).size()).isEqualTo(1); + } + + @Test + public void jmapMovedMessageShouldNotEndUpInTheVault() { + bartSendMessageToHomer(); + WAIT_TWO_MINUTES.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1); + String messageId = listMessageIdsForAccount(homerAccessToken).get(0); + + homerMovesTheMailInAnotherMailbox(messageId); + + //Moved messages should not be moved to the vault + restoreAllMessagesOfHomer(); + WAIT_TWO_MINUTES.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1); + + + // No messages restored for bart + assertThat(listMessageIdsForAccount(bartAccessToken).size()).isEqualTo(1); + } + + @Test public void restoreShouldNotImpactOtherUsers() { bartSendMessageToHomer(); WAIT_TWO_MINUTES.until(() -> listMessageIdsForAccount(homerAccessToken).size() == 1); @@ -311,4 +350,24 @@ public abstract class DeletedMessagesVaultTest { .then() .body("status", is("completed")); } + + private void homerMovesTheMailInAnotherMailbox(String messageId) { + String updateRequestBody = "[" + + " [" + + " \"setMessages\"," + + " {" + + " \"update\": { \"" + messageId + "\" : {" + + " \"mailboxIds\": [\"" + otherMailboxId.serialize() + "\"]" + + " }}" + + " }," + + " \"#0\"" + + " ]" + + "]"; + + given() + .header("Authorization", bartAccessToken.serialize()) + .body(updateRequestBody) + .when() + .post("/jmap"); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org