Repository: james-project Updated Branches: refs/heads/master 5c7471cd9 -> 0cad05775
JAMES-1794 Add a failing related test Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/a989a4ef Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/a989a4ef Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/a989a4ef Branch: refs/heads/master Commit: a989a4ef5a52dd46535284fef9542f46cd8dd6ba Parents: c5714ed Author: Raphael Ouazana <[email protected]> Authored: Fri Jul 8 16:40:12 2016 +0200 Committer: Raphael Ouazana <[email protected]> Committed: Fri Jul 8 16:47:53 2016 +0200 ---------------------------------------------------------------------- .../integration/SetMessagesMethodTest.java | 67 ++++++++++++++++++++ 1 file changed, 67 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/a989a4ef/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java index e318778..306c070 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java @@ -1840,4 +1840,71 @@ public abstract class SetMessagesMethodTest { .body(firstAttachment + ".type", equalTo("text/html")) .body(firstAttachment + ".size", equalTo((int) attachment.getSize())); } + + @Ignore("We should rework org.apache.james.jmap.model.message.MimePart to handle multipart/alternative and multipart/mixed") + @Test + public void attachmentsAndBodyShouldBeRetrievedWhenChainingSetMessagesAndGetMessagesWithTextBodyAndHtmlAttachment() throws Exception { + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "sent"); + + Attachment attachment = Attachment.builder() + .bytes(("<html>\n" + + " <body>attachment</body>\n" + // needed indentation, else restassured is adding some + "</html>").getBytes(Charsets.UTF_8)) + .type("text/html; charset=UTF-8") + .build(); + uploadTextAttachment(attachment); + + String messageCreationId = "creationId"; + String fromAddress = username; + String outboxId = getOutboxId(accessToken); + String requestBody = "[" + + " [" + + " \"setMessages\","+ + " {" + + " \"create\": { \"" + messageCreationId + "\" : {" + + " \"from\": { \"name\": \"Me\", \"email\": \"" + fromAddress + "\"}," + + " \"to\": [{ \"name\": \"Me\", \"email\": \"" + fromAddress + "\"}]," + + " \"subject\": \"Message with an attachment\"," + + " \"textBody\": \"Test body, plain text version\"," + + " \"mailboxIds\": [\"" + outboxId + "\"], " + + " \"attachments\": [" + + " {\"blobId\" : \"" + attachment.getAttachmentId().getId() + "\", " + + " \"type\" : \"" + attachment.getType() + "\", " + + " \"size\" : " + attachment.getSize() + ", " + + " \"isInline\" : false }" + + " ]" + + " }}" + + " }," + + " \"#0\"" + + " ]" + + "]"; + + given() + .header("Authorization", accessToken.serialize()) + .body(requestBody) + .when() + .post("/jmap"); + + calmlyAwait.atMost(30, TimeUnit.SECONDS).until( () -> isAnyMessageFoundInInbox(accessToken)); + + String firstMessage = ARGUMENTS + ".list[0]"; + String firstAttachment = firstMessage + ".attachments[0]"; + String presumedMessageId = "[email protected]|INBOX|1"; + given() + .header("Authorization", accessToken.serialize()) + .body("[[\"getMessages\", {\"ids\": [\"" + presumedMessageId + "\"]}, \"#0\"]]") + .when() + .post("/jmap") + .then() + .statusCode(200) + .log().ifValidationFails() + .body(NAME, equalTo("messages")) + .body(ARGUMENTS + ".list", hasSize(1)) + .body(firstMessage + ".textBody", equalTo("Test body, plain text version")) + .body(firstMessage + ".htmlBody", isEmptyOrNullString()) + .body(firstMessage + ".attachments", hasSize(1)) + .body(firstAttachment + ".blobId", equalTo(attachment.getAttachmentId().getId())) + .body(firstAttachment + ".type", equalTo("text/html")) + .body(firstAttachment + ".size", equalTo((int) attachment.getSize())); + } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
