james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [04/12] james-project git commit: JAMES-2560 Integration test for ICSSanitizer
Date Fri, 12 Oct 2018 08:28:55 GMT
JAMES-2560 Integration test for ICSSanitizer


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/d722432d
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/d722432d
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/d722432d

Branch: refs/heads/master
Commit: d722432dde9161c7e210273692b132311ed7566a
Parents: 09b4165
Author: Benoit Tellier <btellier@linagora.com>
Authored: Thu Oct 11 12:24:40 2018 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Fri Oct 12 15:26:53 2018 +0700

----------------------------------------------------------------------
 server/container/guice/memory-guice/pom.xml     |  5 +++
 .../src/test/resources/mailetcontainer.xml      |  1 +
 .../cucumber/GetMessagesMethodStepdefs.java     | 26 +++++++++++
 .../test/resources/cucumber/GetMessages.feature | 15 +++++++
 .../src/test/resources/eml/ics_in_header.eml    | 46 ++++++++++++++++++++
 .../src/test/resources/mailetcontainer.xml      |  1 +
 6 files changed, 94 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/d722432d/server/container/guice/memory-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/pom.xml b/server/container/guice/memory-guice/pom.xml
index 661634c..3bb24f2 100644
--- a/server/container/guice/memory-guice/pom.xml
+++ b/server/container/guice/memory-guice/pom.xml
@@ -60,6 +60,11 @@
         </dependency>
         <dependency>
             <groupId>${james.groupId}</groupId>
+            <artifactId>apache-mailet-icalendar</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>${james.groupId}</groupId>
             <artifactId>event-sourcing-event-store-memory</artifactId>
         </dependency>
         <dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/d722432d/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailetcontainer.xml
b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailetcontainer.xml
index 2ecff3f..3dc8bbf 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailetcontainer.xml
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/src/test/resources/mailetcontainer.xml
@@ -57,6 +57,7 @@
             <mailet match="All" class="RemoveMimeHeader">
                 <name>bcc</name>
             </mailet>
+            <mailet match="All" class="ICSSanitizer"/>
             <mailet match="All" class="org.apache.james.jmap.mailet.TextCalendarBodyToAttachment"/>
             <mailet match="All" class="RecipientRewriteTable">
                 <errorProcessor>rrt-error</errorProcessor>

http://git-wip-us.apache.org/repos/asf/james-project/blob/d722432d/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 efc15e6..13819e5 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
@@ -21,6 +21,7 @@ package org.apache.james.jmap.methods.integration.cucumber;
 
 import static org.apache.james.jmap.TestingConstants.ARGUMENTS;
 import static org.apache.james.jmap.TestingConstants.NAME;
+import static org.apache.james.mailbox.model.MailboxConstants.INBOX;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import java.io.ByteArrayInputStream;
@@ -40,12 +41,17 @@ import javax.mail.Flags;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.text.StringEscapeUtils;
+import org.apache.james.jmap.TestingConstants;
 import org.apache.james.jmap.methods.integration.cucumber.util.TableRow;
 import org.apache.james.jmap.model.MessagePreviewGenerator;
+import org.apache.james.mailbox.model.MailboxConstants;
 import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.MessageId;
+import org.apache.james.modules.protocols.SmtpGuiceProbe;
+import org.apache.james.util.ClassLoaderUtils;
 import org.apache.james.utils.JmapGuiceProbe;
+import org.apache.james.utils.SMTPMessageSender;
 import org.javatuples.Pair;
 
 import com.github.fge.lambdas.Throwing;
@@ -373,6 +379,26 @@ public class GetMessagesMethodStepdefs {
         appendMessage(messageName, mailbox, StringListToFlags.fromFlagList(flagList));
     }
 
