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 bt...@apache.org on 2017/06/06 08:28:50 UTC
[1/6] james-project git commit: fixup! JAMES-2039 Add integration
testing for mail's preview with ISO-8859-1 encoding
Repository: james-project
Updated Branches:
refs/heads/master 747e67154 -> ffd836d54
fixup! JAMES-2039 Add integration testing for mail's preview with ISO-8859-1 encoding
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/dea0525f
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/dea0525f
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/dea0525f
Branch: refs/heads/master
Commit: dea0525f9d7d5e3a507e243f195e896a239ed99d
Parents: dbf21a1
Author: quynhn <qn...@linagora.com>
Authored: Mon Jun 5 15:14:46 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 6 15:27:26 2017 +0700
----------------------------------------------------------------------
.../cucumber/GetMessagesMethodStepdefs.java | 17 ++++----
.../test/resources/cucumber/GetMessages.feature | 13 +++---
.../src/test/resources/eml/iso8859_1charset.eml | 43 --------------------
3 files changed, 17 insertions(+), 56 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/dea0525f/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 357e8ae..107eaf3 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
@@ -122,6 +122,12 @@ public class GetMessagesMethodStepdefs {
messageIdsByName.put(messageName, id);
}
+ @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)));
+ messageIdsByName.put(messageName, id);
+ }
+
@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 {
MessageId id = appendMessage(mailbox, ContentType.noContentType(), subject, content, Optional.of(headers.asMap(String.class, String.class)));
@@ -235,11 +241,6 @@ public class GetMessagesMethodStepdefs {
appendMessage(messageName, "eml/htmlWithLongAndComplicatedContent.eml");
}
- @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with iso charset")
- public void appendMessageWithEncoding(String messageName, String mailbox) throws Exception {
- appendMessage(messageName, "eml/iso8859_1charset.eml");
- }
-
private void appendMessage(String messageName, String emlFileName) throws Exception {
ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
MessageId id = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).appendMessage(userStepdefs.lastConnectedUser,
@@ -491,10 +492,10 @@ public class GetMessagesMethodStepdefs {
assertAttachment(SECOND_ATTACHMENT, attachmentProperties);
}
- @Then("^the preview of the message contains:$")
- public void assertPreviewOfMessageShouldBePrintedWithEncoding(DataTable preview) throws Exception {
+ @Then("^the preview of the message contains: (.*)$")
+ public void assertPreviewOfMessageShouldBePrintedWithEncoding(List<String> preview) throws Exception {
String actual = jsonPath.<String>read(FIRST_MESSAGE + ".preview");
- assertThat(actual).contains(preview.asList(String.class));
+ assertThat(actual).contains(preview);
}
private void assertAttachment(String attachment, DataTable attachmentProperties) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/dea0525f/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 23f8221..a0c4104 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
@@ -294,11 +294,14 @@ Feature: GetMessages method
And the preview of the message is not empty
And the preview should not contain consecutive spaces or blank characters
- Scenario: Preview should display printable characters with iso charset
- Given the user has a message "m1" in "INBOX" mailbox with iso charset
+ 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
+ |Content-Transfer-Encoding |<tranfer-encoding> |
When the user 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 of the message contains:
- |effectué|à|signée dès|
+ And the preview of the message contains: <preview>
+
+ Examples:
+ |content-type |tranfer-encoding |content |preview |
+ |"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 |
http://git-wip-us.apache.org/repos/asf/james-project/blob/dea0525f/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/iso8859_1charset.eml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/iso8859_1charset.eml b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/iso8859_1charset.eml
deleted file mode 100644
index ed84e9e..0000000
--- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/iso8859_1charset.eml
+++ /dev/null
@@ -1,43 +0,0 @@
-Return-Path: <te...@local>
-Received: from local
-From: Test <te...@local>
-To: "Testee" <te...@local>
-Subject: Any subject
-Date: Tue, 30 May 2017 10:06:35 +0000
-Message-ID: <2a...@test.local>
-Accept-Language: fr-FR, en-US
-Content-Language: fr-FR
-X-MS-Has-Attach: yes
-X-MS-TNEF-Correlator:
-x-ms-exchange-transport-fromentityheader: Hosted
-x-originating-ip: [10.11.40.174]
-Content-Type: multipart/mixed;
- boundary="_006_2a338825f11d475bb97e82f064a41119MBXCMC02resslocal_"
-MIME-Version: 1.0
-
---_006_2a338825f11d475bb97e82f064a41119MBXCMC02resslocal_
-Content-Type: multipart/related;
- boundary="_005_2a338825f11d475bb97e82f064a41119MBXCMC02resslocal_";
- type="multipart/alternative"
-
---_005_2a338825f11d475bb97e82f064a41119MBXCMC02resslocal_
-Content-Type: multipart/alternative;
- boundary="_000_2a338825f11d475bb97e82f064a41119MBXCMC02resslocal_"
-
---_000_2a338825f11d475bb97e82f064a41119MBXCMC02resslocal_
-Content-Type: text/plain; charset="iso-8859-1"
-Content-Transfer-Encoding: quoted-printable
-
-Bonjour,
-
-Dans le cadre du stage effectu=E9 par ... 201=7, ... =E0= ... sign=E9e d=E8s que possible.
-
---_000_2a338825f11d475bb97e82f064a41119MBXCMC02resslocal_
-Content-Type: text/html; charset="iso-8859-1"
-Content-Transfer-Encoding: quoted-printable
-
-Bonjour,
-
-Dans le cadre du stage effectu=E9 par ... 201=7, ... =E0= ... sign=E9e d=E8s que possible.
-
---_000_2a338825f11d475bb97e82f064a41119MBXCMC02resslocal_--
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[4/6] james-project git commit: JAMES-2043 UsersRepository should
indicate if it is read-only
Posted by bt...@apache.org.
JAMES-2043 UsersRepository should indicate if it is read-only
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/8e9d7bea
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/8e9d7bea
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/8e9d7bea
Branch: refs/heads/master
Commit: 8e9d7beaf19aceec2464795df0d11ad722d34dbe
Parents: dea0525
Author: benwa <bt...@linagora.com>
Authored: Fri Jun 2 11:50:49 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 6 15:27:57 2017 +0700
----------------------------------------------------------------------
.../main/java/org/apache/james/user/api/UsersRepository.java | 6 ++++++
.../apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java | 5 +++++
.../org/apache/james/user/lib/AbstractUsersRepository.java | 5 +++++
3 files changed, 16 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/8e9d7bea/server/data/data-api/src/main/java/org/apache/james/user/api/UsersRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-api/src/main/java/org/apache/james/user/api/UsersRepository.java b/server/data/data-api/src/main/java/org/apache/james/user/api/UsersRepository.java
index ea02cc3..038fd30 100644
--- a/server/data/data-api/src/main/java/org/apache/james/user/api/UsersRepository.java
+++ b/server/data/data-api/src/main/java/org/apache/james/user/api/UsersRepository.java
@@ -142,4 +142,10 @@ public interface UsersRepository {
*/
boolean isAdministrator(String username) throws UsersRepositoryException;
+ /**
+ * @return true if one can use {@link UsersRepository#updateUser(User)} {@link UsersRepository#addUser(String, String)}
+ * {@link UsersRepository#removeUser(String)} and false overwhise
+ */
+ boolean isReadOnly();
+
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/8e9d7bea/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java b/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
index e91ede4..e2007cb 100644
--- a/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
+++ b/server/data/data-ldap/src/main/java/org/apache/james/user/ldap/ReadOnlyUsersLDAPRepository.java
@@ -818,4 +818,9 @@ public class ReadOnlyUsersLDAPRepository implements UsersRepository, Configurabl
}
return false;
}
+
+ @Override
+ public boolean isReadOnly() {
+ return true;
+ }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/8e9d7bea/server/data/data-library/src/main/java/org/apache/james/user/lib/AbstractUsersRepository.java
----------------------------------------------------------------------
diff --git a/server/data/data-library/src/main/java/org/apache/james/user/lib/AbstractUsersRepository.java b/server/data/data-library/src/main/java/org/apache/james/user/lib/AbstractUsersRepository.java
index f0651fe..bd9a9d2 100644
--- a/server/data/data-library/src/main/java/org/apache/james/user/lib/AbstractUsersRepository.java
+++ b/server/data/data-library/src/main/java/org/apache/james/user/lib/AbstractUsersRepository.java
@@ -159,4 +159,9 @@ public abstract class AbstractUsersRepository implements UsersRepository, LogEna
}
return false;
}
+
+ @Override
+ public boolean isReadOnly() {
+ return false;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[6/6] james-project git commit: JAMES-2043 No mailbox exception was
thrown in UserProvisioningFilter
Posted by bt...@apache.org.
JAMES-2043 No mailbox exception was thrown in UserProvisioningFilter
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/ffd836d5
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/ffd836d5
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/ffd836d5
Branch: refs/heads/master
Commit: ffd836d54fb457ec9351c03b4224b2e4c68faa96
Parents: c05b38f
Author: benwa <bt...@linagora.com>
Authored: Fri Jun 2 12:02:01 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 6 15:28:16 2017 +0700
----------------------------------------------------------------------
.../apache/james/jmap/UserProvisioningFilter.java | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/ffd836d5/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
index 04bee42..6857479 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
@@ -33,8 +33,6 @@ import javax.servlet.ServletResponse;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MailboxSession.User;
-import org.apache.james.mailbox.exception.BadCredentialsException;
-import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.metrics.api.MetricFactory;
import org.apache.james.metrics.api.TimeMetric;
import org.apache.james.user.api.AlreadyExistInUsersRepositoryException;
@@ -79,13 +77,17 @@ public class UserProvisioningFilter implements Filter {
}
} catch (AlreadyExistInUsersRepositoryException e) {
// Ignore
- } catch (UsersRepositoryException|MailboxException e) {
+ } catch (UsersRepositoryException e) {
throw Throwables.propagate(e);
} finally {
timeMetric.stopAndPublish();
}
}
+ private void createAccount(User user) throws UsersRepositoryException {
+ usersRepository.addUser(getUsername(user), generatePassword());
+ }
+
private boolean needsAccountCreation(User user) throws UsersRepositoryException {
return !usersRepository.contains(getUsername(user));
}
@@ -97,14 +99,6 @@ public class UserProvisioningFilter implements Filter {
return user.getUserName();
}
}
-
- private void createAccount(User user) throws UsersRepositoryException, BadCredentialsException, MailboxException {
- createUser(user);
- }
-
- private void createUser(User user) throws UsersRepositoryException {
- usersRepository.addUser(getUsername(user), generatePassword());
- }
private String generatePassword() {
return UUID.randomUUID().toString();
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[3/6] james-project git commit: JAMES-2039 The IT testing methods
should throws Exception instead of Throwable
Posted by bt...@apache.org.
JAMES-2039 The IT testing methods should throws Exception instead of Throwable
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/dbf21a1e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/dbf21a1e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/dbf21a1e
Branch: refs/heads/master
Commit: dbf21a1e9971ad41b820caf66c23022b20b1b1bd
Parents: 2c85e94
Author: quynhn <qn...@linagora.com>
Authored: Mon Jun 5 10:48:45 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 6 15:27:26 2017 +0700
----------------------------------------------------------------------
.../cucumber/GetMessagesMethodStepdefs.java | 100 +++++++++----------
1 file changed, 50 insertions(+), 50 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/dbf21a1e/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 29af204..357e8ae 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
@@ -101,7 +101,7 @@ 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 Throwable {
+ 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.jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox1).getMailboxId();
MailboxId mailboxId2 = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).getMailbox(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox2).getMailboxId();
@@ -111,25 +111,25 @@ public class GetMessagesMethodStepdefs {
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with subject \"([^\"]*)\", content \"([^\"]*)\"$")
- public void appendMessage(String messageName, String mailbox, String subject, String content) throws Throwable {
+ 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("^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 Throwable {
+ public void appendMessage(String messageName, String mailbox, String contentType, String subject, String content) throws Exception {
MessageId id = appendMessage(mailbox, ContentType.from(contentType), subject, content, NO_HEADERS);
messageIdsByName.put(messageName, id);
}
@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 Throwable {
+ public void appendMessage(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("^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 Throwable {
+ public void appendMessageFromFileInlinedMultipart(String messageName, String mailbox) throws Exception {
ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
MessageId id = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).appendMessage(userStepdefs.lastConnectedUser,
new MailboxPath(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, mailbox),
@@ -166,77 +166,77 @@ public class GetMessagesMethodStepdefs {
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with two attachments$")
- public void appendHtmlMessageWithTwoAttachments(String messageName, String mailbox) throws Throwable {
+ public void appendHtmlMessageWithTwoAttachments(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/twoAttachments.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with two attachments in text$")
- public void appendTextMessageWithTwoAttachments(String messageName, String mailbox) throws Throwable {
+ public void appendTextMessageWithTwoAttachments(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/twoAttachmentsTextPlain.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with two same attachments in text$")
- public void appendTextMessageWithTwoSameAttachments(String messageName, String mailbox) throws Throwable {
+ public void appendTextMessageWithTwoSameAttachments(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/twoSameAttachments.eml");
}
@Given("^the user has a multipart message \"([^\"]*)\" in \"([^\"]*)\" mailbox$")
- public void appendMultipartMessageWithOneAttachments(String messageName, String arg1) throws Throwable {
+ public void appendMultipartMessageWithOneAttachments(String messageName, String arg1) throws Exception {
appendMessage(messageName, "eml/htmlAndTextMultipartWithOneAttachment.eml");
}
@Given("^the user has a multipart/related message \"([^\"]*)\" in \"([^\"]*)\" mailbox$")
- public void appendMultipartRelated(String messageName, String mailbox) throws Throwable {
+ public void appendMultipartRelated(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/multipartRelated.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox beginning by a long line$")
- public void appendMessageBeginningByALongLine(String messageName, String mailbox) throws Throwable {
+ public void appendMessageBeginningByALongLine(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/longLine.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with plain/text inline attachment$")
- public void appendMessageWithPlainTextInlineAttachment(String messageName, String mailbox) throws Throwable {
+ public void appendMessageWithPlainTextInlineAttachment(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/embeddedMultipartWithInlineTextAttachment.eml");
}
@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 Throwable {
+ public void appendMessageWithTextInMainMultipartAndHtmlInInnerMultipart(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/textInMainMultipartHtmlInInnerMultipart.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with html body and no text body$")
- public void appendMessageWithNoTextButHtml(String messageName, String mailbox) throws Throwable {
+ public void appendMessageWithNoTextButHtml(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/noTextBodyButHtmlBody.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with inline attachment but no CID$")
- public void appendMessageWithInlineAttachmentButNoCid(String messageName, String mailbox) throws Throwable {
+ public void appendMessageWithInlineAttachmentButNoCid(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/mailWithInlinedAttachmentButNoCid.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with HTML body with many empty tags$")
- public void appendMessageWithNoPreview(String messageName, String mailbox) throws Throwable {
+ public void appendMessageWithNoPreview(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/htmlBodyWithManyEmptyTags.eml");
}
@Given("^the user has a message \"([^\"]*)\" in the \"([^\"]*)\" mailbox with multiple same inlined attachments \"([^\"]*)\"$")
- public void appendMessageWithSameInlinedAttachmentsToMailbox(String messageName, String mailbox, String attachmentId) throws Throwable {
+ public void appendMessageWithSameInlinedAttachmentsToMailbox(String messageName, String mailbox, String attachmentId) throws Exception {
appendMessage(messageName, "eml/sameInlinedImages.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with specific charset$")
- public void appendMessageWithSpecificCharset(String messageName, String mailbox) throws Throwable {
+ public void appendMessageWithSpecificCharset(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/windows1252charset.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with long and complicated HTML content$")
- public void appendMessageWithSpecialCase(String messageName, String mailbox) throws Throwable {
+ public void appendMessageWithSpecialCase(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/htmlWithLongAndComplicatedContent.eml");
}
@Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with iso charset")
- public void appendMessageWithEncoding(String messageName, String mailbox) throws Throwable {
+ public void appendMessageWithEncoding(String messageName, String mailbox) throws Exception {
appendMessage(messageName, "eml/iso8859_1charset.eml");
}
@@ -266,12 +266,12 @@ public class GetMessagesMethodStepdefs {
}
@When("^the user ask for messages$")
- public void post() throws Throwable {
+ public void post() throws Exception {
post("[[\"getMessages\", {\"ids\": []}, \"#0\"]]");
}
@When("^the user ask for messages \"(.*?)\"$")
- public void postWithAListOfIds(List<String> ids) throws Throwable {
+ public void postWithAListOfIds(List<String> ids) throws Exception {
requestedMessageIds = ids.stream()
.map(messageIdsByName::get)
.collect(Guavate.toImmutableList());
@@ -279,7 +279,7 @@ public class GetMessagesMethodStepdefs {
}
@When("^the user ask for an unknown message$")
- public void requestUnknownMessage() throws Throwable {
+ public void requestUnknownMessage() throws Exception {
askMessages(ImmutableList.of(mainStepdefs.messageIdFactory.generate()));
}
@@ -297,7 +297,7 @@ public class GetMessagesMethodStepdefs {
}
@When("^the user is getting messages \"(.*?)\" with properties \"(.*?)\"$")
- public void postWithParameters(List<String> ids, List<String> properties) throws Throwable {
+ public void postWithParameters(List<String> ids, List<String> properties) throws Exception {
requestedMessageIds = ids.stream()
.map(messageIdsByName::get)
.collect(Guavate.toImmutableList());
@@ -333,14 +333,14 @@ public class GetMessagesMethodStepdefs {
}
@Then("^an error \"([^\"]*)\" is returned$")
- public void error(String type) throws Throwable {
+ public void error(String type) throws Exception {
assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
assertThat(jsonPath.<String>read(NAME)).isEqualTo("error");
assertThat(jsonPath.<String>read(ARGUMENTS + ".type")).isEqualTo(type);
}
@Then("^no error is returned$")
- public void noError() throws Throwable {
+ public void noError() throws Exception {
assertThat(response.getStatusLine().getStatusCode()).isEqualTo(200);
assertThat(jsonPath.<String>read(NAME)).isEqualTo("messages");
}
@@ -356,35 +356,35 @@ public class GetMessagesMethodStepdefs {
}
@Then("^the description is \"(.*?)\"$")
- public void assertDescription(String description) throws Throwable {
+ public void assertDescription(String description) throws Exception {
assertThat(jsonPath.<String>read(ARGUMENTS + ".description")).isEqualTo(description);
}
@Then("^the notFound list should contain \"([^\"]*)\"$")
- public void assertNotFoundListContains(String ids) throws Throwable {
+ public void assertNotFoundListContains(String ids) throws Exception {
assertThat(jsonPath.<List<String>>read(ARGUMENTS + ".notFound")).contains(ids);
}
@Then("^the notFound list should contain the requested message id$")
- public void assertNotFoundListContainsRequestedMessages() throws Throwable {
+ public void assertNotFoundListContainsRequestedMessages() throws Exception {
ImmutableList<String> elements = requestedMessageIds.stream().map(MessageId::serialize).collect(Guavate.toImmutableList());
assertThat(jsonPath.<List<String>>read(ARGUMENTS + ".notFound")).containsExactlyElementsOf(elements);
}
@Then("^the list should contain (\\d+) message$")
- public void assertListContains(int numberOfMessages) throws Throwable {
+ public void assertListContains(int numberOfMessages) throws Exception {
assertThat(jsonPath.<List<String>>read(ARGUMENTS + ".list")).hasSize(numberOfMessages);
}
@Then("^the id of the message is \"([^\"]*)\"$")
- public void assertIdOfTheFirstMessage(String messageName) throws Throwable {
+ public void assertIdOfTheFirstMessage(String messageName) throws Exception {
MessageId id = messageIdsByName.get(messageName);
assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".id")).isEqualTo(id.serialize());
}
@Then("^the message is in \"([^\"]*)\" mailboxes")
- public void assertMailboxIdsOfTheFirstMessage(String mailboxIds) throws Throwable {
+ public void assertMailboxIdsOfTheFirstMessage(String mailboxIds) throws Exception {
List<String> values = Splitter.on(",")
.splitToList(mailboxIds).stream()
.map(Throwing.function(name -> mainStepdefs.jmapServer
@@ -400,45 +400,45 @@ public class GetMessagesMethodStepdefs {
}
@Then("^the threadId of the message is \"([^\"]*)\"$")
- public void assertThreadIdOfTheFirstMessage(String threadId) throws Throwable {
+ public void assertThreadIdOfTheFirstMessage(String threadId) throws Exception {
MessageId id = messageIdsByName.get(threadId);
assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".threadId")).isEqualTo(id.serialize());
}
@Then("^the subject of the message is \"([^\"]*)\"$")
- public void assertSubjectOfTheFirstMessage(String subject) throws Throwable {
+ public void assertSubjectOfTheFirstMessage(String subject) throws Exception {
assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".subject")).isEqualTo(subject);
}
@Then("^the textBody of the message is \"([^\"]*)\"$")
- public void assertTextBodyOfTheFirstMessage(String textBody) throws Throwable {
+ public void assertTextBodyOfTheFirstMessage(String textBody) throws Exception {
assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".textBody")).isEqualTo(StringEscapeUtils.unescapeJava(textBody));
}
@Then("^the htmlBody of the message is \"([^\"]*)\"$")
- public void assertHtmlBodyOfTheFirstMessage(String htmlBody) throws Throwable {
+ public void assertHtmlBodyOfTheFirstMessage(String htmlBody) throws Exception {
assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".htmlBody")).isEqualTo(StringEscapeUtils.unescapeJava(htmlBody));
}
@Then("^the isUnread of the message is \"([^\"]*)\"$")
- public void assertIsUnreadOfTheFirstMessage(String isUnread) throws Throwable {
+ public void assertIsUnreadOfTheFirstMessage(String isUnread) throws Exception {
assertThat(jsonPath.<Boolean>read(FIRST_MESSAGE + ".isUnread")).isEqualTo(Boolean.valueOf(isUnread));
}
@Then("^the preview of the message is \"([^\"]*)\"$")
- public void assertPreviewOfTheFirstMessage(String preview) throws Throwable {
+ public void assertPreviewOfTheFirstMessage(String preview) throws Exception {
String actual = jsonPath.<String>read(FIRST_MESSAGE + ".preview").replace("\n", " ");
assertThat(actual).isEqualToIgnoringWhitespace(StringEscapeUtils.unescapeJava(preview));
}
@Then("^the preview of the message is not empty$")
- public void assertPreviewOfTheFirstMessageIsNotEmpty() throws Throwable {
+ public void assertPreviewOfTheFirstMessageIsNotEmpty() throws Exception {
String actual = jsonPath.<String>read(FIRST_MESSAGE + ".preview");
assertThat(actual).isNotEmpty();
}
@Then("^the preview should not contain consecutive spaces or blank characters$")
- public void assertPreviewShouldBeNormalized() throws Throwable {
+ public void assertPreviewShouldBeNormalized() throws Exception {
String actual = jsonPath.<String>read(FIRST_MESSAGE + ".preview");
assertThat(actual).hasSize(MessagePreviewGenerator.MAX_PREVIEW_LENGTH)
.doesNotMatch(" ")
@@ -447,52 +447,52 @@ public class GetMessagesMethodStepdefs {
}
@Then("^the headers of the message contains:$")
- public void assertHeadersOfTheFirstMessage(DataTable headers) throws Throwable {
+ public void assertHeadersOfTheFirstMessage(DataTable headers) throws Exception {
assertThat(jsonPath.<Map<String, String>>read(FIRST_MESSAGE + ".headers")).containsAllEntriesOf(headers.asMap(String.class, String.class));
}
@Then("^the date of the message is \"([^\"]*)\"$")
- public void assertDateOfTheFirstMessage(String date) throws Throwable {
+ public void assertDateOfTheFirstMessage(String date) throws Exception {
assertThat(jsonPath.<String>read(FIRST_MESSAGE + ".date")).isEqualTo(date);
}
@Then("^the hasAttachment of the message is \"([^\"]*)\"$")
- public void assertHasAttachmentOfTheFirstMessage(String hasAttachment) throws Throwable {
+ public void assertHasAttachmentOfTheFirstMessage(String hasAttachment) throws Exception {
assertThat(jsonPath.<Boolean>read(FIRST_MESSAGE + ".hasAttachment")).isEqualTo(Boolean.valueOf(hasAttachment));
}
@Then("^the list of attachments of the message is empty$")
- public void assertAttachmentsOfTheFirstMessageIsEmpty() throws Throwable {
+ public void assertAttachmentsOfTheFirstMessageIsEmpty() throws Exception {
assertThat(jsonPath.<List<Object>>read(ATTACHMENTS)).isEmpty();
}
@Then("^the property \"([^\"]*)\" of the message is null$")
- public void assertPropertyIsNull(String property) throws Throwable {
+ public void assertPropertyIsNull(String property) throws Exception {
assertThat(jsonPath.<String>read(FIRST_MESSAGE + "." + property + ".date")).isNull();
}
@Then("^the list of attachments of the message contains (\\d+) attachments?$")
- public void assertAttachmentsHasSize(int numberOfAttachments) throws Throwable {
+ public void assertAttachmentsHasSize(int numberOfAttachments) throws Exception {
assertThat(jsonPath.<List<Object>>read(ATTACHMENTS)).hasSize(numberOfAttachments);
}
@Then("^the list of attachments of the message contains only one attachment with cid \"([^\"]*)\"?$")
- public void assertAttachmentsAndItsCid(String cid) throws Throwable {
+ public void assertAttachmentsAndItsCid(String cid) throws Exception {
assertThat(jsonPath.<String>read(FIRST_ATTACHMENT + ".cid")).isEqualTo(cid);
}
@Then("^the first attachment is:$")
- public void assertFirstAttachment(DataTable attachmentProperties) throws Throwable {
+ public void assertFirstAttachment(DataTable attachmentProperties) throws Exception {
assertAttachment(FIRST_ATTACHMENT, attachmentProperties);
}
@Then("^the second attachment is:$")
- public void assertSecondAttachment(DataTable attachmentProperties) throws Throwable {
+ public void assertSecondAttachment(DataTable attachmentProperties) throws Exception {
assertAttachment(SECOND_ATTACHMENT, attachmentProperties);
}
@Then("^the preview of the message contains:$")
- public void assertPreviewOfMessageShouldBePrintedWithEncoding(DataTable preview) throws Throwable {
+ public void assertPreviewOfMessageShouldBePrintedWithEncoding(DataTable preview) throws Exception {
String actual = jsonPath.<String>read(FIRST_MESSAGE + ".preview");
assertThat(actual).contains(preview.asList(String.class));
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[2/6] james-project git commit: JAMES-2039 Add integration testing
for mail's preview with ISO-8859-1 encoding
Posted by bt...@apache.org.
JAMES-2039 Add integration testing for mail's preview with ISO-8859-1 encoding
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/2c85e949
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/2c85e949
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/2c85e949
Branch: refs/heads/master
Commit: 2c85e949f35df1e6bc31cbc9f2a1e9a52a379602
Parents: 747e671
Author: quynhn <qn...@linagora.com>
Authored: Wed May 31 15:34:59 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 6 15:27:26 2017 +0700
----------------------------------------------------------------------
.../cucumber/GetMessagesMethodStepdefs.java | 11 +++++
.../test/resources/cucumber/GetMessages.feature | 9 ++++
.../src/test/resources/eml/iso8859_1charset.eml | 43 ++++++++++++++++++++
3 files changed, 63 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/2c85e949/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 bde6f87..29af204 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
@@ -235,6 +235,11 @@ public class GetMessagesMethodStepdefs {
appendMessage(messageName, "eml/htmlWithLongAndComplicatedContent.eml");
}
+ @Given("^the user has a message \"([^\"]*)\" in \"([^\"]*)\" mailbox with iso charset")
+ public void appendMessageWithEncoding(String messageName, String mailbox) throws Throwable {
+ appendMessage(messageName, "eml/iso8859_1charset.eml");
+ }
+
private void appendMessage(String messageName, String emlFileName) throws Exception {
ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z");
MessageId id = mainStepdefs.jmapServer.getProbe(MailboxProbeImpl.class).appendMessage(userStepdefs.lastConnectedUser,
@@ -486,6 +491,12 @@ public class GetMessagesMethodStepdefs {
assertAttachment(SECOND_ATTACHMENT, attachmentProperties);
}
+ @Then("^the preview of the message contains:$")
+ public void assertPreviewOfMessageShouldBePrintedWithEncoding(DataTable preview) throws Throwable {
+ String actual = jsonPath.<String>read(FIRST_MESSAGE + ".preview");
+ assertThat(actual).contains(preview.asList(String.class));
+ }
+
private void assertAttachment(String attachment, DataTable attachmentProperties) {
attachmentProperties.asList(TableRow.class)
.stream()
http://git-wip-us.apache.org/repos/asf/james-project/blob/2c85e949/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 f1ea2e7..23f8221 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
@@ -293,3 +293,12 @@ Feature: GetMessages method
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: Preview should display printable characters with iso charset
+ Given the user has a message "m1" in "INBOX" mailbox with iso charset
+ When the user 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 of the message contains:
+ |effectué|à|signée dès|
http://git-wip-us.apache.org/repos/asf/james-project/blob/2c85e949/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/iso8859_1charset.eml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/iso8859_1charset.eml b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/iso8859_1charset.eml
new file mode 100644
index 0000000..ed84e9e
--- /dev/null
+++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/resources/eml/iso8859_1charset.eml
@@ -0,0 +1,43 @@
+Return-Path: <te...@local>
+Received: from local
+From: Test <te...@local>
+To: "Testee" <te...@local>
+Subject: Any subject
+Date: Tue, 30 May 2017 10:06:35 +0000
+Message-ID: <2a...@test.local>
+Accept-Language: fr-FR, en-US
+Content-Language: fr-FR
+X-MS-Has-Attach: yes
+X-MS-TNEF-Correlator:
+x-ms-exchange-transport-fromentityheader: Hosted
+x-originating-ip: [10.11.40.174]
+Content-Type: multipart/mixed;
+ boundary="_006_2a338825f11d475bb97e82f064a41119MBXCMC02resslocal_"
+MIME-Version: 1.0
+
+--_006_2a338825f11d475bb97e82f064a41119MBXCMC02resslocal_
+Content-Type: multipart/related;
+ boundary="_005_2a338825f11d475bb97e82f064a41119MBXCMC02resslocal_";
+ type="multipart/alternative"
+
+--_005_2a338825f11d475bb97e82f064a41119MBXCMC02resslocal_
+Content-Type: multipart/alternative;
+ boundary="_000_2a338825f11d475bb97e82f064a41119MBXCMC02resslocal_"
+
+--_000_2a338825f11d475bb97e82f064a41119MBXCMC02resslocal_
+Content-Type: text/plain; charset="iso-8859-1"
+Content-Transfer-Encoding: quoted-printable
+
+Bonjour,
+
+Dans le cadre du stage effectu=E9 par ... 201=7, ... =E0= ... sign=E9e d=E8s que possible.
+
+--_000_2a338825f11d475bb97e82f064a41119MBXCMC02resslocal_
+Content-Type: text/html; charset="iso-8859-1"
+Content-Transfer-Encoding: quoted-printable
+
+Bonjour,
+
+Dans le cadre du stage effectu=E9 par ... 201=7, ... =E0= ... sign=E9e d=E8s que possible.
+
+--_000_2a338825f11d475bb97e82f064a41119MBXCMC02resslocal_--
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[5/6] james-project git commit: JAMES-2043 UserProvisioningFilter
should not try to update readOnly users repository
Posted by bt...@apache.org.
JAMES-2043 UserProvisioningFilter should not try to update readOnly users repository
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/c05b38f3
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/c05b38f3
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/c05b38f3
Branch: refs/heads/master
Commit: c05b38f3eaf2db75ad0963fd99f3bfaa31400125
Parents: 8e9d7be
Author: benwa <bt...@linagora.com>
Authored: Fri Jun 2 11:57:38 2017 +0700
Committer: benwa <bt...@linagora.com>
Committed: Tue Jun 6 15:27:57 2017 +0700
----------------------------------------------------------------------
.../james/jmap/UserProvisioningFilter.java | 6 ++--
.../james/jmap/UserProvisioningFilterTest.java | 35 ++++++++++++++++++++
2 files changed, 39 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/c05b38f3/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
index 95425d4..04bee42 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/UserProvisioningFilter.java
@@ -62,8 +62,10 @@ public class UserProvisioningFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
- Optional<MailboxSession> session = Optional.ofNullable((MailboxSession)request.getAttribute(AuthenticationFilter.MAILBOX_SESSION));
- session.ifPresent(this::createAccountIfNeeded);
+ if (!usersRepository.isReadOnly()) {
+ Optional<MailboxSession> session = Optional.ofNullable((MailboxSession) request.getAttribute(AuthenticationFilter.MAILBOX_SESSION));
+ session.ifPresent(this::createAccountIfNeeded);
+ }
chain.doFilter(request, response);
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/c05b38f3/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterTest.java
index 4bab49d..dde8aa5 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/UserProvisioningFilterTest.java
@@ -19,8 +19,11 @@
package org.apache.james.jmap;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import java.io.IOException;
@@ -33,6 +36,7 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.mock.MockMailboxSession;
import org.apache.james.metrics.api.NoopMetricFactory;
+import org.apache.james.user.api.UsersRepository;
import org.apache.james.user.api.UsersRepositoryException;
import org.apache.james.user.lib.mock.InMemoryUsersRepository;
import org.junit.Before;
@@ -90,4 +94,35 @@ public class UserProvisioningFilterTest {
verify(chain).doFilter(request, response);
assertThat(usersRepository.list()).contains(USERNAME);
}
+
+ @Test
+ public void filterShouldNotTryToAddUserWhenReadOnlyUsersRepository() throws Exception {
+ UsersRepository usersRepository = mock(UsersRepository.class);
+ when(usersRepository.isReadOnly()).thenReturn(true);
+ sut = new UserProvisioningFilter(usersRepository, new NoopMetricFactory());
+
+ MailboxSession mailboxSession = new MockMailboxSession(MAIL);
+ when(request.getAttribute(AuthenticationFilter.MAILBOX_SESSION))
+ .thenReturn(mailboxSession);
+
+ sut.doFilter(request, response, chain);
+
+ verify(usersRepository).isReadOnly();
+ verifyNoMoreInteractions(usersRepository);
+ }
+
+ @Test
+ public void filterShouldChainCallsWhenReadOnlyUsersRepository() throws Exception {
+ UsersRepository usersRepository = mock(UsersRepository.class);
+ when(usersRepository.isReadOnly()).thenReturn(true);
+ sut = new UserProvisioningFilter(usersRepository, new NoopMetricFactory());
+
+ MailboxSession mailboxSession = new MockMailboxSession(MAIL);
+ when(request.getAttribute(AuthenticationFilter.MAILBOX_SESSION))
+ .thenReturn(mailboxSession);
+
+ sut.doFilter(request, response, chain);
+
+ verify(chain).doFilter(eq(request), any());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org