JAMES-2183 Integration test for flag consistency when delegation mailbox
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/3674c006 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/3674c006 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/3674c006 Branch: refs/heads/master Commit: 3674c006b7cd54e2884a9e32909dfcbb66a34fad Parents: 9c50c0b Author: quynhn <[email protected]> Authored: Mon Oct 23 09:57:04 2017 +0700 Committer: Raphael Ouazana <[email protected]> Committed: Wed Oct 25 17:12:11 2017 +0200 ---------------------------------------------------------------------- ...wordsConsistencyOnDelegationMailboxTest.java | 44 ++++++ .../cucumber/GetMessageListMethodStepdefs.java | 28 +++- .../cucumber/GetMessagesMethodStepdefs.java | 6 + .../integration/cucumber/MailboxStepdefs.java | 72 ++++++++++ .../integration/cucumber/MainStepdefs.java | 3 + .../cucumber/SetMessagesMethodStepdefs.java | 34 +++-- .../integration/cucumber/UserStepdefs.java | 14 -- .../cucumber/ImapKeywordsConsistency.feature | 42 +++--- ...essagesMailboxesUpdatesCompatibility.feature | 2 +- ...ywordsConsistencyOnDelegationMailbox.feature | 141 +++++++++++++++++++ ...wordsConsistencyOnDelegationMailboxTest.java | 32 +++++ 11 files changed, 370 insertions(+), 48 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/3674c006/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraKeywordsConsistencyOnDelegationMailboxTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraKeywordsConsistencyOnDelegationMailboxTest.java b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraKeywordsConsistencyOnDelegationMailboxTest.java new file mode 100644 index 0000000..2e8688f --- /dev/null +++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/java/org/apache/james/jmap/cassandra/cucumber/CassandraKeywordsConsistencyOnDelegationMailboxTest.java @@ -0,0 +1,44 @@ +/**************************************************************** + * 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.jmap.cassandra.cucumber; + +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.runner.RunWith; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; + +@RunWith(Cucumber.class) +@CucumberOptions(features="classpath:cucumber/KeywordsConsistencyOnDelegationMailbox.feature", + glue={"org.apache.james.jmap.methods.integration", "org.apache.james.jmap.cassandra.cucumber"}, + strict = true) +public class CassandraKeywordsConsistencyOnDelegationMailboxTest { + + @BeforeClass + public static void init() { + CucumberCassandraSingleton.cassandraServer.start(); + } + + @AfterClass + public static void after() { + CucumberCassandraSingleton.cassandraServer.stop(); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/3674c006/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessageListMethodStepdefs.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessageListMethodStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessageListMethodStepdefs.java index b578c77..4a32a19 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessageListMethodStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessageListMethodStepdefs.java @@ -32,6 +32,8 @@ import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MessageId; import org.apache.james.modules.MailboxProbeImpl; +import com.github.steveash.guavate.Guavate; +import com.google.common.base.Joiner; import com.jayway.jsonpath.Configuration; import com.jayway.jsonpath.DocumentContext; import com.jayway.jsonpath.JsonPath; @@ -59,11 +61,31 @@ public class GetMessageListMethodStepdefs { this.messagesMethodStepdefs = messagesMethodStepdefs; } - @When("^the user asks for message list in mailbox \"([^\"]*)\" with flag \"([^\"]*)\"$") - public void getMessageList(String mailbox, String flag) throws Exception { + @When("^\"([^\"]*)\" asks for message list in mailboxes \"([^\"]*)\" with flag \"([^\"]*)\"$") + public void getMessageList(String username, List<String> mailboxes, String flag) throws Exception { + String mailboxIds = Joiner.on("\",\"") + .join(mailboxes.stream() + .map(mailbox -> mainStepdefs.jmapServer + .getProbe(MailboxProbeImpl.class) + .getMailbox(MailboxConstants.USER_NAMESPACE, username, mailbox) + .getMailboxId() + .serialize()) + .collect(Guavate.toImmutableList())); + + post(String.format( + "[[\"getMessageList\", {\"filter\":{" + + " \"inMailboxes\":[\"%s\"]," + + " \"hasKeyword\":\"%s\"" + + "}}, \"#0\"]]", + mailboxIds, + flag)); + } + + @When("^\"([^\"]*)\" asks for message list in mailbox \"([^\"]*)\" with flag \"([^\"]*)\"$") + public void getMessageList(String username, String mailbox, String flag) throws Exception { MailboxId mailboxId = mainStepdefs.jmapServer .getProbe(MailboxProbeImpl.class) - .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.getConnectedUser(), mailbox) + .getMailbox(MailboxConstants.USER_NAMESPACE, username, mailbox) .getMailboxId(); post(String.format( http://git-wip-us.apache.org/repos/asf/james-project/blob/3674c006/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java index 81f6e9d..b2f22ff 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java @@ -677,6 +677,12 @@ public class GetMessagesMethodStepdefs { .containsOnlyElementsOf(keywords); } + @Then("^the message has no keyword$") + public void assertMessageHasNoKeyword() throws Exception { + assertThat(jsonPath.<Map<String, Boolean>>read(FIRST_MESSAGE + ".keywords")) + .isNullOrEmpty(); + } + private void assertAttachment(String attachment, DataTable attachmentProperties) { attachmentProperties.asList(TableRow.class) .forEach(entry -> assertThat(jsonPath.<Object>read(attachment + "." + entry.getKey())).isEqualTo(entry.getValue())); http://git-wip-us.apache.org/repos/asf/james-project/blob/3674c006/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MailboxStepdefs.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MailboxStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MailboxStepdefs.java new file mode 100644 index 0000000..ddf7ea5 --- /dev/null +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MailboxStepdefs.java @@ -0,0 +1,72 @@ +/**************************************************************** + * 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.jmap.methods.integration.cucumber; + +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; + +import javax.inject.Inject; + +import org.apache.james.jmap.api.access.AccessToken; +import org.apache.james.mailbox.exception.UnsupportedRightException; +import org.apache.james.mailbox.model.MailboxACL; +import org.apache.james.mailbox.model.MailboxConstants; +import org.apache.james.mailbox.model.MailboxPath; + +import com.github.steveash.guavate.Guavate; + +import cucumber.api.java.en.Given; +import cucumber.runtime.java.guice.ScenarioScoped; + +@ScenarioScoped +public class MailboxStepdefs { + + private final MainStepdefs mainStepdefs; + + @Inject + private MailboxStepdefs(MainStepdefs mainStepdefs) { + this.mainStepdefs = mainStepdefs; + } + + @Given("^\"([^\"]*)\" has a mailbox \"([^\"]*)\"$") + public void createMailbox(String username, String mailbox) throws Throwable { + mainStepdefs.mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, mailbox); + } + + @Given("^\"([^\"]*)\" shares its mailbox \"([^\"]*)\" with \"([^\"]*)\"$") + public void shareMailbox(String owner, String mailbox, String shareTo) throws Throwable { + MailboxPath mailboxPath = MailboxPath.forUser(owner, mailbox); + MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Lookup, MailboxACL.Right.Read); + + mainStepdefs.aclProbe.addRights(mailboxPath, shareTo, rights); + } + + @Given("^\"([^\"]*)\" shares its mailbox \"([^\"]*)\" with rights \"([^\"]*)\" with \"([^\"]*)\"$") + public void shareMailboxWithRight(String owner, String mailbox, String rights, String shareTo) throws Throwable { + MailboxPath mailboxPath = MailboxPath.forUser(owner, mailbox); + + mainStepdefs.aclProbe.replaceRights(mailboxPath, shareTo, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights(rights)); + } +} http://git-wip-us.apache.org/repos/asf/james-project/blob/3674c006/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MainStepdefs.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MainStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MainStepdefs.java index c6f8261..10913f0 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MainStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/MainStepdefs.java @@ -29,6 +29,7 @@ import org.apache.james.modules.MailboxProbeImpl; import org.apache.james.probe.DataProbe; import org.apache.james.utils.DataProbeImpl; import org.apache.james.utils.JmapGuiceProbe; +import org.apache.james.utils.MessageIdProbe; import com.google.common.base.Charsets; @@ -41,6 +42,7 @@ public class MainStepdefs { public DataProbe dataProbe; public MailboxProbe mailboxProbe; public ACLProbe aclProbe; + public MessageIdProbe messageIdProbe; public Runnable awaitMethod = () -> {}; public MessageId.Factory messageIdFactory; @@ -49,6 +51,7 @@ public class MainStepdefs { dataProbe = jmapServer.getProbe(DataProbeImpl.class); mailboxProbe = jmapServer.getProbe(MailboxProbeImpl.class); aclProbe = jmapServer.getProbe(ACLProbeImpl.class); + messageIdProbe = jmapServer.getProbe(MessageIdProbe.class); } http://git-wip-us.apache.org/repos/asf/james-project/blob/3674c006/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java index 9c0bb43..600070c 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMessagesMethodStepdefs.java @@ -23,14 +23,18 @@ import java.util.List; import java.util.stream.Collectors; import javax.inject.Inject; +import javax.mail.Flags; import org.apache.http.entity.ContentType; import org.apache.http.client.fluent.Request; +import org.apache.james.jmap.model.Keywords; import org.apache.james.mailbox.model.MailboxConstants; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MessageId; import org.apache.james.modules.MailboxProbeImpl; +import com.google.common.collect.ImmutableList; + import cucumber.api.java.en.When; import cucumber.runtime.java.guice.ScenarioScoped; @@ -76,17 +80,16 @@ public class SetMessagesMethodStepdefs { mainStepdefs.awaitMethod.run(); } - @When("^the user copy \"([^\"]*)\" from mailbox \"([^\"]*)\" to mailbox \"([^\"]*)\"") - public void copyMessageToMailbox(String message, String sourceMailbox, String destinationMailbox) throws Throwable { - String username = userStepdefs.getConnectedUser(); + @When("^\"([^\"]*)\" copy \"([^\"]*)\" from mailbox \"([^\"]*)\" to mailbox \"([^\"]*)\"") + public void copyMessageToMailbox(String userName, String message, String sourceMailbox, String destinationMailbox) throws Throwable { MessageId messageId = getMessagesMethodStepdefs.getMessageId(message); MailboxId sourceMailboxId = mainStepdefs.jmapServer .getProbe(MailboxProbeImpl.class) - .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.getConnectedUser(), sourceMailbox) + .getMailbox(MailboxConstants.USER_NAMESPACE, userName, sourceMailbox) .getMailboxId(); MailboxId destinationMailboxId = mainStepdefs.jmapServer .getProbe(MailboxProbeImpl.class) - .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.getConnectedUser(), destinationMailbox) + .getMailbox(MailboxConstants.USER_NAMESPACE, userName, destinationMailbox) .getMailboxId(); String requestBody = "[" + @@ -101,16 +104,15 @@ public class SetMessagesMethodStepdefs { " ]" + "]"; Request.Post(mainStepdefs.baseUri().setPath("/jmap").build()) - .addHeader("Authorization", userStepdefs.getTokenForUser(username).serialize()) + .addHeader("Authorization", userStepdefs.getTokenForUser(userName).serialize()) .bodyString(requestBody, ContentType.APPLICATION_JSON) .execute() .discardContent(); mainStepdefs.awaitMethod.run(); } - @When("^the user set flags on \"([^\"]*)\" to \"([^\"]*)\"") - public void setFlags(String message, List<String> keywords) throws Throwable { - String username = userStepdefs.getConnectedUser(); + @When("^\"([^\"]*)\" set flags on \"([^\"]*)\" to \"([^\"]*)\"") + public void setFlags(String username, String message, List<String> keywords) throws Throwable { MessageId messageId = getMessagesMethodStepdefs.getMessageId(message); String keywordString = keywords .stream() @@ -135,4 +137,18 @@ public class SetMessagesMethodStepdefs { .discardContent(); mainStepdefs.awaitMethod.run(); } + + @When("^message \"([^\"]*)\" has flags (.*) in mailbox \"([^\"]*)\" of user \"([^\"]*)\"") + public void setMessageFlagsInSpecifiedMailbox(String message, List<String> flags, String mailbox, String mailboxOwner) throws Exception { + Flags newFlags = Keywords.factory().fromList(flags).asFlags(); + String username = userStepdefs.getConnectedUser(); + MessageId messageId = getMessagesMethodStepdefs.getMessageId(message); + MailboxId mailboxId = mainStepdefs.jmapServer + .getProbe(MailboxProbeImpl.class) + .getMailbox(MailboxConstants.USER_NAMESPACE, mailboxOwner, mailbox) + .getMailboxId(); + + mainStepdefs.messageIdProbe.updateNewFlags(username, newFlags, messageId, ImmutableList.of(mailboxId)); + mainStepdefs.awaitMethod.run(); + } } http://git-wip-us.apache.org/repos/asf/james-project/blob/3674c006/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java index 408f726..569d59a 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/UserStepdefs.java @@ -115,12 +115,6 @@ public class UserStepdefs { connectUser(username); } - @Given("^\"([^\"]*)\" has a mailbox \"([^\"]*)\"$") - public void createMailbox(String username, String mailbox) throws Throwable { - mainStepdefs.mailboxProbe.createMailbox(MailboxConstants.USER_NAMESPACE, username, mailbox); - } - - @Given("^\"([^\"]*)\" is connected$") public void connectUser(String username) throws Throwable { AccessToken accessToken = getTokenForUser(username); @@ -136,14 +130,6 @@ public class UserStepdefs { return HttpJmapAuthentication.authenticateJamesUser(mainStepdefs.baseUri(), user, password); }); } - - @Given("^\"([^\"]*)\" shares its mailbox \"([^\"]*)\" with \"([^\"]*)\"$") - public void shareMailbox(String owner, String mailbox, String shareTo) throws Throwable { - MailboxPath mailboxPath = MailboxPath.forUser(owner, mailbox); - MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Lookup, MailboxACL.Right.Read); - - mainStepdefs.aclProbe.addRights(mailboxPath, shareTo, rights); - } private String generatePassword(String username) { return Hashing.murmur3_128().hashString(username, Charsets.UTF_8).toString(); http://git-wip-us.apache.org/repos/asf/james-project/blob/3674c006/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/ImapKeywordsConsistency.feature ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/ImapKeywordsConsistency.feature b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/ImapKeywordsConsistency.feature index 4650033..188ec86 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/ImapKeywordsConsistency.feature +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/ImapKeywordsConsistency.feature @@ -28,7 +28,7 @@ Feature: Impact of IMAP on JMAP keywords consistency Scenario Outline: GetMessages should union keywords when an inconsistency was created via IMAP Given the user has a message "m1" in "source" mailbox with subject "My awesome subject", content "This is the content" - And the user copy "m1" from mailbox "source" to mailbox "mailbox" + And "[email protected]" copy "m1" from mailbox "source" to mailbox "mailbox" And the user has an open IMAP connection with mailbox "<mailbox>" selected And the user set flags via IMAP to "(\Flagged)" for all messages in mailbox "<mailbox>" When the user ask for messages "m1" @@ -44,7 +44,7 @@ Feature: Impact of IMAP on JMAP keywords consistency Scenario Outline: GetMessages should intersect Draft when an inconsistency was created via IMAP Given the user has a message "m1" in "source" mailbox with subject "My awesome subject", content "This is the content" - And the user copy "m1" from mailbox "source" to mailbox "mailbox" + And "[email protected]" copy "m1" from mailbox "source" to mailbox "mailbox" And the user has an open IMAP connection with mailbox "<mailbox>" selected And the user set flags via IMAP to "(\Draft)" for all messages in mailbox "<mailbox>" When the user ask for messages "m1" @@ -60,7 +60,7 @@ Feature: Impact of IMAP on JMAP keywords consistency Scenario: GetMessageList should return matching messageId when matching in at least 1 mailbox Given the user has a message "m1" in "source" mailbox with subject "My awesome subject", content "This is the content" - And the user copy "m1" from mailbox "source" to mailbox "mailbox" + And "[email protected]" copy "m1" from mailbox "source" to mailbox "mailbox" And the user has an open IMAP connection with mailbox "mailbox" selected And the user set flags via IMAP to "(\Flagged)" for all messages in mailbox "mailbox" When the user asks for message list with flag "$Flagged" @@ -69,40 +69,40 @@ Feature: Impact of IMAP on JMAP keywords consistency Scenario: GetMessageList in specific mailbox should return messageId when matching Given the user has a message "m1" in "source" mailbox with subject "My awesome subject", content "This is the content" - And the user copy "m1" from mailbox "source" to mailbox "mailbox" + And "[email protected]" copy "m1" from mailbox "source" to mailbox "mailbox" And the user has an open IMAP connection with mailbox "mailbox" selected And the user set flags via IMAP to "(\Flagged)" for all messages in mailbox "mailbox" - When the user asks for message list in mailbox "mailbox" with flag "$Flagged" + When "[email protected]" asks for message list in mailbox "mailbox" with flag "$Flagged" Then the message list has size 1 And the message list contains "m1" Scenario: GetMessageList in specific mailbox should skip messageId when not matching Given the user has a message "m1" in "source" mailbox with subject "My awesome subject", content "This is the content" - And the user copy "m1" from mailbox "source" to mailbox "mailbox" + And "[email protected]" copy "m1" from mailbox "source" to mailbox "mailbox" And the user has an open IMAP connection with mailbox "mailbox" selected And the user set flags via IMAP to "(\Flagged)" for all messages in mailbox "mailbox" - When the user asks for message list in mailbox "source" with flag "$Flagged" + When "[email protected]" asks for message list in mailbox "source" with flag "$Flagged" Then the message list is empty Scenario: SetMessages should succeed to solve Keywords conflict introduced via IMAP upon flags addition (GetMessageList) Given the user has a message "m1" in "source" mailbox with subject "My awesome subject", content "This is the content" - And the user copy "m1" from mailbox "source" to mailbox "mailbox" + And "[email protected]" copy "m1" from mailbox "source" to mailbox "mailbox" And the user has an open IMAP connection with mailbox "mailbox" selected And the user set flags via IMAP to "(\Flagged)" for all messages in mailbox "mailbox" - When the user set flags on "m1" to "$Flagged" - Then the user asks for message list in mailbox "mailbox" with flag "$Flagged" + When "[email protected]" set flags on "m1" to "$Flagged" + Then "[email protected]" asks for message list in mailbox "mailbox" with flag "$Flagged" And the message list has size 1 And the message list contains "m1" - And the user asks for message list in mailbox "source" with flag "$Flagged" + And "[email protected]" asks for message list in mailbox "source" with flag "$Flagged" And the message list has size 1 And the message list contains "m1" Scenario: SetMessages should succeed to solve Keywords conflict introduced via IMAP upon flags addition with GetMessages Given the user has a message "m1" in "source" mailbox with subject "My awesome subject", content "This is the content" - And the user copy "m1" from mailbox "source" to mailbox "mailbox" + And "[email protected]" copy "m1" from mailbox "source" to mailbox "mailbox" And the user has an open IMAP connection with mailbox "mailbox" selected And the user set flags via IMAP to "(\Flagged)" for all messages in mailbox "mailbox" - When the user set flags on "m1" to "$Flagged" + When "[email protected]" set flags on "m1" to "$Flagged" Then the user ask for messages "m1" And no error is returned And the list should contain 1 message @@ -111,27 +111,27 @@ Feature: Impact of IMAP on JMAP keywords consistency Scenario: SetMessages should ignore Keywords conflict introduced via IMAP upon flags deletion with GetMessageList Given the user has a message "m1" in "source" mailbox with subject "My awesome subject", content "This is the content" - And the user copy "m1" from mailbox "source" to mailbox "mailbox" + And "[email protected]" copy "m1" from mailbox "source" to mailbox "mailbox" And the user has an open IMAP connection with mailbox "mailbox" selected And the user set flags via IMAP to "(\Flagged)" for all messages in mailbox "mailbox" - When the user set flags on "m1" to "$Answered" - Then the user asks for message list in mailbox "mailbox" with flag "$Flagged" + When "[email protected]" set flags on "m1" to "$Answered" + Then "[email protected]" asks for message list in mailbox "mailbox" with flag "$Flagged" And the message list is empty - And the user asks for message list in mailbox "source" with flag "$Flagged" + And "[email protected]" asks for message list in mailbox "source" with flag "$Flagged" And the message list is empty - Then the user asks for message list in mailbox "mailbox" with flag "$Answered" + Then "[email protected]" asks for message list in mailbox "mailbox" with flag "$Answered" And the message list has size 1 And the message list contains "m1" - And the user asks for message list in mailbox "source" with flag "$Answered" + And "[email protected]" asks for message list in mailbox "source" with flag "$Answered" And the message list has size 1 And the message list contains "m1" Scenario: SetMessages should ignore Keywords conflict introduced via IMAP upon flags deletion with GetMessages Given the user has a message "m1" in "source" mailbox with subject "My awesome subject", content "This is the content" - And the user copy "m1" from mailbox "source" to mailbox "mailbox" + And "[email protected]" copy "m1" from mailbox "source" to mailbox "mailbox" And the user has an open IMAP connection with mailbox "mailbox" selected And the user set flags via IMAP to "(\Flagged)" for all messages in mailbox "mailbox" - When the user set flags on "m1" to "$Answered" + When "[email protected]" set flags on "m1" to "$Answered" Then the user ask for messages "m1" And no error is returned And the list should contain 1 message http://git-wip-us.apache.org/repos/asf/james-project/blob/3674c006/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/ImapSetMessagesMailboxesUpdatesCompatibility.feature ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/ImapSetMessagesMailboxesUpdatesCompatibility.feature b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/ImapSetMessagesMailboxesUpdatesCompatibility.feature index 33ae498..bc70272 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/ImapSetMessagesMailboxesUpdatesCompatibility.feature +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/ImapSetMessagesMailboxesUpdatesCompatibility.feature @@ -36,7 +36,7 @@ Feature: IMAP compatibility of JMAP setMessages method used to update mailboxes Scenario: A message copied by JMAP is seen as copied by IMAP Given the user has a message "m1" in "source" mailbox with subject "My awesome subject", content "This is the content" - When the user copy "m1" from mailbox "source" to mailbox "mailbox" + When "[email protected]" copy "m1" from mailbox "source" to mailbox "mailbox" Then the user has a IMAP message in mailbox "mailbox" And the user has a IMAP message in mailbox "source" http://git-wip-us.apache.org/repos/asf/james-project/blob/3674c006/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/KeywordsConsistencyOnDelegationMailbox.feature ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/KeywordsConsistencyOnDelegationMailbox.feature b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/KeywordsConsistencyOnDelegationMailbox.feature new file mode 100644 index 0000000..44f34d6 --- /dev/null +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/KeywordsConsistencyOnDelegationMailbox.feature @@ -0,0 +1,141 @@ +#*************************************************************** +# 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. * +# **************************************************************/ +Feature: Keywords consistency on delegation mailbox + + Background: + Given a domain named "domain.tld" + And a user "[email protected]" + And a user "[email protected]" + And "[email protected]" has a mailbox "notShared" + And "[email protected]" has a mailbox "shared" + And "[email protected]" shares its mailbox "shared" with rights "lrw" with "[email protected]" + And "[email protected]" has a message "m1" in "notShared" mailbox with subject "My awesome subject", content "This is the content" + And "[email protected]" copy "m1" from mailbox "notShared" to mailbox "shared" + + Scenario: getMessageList filtered by flag should combine flag when delegation mailbox + Given "[email protected]" set flags on "m1" to "$Flagged" + When "[email protected]" asks for message list in mailboxes "shared,notShared" with flag "$Flagged" + Then the message list contains "m1" + + Scenario: getMessageList filtered by flag should keep flag on non-shared mailbox + Given "[email protected]" set flags on "m1" to "$Flagged" + When "[email protected]" asks for message list in mailboxes "notShared" with flag "$Flagged" + Then the message list is empty + + Scenario: getMessageList filtered by flag should keep flag on delegation mailbox + Given "[email protected]" set flags on "m1" to "$Flagged" + When "[email protected]" asks for message list in mailboxes "shared" with flag "$Flagged" + Then the message list contains "m1" + + Scenario: Get message list should select Draft flag on all mailbox + Given message "m1" has flags $Draft in mailbox "shared" of user "[email protected]" + When "[email protected]" asks for message list in mailboxes "shared,notShared" with flag "$Draft" + Then the message list contains "m1" + + Scenario: Get message list should keep flags on non-shared mailbox + Given message "m1" has flags $Draft in mailbox "shared" of user "[email protected]" + When "[email protected]" asks for message list in mailbox "notShared" with flag "$Draft" + Then the message list is empty + + Scenario: Get message list should keep flags on shared mailbox + Given message "m1" has flags $Draft in mailbox "shared" of user "[email protected]" + When "[email protected]" asks for message list in mailbox "shared" with flag "$Draft" + Then the message list contains "m1" + + Scenario: getMessage with shared user should return message with combine flag when delegation mailbox + Given message "m1" has flags $Flagged in mailbox "shared" of user "[email protected]" + When "[email protected]" ask for messages "m1" + Then no error is returned + And the keywords of the message is $Flagged + + Scenario: getMessage of owner mailbox should return message with combine flag when delegation mailbox + Given message "m1" has flags $Flagged in mailbox "shared" of user "[email protected]" + When "[email protected]" ask for messages "m1" + Then no error is returned + And the keywords of the message is $Flagged + + Scenario: message should update message status based on delegation mailbox + Given "[email protected]" set flags on "m1" to "$Flagged,$Seen" + And "[email protected]" set flags on "m1" to "$Seen" + When "[email protected]" ask for messages "m1" + Then no error is returned + And the message has IMAP flag "\Flagged \Seen" in mailbox "notShared" for "[email protected]" + And the message has IMAP flag "\Seen" in mailbox "shared" for "[email protected]" + + Scenario: message should keep origin message status when cut the sharing + Given "[email protected]" set flags on "m1" to "$Flagged" + And "[email protected]" shares its mailbox "shared" with rights "" with "[email protected]" + When "[email protected]" ask for messages "m1" + Then no error is returned + And the message has IMAP flag "\Flagged" in mailbox "shared" for "[email protected]" + And the message has IMAP flag "" in mailbox "notShared" for "[email protected]" + + Scenario: getMessage should keep origin message status when delegation mailbox + Given message "m1" has flags $Flagged in mailbox "notShared" of user "[email protected]" + And message "m1" has flags $Seen in mailbox "shared" of user "[email protected]" + And "[email protected]" shares its mailbox "shared" with rights "" with "[email protected]" + When "[email protected]" ask for messages "m1" + Then no error is returned + And the keywords of the message is $Flagged,$Seen + + Scenario: getMessage on mailbox should keep its flag as it is when owner + Given "[email protected]" set flags on "m1" to "$Flagged" + When "[email protected]" ask for messages "m1" + Then no error is returned + And the message has IMAP flag "\Flagged" in mailbox "shared" for "[email protected]" + And the message has IMAP flag "\Flagged" in mailbox "notShared" for "[email protected]" + + Scenario: messages should keep Draft flag as it is when onwer + Given message "m1" has flags $Draft in mailbox "shared" of user "[email protected]" + When "[email protected]" ask for messages "m1" + Then no error is returned + And the keywords of the message is $Draft + + Scenario: message should intersect flag when Draft + Given message "m1" has flags $Draft in mailbox "shared" of user "[email protected]" + When "[email protected]" ask for messages "m1" + Then no error is returned + And the message has no keyword + + Scenario: message should intersect flag when Draft after cut sharing + Given message "m1" has flags $Draft in mailbox "shared" of user "[email protected]" + And "[email protected]" shares its mailbox "shared" with rights "" with "[email protected]" + When "[email protected]" ask for messages "m1" + Then no error is returned + And the message has no keyword + + Scenario: message should combine flag if not Draft + Given the user has an open IMAP connection with mailbox "shared" selected + And the user set flags via IMAP to "\FLAGGED" for all messages in mailbox "shared" + When "[email protected]" ask for messages "m1" + Then no error is returned + And the keywords of the message is $Flagged + + Scenario: message should combine flag if not Draft on all mailboxes + Given "[email protected]" set flags on "m1" to "$Flagged" + When "[email protected]" ask for messages "m1" + Then no error is returned + And the keywords of the message is $Flagged + + Scenario: message should intersect Draft flag with onwer mailbox + Given the user has an open IMAP connection with mailbox "shared" selected + And the user set flags via IMAP to "\DRAFT" for all messages in mailbox "shared" + When "[email protected]" ask for messages "m1" + Then no error is returned + And the message has no keyword http://git-wip-us.apache.org/repos/asf/james-project/blob/3674c006/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/cucumber/MemoryKeywordsConsistencyOnDelegationMailboxTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/cucumber/MemoryKeywordsConsistencyOnDelegationMailboxTest.java b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/cucumber/MemoryKeywordsConsistencyOnDelegationMailboxTest.java new file mode 100644 index 0000000..2dc8e74 --- /dev/null +++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/java/org/apache/james/jmap/memory/cucumber/MemoryKeywordsConsistencyOnDelegationMailboxTest.java @@ -0,0 +1,32 @@ +/**************************************************************** + * 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.jmap.memory.cucumber; + +import org.junit.runner.RunWith; + +import cucumber.api.CucumberOptions; +import cucumber.api.junit.Cucumber; + +@RunWith(Cucumber.class) +@CucumberOptions(features="classpath:cucumber/KeywordsConsistencyOnDelegationMailbox.feature", + glue={"org.apache.james.jmap.methods.integration", "org.apache.james.jmap.memory.cucumber"}, + strict = true) +public class MemoryKeywordsConsistencyOnDelegationMailboxTest { +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
