JAMES-2186 make GetMessages cucumber test stateless
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/eff87da0 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/eff87da0 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/eff87da0 Branch: refs/heads/master Commit: eff87da0cd1710e0705bf7e1f6c6613bb0db7f04 Parents: 1a7ebcd Author: Luc DUZAN <[email protected]> Authored: Thu Oct 19 14:17:48 2017 +0700 Committer: Matthieu Baechler <[email protected]> Committed: Mon Oct 23 13:50:39 2017 +0200 ---------------------------------------------------------------------- .../cucumber/GetMessageListMethodStepdefs.java | 4 +- .../cucumber/GetMessagesMethodStepdefs.java | 238 +++++++++++++++---- .../integration/cucumber/ImapStepdefs.java | 16 +- .../cucumber/SetMailboxesMethodStepdefs.java | 14 +- .../cucumber/SetMessagesMethodStepdefs.java | 12 +- .../integration/cucumber/UserStepdefs.java | 23 +- .../test/resources/cucumber/GetMessages.feature | 144 ++++++----- 7 files changed, 307 insertions(+), 144 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/eff87da0/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 c718803..74346e0 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 @@ -63,7 +63,7 @@ public class GetMessageListMethodStepdefs { public void getMessageList(String mailbox, String flag) throws Exception { MailboxId mailboxId = mainStepdefs.jmapServer .getProbe(MailboxProbeImpl.class) - .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox) + .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.getConnectedUser(), mailbox) .getMailboxId(); post(String.format( @@ -105,7 +105,7 @@ public class GetMessageListMethodStepdefs { private void post(String requestBody) throws Exception { response = Request.Post(mainStepdefs.baseUri().setPath("/jmap").build()) - .addHeader("Authorization", userStepdefs.tokenByUser.get(userStepdefs.lastConnectedUser).serialize()) + .addHeader("Authorization", userStepdefs.tokenByUser.get(userStepdefs.getConnectedUser()).serialize()) .addHeader("Accept", org.apache.http.entity.ContentType.APPLICATION_JSON.getMimeType()) .bodyString(requestBody, org.apache.http.entity.ContentType.APPLICATION_JSON) .execute() http://git-wip-us.apache.org/repos/asf/james-project/blob/eff87da0/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 08f4a79..2be46bf 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 @@ -103,26 +103,46 @@ public class GetMessagesMethodStepdefs { @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" and \"([^\"]*)\" mailboxes with subject \"([^\"]*)\", content \"([^\"]*)\"$") public void appendMessageInTwoMailboxes(String messageName, String mailbox1, String mailbox2, String subject, String content) throws Exception { MessageId id = appendMessage(mailbox1, ContentType.noContentType(), subject, content, NO_HEADERS); - MailboxId mailboxId1 = mainStepdefs.mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox1).getMailboxId(); - MailboxId mailboxId2 = mainStepdefs.mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox2).getMailboxId(); + MailboxId mailboxId1 = mainStepdefs.mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.getConnectedUser(), mailbox1).getMailboxId(); + MailboxId mailboxId2 = mainStepdefs.mailboxProbe.getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.getConnectedUser(), mailbox2).getMailboxId(); - mainStepdefs.jmapServer.getProbe(JmapGuiceProbe.class).setInMailboxes(id, userStepdefs.lastConnectedUser, mailboxId1, mailboxId2); + mainStepdefs.jmapServer.getProbe(JmapGuiceProbe.class).setInMailboxes(id, userStepdefs.getConnectedUser(), mailboxId1, mailboxId2); messageIdsByName.put(messageName, id); mainStepdefs.awaitMethod.run(); } + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" and \"([^\"]*)\" mailboxes with subject \"([^\"]*)\", content \"([^\"]*)\"$") + public void appendMessageInTwoMailboxes(String username, String messageName, String mailbox1, String mailbox2, String subject, String content) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMessageInTwoMailboxes(messageName, mailbox1, mailbox2, subject, content)); + } + @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with subject \"([^\"]*)\", content \"([^\"]*)\"$") public void appendMessage(String messageName, String mailbox, String subject, String content) throws Exception { MessageId id = appendMessage(mailbox, ContentType.noContentType(), subject, content, NO_HEADERS); messageIdsByName.put(messageName, id); } + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with subject \"([^\"]*)\", content \"([^\"]*)\"$") + public void appendMessage(String username, String messageName, String mailbox, String subject, String content) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMessage(messageName, mailbox, subject, content)); + } + + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with content-type \"([^\"]*)\" subject \"([^\"]*)\", content \"([^\"]*)\"$") + public void appendMessageWithContentType(String username, String messageName, String mailbox, String contentType, String subject, String content) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMessageWithContentType(messageName, mailbox, contentType, subject, content)); + } + @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with content-type \"([^\"]*)\" subject \"([^\"]*)\", content \"([^\"]*)\"$") - public void appendMessage(String messageName, String mailbox, String contentType, String subject, String content) throws Exception { + public void appendMessageWithContentType(String messageName, String mailbox, String contentType, String subject, String content) throws Throwable { MessageId id = appendMessage(mailbox, ContentType.from(contentType), subject, content, NO_HEADERS); messageIdsByName.put(messageName, id); } + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with content-type \"([^\"]*)\" subject \"([^\"]*)\", content \"([^\"]*)\", headers$") + public void appendMessage(String username, String messageName, String mailbox, String contentType, String subject, String content, DataTable headers) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMessage(messageName, mailbox, contentType, subject, content, headers)); + } + @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with content-type \"([^\"]*)\" subject \"([^\"]*)\", content \"([^\"]*)\", headers$") public void appendMessage(String messageName, String mailbox, String contentType, String subject, String content, DataTable headers) throws Exception { MessageId id = appendMessage(mailbox, ContentType.from(contentType), subject, content, Optional.of(headers.asMap(String.class, String.class))); @@ -130,19 +150,29 @@ public class GetMessagesMethodStepdefs { } @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with subject \"([^\"]*)\", content \"([^\"]*)\", headers$") - public void appendMessage(String messageName, String mailbox, String subject, String content, DataTable headers) throws Exception { + public void appendMessageWithHeader(String messageName, String mailbox, String subject, String content, DataTable headers) throws Exception { MessageId id = appendMessage(mailbox, ContentType.noContentType(), subject, content, Optional.of(headers.asMap(String.class, String.class))); messageIdsByName.put(messageName, id); } + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with subject \"([^\"]*)\", content \"([^\"]*)\", headers$") + public void appendMessageWithHeader(String username, String messageName, String mailbox, String subject, String content, DataTable headers) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMessageWithHeader(messageName, mailbox, subject, content, headers)); + } + + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox, composed of a multipart with inlined text part and inlined html part$") + public void appendMessageFromFileInlinedMultipart(String username, String messageName, String mailbox) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMessageFromFileInlinedMultipart(messageName, mailbox)); + } + @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox, composed of a multipart with inlined text part and inlined html part$") public void appendMessageFromFileInlinedMultipart(String messageName, String mailbox) throws Exception { ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); - MessageId id = mainStepdefs.mailboxProbe.appendMessage(userStepdefs.lastConnectedUser, - MailboxPath.forUser(userStepdefs.lastConnectedUser, mailbox), - ClassLoader.getSystemResourceAsStream("eml/inlinedMultipart.eml"), - Date.from(dateTime.toInstant()), false, new Flags()) - .getMessageId(); + MessageId id = mainStepdefs.mailboxProbe.appendMessage(userStepdefs.getConnectedUser(), + MailboxPath.forUser(userStepdefs.getConnectedUser(), mailbox), + ClassLoader.getSystemResourceAsStream("eml/inlinedMultipart.eml"), + Date.from(dateTime.toInstant()), false, new Flags()) + .getMessageId(); messageIdsByName.put(messageName, id); mainStepdefs.awaitMethod.run(); } @@ -150,8 +180,8 @@ public class GetMessagesMethodStepdefs { private MessageId appendMessage(String mailbox, ContentType contentType, String subject, String content, Optional<Map<String, String>> headers) throws Exception { ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); try { - return mainStepdefs.mailboxProbe.appendMessage(userStepdefs.lastConnectedUser, - MailboxPath.forUser(userStepdefs.lastConnectedUser, mailbox), + return mainStepdefs.mailboxProbe.appendMessage(userStepdefs.getConnectedUser(), + MailboxPath.forUser(userStepdefs.getConnectedUser(), mailbox), new ByteArrayInputStream(message(contentType, subject, content, headers).getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags()).getMessageId(); } finally { @@ -165,16 +195,16 @@ public class GetMessagesMethodStepdefs { private String serialize(Optional<Map<String,String>> headers) { return headers - .map(Map::entrySet) - .map(entriesToString()) - .orElse(""); + .map(Map::entrySet) + .map(entriesToString()) + .orElse(""); } private Function<Set<Entry<String, String>>, String> entriesToString() { return entries -> entries.stream() - .map(this::entryToPair) - .map(this::joinKeyValue) - .collect(Collectors.joining("\r\n", "", "\r\n")); + .map(this::entryToPair) + .map(this::joinKeyValue) + .collect(Collectors.joining("\r\n", "", "\r\n")); } @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with two attachments$") @@ -182,76 +212,157 @@ public class GetMessagesMethodStepdefs { appendMessage(messageName, "eml/twoAttachments.eml"); } + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with two attachments$") + public void appendHtmlMessageWithTwoAttachments(String username, String messageName, String mailbox) throws Throwable { + userStepdefs.execWithUser(username, () -> appendHtmlMessageWithTwoAttachments(messageName, mailbox)); + } + + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with two attachments in text$") + public void appendTextMessageWithTwoAttachments(String username, String messageName, String mailbox) throws Throwable { + userStepdefs.execWithUser(username, () -> appendTextMessageWithTwoAttachments(messageName, mailbox)); + } + @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with two attachments in text$") public void appendTextMessageWithTwoAttachments(String messageName, String mailbox) throws Exception { appendMessage(messageName, "eml/twoAttachmentsTextPlain.eml"); } + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with two same attachments in text$") + public void appendTextMessageWithTwoSameAttachments(String username, String messageName, String mailbox) throws Throwable { + userStepdefs.execWithUser(username, () -> appendTextMessageWithTwoAttachments(messageName, mailbox)); + } + @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with two same attachments in text$") public void appendTextMessageWithTwoSameAttachments(String messageName, String mailbox) throws Exception { appendMessage(messageName, "eml/twoSameAttachments.eml"); } + @Given("^\"([^\"]*)\" has a multipart message \"([^\"]*)\" in \"([^\"]*)\" mailbox$") + public void appendMultipartMessageWithOneAttachments(String username, String messageName, String arg1) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMultipartMessageWithOneAttachments(messageName, arg1)); + } + @Given("^the user has a multipart message \"([^\"]*)\" in \"([^\"]*)\" mailbox$") public void appendMultipartMessageWithOneAttachments(String messageName, String arg1) throws Exception { appendMessage(messageName, "eml/htmlAndTextMultipartWithOneAttachment.eml"); } + @Given("\"([^\"]*)\" has a multipart/related message \"([^\"]*)\" in \"([^\"]*)\" mailbox$") + public void appendMultipartRelated(String username, String messageName, String mailbox) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMultipartRelated(messageName, mailbox)); + } + @Given("^the user has a multipart/related message \"([^\"]*)\" in \"([^\"]*)\" mailbox$") public void appendMultipartRelated(String messageName, String mailbox) throws Exception { appendMessage(messageName, "eml/multipartRelated.eml"); } + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox beginning by a long line$") + public void appendMessageBeginningByALongLine(String username, String messageName, String mailbox) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMessageBeginningByALongLine(messageName, mailbox)); + } + @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox beginning by a long line$") public void appendMessageBeginningByALongLine(String messageName, String mailbox) throws Exception { appendMessage(messageName, "eml/longLine.eml"); } + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with plain/text inline attachment$") + public void appendMessageWithPlainTextInlineAttachment(String username, String messageName, String mailbox) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMessageWithPlainTextInlineAttachment(messageName, mailbox)); + } + @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with plain/text inline attachment$") public void appendMessageWithPlainTextInlineAttachment(String messageName, String mailbox) throws Exception { appendMessage(messageName, "eml/embeddedMultipartWithInlineTextAttachment.eml"); } + + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with text in main multipart and html in inner multipart$") + public void appendMessageWithTextInMainMultipartAndHtmlInInnerMultipart(String username, String messageName, String mailbox) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMessageWithTextInMainMultipartAndHtmlInInnerMultipart(messageName, mailbox)); + } + @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with text in main multipart and html in inner multipart$") public void appendMessageWithTextInMainMultipartAndHtmlInInnerMultipart(String messageName, String mailbox) throws Exception { appendMessage(messageName, "eml/textInMainMultipartHtmlInInnerMultipart.eml"); } + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with html body and no text body$") + public void appendMessageWithNoTextButHtml(String username, String messageName, String mailbox) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMessageWithNoTextButHtml(messageName, mailbox)); + } + @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with html body and no text body$") public void appendMessageWithNoTextButHtml(String messageName, String mailbox) throws Exception { appendMessage(messageName, "eml/noTextBodyButHtmlBody.eml"); } + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with inline attachment but no CID$") + public void appendMessageWithInlineAttachmentButNoCid(String username, String messageName, String mailbox) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMessageWithInlineAttachmentButNoCid(messageName, mailbox)); + } + @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with inline attachment but no CID$") public void appendMessageWithInlineAttachmentButNoCid(String messageName, String mailbox) throws Exception { appendMessage(messageName, "eml/mailWithInlinedAttachmentButNoCid.eml"); } + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with inline attachment and blank CID$") + public void appendMessageWithInlineAttachmentAndBlankCid(String username, String messageName, String mailbox) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMessageWithInlineAttachmentAndBlankCid(messageName, mailbox)); + } + @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with inline attachment and blank CID$") public void appendMessageWithInlineAttachmentAndBlankCid(String messageName, String mailbox) throws Throwable { appendMessage(messageName, "eml/mailWithInlinedAttachmentAndBlankCid.eml"); } + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with HTML body with many empty tags$") + public void appendMessageWithNoPreview(String username, String messageName, String mailbox) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMessageWithNoPreview(messageName, mailbox)); + } + @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with HTML body with many empty tags$") public void appendMessageWithNoPreview(String messageName, String mailbox) throws Exception { appendMessage(messageName, "eml/htmlBodyWithManyEmptyTags.eml"); } + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in the \"([^\"]*)\" mailbox with multiple same inlined attachments \"([^\"]*)\"$") + public void appendMessageWithSameInlinedAttachmentsToMailbox(String username, String messageName, String mailbox, String attachmentId) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMessageWithSameInlinedAttachmentsToMailbox(messageName, mailbox, attachmentId)); + } + @Given("^the user has a message \"([^\"]*)\" in the \"([^\"]*)\" mailbox with multiple same inlined attachments \"([^\"]*)\"$") public void appendMessageWithSameInlinedAttachmentsToMailbox(String messageName, String mailbox, String attachmentId) throws Exception { appendMessage(messageName, "eml/sameInlinedImages.eml"); } + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with specific charset$") + public void appendMessageWithSpecificCharset(String username, String messageName, String mailbox) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMessageWithSpecificCharset(messageName, mailbox)); + } + @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with specific charset$") public void appendMessageWithSpecificCharset(String messageName, String mailbox) throws Exception { appendMessage(messageName, "eml/windows1252charset.eml"); } + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with long and complicated HTML content$") + public void appendMessageWithSpecialCase(String username, String messageName, String mailbox) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMessageWithSpecialCase(messageName, mailbox)); + } + @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with long and complicated HTML content$") public void appendMessageWithSpecialCase(String messageName, String mailbox) throws Exception { appendMessage(messageName, "eml/htmlWithLongAndComplicatedContent.eml"); } + @Given("^\"([^\"]*)\" has a message \"([^\"]*)\" in the \"([^\"]*)\" mailbox with flags \"([^\"]*)\"$") + public void appendMessageWithFlags(String username, String messageName, String mailbox, List<String> flagList) throws Throwable { + userStepdefs.execWithUser(username, () -> appendMessageWithFlags(messageName, mailbox, flagList)); + } + @Given("^the user has a message \"([^\"]*)\" in the \"([^\"]*)\" mailbox with flags \"([^\"]*)\"$") public void appendMessageWithFlags(String messageName, String mailbox, List<String> flagList) throws Exception { appendMessage(messageName, StringListToFlags.fromFlagList(flagList)); @@ -260,29 +371,39 @@ public class GetMessagesMethodStepdefs { private void appendMessage(String messageName, Flags flags) throws Exception { ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); boolean isRecent = flags.contains(Flags.Flag.RECENT); - MessageId id = mainStepdefs.mailboxProbe.appendMessage(userStepdefs.lastConnectedUser, - MailboxPath.forUser(userStepdefs.lastConnectedUser, DefaultMailboxes.INBOX), - new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), - Date.from(dateTime.toInstant()), isRecent, flags) - .getMessageId(); + MessageId id = mainStepdefs.mailboxProbe.appendMessage(userStepdefs.getConnectedUser(), + MailboxPath.forUser(userStepdefs.getConnectedUser(), DefaultMailboxes.INBOX), + new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), + Date.from(dateTime.toInstant()), isRecent, flags) + .getMessageId(); messageIdsByName.put(messageName, id); } private void appendMessage(String messageName, String emlFileName) throws Exception { ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); - MessageId id = mainStepdefs.mailboxProbe.appendMessage(userStepdefs.lastConnectedUser, - MailboxPath.forUser(userStepdefs.lastConnectedUser, DefaultMailboxes.INBOX), - ClassLoader.getSystemResourceAsStream(emlFileName), - Date.from(dateTime.toInstant()), false, new Flags()) - .getMessageId(); + MessageId id = mainStepdefs.mailboxProbe.appendMessage(userStepdefs.getConnectedUser(), + MailboxPath.forUser(userStepdefs.getConnectedUser(), DefaultMailboxes.INBOX), + ClassLoader.getSystemResourceAsStream(emlFileName), + Date.from(dateTime.toInstant()), false, new Flags()) + .getMessageId(); messageIdsByName.put(messageName, id); } - @When("^the user ask for messages using its accountId$") + @When("^\"([^\"]*)\" ask for messages using its accountId$") + public void postWithAccountId(String user) throws Throwable { + userStepdefs.execWithUser(user, this::postWithAccountId); + } + + @When("^\the user ask for messages using its accountId$") public void postWithAccountId() throws Exception { post("[[\"getMessages\", {\"accountId\": \"1\"}, \"#0\"]]"); } + @When("^\"([^\"]*)\" ask for messages using unknown arguments$") + public void postWithUnknownArguments(String user) throws Throwable { + userStepdefs.execWithUser(user, this::postWithUnknownArguments); + } + @When("^the user ask for messages using unknown arguments$") public void postWithUnknownArguments() throws Exception { post("[[\"getMessages\", {\"WAT\": true}, \"#0\"]]"); @@ -293,19 +414,39 @@ public class GetMessagesMethodStepdefs { post("[[\"getMessages\", {\"ids\": null}, \"#0\"]]"); } + @When("^\"([^\"]*)\" ask for messages using invalid argument$") + public void postWithInvalidArguments(String user) throws Throwable { + userStepdefs.execWithUser(user, this::postWithInvalidArguments); + } + @When("^the user ask for messages$") public void post() throws Exception { post("[[\"getMessages\", {\"ids\": []}, \"#0\"]]"); } + @When("^\"(.*?)\" ask for messages$") + public void postWithGivenUser(String username) throws Throwable { + userStepdefs.execWithUser(username, this::post); + } + @When("^the user ask for messages \"(.*?)\"$") public void postWithAListOfIds(List<String> ids) throws Exception { requestedMessageIds = ids.stream() - .map(messageIdsByName::get) - .collect(Guavate.toImmutableList()); + .map(messageIdsByName::get) + .collect(Guavate.toImmutableList()); askMessages(requestedMessageIds); } + @When("^\"(.*?)\" ask for messages \"(.*?)\"$") + public void postWithAListOfIds(String user, List<String> ids) throws Throwable { + userStepdefs.execWithUser(user, () -> postWithAListOfIds(ids)); + } + + @When("^\"(.*?)\" ask for an unknown message$") + public void requestUnknownMessage(String user) throws Throwable { + userStepdefs.execWithUser(user, this::requestUnknownMessage); + } + @When("^the user ask for an unknown message$") public void requestUnknownMessage() throws Exception { askMessages(ImmutableList.of(mainStepdefs.messageIdFactory.generate())); @@ -314,9 +455,9 @@ public class GetMessagesMethodStepdefs { private void askMessages(List<MessageId> messageIds) throws Exception { requestedMessageIds = messageIds; String serializedIds = requestedMessageIds.stream() - .map(MessageId::serialize) - .map(toJsonString()) - .collect(Collectors.joining(",", "[", "]" )); + .map(MessageId::serialize) + .map(toJsonString()) + .collect(Collectors.joining(",", "[", "]" )); post("[[\"getMessages\", {\"ids\": " + serializedIds + "}, \"#0\"]]"); } @@ -324,20 +465,25 @@ public class GetMessagesMethodStepdefs { return string -> "\"" + string + "\""; } + @When("^\"(.*?)\" is getting messages \"(.*?)\" with properties \"(.*?)\"$") + public void postWithParameters(String username, List<String> ids, List<String> properties) throws Throwable { + userStepdefs.execWithUser(username, () -> postWithParameters(ids, properties)); + } + @When("^the user is getting messages \"(.*?)\" with properties \"(.*?)\"$") public void postWithParameters(List<String> ids, List<String> properties) throws Exception { requestedMessageIds = ids.stream() - .map(messageIdsByName::get) - .collect(Guavate.toImmutableList()); + .map(messageIdsByName::get) + .collect(Guavate.toImmutableList()); String serializedIds = requestedMessageIds.stream() - .map(MessageId::serialize) - .map(toJsonString()) - .collect(Collectors.joining(",", "[", "]" )); + .map(MessageId::serialize) + .map(toJsonString()) + .collect(Collectors.joining(",", "[", "]" )); String serializedProperties = properties.stream() - .map(toJsonString()) - .collect(Collectors.joining(",", "[", "]" )); + .map(toJsonString()) + .collect(Collectors.joining(",", "[", "]" )); post("[[\"getMessages\", {\"ids\": " + serializedIds + ", \"properties\": " + serializedProperties + "}, \"#0\"]]"); } @@ -352,7 +498,7 @@ public class GetMessagesMethodStepdefs { private void post(String requestBody) throws Exception { response = Request.Post(mainStepdefs.baseUri().setPath("/jmap").build()) - .addHeader("Authorization", userStepdefs.tokenByUser.get(userStepdefs.lastConnectedUser).serialize()) + .addHeader("Authorization", userStepdefs.tokenByUser.get(userStepdefs.getConnectedUser()).serialize()) .addHeader("Accept", org.apache.http.entity.ContentType.APPLICATION_JSON.getMimeType()) .bodyString(requestBody, org.apache.http.entity.ContentType.APPLICATION_JSON) .execute() @@ -417,7 +563,7 @@ public class GetMessagesMethodStepdefs { .splitToList(mailboxIds).stream() .map(Throwing.function(name -> mainStepdefs.jmapServer .getProbe(MailboxProbeImpl.class) - .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, name) + .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.getConnectedUser(), name) .getMailboxId() .serialize())) .distinct() @@ -469,9 +615,9 @@ public class GetMessagesMethodStepdefs { public void assertPreviewShouldBeNormalized() throws Exception { String actual = jsonPath.<String>read(FIRST_MESSAGE + ".preview"); assertThat(actual).hasSize(MessagePreviewGenerator.MAX_PREVIEW_LENGTH) - .doesNotMatch(" ") - .doesNotContain(StringUtils.CR) - .doesNotContain(StringUtils.LF); + .doesNotMatch(" ") + .doesNotContain(StringUtils.CR) + .doesNotContain(StringUtils.LF); } @Then("^the headers of the message contains:$") http://git-wip-us.apache.org/repos/asf/james-project/blob/eff87da0/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/ImapStepdefs.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/ImapStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/ImapStepdefs.java index 4f0f5f6..f135de4 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/ImapStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/ImapStepdefs.java @@ -55,8 +55,8 @@ public class ImapStepdefs { public void hasMessageInMailbox(String mailbox) throws Throwable { try (IMAPMessageReader imapMessageReader = new IMAPMessageReader(LOCALHOST, IMAP_PORT);) { assertThat( - imapMessageReader.userReceivedMessageInMailbox(userStepdefs.lastConnectedUser, - userStepdefs.passwordByUser.get(userStepdefs.lastConnectedUser), + imapMessageReader.userReceivedMessageInMailbox(userStepdefs.getConnectedUser(), + userStepdefs.passwordByUser.get(userStepdefs.getConnectedUser()), mailbox)) .isTrue(); } @@ -66,8 +66,8 @@ public class ImapStepdefs { public void hasANotificationAboutNewMessagesInMailbox(int numOfNewMessage, String mailbox) throws Throwable { try (IMAPMessageReader imapMessageReader = new IMAPMessageReader(LOCALHOST, IMAP_PORT);) { assertThat( - imapMessageReader.userGetNotifiedForNewMessagesWhenSelectingMailbox(userStepdefs.lastConnectedUser, - userStepdefs.passwordByUser.get(userStepdefs.lastConnectedUser), + imapMessageReader.userGetNotifiedForNewMessagesWhenSelectingMailbox(userStepdefs.getConnectedUser(), + userStepdefs.passwordByUser.get(userStepdefs.getConnectedUser()), numOfNewMessage, mailbox)) .isTrue(); } @@ -77,8 +77,8 @@ public class ImapStepdefs { public void hasNoMessageInMailbox(String mailbox) throws Throwable { try (IMAPMessageReader imapMessageReader = new IMAPMessageReader(LOCALHOST, IMAP_PORT);) { assertThat( - imapMessageReader.userDoesNotReceiveMessageInMailbox(userStepdefs.lastConnectedUser, - userStepdefs.passwordByUser.get(userStepdefs.lastConnectedUser), + imapMessageReader.userDoesNotReceiveMessageInMailbox(userStepdefs.getConnectedUser(), + userStepdefs.passwordByUser.get(userStepdefs.getConnectedUser()), mailbox)) .isTrue(); } @@ -88,7 +88,7 @@ public class ImapStepdefs { public void openImapConnectionAndSelectMailbox(String mailbox) throws Throwable { IMAPMessageReader imapMessageReader = new IMAPMessageReader(LOCALHOST, IMAP_PORT); - String login = userStepdefs.lastConnectedUser; + String login = userStepdefs.getConnectedUser(); String password = userStepdefs.passwordByUser.get(login); imapMessageReader.connectAndSelect(login, password, mailbox); @@ -113,7 +113,7 @@ public class ImapStepdefs { public void copyAMessageByIMAP(String srcMailbox, String destMailbox) throws Throwable { IMAPMessageReader imapMessageReader = new IMAPMessageReader(LOCALHOST, IMAP_PORT); - String login = userStepdefs.lastConnectedUser; + String login = userStepdefs.getConnectedUser(); String password = userStepdefs.passwordByUser.get(login); imapMessageReader.connectAndSelect(login, password, srcMailbox); http://git-wip-us.apache.org/repos/asf/james-project/blob/eff87da0/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java index 59fef05..5104a28 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/SetMailboxesMethodStepdefs.java @@ -64,8 +64,8 @@ public class SetMailboxesMethodStepdefs { @Given("^mailbox \"([^\"]*)\" with (\\d+) messages$") public void mailboxWithMessages(String mailboxName, int messageCount) throws Throwable { - mainStepdefs.mailboxProbe.createMailbox("#private", userStepdefs.lastConnectedUser, mailboxName); - MailboxPath mailboxPath = MailboxPath.forUser(userStepdefs.lastConnectedUser, mailboxName); + mainStepdefs.mailboxProbe.createMailbox("#private", userStepdefs.getConnectedUser(), mailboxName); + MailboxPath mailboxPath = MailboxPath.forUser(userStepdefs.getConnectedUser(), mailboxName); IntStream .range(0, messageCount) .forEach(Throwing.intConsumer(i -> appendMessage(mailboxPath, i))); @@ -75,14 +75,14 @@ public class SetMailboxesMethodStepdefs { private void appendMessage(MailboxPath mailboxPath, int i) throws MailboxException { String content = "Subject: test" + i + "\r\n\r\n" + "testBody" + i; - mainStepdefs.mailboxProbe.appendMessage(userStepdefs.lastConnectedUser, mailboxPath, + mainStepdefs.mailboxProbe.appendMessage(userStepdefs.getConnectedUser(), mailboxPath, new ByteArrayInputStream(content.getBytes()), new Date(), false, new Flags()); } @When("^renaming mailbox \"([^\"]*)\" to \"([^\"]*)\"") public void renamingMailbox(String actualMailboxName, String newMailboxName) throws Throwable { - String username = userStepdefs.lastConnectedUser; - Mailbox mailbox = mainStepdefs.mailboxProbe.getMailbox("#private", userStepdefs.lastConnectedUser, actualMailboxName); + String username = userStepdefs.getConnectedUser(); + Mailbox mailbox = mainStepdefs.mailboxProbe.getMailbox("#private", userStepdefs.getConnectedUser(), actualMailboxName); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = "[" + @@ -106,7 +106,7 @@ public class SetMailboxesMethodStepdefs { @When("^moving mailbox \"([^\"]*)\" to \"([^\"]*)\"$") public void movingMailbox(String actualMailboxPath, String newParentMailboxPath) throws Throwable { - String username = userStepdefs.lastConnectedUser; + String username = userStepdefs.getConnectedUser(); Mailbox mailbox = mainStepdefs.mailboxProbe.getMailbox("#private", username, actualMailboxPath); String mailboxId = mailbox.getMailboxId().serialize(); Mailbox parent = mainStepdefs.mailboxProbe.getMailbox("#private", username, newParentMailboxPath); @@ -136,7 +136,7 @@ public class SetMailboxesMethodStepdefs { @Then("^mailbox \"([^\"]*)\" contains (\\d+) messages$") public void mailboxContainsMessages(String mailboxName, int messageCount) throws Throwable { Duration slowPacedPollInterval = Duration.FIVE_HUNDRED_MILLISECONDS; - String username = userStepdefs.lastConnectedUser; + String username = userStepdefs.getConnectedUser(); Mailbox mailbox = mainStepdefs.mailboxProbe.getMailbox("#private", username, mailboxName); String mailboxId = mailbox.getMailboxId().serialize(); http://git-wip-us.apache.org/repos/asf/james-project/blob/eff87da0/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 364c39e..5438e27 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 @@ -50,11 +50,11 @@ public class SetMessagesMethodStepdefs { @When("^the user move \"([^\"]*)\" to mailbox \"([^\"]*)\"") public void moveMessageToMailbox(String message, String mailbox) throws Throwable { - String username = userStepdefs.lastConnectedUser; + String username = userStepdefs.getConnectedUser(); MessageId messageId = getMessagesMethodStepdefs.getMessageId(message); MailboxId mailboxId = mainStepdefs.jmapServer .getProbe(MailboxProbeImpl.class) - .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox) + .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.getConnectedUser(), mailbox) .getMailboxId(); String requestBody = "[" + @@ -78,15 +78,15 @@ public class SetMessagesMethodStepdefs { @When("^the user copy \"([^\"]*)\" from mailbox \"([^\"]*)\" to mailbox \"([^\"]*)\"") public void copyMessageToMailbox(String message, String sourceMailbox, String destinationMailbox) throws Throwable { - String username = userStepdefs.lastConnectedUser; + String username = userStepdefs.getConnectedUser(); MessageId messageId = getMessagesMethodStepdefs.getMessageId(message); MailboxId sourceMailboxId = mainStepdefs.jmapServer .getProbe(MailboxProbeImpl.class) - .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, sourceMailbox) + .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.getConnectedUser(), sourceMailbox) .getMailboxId(); MailboxId destinationMailboxId = mainStepdefs.jmapServer .getProbe(MailboxProbeImpl.class) - .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, destinationMailbox) + .getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.getConnectedUser(), destinationMailbox) .getMailboxId(); String requestBody = "[" + @@ -110,7 +110,7 @@ public class SetMessagesMethodStepdefs { @When("^the user set flags on \"([^\"]*)\" to \"([^\"]*)\"") public void setFlags(String message, List<String> keywords) throws Throwable { - String username = userStepdefs.lastConnectedUser; + String username = userStepdefs.getConnectedUser(); MessageId messageId = getMessagesMethodStepdefs.getMessageId(message); String keywordString = keywords .stream() http://git-wip-us.apache.org/repos/asf/james-project/blob/eff87da0/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 b8e8737..c435b3c 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 @@ -23,10 +23,12 @@ 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 com.github.fge.lambdas.runnable.ThrowingRunnable; import org.apache.james.jmap.HttpJmapAuthentication; import org.apache.james.jmap.api.access.AccessToken; import org.apache.james.mailbox.model.MailboxACL; @@ -50,7 +52,7 @@ public class UserStepdefs { protected Map<String, String> passwordByUser; protected Set<String> domains; protected Map<String, AccessToken> tokenByUser; - protected String lastConnectedUser; + protected Optional<String> lastConnectedUser; @Inject private UserStepdefs(MainStepdefs mainStepdefs) { @@ -58,6 +60,23 @@ public class UserStepdefs { this.domains = new HashSet<>(); this.passwordByUser = new HashMap<>(); this.tokenByUser = new HashMap<>(); + this.lastConnectedUser = Optional.empty(); + } + + public void execWithUser(String user, ThrowingRunnable sideEffect) throws Throwable { + Optional<String> previousConnectedUser = lastConnectedUser; + connectUser(user); + try { + sideEffect.run(); + } finally { + previousConnectedUser.ifPresent(Throwing.consumer(this::connectUser)); + } + } + + public String getConnectedUser() { + Preconditions.checkArgument(lastConnectedUser.isPresent(), "No user is connected"); + + return lastConnectedUser.get(); } @Given("^a domain named \"([^\"]*)\"$") @@ -102,7 +121,7 @@ public class UserStepdefs { Preconditions.checkState(password != null, "unknown user " + username); AccessToken accessToken = HttpJmapAuthentication.authenticateJamesUser(mainStepdefs.baseUri(), username, password); tokenByUser.put(username, accessToken); - lastConnectedUser = username; + lastConnectedUser = Optional.of(username); } @Given("^\"([^\"]*)\" shares its mailbox \"([^\"]*)\" with \"([^\"]*)\"$") http://git-wip-us.apache.org/repos/asf/james-project/blob/eff87da0/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature index d586941..fd5a10a 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/cucumber/GetMessages.feature @@ -23,14 +23,14 @@ Feature: GetMessages method Background: Given a domain named "domain.tld" - And a connected user "[email protected]" + And a user "[email protected]" And a user "[email protected]" And "[email protected]" has a mailbox "INBOX" Scenario: Retrieving a message in several mailboxes should return a single message in these mailboxes Given "[email protected]" has a mailbox "custom" - And the user has a message "m1" in "INBOX" and "custom" mailboxes with subject "my test subject", content "testmail" - When the user ask for messages "m1" + And "[email protected]" has a message "m1" in "INBOX" and "custom" mailboxes with subject "my test subject", content "testmail" + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the id of the message is "m1" @@ -38,50 +38,48 @@ Feature: GetMessages method Scenario: Retrieving a message in a mailbox delegated to me Given "[email protected]" has a mailbox "shared" - Given "[email protected]" shares its mailbox "shared" with "[email protected]" - And the user has a message "m1" in "shared" mailbox with subject "my test subject", content "testmail" - Given "[email protected]" is connected - When the user ask for messages "m1" + And "[email protected]" shares its mailbox "shared" with "[email protected]" + And "[email protected]" has a message "m1" in "shared" mailbox with subject "my test subject", content "testmail" + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the id of the message is "m1" Scenario: Retrieving a message in a mailbox not delegated to me Given "[email protected]" has a mailbox "notShared" - And the user has a message "m1" in "notShared" mailbox with subject "my test subject", content "testmail" - Given "[email protected]" is connected - When the user ask for messages "m1" + And "[email protected]" has a message "m1" in "notShared" mailbox with subject "my test subject", content "testmail" + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 0 message Scenario: Retrieving messages with a non null accountId should return a NotSupported error - When the user ask for messages using its accountId + When "[email protected]" ask for messages using its accountId Then an error "Not yet implemented" is returned Scenario: Unknown arguments should be ignored when retrieving messages - When the user ask for messages using unknown arguments + When "[email protected]" ask for messages using unknown arguments Then no error is returned And the list of unknown messages is empty And the list of messages is empty Scenario: Retrieving messages with invalid argument should return an InvalidArguments error - When the user ask for messages using invalid argument + When "[email protected]" ask for messages using invalid argument Then an error "invalidArguments" is returned And the description is "N/A (through reference chain: org.apache.james.jmap.model.Builder["ids"])" Scenario: Retrieving messages should return empty list when no message - When the user ask for messages + When "[email protected]" ask for messages Then no error is returned And the list of messages is empty Scenario: Retrieving message should return not found when message doesn't exist - When the user ask for an unknown message + When "[email protected]" ask for an unknown message Then no error is returned And the notFound list should contain the requested message id Scenario: Retrieving message should return messages when exists - Given the user has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail" - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail" + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the id of the message is "m1" @@ -97,8 +95,8 @@ Feature: GetMessages method And the list of attachments of the message is empty Scenario Outline: Retrieving message should return messages when exists and is a html message - Given the user has a message "m1" in <mailbox> mailbox with content-type <content-type> subject <subject>, content <content> - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in <mailbox> mailbox with content-type <content-type> subject <subject>, content <content> + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the id of the message is "m1" @@ -119,8 +117,8 @@ Feature: GetMessages method |"INBOX" |"text/html" |"my test subject" |my test subject |"This is a <ganan>HTML</b> mail" |"This is a HTML mail" | Scenario Outline: Retrieving message should return preview with tags when text message - Given the user has a message "m1" in <mailbox> mailbox with content-type <content-type> subject <subject>, content <content> - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in <mailbox> mailbox with content-type <content-type> subject <subject>, content <content> + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the preview of the message is <preview> @@ -130,8 +128,8 @@ Feature: GetMessages method |"INBOX" |"text/plain" |"my test subject" |"Here is a listing of HTML tags : <b>jfjfjfj</b>, <i>jfhdgdgdfj</i>, <u>jfjaaafj</u>" |"Here is a listing of HTML tags : <b>jfjfjfj</b>, <i>jfhdgdgdfj</i>, <u>jfjaaafj</u>" | Scenario: Retrieving message should filter properties - Given the user has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail" - When the user is getting messages "m1" with properties "id, subject" + Given "[email protected]" has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail" + When "[email protected]" is getting messages "m1" with properties "id, subject" Then no error is returned And the list should contain 1 message And the id of the message is "m1" @@ -143,11 +141,11 @@ Feature: GetMessages method And the property "date" of the message is null Scenario: Retrieving message should filter header properties - Given the user has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail", headers + Given "[email protected]" has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail", headers |From |[email protected] | |header1 |Header1Content | |HEADer2 |Header2Content | - When the user is getting messages "m1" with properties "headers.from, headers.heADER2" + When "[email protected]" is getting messages "m1" with properties "headers.from, headers.heADER2" Then no error is returned And the list should contain 1 message And the id of the message is "m1" @@ -161,23 +159,23 @@ Feature: GetMessages method And the property "date" of the message is null Scenario: Retrieving message should return not found when id does not match - Given the user has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail" - When the user ask for an unknown message + Given "[email protected]" has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail" + When "[email protected]" ask for an unknown message Then no error is returned And the list of messages is empty And the notFound list should contain the requested message id Scenario: Retrieving message should return mandatory properties when not asked - Given the user has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail" - When the user is getting messages "m1" with properties "subject" + Given "[email protected]" has a message "m1" in "INBOX" mailbox with subject "my test subject", content "testmail" + When "[email protected]" is getting messages "m1" with properties "subject" Then no error is returned And the list should contain 1 message And the id of the message is "m1" And the subject of the message is "my test subject" Scenario: Retrieving message should return attachments when some - Given the user has a message "m1" in "INBOX" mailbox with two attachments - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in "INBOX" mailbox with two attachments + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the hasAttachment of the message is "true" @@ -198,8 +196,8 @@ Feature: GetMessages method |isInline |true | Scenario: Retrieving message should return attachments and html body when some attachments and html message - Given the user has a message "m1" in "INBOX" mailbox with two attachments - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in "INBOX" mailbox with two attachments + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the hasAttachment of the message is "true" @@ -209,8 +207,8 @@ Feature: GetMessages method And the htmlBody of the message is "<b>html</b>\n" Scenario: Retrieving message should return attachments and text body when some attachments and text message - Given the user has a message "m1" in "INBOX" mailbox with two attachments in text - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in "INBOX" mailbox with two attachments in text + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the hasAttachment of the message is "true" @@ -220,8 +218,8 @@ Feature: GetMessages method And the property "htmlBody" of the message is null Scenario: Retrieving message should return attachments and both html/text body when some attachments and both html/text message - Given the user has a multipart message "m1" in "INBOX" mailbox - When the user ask for messages "m1" + Given "[email protected]" has a multipart message "m1" in "INBOX" mailbox + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the hasAttachment of the message is "true" @@ -231,8 +229,8 @@ Feature: GetMessages method And the htmlBody of the message is "<i>blabla</i>\n<b>bloblo</b>\n" Scenario: Retrieving message should return image and html body when multipart/alternative where first part is multipart/related with html and image - Given the user has a multipart/related message "m1" in "INBOX" mailbox - When the user ask for messages "m1" + Given "[email protected]" has a multipart/related message "m1" in "INBOX" mailbox + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the hasAttachment of the message is "true" @@ -242,29 +240,29 @@ Feature: GetMessages method And the htmlBody of the message is "<html>multipart/related content</html>\n" Scenario: Retrieving message should return textBody and htmlBody when incoming mail have an inlined HTML and text body without Content-ID - Given the user has a message "m1" in "INBOX" mailbox, composed of a multipart with inlined text part and inlined html part - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in "INBOX" mailbox, composed of a multipart with inlined text part and inlined html part + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the textBody of the message is "Hello text body\n" And the htmlBody of the message is "<html>Hello html body</html>\n" Scenario: Retrieving message with more than 1000 char by line should return message when exists - Given the user has a message "m1" in "INBOX" mailbox beginning by a long line - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in "INBOX" mailbox beginning by a long line + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the id of the message is "m1" Scenario: - Given the user has a message "m1" in "INBOX" mailbox with two same attachments in text - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in "INBOX" mailbox with two same attachments in text + When "[email protected]" ask for messages "m1" Then no error is returned And the list of attachments of the message contains 2 attachments Scenario: Retrieving message should read content from multipart when some inline attachment and both html/text multipart - Given the user has a message "m1" in "INBOX" mailbox with plain/text inline attachment - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in "INBOX" mailbox with plain/text inline attachment + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the hasAttachment of the message is "false" @@ -272,24 +270,24 @@ Feature: GetMessages method And the htmlBody of the message is "<i>blabla</i>\n<b>bloblo</b>\n" Scenario: Retrieving message should find html body when text in main multipart and html in inner multipart - Given the user has a message "m1" in "INBOX" mailbox with text in main multipart and html in inner multipart - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in "INBOX" mailbox with text in main multipart and html in inner multipart + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the textBody of the message is "/blabla/\r\n*bloblo*\r\n" And the htmlBody of the message is "<i>blabla</i>\r\n<b>bloblo</b>\r\n" Scenario: Retrieving message should compute text body from html body - Given the user has a message "m1" in "INBOX" mailbox with html body and no text body - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in "INBOX" mailbox with html body and no text body + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the textBody of the message is "The Test User created an issue" And the htmlBody of the message is "<a>The Test User</a> <strong>created</strong> an issue" Scenario: Retrieving message with inline attachment but no CID should convert that inlined attachment to normal attachment - Given the user has a message "m1" in "INBOX" mailbox with inline attachment but no CID - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in "INBOX" mailbox with inline attachment but no CID + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the hasAttachment of the message is "true" @@ -301,8 +299,8 @@ Feature: GetMessages method |isInline |true | Scenario: Retrieving message with inline attachment and blank CID should convert that inlined attachment to normal attachment - Given the user has a message "m1" in "INBOX" mailbox with inline attachment and blank CID - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in "INBOX" mailbox with inline attachment and blank CID + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the hasAttachment of the message is "true" @@ -314,23 +312,23 @@ Feature: GetMessages method |isInline |true | Scenario: Preview should be computed even when HTML body contains many tags without content - Given the user has a message "m1" in "INBOX" mailbox with HTML body with many empty tags - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in "INBOX" mailbox with HTML body with many empty tags + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the preview of the message is not empty Scenario: Retrieving message which contains multiple same inlined attachments - Given the user has a message "m1" in the "inbox" mailbox with multiple same inlined attachments "ia1" - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in the "inbox" mailbox with multiple same inlined attachments "ia1" + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the hasAttachment of the message is "false" And the list of attachments of the message contains only one attachment with cid "[email protected]" Scenario: Preview and bodies should respect given charset - Given the user has a message "m1" in "INBOX" mailbox with specific charset - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in "INBOX" mailbox with specific charset + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the preview of the message is "à à à à éééé èèèè" @@ -338,17 +336,17 @@ Feature: GetMessages method And the htmlBody of the message is "<html>\r\n <p>à à à à </p>\r\n <p>éééé</p>\r\n <p>èèèè</p>\r\n</html>\r\n" Scenario: Preview should be normalized in case of long and complicated HTML content - Given the user has a message "m1" in "INBOX" mailbox with long and complicated HTML content - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in "INBOX" mailbox with long and complicated HTML content + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the preview of the message is not empty And the preview should not contain consecutive spaces or blank characters Scenario Outline: Preview should display printable characters with charset - Given the user has a message "m1" in "INBOX" mailbox with content-type <content-type> subject "Subject", content <content>, headers + Given "[email protected]" has a message "m1" in "INBOX" mailbox with content-type <content-type> subject "Subject", content <content>, headers |Content-Transfer-Encoding |<tranfer-encoding> | - When the user ask for messages "m1" + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the preview of the message contains: <preview> @@ -358,8 +356,8 @@ Feature: GetMessages method |"text/html; charset=iso-8859-1" |quoted-printable |"Dans le cadre du stage effectu=E9 Mlle 2017, =E0 sign=E9e d=E8s que possible, =E0, tr=E8s, journ=E9e.." |effectué, à , signée dès, très, journée | Scenario Outline: Retrieving message should display keywords as jmap flag - Given the user has a message "m1" in the "inbox" mailbox with flags <flags> - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in the "inbox" mailbox with flags <flags> + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the keywords of the message is <keyword> @@ -369,8 +367,8 @@ Feature: GetMessages method |"$Flagged,$Answered,$Draft" |$Flagged,$Answered,$Draft | Scenario Outline: GetMessages should filter invalid keywords - Given the user has a message "m1" in the "inbox" mailbox with flags <flags> - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in the "inbox" mailbox with flags <flags> + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the keywords of the message is <keyword> @@ -380,8 +378,8 @@ Feature: GetMessages method |"$Draft,@ert,t^a,op§,$user_flag" |$Draft,$user_flag | Scenario Outline: Retrieving message should display keywords without unsupported jmap flag - Given the user has a message "m1" in the "inbox" mailbox with flags <flags> - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in the "inbox" mailbox with flags <flags> + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the keywords of the message is <keyword> @@ -391,8 +389,8 @@ Feature: GetMessages method |"$Flagged,$Answered,$Deleted,$Recent" |$Flagged,$Answered | Scenario Outline: Retrieving message should display keywords with custom user jmap flag - Given the user has a message "m1" in the "inbox" mailbox with flags <flags> - When the user ask for messages "m1" + Given "[email protected]" has a message "m1" in the "inbox" mailbox with flags <flags> + When "[email protected]" ask for messages "m1" Then no error is returned And the list should contain 1 message And the keywords of the message is <keyword> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