+    @Given("^\"([^\"]*)\" receives a SMTP message specified in file \"([^\"]*)\" as message
\"([^\"]*)\"$")
+    public void smtpSend(String user, String fileName, String messageName) throws Exception
{
+        MailboxId mailboxId = mainStepdefs.mailboxProbe.getMailboxId(MailboxConstants.USER_NAMESPACE,
user, INBOX);
+        SMTPMessageSender smtpMessageSender = new SMTPMessageSender("domain.com");
+        smtpMessageSender
+            .connect("127.0.0.1", mainStepdefs.jmapServer.getProbe(SmtpGuiceProbe.class).getSmtpPort())
+            .sendMessageWithHeaders("from@domain.com", user,
+                ClassLoaderUtils.getSystemResourceAsString(fileName));
+        smtpMessageSender.close();
+
+        TestingConstants.calmlyAwait.until(() -> !retrieveIds(user, mailboxId).isEmpty());
+        List<String> ids = retrieveIds(user, mailboxId);
+        messageIdStepdefs.addMessageId(messageName, mainStepdefs.messageIdFactory.fromString(ids.get(0)));
+    }
+
+    public List<String> retrieveIds(String user, MailboxId mailboxId) {
+        userStepdefs.execWithUser(user, () -> httpClient.post("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\""
+ mailboxId.serialize() + "\"]}}, \"#0\"]]"));
+        return httpClient.jsonPath.read(ARGUMENTS + ".messageIds.[*]");
+    }
+
     private void appendMessage(String messageName, String mailbox, Flags flags) throws Exception
{
         ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
         boolean isRecent = flags.contains(Flags.Flag.RECENT);

http://git-wip-us.apache.org/repos/asf/james-project/blob/d722432d/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 828f068..7e79e5c 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
@@ -419,3 +419,18 @@ Feature: GetMessages method
     |cid      |null                          |
     |name     |"IMG_6112.JPG"                |
     |isInline |false                         |
+
+  @Only
+  Scenario: Header only text calendar should be read as normal calendar attachment by JMAP
+    Given "alice@domain.tld" receives a SMTP message specified in file "eml/ics_in_header.eml"
as message "m1"
+    When "alice@domain.tld" ask for messages "m1"
+    Then no error is returned
+    And the list should contain 1 message
+    And the hasAttachment of the message is "true"
+    And the list of attachments of the message contains 1 attachments
+    And the first attachment is:
+    |key      | value                        |
+    |type     |"text/calendar"               |
+    |size     |1056                          |
+    |name     |"event.ics"                |
+    |isInline |false                         |

http://git-wip-us.apache.org/repos/asf/james-project/blob/d722432d/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/ics_in_header.eml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/ics_in_header.eml
b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/ics_in_header.eml
new file mode 100644
index 0000000..76ca1b7
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/ics_in_header.eml
@@ -0,0 +1,46 @@
+MIME-Version: 1.0
+Content-Type: multipart/mixed; 
+	boundary="----=_Part_80_888179120.1536742699653"
+From: Alice <alice@linagora.com>
+Message-ID: <82eb227b-d3e1-3d7a-3220-8a1b4e96a85b@linagora.com>
+To: Bob <bob@linagora.com>
+Date: Wed, 12 Sep 2018 10:58:18 +0200
+Subject: Event Invitation Reply (Accepted):
+ Point Produit
+
+------=_Part_80_888179120.1536742699653
+BEGIN:VCALENDAR
+PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
+VERSION:2.0
+METHOD:REPLY
+BEGIN:VEVENT
+CREATED:20180911T144134Z
+LAST-MODIFIED:20180912T085818Z
+DTSTAMP:20180912T085818Z
+UID:f1514f44bf39311568d64072945fc3b2973debebb0d550e8c841f3f0604b2481e047fe
+ b2aab16e43439a608f28671ab7c10e754cbbe63441a01ba232a553df751eb0931728d67672
+ 
+SUMMARY:Point Produit
+PRIORITY:5
+ORGANIZER;CN=Bob;X-OBM-ID=348:mailto:bob@linagora.com
+ATTENDEE;CN=Alice;PARTSTAT=ACCEPTED;CUTYPE=INDIVIDUAL;X-OBM-ID=810:
+ mailto:alice@linagora.com
+DTSTART:20180919T123000Z
+DURATION:PT1H
+TRANSP:OPAQUE
+SEQUENCE:0
+X-LIC-ERROR;X-LIC-ERRORTYPE=VALUE-PARSE-ERROR:No value for X property. Rem
+ oving entire property:
+CLASS:PUBLIC
+X-OBM-DOMAIN:linagora.com
+X-OBM-DOMAIN-UUID:02874f7c-d10e-102f-acda-0015176f7922
+LOCATION:Téléphone
+END:VEVENT
+END:VCALENDAR
+Content-class: urn:content-classes:calendarmessage
+Content-type: text/calendar; method=REPLY; charset=UTF-8
+Content-transfer-encoding: 8BIT
+Content-Disposition: attachment
+
+
+------=_Part_80_888179120.1536742699653--

http://git-wip-us.apache.org/repos/asf/james-project/blob/d722432d/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml
b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml
index c890709..8201e60 100644
--- a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/src/test/resources/mailetcontainer.xml
@@ -58,6 +58,7 @@
             <mailet match="All" class="RemoveMimeHeader">
                 <name>bcc</name>
             </mailet>
+            <mailet match="All" class="ICSSanitizer"/>
             <mailet match="All" class="org.apache.james.jmap.mailet.TextCalendarBodyToAttachment"/>
             <mailet match="All" class="RecipientRewriteTable">
                 <errorProcessor>rrt-error</errorProcessor>


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


Mime
View raw message