You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ma...@apache.org on 2017/09/11 09:29:29 UTC
[1/4] james-project git commit: JAMES-2135 IT from JMAP layer for
converting from text/calendar bodies to attachment
Repository: james-project
Updated Branches:
refs/heads/master daaa36a02 -> 238d1c799
JAMES-2135 IT from JMAP layer for converting from text/calendar bodies to attachment
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/8aecdf03
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/8aecdf03
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/8aecdf03
Branch: refs/heads/master
Commit: 8aecdf03b9730a77446afd1d30db9592a187b521
Parents: ebad05e
Author: quynhn <qn...@linagora.com>
Authored: Fri Sep 8 11:29:11 2017 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Mon Sep 11 11:28:15 2017 +0200
----------------------------------------------------------------------
.../cassandra-jmap-integration-testing/pom.xml | 6 ++
.../src/test/resources/mailetcontainer.xml | 1 +
.../jmap-integration-testing-common/pom.xml | 6 ++
.../integration/SetMessagesMethodTest.java | 76 +++++++++++++++++---
.../src/test/resources/eml/calendar.eml | 42 +++++++++++
.../memory-jmap-integration-testing/pom.xml | 6 ++
.../src/test/resources/mailetcontainer.xml | 1 +
7 files changed, 127 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/8aecdf03/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
index b2e3329..745c0d1 100644
--- a/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
+++ b/server/protocols/jmap-integration-testing/cassandra-jmap-integration-testing/pom.xml
@@ -65,6 +65,12 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apache-mailet-base</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>james-server-cassandra-guice</artifactId>
<scope>test</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/8aecdf03/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 f26cd89..b998dcd 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
@@ -50,6 +50,7 @@
<mailet match="All" class="RemoveMimeHeader">
<name>bcc</name>
</mailet>
+ <mailet match="All" class="org.apache.james.jmap.mailet.TextCalendarBodyToAttachment"/>
<mailet match="RecipientIsLocal" class="org.apache.james.jmap.mailet.VacationMailet"/>
<mailet match="RecipientIsLocal" class="Sieve"/>
<mailet match="RecipientIsLocal" class="LocalDelivery"/>
http://git-wip-us.apache.org/repos/asf/james-project/blob/8aecdf03/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
index 84b1dbc..8e348ae 100644
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/pom.xml
@@ -35,6 +35,12 @@
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apache-mailet-base</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>james-server-data-jmap</artifactId>
<scope>test</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/8aecdf03/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 4267638..a9efa83 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
@@ -39,6 +39,7 @@ import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.collection.IsMapWithSize.aMapWithSize;
import static org.hamcrest.collection.IsMapWithSize.anEmptyMap;
+
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.time.ZonedDateTime;
@@ -47,9 +48,13 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
+
import javax.mail.Flags;
import javax.mail.Flags.Flag;
+import javax.mail.internet.MimeMessage;
+import org.apache.commons.io.IOUtils;
+import org.apache.http.client.utils.URIBuilder;
import org.apache.james.GuiceJamesServer;
import org.apache.james.jmap.DefaultMailboxes;
import org.apache.james.jmap.HttpJmapAuthentication;
@@ -68,13 +73,22 @@ import org.apache.james.mailbox.store.event.EventFactory;
import org.apache.james.mailbox.store.mail.model.Mailbox;
import org.apache.james.mailbox.store.probe.MailboxProbe;
import org.apache.james.modules.MailboxProbeImpl;
-import org.apache.james.utils.MessageIdProbe;
import org.apache.james.probe.DataProbe;
import org.apache.james.util.ZeroedInputStream;
import org.apache.james.utils.DataProbeImpl;
import org.apache.james.utils.JmapGuiceProbe;
-import org.apache.commons.io.IOUtils;
-import org.apache.http.client.utils.URIBuilder;
+import org.apache.james.utils.MessageIdProbe;
+import org.apache.james.utils.SMTPMessageSender;
+import org.apache.mailet.Mail;
+import org.apache.mailet.MailAddress;
+import org.apache.mailet.base.test.FakeMail;
+import org.apache.mailet.base.test.MimeMessageBuilder;
+import org.hamcrest.Matcher;
+import org.hamcrest.Matchers;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
import com.google.common.base.Charsets;
import com.google.common.collect.ImmutableList;
@@ -88,16 +102,11 @@ import com.jayway.restassured.builder.RequestSpecBuilder;
import com.jayway.restassured.builder.ResponseSpecBuilder;
import com.jayway.restassured.http.ContentType;
import com.jayway.restassured.specification.ResponseSpecification;
-import org.hamcrest.Matcher;
-import org.hamcrest.Matchers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
public abstract class SetMessagesMethodTest {
-
- private final static String FORWARDED = "$Forwarded";
+ private static final String LOCALHOST_IP = "127.0.0.1";
+ private static final int SMTP_PORT = 1025;
+ private static final String FORWARDED = "$Forwarded";
private static final int _1MB = 1024*1024;
private static final String NAME = "[0][0]";
private static final String ARGUMENTS = "[0][1]";
@@ -3688,4 +3697,49 @@ public abstract class SetMessagesMethodTest {
.body(ARGUMENTS + ".type", equalTo("invalidArguments"))
.body(ARGUMENTS + ".description", containsString("Does not allow to update 'Deleted' or 'Recent' flag"));
}
+
+ @Test
+ public void textBodyOfMessageWithTextCalendarShouldBeConvertedToAttachment() throws Exception {
+ MimeMessage calendarMessage = MimeMessageBuilder.mimeMessageFromStream(ClassLoader.getSystemResourceAsStream("eml/calendar.eml"));
+ String fromAddress = USERNAME;
+
+ Mail mail = FakeMail.builder()
+ .mimeMessage(calendarMessage)
+ .sender(new MailAddress(fromAddress))
+ .recipient(new MailAddress(fromAddress))
+ .build();
+ try (SMTPMessageSender messageSender = SMTPMessageSender.noAuthentication(LOCALHOST_IP, SMTP_PORT, USERS_DOMAIN);) {
+ messageSender.sendMessage(mail);
+ calmlyAwait.atMost(Duration.ONE_MINUTE).until(messageSender::messageHasBeenSent);
+ }
+
+ calmlyAwait.atMost(30, TimeUnit.SECONDS).until( () -> isAnyMessageFoundInInbox(accessToken));
+
+ String message = ARGUMENTS + ".list[0]";
+ String firstAttachment = message + ".attachments[0]";
+
+ String inboxId = getMailboxId(accessToken, Role.INBOX);
+ String receivedMessageId =
+ with()
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"" + inboxId + "\"]}}, \"#0\"]]")
+ .post("/jmap")
+ .then()
+ .extract()
+ .path(ARGUMENTS + ".messageIds[0]");
+
+ given()
+ .header("Authorization", accessToken.serialize())
+ .body("[[\"getMessages\", {\"ids\": [\"" + receivedMessageId + "\"]}, \"#0\"]]")
+ .when()
+ .post("/jmap")
+ .then()
+ .statusCode(200)
+ .log().ifValidationFails()
+ .body(NAME, equalTo("messages"))
+ .body(ARGUMENTS + ".list", hasSize(1))
+ .body(message + ".attachments", hasSize(1))
+ .body(firstAttachment + ".type", equalTo("text/calendar"))
+ .body(firstAttachment + ".blobId", not(isEmptyOrNullString()));
+ }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/8aecdf03/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/calendar.eml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/calendar.eml b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/calendar.eml
new file mode 100644
index 0000000..2ae4533
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/calendar.eml
@@ -0,0 +1,42 @@
+Return-Path: <lo...@localhost.com>
+MIME-Version: 1.0
+Delivered-To: to@localhost.com
+From: User From <fr...@localhost.com>
+Message-ID: <2d...@localhost.com>
+To: User To <to...@linagora.com>
+Date: Wed, 26 Jul 2017 10:34:02 +0200
+Subject: Any subject
+Content-class: urn:content-classes:calendarmessage
+Content-Type: text/calendar; method=REPLY; charset=UTF-8
+Content-transfer-encoding: 8BIT
+
+BEGIN:VCALENDAR
+PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
+VERSION:2.0
+METHOD:REPLY
+BEGIN:VEVENT
+CREATED:20170726T081145Z
+LAST-MODIFIED:20170726T083402Z
+DTSTAMP:20170726T083402Z
+UID:f1514f44bf39311568d6407249cb76c48103fcd1fb398c3c501cb72b2d293f36e04
+ b2aab16e43439a608f28671ab7c10e754cbc85ddee4a07fa8cf8f4f7af05bfb502b8f6
+
+SUMMARY:[A CONFIRMER] Call OVH
+PRIORITY:5
+ORGANIZER;CN=User;X-OBM-ID=id:mailto:userTo@localhost.com
+ATTENDEE;CN=User;PARTSTAT=ACCEPTED;CUTYPE=INDIVIDUAL;X-OBM-ID=810:
+ mailto:user1To@linagora.com
+DTSTART:20170727T130000Z
+DURATION:PT1H
+TRANSP:OPAQUE
+SEQUENCE:2
+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:uuid_value
+LOCATION:01.78.14.42.61 / 1586
+X-OBM-ALERT;X-OBM-ID=486:600
+END:VEVENT
+END:VCALENDAR
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/8aecdf03/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
index 2522c75..dd8daa7 100644
--- a/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
+++ b/server/protocols/jmap-integration-testing/memory-jmap-integration-testing/pom.xml
@@ -35,6 +35,12 @@
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apache-mailet-base</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>james-server-dnsservice-api</artifactId>
<type>test-jar</type>
</dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/8aecdf03/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 8e66ed5..7b421ca 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
@@ -50,6 +50,7 @@
<mailet match="All" class="RemoveMimeHeader">
<name>bcc</name>
</mailet>
+ <mailet match="All" class="org.apache.james.jmap.mailet.TextCalendarBodyToAttachment"/>
<mailet match="RecipientIsLocal" class="org.apache.james.jmap.mailet.VacationMailet"/>
<mailet match="RecipientIsLocal" class="Sieve"/>
<mailet match="RecipientIsLocal" class="LocalDelivery"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[3/4] james-project git commit: JAMES-2135 text/calendar bodies
should not be displayed in textBody
Posted by ma...@apache.org.
JAMES-2135 text/calendar bodies should not be displayed in textBody
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/f4fc1393
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/f4fc1393
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/f4fc1393
Branch: refs/heads/master
Commit: f4fc1393777ae92c065a2259be3df3754a9f173e
Parents: daaa36a
Author: quynhn <qn...@linagora.com>
Authored: Fri Sep 1 14:18:22 2017 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Mon Sep 11 11:28:15 2017 +0200
----------------------------------------------------------------------
.../mailets/ICSAttachmentWorkflowTest.java | 30 ++-
.../src/test/resources/eml/calendar.eml | 42 ++++
.../mailet/TextCalendarBodyToAttachment.java | 108 +++++++++
.../TextCalendarBodyToAttachmentTest.java | 243 +++++++++++++++++++
.../jmap/src/test/resources/calendar.eml | 42 ++++
5 files changed, 462 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/f4fc1393/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java
index 6247e2e..22d68a9 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java
@@ -36,8 +36,8 @@ import org.apache.james.modules.MailboxProbeImpl;
import org.apache.james.probe.DataProbe;
import org.apache.james.transport.mailets.amqp.AmqpRule;
import org.apache.james.util.streams.SwarmGenericContainer;
-import org.apache.james.utils.IMAPMessageReader;
import org.apache.james.utils.DataProbeImpl;
+import org.apache.james.utils.IMAPMessageReader;
import org.apache.mailet.Mail;
import org.apache.james.core.MailAddress;
import org.apache.mailet.base.test.FakeMail;
@@ -76,7 +76,7 @@ public class ICSAttachmentWorkflowTest {
private static final String JSON_MAIL_ATTRIBUTE = "ical.json";
private static final String EXCHANGE_NAME = "myExchange";
private static final String ROUTING_KEY = "myRoutingKey";
-
+
private static final String ICS_UID = "f1514f44bf39311568d640727cff54e819573448d09d2e5677987ff29caa01a9e047feb2aab16e43439a608f28671ab7c10e754ce92be513f8e04ae9ff15e65a9819cf285a6962bc";
private static final String ICS_DTSTAMP = "20170106T115036Z";
private static final String ICS_SEQUENCE = "0";
@@ -161,7 +161,7 @@ public class ICSAttachmentWorkflowTest {
" S-ACTION;X-OBM-ID=769:MAILTO:nguyen@linagora.com\n" +
"END:VEVENT\n" +
"END:VCALENDAR\n";
-
+
private static final String ICS_3 = "BEGIN:VCALENDAR\n" +
"PRODID:-//Aliasource Groupe LINAGORA//OBM Calendar 3.2.1-rc2//FR\n" +
"CALSCALE:GREGORIAN\n" +
@@ -491,6 +491,10 @@ public class ICSAttachmentWorkflowTest {
.addProperty("destination", JSON_MAIL_ATTRIBUTE)
.build())
.addMailet(MailetConfiguration.builder()
+ .match("All")
+ .clazz("org.apache.james.jmap.mailet.TextCalendarBodyToAttachment")
+ .build())
+ .addMailet(MailetConfiguration.builder()
.match("All")
.clazz("AmqpForwardAttribute")
.addProperty("uri", amqpRule.getAmqpUri())
@@ -823,4 +827,24 @@ public class ICSAttachmentWorkflowTest {
assertThat(amqpRule.readContent()).isEmpty();
}
+ @Test
+ public void mailShouldNotContainCalendarContentInTextBodyButAttachment() throws Exception {
+ MimeMessage calendarMessage = MimeMessageBuilder.mimeMessageFromStream(ClassLoader.getSystemResourceAsStream("eml/calendar.eml"));
+ Mail mail = FakeMail.builder()
+ .mimeMessage(calendarMessage)
+ .sender(new MailAddress(FROM))
+ .recipient(new MailAddress(RECIPIENT))
+ .build();
+
+ try (SMTPMessageSender messageSender = SMTPMessageSender.noAuthentication(LOCALHOST_IP, SMTP_PORT, JAMES_APACHE_ORG);
+ IMAPMessageReader imapMessageReader = new IMAPMessageReader(LOCALHOST_IP, IMAP_PORT)) {
+ messageSender.sendMessage(mail);
+ calmlyAwait.atMost(Duration.ONE_MINUTE).until(messageSender::messageHasBeenSent);
+ calmlyAwait.atMost(Duration.ONE_MINUTE).until(() -> imapMessageReader.userReceivedMessage(RECIPIENT, PASSWORD));
+
+ String receivedMessage = imapMessageReader.readFirstMessageInInbox(RECIPIENT, PASSWORD);
+
+ assertThat(receivedMessage).containsSequence("Content-Type: multipart/mixed", "Content-Disposition: attachment");
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f4fc1393/server/mailet/integration-testing/src/test/resources/eml/calendar.eml
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/resources/eml/calendar.eml b/server/mailet/integration-testing/src/test/resources/eml/calendar.eml
new file mode 100644
index 0000000..2ae4533
--- /dev/null
+++ b/server/mailet/integration-testing/src/test/resources/eml/calendar.eml
@@ -0,0 +1,42 @@
+Return-Path: <lo...@localhost.com>
+MIME-Version: 1.0
+Delivered-To: to@localhost.com
+From: User From <fr...@localhost.com>
+Message-ID: <2d...@localhost.com>
+To: User To <to...@linagora.com>
+Date: Wed, 26 Jul 2017 10:34:02 +0200
+Subject: Any subject
+Content-class: urn:content-classes:calendarmessage
+Content-Type: text/calendar; method=REPLY; charset=UTF-8
+Content-transfer-encoding: 8BIT
+
+BEGIN:VCALENDAR
+PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
+VERSION:2.0
+METHOD:REPLY
+BEGIN:VEVENT
+CREATED:20170726T081145Z
+LAST-MODIFIED:20170726T083402Z
+DTSTAMP:20170726T083402Z
+UID:f1514f44bf39311568d6407249cb76c48103fcd1fb398c3c501cb72b2d293f36e04
+ b2aab16e43439a608f28671ab7c10e754cbc85ddee4a07fa8cf8f4f7af05bfb502b8f6
+
+SUMMARY:[A CONFIRMER] Call OVH
+PRIORITY:5
+ORGANIZER;CN=User;X-OBM-ID=id:mailto:userTo@localhost.com
+ATTENDEE;CN=User;PARTSTAT=ACCEPTED;CUTYPE=INDIVIDUAL;X-OBM-ID=810:
+ mailto:user1To@linagora.com
+DTSTART:20170727T130000Z
+DURATION:PT1H
+TRANSP:OPAQUE
+SEQUENCE:2
+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:uuid_value
+LOCATION:01.78.14.42.61 / 1586
+X-OBM-ALERT;X-OBM-ID=486:600
+END:VEVENT
+END:VCALENDAR
+
http://git-wip-us.apache.org/repos/asf/james-project/blob/f4fc1393/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/TextCalendarBodyToAttachment.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/TextCalendarBodyToAttachment.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/TextCalendarBodyToAttachment.java
new file mode 100644
index 0000000..e43a941
--- /dev/null
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/TextCalendarBodyToAttachment.java
@@ -0,0 +1,108 @@
+/****************************************************************
+ * 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.mailet;
+
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+
+import javax.mail.Header;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.Part;
+import javax.mail.internet.MimeBodyPart;
+import javax.mail.internet.MimeMessage;
+import javax.mail.internet.MimeMultipart;
+
+import org.apache.mailet.Mail;
+import org.apache.mailet.base.GenericMailet;
+
+import com.github.steveash.guavate.Guavate;
+import com.google.common.annotations.VisibleForTesting;
+
+/**
+ * This mailet converts Content-Type of MimeMessage from text/calendar to mulitpart/mixed
+ *
+ * The BodyPart should be retrieved from content of text/calendar with all the same "Content-*" headers from original message
+ * and those "Content-" header are removed from original message
+ *
+ * <br />
+ * It does not takes any parameter
+ *
+ * Sample configuration:
+ * <p/>
+ * <pre><code>
+ * <mailet match="All" class="TextCalendarBodyToAttachment"/>
+ * </code></pre>
+ *
+ */
+public class TextCalendarBodyToAttachment extends GenericMailet {
+ private static final String TEXT_CALENDAR_TYPE = "text/calendar";
+ private static final String CONTENT_HEADER_PREFIX = "Content-";
+
+ @Override
+ public String getMailetInfo() {
+ return "Moves body part of content type text/calendar to attachment";
+ }
+
+ @Override
+ public void service(Mail mail) throws MessagingException {
+ MimeMessage mimeMessage = mail.getMessage();
+ if (mimeMessage.isMimeType(TEXT_CALENDAR_TYPE)) {
+ processTextBodyAsAttachment(mimeMessage);
+ }
+ }
+
+ @VisibleForTesting
+ void processTextBodyAsAttachment(MimeMessage mimeMessage) throws MessagingException {
+ List<Header> contentHeaders = getContentHeadersFromMimeMessage(mimeMessage);
+
+ removeAllContentHeaderFromMimeMessage(mimeMessage, contentHeaders);
+
+ Multipart multipart = new MimeMultipart();
+ multipart.addBodyPart(createMimeBodyPartWithContentHeadersFromMimeMessage(mimeMessage, contentHeaders));
+
+ mimeMessage.setContent(multipart);
+ mimeMessage.saveChanges();
+ }
+
+ private List<Header> getContentHeadersFromMimeMessage(MimeMessage mimeMessage) throws MessagingException {
+ return Collections.list((Enumeration<Header>) mimeMessage.getAllHeaders())
+ .stream()
+ .filter(header -> header.getName().startsWith(CONTENT_HEADER_PREFIX))
+ .collect(Guavate.toImmutableList());
+ }
+
+ private MimeBodyPart createMimeBodyPartWithContentHeadersFromMimeMessage(MimeMessage mimeMessage, List<Header> contentHeaders) throws MessagingException {
+ MimeBodyPart fileBody = new MimeBodyPart(mimeMessage.getRawInputStream());
+ for (Header header : contentHeaders) {
+ fileBody.setHeader(header.getName(), header.getValue());
+ }
+
+ fileBody.setDisposition(Part.ATTACHMENT);
+ return fileBody;
+ }
+
+ private void removeAllContentHeaderFromMimeMessage(MimeMessage mimeMessage, List<Header> contentHeaders) throws MessagingException {
+ for (Header header : contentHeaders) {
+ mimeMessage.removeHeader(header.getName());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/f4fc1393/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/TextCalendarBodyToAttachmentTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/TextCalendarBodyToAttachmentTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/TextCalendarBodyToAttachmentTest.java
new file mode 100644
index 0000000..d43fe2a
--- /dev/null
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/mailet/TextCalendarBodyToAttachmentTest.java
@@ -0,0 +1,243 @@
+/****************************************************************
+ * 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.mailet;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.io.ByteArrayInputStream;
+import java.nio.charset.StandardCharsets;
+
+import javax.mail.BodyPart;
+import javax.mail.MessagingException;
+import javax.mail.Multipart;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.mailet.Mail;
+import org.apache.mailet.base.test.FakeMail;
+import org.apache.mailet.base.test.FakeMailetConfig;
+import org.apache.mailet.base.test.MimeMessageBuilder;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+public class TextCalendarBodyToAttachmentTest {
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ private TextCalendarBodyToAttachment mailet = new TextCalendarBodyToAttachment();
+
+ private MimeMessage calendarMessage;
+
+ @Before
+ public void setUp() throws Exception {
+ mailet.init(FakeMailetConfig.builder()
+ .mailetName("TextCalendarBodyToAttachment")
+ .build());
+
+ calendarMessage = MimeMessageBuilder.mimeMessageFromStream(ClassLoader.getSystemResourceAsStream("calendar.eml"));
+ }
+
+ @Test
+ public void getMailetInformationShouldReturnInformation() throws Exception {
+ assertThat(mailet.getMailetInfo()).isEqualTo("Moves body part of content type text/calendar to attachment");
+ }
+
+ @Test
+ public void serviceShouldThrowWhenCanNotGetMessageFromMail() throws Exception {
+ expectedException.expect(MessagingException.class);
+ Mail mail = mock(Mail.class);
+ when(mail.getMessage())
+ .thenThrow(MessagingException.class);
+
+ mailet.service(mail);
+ }
+
+ @Test
+ public void serviceShouldThrowWhenMessageCanNotGetContentType() throws Exception {
+ expectedException.expect(MessagingException.class);
+
+ MimeMessage message = mock(MimeMessage.class);
+ Mail mail = FakeMail.from(message);
+
+ when(message.isMimeType(anyString())).thenThrow(MessagingException.class);
+
+ mailet.service(mail);
+ }
+
+ @Test
+ public void serviceShouldKeepMessageAsItIsWhenMessageIsNotTextCalendar() throws Exception {
+ String messageContent = "Content-type: text/html; method=REPLY; charset=UTF-8\n" +
+ "Content-transfer-encoding: 8BIT\n" +
+ "\n" +
+ "BEGIN:VCALENDAR";
+ MimeMessage message = MimeMessageBuilder.mimeMessageFromStream(new ByteArrayInputStream(messageContent.getBytes(StandardCharsets.US_ASCII)));
+
+ Mail mail = FakeMail.builder()
+ .mimeMessage(message)
+ .build();
+
+ mailet.service(mail);
+
+ assertThat(mail.getMessage().isMimeType("text/html")).isTrue();
+ assertThat(mail.getMessage().getDisposition()).isNull();
+ }
+
+ @Test
+ public void serviceShouldChangeMessageContentTypeToMultipartWhenTextCalendarMessage() throws Exception {
+ String messageContent = "Content-type: text/calendar; method=REPLY; charset=UTF-8\n" +
+ "Content-transfer-encoding: 8BIT\n" +
+ "\n" +
+ "BEGIN:VCALENDAR";
+ MimeMessage message = MimeMessageBuilder.mimeMessageFromStream(new ByteArrayInputStream(messageContent.getBytes(StandardCharsets.US_ASCII)));
+
+ Mail mail = FakeMail.builder()
+ .mimeMessage(message)
+ .build();
+
+ mailet.service(mail);
+
+ assertThat(mail.getMessage().isMimeType("multipart/*")).isTrue();
+ }
+
+ @Test
+ public void serviceShouldConvertTextBodyOfMessageToAttachmentWhenTextCalendar() throws Exception {
+ String messageContent = "Content-type: text/calendar; method=REPLY; charset=UTF-8\n" +
+ "Content-transfer-encoding: 8BIT\n" +
+ "\n" +
+ "BEGIN:VCALENDAR\n" +
+ "END:VEVENT\n" +
+ "END:VCALENDAR";
+ MimeMessage message = MimeMessageBuilder.mimeMessageFromStream(new ByteArrayInputStream(messageContent.getBytes(StandardCharsets.US_ASCII)));
+
+ Mail mail = FakeMail.builder()
+ .mimeMessage(message)
+ .build();
+
+ mailet.service(mail);
+
+ MimeMessage actual = mail.getMessage();
+ Multipart multipart = (Multipart)actual.getContent();
+
+ assertThat(multipart.getCount()).isEqualTo(1);
+ assertThat(multipart.getBodyPart(0).getDisposition()).isEqualTo("attachment");
+ }
+
+ @Test
+ public void contentTypeOfAttachmentShouldBeTakenFromOriginalMessage() throws Exception {
+ Mail mail = FakeMail.builder()
+ .mimeMessage(calendarMessage)
+ .build();
+
+ mailet.service(mail);
+
+ Multipart multipart = (Multipart)mail.getMessage().getContent();
+
+ int firstBodyPartIndex = 0;
+ BodyPart firstBodyPart = multipart.getBodyPart(firstBodyPartIndex);
+ assertThat(firstBodyPart.getContentType()).isEqualTo("text/calendar; method=REPLY; charset=UTF-8");
+ }
+
+ @Test
+ public void contentTransferEncodingOfAttachmentShouldBeTakenFromOriginalMessage() throws Exception {
+ Mail mail = FakeMail.builder()
+ .mimeMessage(calendarMessage)
+ .build();
+
+ mailet.service(mail);
+
+ Multipart multipart = (Multipart)mail.getMessage().getContent();
+
+ int firstBodyPartIndex = 0;
+ BodyPart firstBodyPart = multipart.getBodyPart(firstBodyPartIndex);
+ assertThat(firstBodyPart.getHeader("Content-transfer-encoding")).containsExactly("8BIT");
+ }
+
+ @Test
+ public void contentClassOfAttachmentShouldBeTakenFromOriginalMessage() throws Exception {
+ Mail mail = FakeMail.builder()
+ .mimeMessage(calendarMessage)
+ .build();
+
+ mailet.service(mail);
+
+ Multipart multipart = (Multipart)mail.getMessage().getContent();
+
+ int firstBodyPartIndex = 0;
+ BodyPart firstBodyPart = multipart.getBodyPart(firstBodyPartIndex);
+ assertThat(firstBodyPart.getHeader("Content-class")).containsExactly("urn:content-classes:calendarmessage");
+ }
+
+ @Test
+ public void contentClassHeaderShouldBeRemoveFromOriginalMessage() throws Exception {
+ Mail mail = FakeMail.builder()
+ .mimeMessage(calendarMessage)
+ .build();
+
+ mailet.service(mail);
+
+ assertThat(mail.getMessage().getHeader("Content-class")).isNullOrEmpty();
+ }
+
+ @Test
+ public void contentDispositionHeaderShouldBeRemoveFromOriginalMessage() throws Exception {
+ String messageContent = "Content-type: text/calendar; method=REPLY; charset=UTF-8\n" +
+ "Content-Disposition: inline\n" +
+ "\n" +
+ "BEGIN:VCALENDAR\n" +
+ "END:VEVENT\n" +
+ "END:VCALENDAR";
+ MimeMessage message = MimeMessageBuilder.mimeMessageFromStream(new ByteArrayInputStream(messageContent.getBytes(StandardCharsets.US_ASCII)));
+
+ Mail mail = FakeMail.builder()
+ .mimeMessage(message)
+ .build();
+
+ mailet.service(mail);
+
+ assertThat(mail.getMessage().getHeader("Content-Disposition")).isNullOrEmpty();
+ }
+
+ @Test
+ public void contentDispositionOfAttachmentShouldBeOverwrittenWhenOriginalMessageHasContentDisposition() throws Exception {
+ String messageContent = "Content-type: text/calendar; method=REPLY; charset=UTF-8\n" +
+ "Content-Disposition: inline\n" +
+ "\n" +
+ "BEGIN:VCALENDAR\n" +
+ "END:VEVENT\n" +
+ "END:VCALENDAR";
+ MimeMessage message = MimeMessageBuilder.mimeMessageFromStream(new ByteArrayInputStream(messageContent.getBytes(StandardCharsets.US_ASCII)));
+
+ Mail mail = FakeMail.builder()
+ .mimeMessage(message)
+ .build();
+
+ mailet.service(mail);
+
+ Multipart multipart = (Multipart)mail.getMessage().getContent();
+
+ int firstBodyPartIndex = 0;
+ BodyPart firstBodyPart = multipart.getBodyPart(firstBodyPartIndex);
+ assertThat(firstBodyPart.getHeader("Content-Disposition")).containsExactly("attachment");
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/f4fc1393/server/protocols/jmap/src/test/resources/calendar.eml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/resources/calendar.eml b/server/protocols/jmap/src/test/resources/calendar.eml
new file mode 100644
index 0000000..2ae4533
--- /dev/null
+++ b/server/protocols/jmap/src/test/resources/calendar.eml
@@ -0,0 +1,42 @@
+Return-Path: <lo...@localhost.com>
+MIME-Version: 1.0
+Delivered-To: to@localhost.com
+From: User From <fr...@localhost.com>
+Message-ID: <2d...@localhost.com>
+To: User To <to...@linagora.com>
+Date: Wed, 26 Jul 2017 10:34:02 +0200
+Subject: Any subject
+Content-class: urn:content-classes:calendarmessage
+Content-Type: text/calendar; method=REPLY; charset=UTF-8
+Content-transfer-encoding: 8BIT
+
+BEGIN:VCALENDAR
+PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
+VERSION:2.0
+METHOD:REPLY
+BEGIN:VEVENT
+CREATED:20170726T081145Z
+LAST-MODIFIED:20170726T083402Z
+DTSTAMP:20170726T083402Z
+UID:f1514f44bf39311568d6407249cb76c48103fcd1fb398c3c501cb72b2d293f36e04
+ b2aab16e43439a608f28671ab7c10e754cbc85ddee4a07fa8cf8f4f7af05bfb502b8f6
+
+SUMMARY:[A CONFIRMER] Call OVH
+PRIORITY:5
+ORGANIZER;CN=User;X-OBM-ID=id:mailto:userTo@localhost.com
+ATTENDEE;CN=User;PARTSTAT=ACCEPTED;CUTYPE=INDIVIDUAL;X-OBM-ID=810:
+ mailto:user1To@linagora.com
+DTSTART:20170727T130000Z
+DURATION:PT1H
+TRANSP:OPAQUE
+SEQUENCE:2
+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:uuid_value
+LOCATION:01.78.14.42.61 / 1586
+X-OBM-ALERT;X-OBM-ID=486:600
+END:VEVENT
+END:VCALENDAR
+
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[4/4] james-project git commit: Merge branch 'JAMES-2135'
Posted by ma...@apache.org.
Merge branch 'JAMES-2135'
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/238d1c79
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/238d1c79
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/238d1c79
Branch: refs/heads/master
Commit: 238d1c7996623987e234755a813bf83dbffd3a7d
Parents: daaa36a 8aecdf0
Author: Matthieu Baechler <ma...@apache.org>
Authored: Mon Sep 11 11:29:09 2017 +0200
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Mon Sep 11 11:29:09 2017 +0200
----------------------------------------------------------------------
.../james/mailets/AddDeliveredToHeaderTest.java | 2 +-
.../mailets/CommonMailetConfigurationTest.java | 2 +-
.../RecipientRewriteTableIntegrationTest.java | 2 +-
.../org/apache/james/mailets/SieveDelivery.java | 2 +-
.../crypto/SMIMEDecryptIntegrationTest.java | 2 +-
.../crypto/SMIMESignIntegrationTest.java | 2 +-
.../james/mailets/utils/SMTPMessageSender.java | 117 ---------
.../mailets/AmqpForwardAttachmentTest.java | 2 +-
.../mailets/ICSAttachmentWorkflowTest.java | 32 ++-
.../transport/mailets/StripAttachmentTest.java | 2 +-
.../src/test/resources/eml/calendar.eml | 42 ++++
.../cassandra-jmap-integration-testing/pom.xml | 6 +
.../src/test/resources/mailetcontainer.xml | 1 +
.../jmap-integration-testing-common/pom.xml | 6 +
.../integration/SetMessagesMethodTest.java | 76 +++++-
.../src/test/resources/eml/calendar.eml | 42 ++++
.../memory-jmap-integration-testing/pom.xml | 6 +
.../src/test/resources/mailetcontainer.xml | 1 +
.../mailet/TextCalendarBodyToAttachment.java | 108 +++++++++
.../TextCalendarBodyToAttachmentTest.java | 243 +++++++++++++++++++
.../jmap/src/test/resources/calendar.eml | 42 ++++
server/testing/pom.xml | 4 +
.../apache/james/utils/SMTPMessageSender.java | 117 +++++++++
23 files changed, 719 insertions(+), 140 deletions(-)
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[2/4] james-project git commit: JAMES-2135 Move SMTPMessageSender to
server/testing then easier for using it on all testings
Posted by ma...@apache.org.
JAMES-2135 Move SMTPMessageSender to server/testing then easier for using it on all testings
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/ebad05e4
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/ebad05e4
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/ebad05e4
Branch: refs/heads/master
Commit: ebad05e45972d831230810f7abe10fd5f4c3f551
Parents: f4fc139
Author: quynhn <qn...@linagora.com>
Authored: Fri Sep 8 09:37:33 2017 +0700
Committer: Matthieu Baechler <ma...@apache.org>
Committed: Mon Sep 11 11:28:15 2017 +0200
----------------------------------------------------------------------
.../james/mailets/AddDeliveredToHeaderTest.java | 2 +-
.../mailets/CommonMailetConfigurationTest.java | 2 +-
.../RecipientRewriteTableIntegrationTest.java | 2 +-
.../org/apache/james/mailets/SieveDelivery.java | 2 +-
.../crypto/SMIMEDecryptIntegrationTest.java | 2 +-
.../crypto/SMIMESignIntegrationTest.java | 2 +-
.../james/mailets/utils/SMTPMessageSender.java | 117 -------------------
.../mailets/AmqpForwardAttachmentTest.java | 2 +-
.../mailets/ICSAttachmentWorkflowTest.java | 2 +-
.../transport/mailets/StripAttachmentTest.java | 2 +-
server/testing/pom.xml | 4 +
.../apache/james/utils/SMTPMessageSender.java | 117 +++++++++++++++++++
12 files changed, 130 insertions(+), 126 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/ebad05e4/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/AddDeliveredToHeaderTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/AddDeliveredToHeaderTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/AddDeliveredToHeaderTest.java
index be54831..1e18728 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/AddDeliveredToHeaderTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/AddDeliveredToHeaderTest.java
@@ -22,7 +22,7 @@ package org.apache.james.mailets;
import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailets.configuration.CommonProcessors;
import org.apache.james.mailets.configuration.MailetContainer;
-import org.apache.james.mailets.utils.SMTPMessageSender;
+import org.apache.james.utils.SMTPMessageSender;
import org.apache.james.modules.MailboxProbeImpl;
import org.apache.james.probe.DataProbe;
import org.apache.james.transport.mailets.AddDeliveredToHeader;
http://git-wip-us.apache.org/repos/asf/james-project/blob/ebad05e4/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java
index 989beb5..c4fc960 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/CommonMailetConfigurationTest.java
@@ -22,7 +22,7 @@ package org.apache.james.mailets;
import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailets.configuration.CommonProcessors;
import org.apache.james.mailets.configuration.MailetContainer;
-import org.apache.james.mailets.utils.SMTPMessageSender;
+import org.apache.james.utils.SMTPMessageSender;
import org.apache.james.modules.MailboxProbeImpl;
import org.apache.james.probe.DataProbe;
import org.apache.james.utils.IMAPMessageReader;
http://git-wip-us.apache.org/repos/asf/james-project/blob/ebad05e4/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
index 3b0d101..75ae12d 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/RecipientRewriteTableIntegrationTest.java
@@ -22,7 +22,7 @@ package org.apache.james.mailets;
import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailets.configuration.CommonProcessors;
import org.apache.james.mailets.configuration.MailetContainer;
-import org.apache.james.mailets.utils.SMTPMessageSender;
+import org.apache.james.utils.SMTPMessageSender;
import org.apache.james.modules.MailboxProbeImpl;
import org.apache.james.probe.DataProbe;
import org.apache.james.utils.IMAPMessageReader;
http://git-wip-us.apache.org/repos/asf/james-project/blob/ebad05e4/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SieveDelivery.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SieveDelivery.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SieveDelivery.java
index e9a0016..b80f3a9 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SieveDelivery.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/SieveDelivery.java
@@ -23,7 +23,7 @@ import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.store.probe.MailboxProbe;
import org.apache.james.mailets.configuration.CommonProcessors;
import org.apache.james.mailets.configuration.MailetContainer;
-import org.apache.james.mailets.utils.SMTPMessageSender;
+import org.apache.james.utils.SMTPMessageSender;
import org.apache.james.modules.MailboxProbeImpl;
import org.apache.james.modules.protocols.SieveProbeImpl;
import org.apache.james.probe.DataProbe;
http://git-wip-us.apache.org/repos/asf/james-project/blob/ebad05e4/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/crypto/SMIMEDecryptIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/crypto/SMIMEDecryptIntegrationTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/crypto/SMIMEDecryptIntegrationTest.java
index 75c6844..7055506 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/crypto/SMIMEDecryptIntegrationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/crypto/SMIMEDecryptIntegrationTest.java
@@ -31,7 +31,7 @@ import org.apache.james.mailets.configuration.CommonProcessors;
import org.apache.james.mailets.configuration.MailetConfiguration;
import org.apache.james.mailets.configuration.MailetContainer;
import org.apache.james.mailets.configuration.ProcessorConfiguration;
-import org.apache.james.mailets.utils.SMTPMessageSender;
+import org.apache.james.utils.SMTPMessageSender;
import org.apache.james.modules.MailboxProbeImpl;
import org.apache.james.util.date.ZonedDateTimeProvider;
import org.apache.james.utils.IMAPMessageReader;
http://git-wip-us.apache.org/repos/asf/james-project/blob/ebad05e4/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/crypto/SMIMESignIntegrationTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/crypto/SMIMESignIntegrationTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/crypto/SMIMESignIntegrationTest.java
index ecd0729..d84a28d 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/crypto/SMIMESignIntegrationTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/crypto/SMIMESignIntegrationTest.java
@@ -29,7 +29,7 @@ import org.apache.james.mailets.configuration.CommonProcessors;
import org.apache.james.mailets.configuration.MailetConfiguration;
import org.apache.james.mailets.configuration.MailetContainer;
import org.apache.james.mailets.configuration.ProcessorConfiguration;
-import org.apache.james.mailets.utils.SMTPMessageSender;
+import org.apache.james.utils.SMTPMessageSender;
import org.apache.james.modules.MailboxProbeImpl;
import org.apache.james.probe.DataProbe;
import org.apache.james.util.date.ZonedDateTimeProvider;
http://git-wip-us.apache.org/repos/asf/james-project/blob/ebad05e4/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/utils/SMTPMessageSender.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/utils/SMTPMessageSender.java b/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/utils/SMTPMessageSender.java
deleted file mode 100644
index a2475eb..0000000
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/mailets/utils/SMTPMessageSender.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************
- * 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.mailets.utils;
-
-import java.io.ByteArrayOutputStream;
-import java.io.Closeable;
-import java.io.IOException;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.spec.InvalidKeySpecException;
-
-import javax.mail.Message;
-import javax.mail.MessagingException;
-
-import org.apache.commons.net.smtp.AuthenticatingSMTPClient;
-import org.apache.commons.net.smtp.SMTPClient;
-import org.apache.mailet.Mail;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Joiner;
-import com.google.common.base.Throwables;
-
-public class SMTPMessageSender implements Closeable {
-
- public static SMTPMessageSender noAuthentication(String ip, int port, String senderDomain) throws IOException {
- SMTPClient smtpClient = new SMTPClient();
- smtpClient.connect(ip, port);
- return new SMTPMessageSender(smtpClient, senderDomain);
- }
-
- public static SMTPMessageSender authentication(String ip, int port, String senderDomain, String username, String password)
- throws NoSuchAlgorithmException, IOException, InvalidKeySpecException, InvalidKeyException {
- AuthenticatingSMTPClient smtpClient = new AuthenticatingSMTPClient();
- smtpClient.connect(ip, port);
- smtpClient.auth(AuthenticatingSMTPClient.AUTH_METHOD.PLAIN, username, password);
- return new SMTPMessageSender(smtpClient, senderDomain);
- }
-
- private final SMTPClient smtpClient;
- private final String senderDomain;
-
- private SMTPMessageSender(SMTPClient smtpClient, String senderDomain) {
- this.smtpClient = smtpClient;
- this.senderDomain = senderDomain;
- }
-
- public void sendMessage(String from, String recipient) {
- try {
- smtpClient.helo(senderDomain);
- smtpClient.setSender(from);
- smtpClient.rcpt("<" + recipient + ">");
- smtpClient.sendShortMessageData("FROM: " + from + "\r\n" +
- "subject: test\r\n" +
- "\r\n" +
- "content\r\n" +
- ".\r\n");
- } catch (IOException e) {
- throw Throwables.propagate(e);
- }
- }
-
- public void sendMessageWithHeaders(String from, String recipient, String message) {
- try {
- smtpClient.helo(senderDomain);
- smtpClient.setSender(from);
- smtpClient.rcpt("<" + recipient + ">");
- smtpClient.sendShortMessageData(message);
- } catch (IOException e) {
- throw Throwables.propagate(e);
- }
- }
-
- public void sendMessage(Mail mail) throws MessagingException {
- try {
- String from = mail.getSender().asString();
- smtpClient.helo(senderDomain);
- smtpClient.setSender(from);
- smtpClient.rcpt("<" + Joiner.on(", ").join(mail.getRecipients()) + ">");
- smtpClient.sendShortMessageData(asString(mail.getMessage()));
- } catch (IOException e) {
- throw Throwables.propagate(e);
- }
- }
-
- private String asString(Message message) throws IOException, MessagingException {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- message.writeTo(outputStream);
- return new String(outputStream.toByteArray(), Charsets.UTF_8);
- }
-
- public boolean messageHasBeenSent() throws IOException {
- return smtpClient.getReplyString()
- .contains("250 2.6.0 Message received");
- }
-
- @Override
- public void close() throws IOException {
- smtpClient.disconnect();
- }
-}
http://git-wip-us.apache.org/repos/asf/james-project/blob/ebad05e4/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttachmentTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttachmentTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttachmentTest.java
index 47f71c4..db43632 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttachmentTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/AmqpForwardAttachmentTest.java
@@ -29,7 +29,7 @@ import org.apache.james.mailets.configuration.CommonProcessors;
import org.apache.james.mailets.configuration.MailetConfiguration;
import org.apache.james.mailets.configuration.MailetContainer;
import org.apache.james.mailets.configuration.ProcessorConfiguration;
-import org.apache.james.mailets.utils.SMTPMessageSender;
+import org.apache.james.utils.SMTPMessageSender;
import org.apache.james.modules.MailboxProbeImpl;
import org.apache.james.probe.DataProbe;
import org.apache.james.transport.mailets.amqp.AmqpRule;
http://git-wip-us.apache.org/repos/asf/james-project/blob/ebad05e4/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java
index 22d68a9..5c6e777 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/ICSAttachmentWorkflowTest.java
@@ -31,7 +31,7 @@ import org.apache.james.mailets.configuration.CommonProcessors;
import org.apache.james.mailets.configuration.MailetConfiguration;
import org.apache.james.mailets.configuration.MailetContainer;
import org.apache.james.mailets.configuration.ProcessorConfiguration;
-import org.apache.james.mailets.utils.SMTPMessageSender;
+import org.apache.james.utils.SMTPMessageSender;
import org.apache.james.modules.MailboxProbeImpl;
import org.apache.james.probe.DataProbe;
import org.apache.james.transport.mailets.amqp.AmqpRule;
http://git-wip-us.apache.org/repos/asf/james-project/blob/ebad05e4/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
----------------------------------------------------------------------
diff --git a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
index bb24326..24a3ecb 100644
--- a/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
+++ b/server/mailet/integration-testing/src/test/java/org/apache/james/transport/mailets/StripAttachmentTest.java
@@ -29,7 +29,7 @@ import org.apache.james.mailets.configuration.CommonProcessors;
import org.apache.james.mailets.configuration.MailetConfiguration;
import org.apache.james.mailets.configuration.MailetContainer;
import org.apache.james.mailets.configuration.ProcessorConfiguration;
-import org.apache.james.mailets.utils.SMTPMessageSender;
+import org.apache.james.utils.SMTPMessageSender;
import org.apache.james.modules.MailboxProbeImpl;
import org.apache.james.probe.DataProbe;
import org.apache.james.utils.IMAPMessageReader;
http://git-wip-us.apache.org/repos/asf/james-project/blob/ebad05e4/server/testing/pom.xml
----------------------------------------------------------------------
diff --git a/server/testing/pom.xml b/server/testing/pom.xml
index 3836069..069fab8 100644
--- a/server/testing/pom.xml
+++ b/server/testing/pom.xml
@@ -32,6 +32,10 @@
<dependencies>
<dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>apache-mailet-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/ebad05e4/server/testing/src/main/java/org/apache/james/utils/SMTPMessageSender.java
----------------------------------------------------------------------
diff --git a/server/testing/src/main/java/org/apache/james/utils/SMTPMessageSender.java b/server/testing/src/main/java/org/apache/james/utils/SMTPMessageSender.java
new file mode 100644
index 0000000..2a0e5fc
--- /dev/null
+++ b/server/testing/src/main/java/org/apache/james/utils/SMTPMessageSender.java
@@ -0,0 +1,117 @@
+/****************************************************************
+ * 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.utils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.Closeable;
+import java.io.IOException;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.spec.InvalidKeySpecException;
+
+import javax.mail.Message;
+import javax.mail.MessagingException;
+
+import org.apache.commons.net.smtp.AuthenticatingSMTPClient;
+import org.apache.commons.net.smtp.SMTPClient;
+import org.apache.mailet.Mail;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Joiner;
+import com.google.common.base.Throwables;
+
+public class SMTPMessageSender implements Closeable {
+
+ public static SMTPMessageSender noAuthentication(String ip, int port, String senderDomain) throws IOException {
+ SMTPClient smtpClient = new SMTPClient();
+ smtpClient.connect(ip, port);
+ return new SMTPMessageSender(smtpClient, senderDomain);
+ }
+
+ public static SMTPMessageSender authentication(String ip, int port, String senderDomain, String username, String password)
+ throws NoSuchAlgorithmException, IOException, InvalidKeySpecException, InvalidKeyException {
+ AuthenticatingSMTPClient smtpClient = new AuthenticatingSMTPClient();
+ smtpClient.connect(ip, port);
+ smtpClient.auth(AuthenticatingSMTPClient.AUTH_METHOD.PLAIN, username, password);
+ return new SMTPMessageSender(smtpClient, senderDomain);
+ }
+
+ private final SMTPClient smtpClient;
+ private final String senderDomain;
+
+ private SMTPMessageSender(SMTPClient smtpClient, String senderDomain) {
+ this.smtpClient = smtpClient;
+ this.senderDomain = senderDomain;
+ }
+
+ public void sendMessage(String from, String recipient) {
+ try {
+ smtpClient.helo(senderDomain);
+ smtpClient.setSender(from);
+ smtpClient.rcpt("<" + recipient + ">");
+ smtpClient.sendShortMessageData("FROM: " + from + "\r\n" +
+ "subject: test\r\n" +
+ "\r\n" +
+ "content\r\n" +
+ ".\r\n");
+ } catch (IOException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ public void sendMessageWithHeaders(String from, String recipient, String message) {
+ try {
+ smtpClient.helo(senderDomain);
+ smtpClient.setSender(from);
+ smtpClient.rcpt("<" + recipient + ">");
+ smtpClient.sendShortMessageData(message);
+ } catch (IOException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ public void sendMessage(Mail mail) throws MessagingException {
+ try {
+ String from = mail.getSender().asString();
+ smtpClient.helo(senderDomain);
+ smtpClient.setSender(from);
+ smtpClient.rcpt("<" + Joiner.on(", ").join(mail.getRecipients()) + ">");
+ smtpClient.sendShortMessageData(asString(mail.getMessage()));
+ } catch (IOException e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ private String asString(Message message) throws IOException, MessagingException {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ message.writeTo(outputStream);
+ return new String(outputStream.toByteArray(), Charsets.UTF_8);
+ }
+
+ public boolean messageHasBeenSent() throws IOException {
+ return smtpClient.getReplyString()
+ .contains("250 2.6.0 Message received");
+ }
+
+ @Override
+ public void close() throws IOException {
+ smtpClient.disconnect();
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org