You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2020/12/23 03:51:14 UTC
[james-project] branch master updated (24dc4ec -> 7691aae)
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git.
from 24dc4ec JAMES-3481 Move common JMAP methods to a dedicated object
new 22b5bba MAILBOX-403 Email main body is also indexed as an attachment
new 187c13e MAILBOX-403 Consider headername as keyword
new c83d74a MAILBOX-403 From, To, Cc, Bcc fields do not need to be nested
new 9caa18b MAILBOX-403 Functional tests for Body address matching
new a3c4ba4 MAILBOX-403 Relax address matching for text body in ElasticSearch implementation
new 6acaaa1 MAILBOX-403 Remove unneeded display sort forFrom, To, Cc, Bcc fields
new 4492d17 JAMES-3483 ValidRcptHandler need to log errors at the ERROR level
new 44480e5 JAMES-3464 Mailbox/set should return newState & oldState
new cac509b JAMES-3464 Mailbox/get+set state properties should respect specified SHARES capability
new 7691aae JAMES-3481 MailboxDeletion event should carry mailboxACL
The 10 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../james/backends/es/NodeMappingFactory.java | 1 -
.../james/mailbox/events/MailboxListener.java | 12 +-
.../apache/james/mailbox/model/SearchQuery.java | 14 -
.../apache/james/mailbox/MailboxListenerTest.java | 2 +-
.../elasticsearch/MailboxMappingFactory.java | 50 +-
.../james/mailbox/elasticsearch/json/MimePart.java | 3 +-
.../elasticsearch/query/CriterionConverter.java | 20 +-
.../mailbox/elasticsearch/query/SortConverter.java | 13 +-
.../ElasticSearchIntegrationTest.java | 11 +-
.../scala/org/apache/james/event/json/DTOs.scala | 17 +-
.../apache/james/event/json/EventSerializer.scala | 9 +-
.../json/MailboxDeletionSerializationTest.java | 126 +++-
.../lucene/search/LuceneMessageSearchIndex.java | 10 -
.../LuceneMailboxMessageSearchIndexTest.java | 32 -
.../search/LuceneMessageSearchIndexTest.java | 21 +-
.../store/search/SimpleMessageSearchIndexTest.java | 10 -
.../james/mailbox/store/StoreMailboxManager.java | 1 +
.../james/mailbox/store/event/EventFactory.java | 18 +-
.../search/comparator/CombinedComparator.java | 4 -
.../store/event/MailboxAnnotationListenerTest.java | 2 +
.../search/AbstractMessageSearchIndexTest.java | 138 +++-
.../store/search/CombinedComparatorTest.java | 12 -
mailbox/store/src/test/resources/eml/htmlMail.json | 19 +-
.../store/src/test/resources/eml/nonTextual.json | 8 -
.../src/test/resources/eml/recursiveMail.json | 32 -
.../change/CassandraMailboxChangeRepository.java | 5 +
.../james/jmap/api/change/MailboxChange.java | 21 +-
.../jmap/api/change/MailboxChangeRepository.java | 2 +
.../change/MemoryMailboxChangeRepository.java | 9 +
.../change/MailboxChangeRepositoryContract.java | 68 ++
.../contract/EmailQueryMethodContract.scala | 10 +-
.../contract/MailboxChangesMethodContract.scala | 3 +-
.../contract/MailboxGetMethodContract.scala | 97 +++
.../contract/MailboxSetMethodContract.scala | 707 ++++++++++++++-------
.../james/jmap/method/MailboxGetMethod.scala | 16 +-
.../james/jmap/method/MailboxSetMethod.scala | 28 +-
.../smtpserver/fastfail/ValidRcptHandler.java | 4 +-
37 files changed, 1025 insertions(+), 530 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[james-project] 05/10: MAILBOX-403 Relax address matching for text
body in ElasticSearch implementation
Posted by rc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit a3c4ba473bd88d5bbf3266093dab15ee9e4b0188
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Dec 22 12:40:26 2020 +0700
MAILBOX-403 Relax address matching for text body in ElasticSearch implementation
Address matching is less relevant for text content.
We keep strong constraints for address matching on address header fields.
Relaxing this constraint enable indexing only one time each text field. Thus reclaiming performance and disk space.
---
.../james/backends/es/NodeMappingFactory.java | 1 -
.../elasticsearch/MailboxMappingFactory.java | 19 +----
.../elasticsearch/query/CriterionConverter.java | 10 ---
.../ElasticSearchIntegrationTest.java | 89 ++-------------------
.../search/LuceneMessageSearchIndexTest.java | 20 +++++
.../search/AbstractMessageSearchIndexTest.java | 91 +++++++++++++++++++++-
6 files changed, 116 insertions(+), 114 deletions(-)
diff --git a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/NodeMappingFactory.java b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/NodeMappingFactory.java
index 25b82e7..e7408e9 100644
--- a/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/NodeMappingFactory.java
+++ b/backends-common/elasticsearch/src/main/java/org/apache/james/backends/es/NodeMappingFactory.java
@@ -47,7 +47,6 @@ public class NodeMappingFactory {
public static final String NESTED = "nested";
public static final String FIELDS = "fields";
public static final String RAW = "raw";
- public static final String SPLIT_EMAIL = "splitEmail";
public static final String ANALYZER = "analyzer";
public static final String NORMALIZER = "normalizer";
public static final String SEARCH_ANALYZER = "search_analyzer";
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
index 088a288..9d74266 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
@@ -34,7 +34,6 @@ import static org.apache.james.backends.es.NodeMappingFactory.RAW;
import static org.apache.james.backends.es.NodeMappingFactory.REQUIRED;
import static org.apache.james.backends.es.NodeMappingFactory.ROUTING;
import static org.apache.james.backends.es.NodeMappingFactory.SEARCH_ANALYZER;
-import static org.apache.james.backends.es.NodeMappingFactory.SPLIT_EMAIL;
import static org.apache.james.backends.es.NodeMappingFactory.TYPE;
import static org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants.ATTACHMENTS;
import static org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants.BCC;
@@ -297,26 +296,12 @@ public class MailboxMappingFactory {
.startObject(TEXT_BODY)
.field(TYPE, TEXT)
- .field(ANALYZER, KEEP_MAIL_AND_URL)
- .startObject(FIELDS)
- .startObject(SPLIT_EMAIL)
- .field(TYPE, TEXT)
- .field(ANALYZER, STANDARD)
- .field(SEARCH_ANALYZER, KEEP_MAIL_AND_URL)
- .endObject()
- .endObject()
+ .field(ANALYZER, STANDARD)
.endObject()
.startObject(HTML_BODY)
.field(TYPE, TEXT)
- .field(ANALYZER, KEEP_MAIL_AND_URL)
- .startObject(FIELDS)
- .startObject(SPLIT_EMAIL)
- .field(TYPE, TEXT)
- .field(ANALYZER, STANDARD)
- .field(SEARCH_ANALYZER, KEEP_MAIL_AND_URL)
- .endObject()
- .endObject()
+ .field(ANALYZER, STANDARD)
.endObject()
.startObject(HAS_ATTACHMENT)
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/CriterionConverter.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/CriterionConverter.java
index 031dd47..df39e14 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/CriterionConverter.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/CriterionConverter.java
@@ -20,7 +20,6 @@
package org.apache.james.mailbox.elasticsearch.query;
import static org.apache.james.backends.es.NodeMappingFactory.RAW;
-import static org.apache.james.backends.es.NodeMappingFactory.SPLIT_EMAIL;
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
import static org.elasticsearch.index.query.QueryBuilders.matchQuery;
@@ -150,19 +149,10 @@ public class CriterionConverter {
case BODY:
return boolQuery()
.should(matchQuery(JsonMessageConstants.TEXT_BODY, textCriterion.getOperator().getValue()))
- .should(matchQuery(JsonMessageConstants.TEXT_BODY + "." + SPLIT_EMAIL,
- textCriterion.getOperator().getValue()))
- .should(matchQuery(JsonMessageConstants.HTML_BODY + "." + SPLIT_EMAIL,
- textCriterion.getOperator().getValue()))
.should(matchQuery(JsonMessageConstants.HTML_BODY, textCriterion.getOperator().getValue()));
case FULL:
return boolQuery()
.should(matchQuery(JsonMessageConstants.TEXT_BODY, textCriterion.getOperator().getValue()))
- .should(matchQuery(JsonMessageConstants.TEXT_BODY + "." + SPLIT_EMAIL,
- textCriterion.getOperator().getValue()))
- .should(matchQuery(JsonMessageConstants.HTML_BODY + "." + SPLIT_EMAIL,
- textCriterion.getOperator().getValue()))
- .should(matchQuery(JsonMessageConstants.HTML_BODY, textCriterion.getOperator().getValue()))
.should(matchQuery(JsonMessageConstants.HTML_BODY, textCriterion.getOperator().getValue()))
.should(matchQuery(JsonMessageConstants.ATTACHMENTS + "." + JsonMessageConstants.Attachment.TEXT_CONTENT,
textCriterion.getOperator().getValue()));
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
index b25c05e..9178820 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
@@ -20,6 +20,7 @@
package org.apache.james.mailbox.elasticsearch;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -28,6 +29,7 @@ import java.time.ZoneId;
import org.apache.james.backends.es.DockerElasticSearchExtension;
import org.apache.james.backends.es.ElasticSearchIndexer;
import org.apache.james.backends.es.ReactorElasticSearchClient;
+import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MailboxSessionUtil;
import org.apache.james.mailbox.MessageManager;
@@ -36,6 +38,7 @@ import org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJson;
import org.apache.james.mailbox.elasticsearch.query.CriterionConverter;
import org.apache.james.mailbox.elasticsearch.query.QueryConverter;
import org.apache.james.mailbox.elasticsearch.search.ElasticSearchSearcher;
+import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.inmemory.InMemoryId;
import org.apache.james.mailbox.inmemory.InMemoryMessageId;
import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
@@ -56,6 +59,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableList;
import reactor.core.publisher.Flux;
@@ -266,7 +270,6 @@ class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest {
@Test
void addressMatchesShouldBeExact() throws Exception {
- // results should not include the domain part nor the local part but the full email address
MailboxPath mailboxPath = MailboxPath.forUser(USERNAME, INBOX);
MailboxSession session = MailboxSessionUtil.create(USERNAME);
MessageManager messageManager = storeMailboxManager.getMailbox(mailboxPath, session);
@@ -296,90 +299,10 @@ class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest {
.containsOnly(messageId2.getUid());
}
+ @Disabled("MAILBOX-403 Relaxed the matching constraints for email addresses in text bodies to reduce ElasticSearch disk space usage")
@Test
- void textShouldMatchFullEmailAddress() throws Exception {
- MailboxPath mailboxPath = MailboxPath.forUser(USERNAME, INBOX);
- MailboxSession session = MailboxSessionUtil.create(USERNAME);
- MessageManager messageManager = storeMailboxManager.getMailbox(mailboxPath, session);
-
-
- ComposedMessageId messageId1 = messageManager.appendMessage(
- MessageManager.AppendCommand.builder().build(
- Message.Builder
- .of()
- .setSubject("test")
- .setBody("benwa@apache.org email address do not exist", StandardCharsets.UTF_8)
- .build()),
- session).getId();
-
- elasticSearch.awaitForElasticSearch();
-
- assertThat(Flux.from(messageManager.search(SearchQuery.of(SearchQuery.bodyContains("benwa@apache.org")), session)).toStream())
- .containsOnly(messageId1.getUid());
- }
-
- @Test
- void textShouldMatchEmailAddressLocalPart() throws Exception {
- MailboxPath mailboxPath = MailboxPath.forUser(USERNAME, INBOX);
- MailboxSession session = MailboxSessionUtil.create(USERNAME);
- MessageManager messageManager = storeMailboxManager.getMailbox(mailboxPath, session);
-
- ComposedMessageId messageId1 = messageManager.appendMessage(
- MessageManager.AppendCommand.builder().build(
- Message.Builder
- .of()
- .setSubject("test")
- .setBody("benwa@apache.org email address do not exist", StandardCharsets.UTF_8)
- .build()),
- session).getId();
-
- elasticSearch.awaitForElasticSearch();
-
- assertThat(Flux.from(messageManager.search(SearchQuery.of(SearchQuery.bodyContains("benwa")), session)).toStream())
- .containsOnly(messageId1.getUid());
- }
-
- @Test
- void textShouldMatchEmailAddressDomainPart() throws Exception {
- MailboxPath mailboxPath = MailboxPath.forUser(USERNAME, INBOX);
- MailboxSession session = MailboxSessionUtil.create(USERNAME);
- MessageManager messageManager = storeMailboxManager.getMailbox(mailboxPath, session);
-
- ComposedMessageId messageId1 = messageManager.appendMessage(
- MessageManager.AppendCommand.builder().build(
- Message.Builder
- .of()
- .setSubject("test")
- .setBody("benwa@apache.org email address do not exist", StandardCharsets.UTF_8)
- .build()),
- session).getId();
-
- elasticSearch.awaitForElasticSearch();
-
- assertThat(Flux.from(messageManager.search(SearchQuery.of(SearchQuery.bodyContains("apache.org")), session)).toStream())
- .containsOnly(messageId1.getUid());
- }
-
- @Test
- void textShouldNotMatchOtherAddressesOfTheSameDomain() throws Exception {
- MailboxPath mailboxPath = MailboxPath.forUser(USERNAME, INBOX);
- MailboxSession session = MailboxSessionUtil.create(USERNAME);
- MessageManager messageManager = storeMailboxManager.getMailbox(mailboxPath, session);
-
- messageManager.appendMessage(
- MessageManager.AppendCommand.builder().build(
- Message.Builder
- .of()
- .setSubject("test")
- .setBody("benwa@apache.org email address do not exist", StandardCharsets.UTF_8)
- .build()),
- session).getId();
-
-
- elasticSearch.awaitForElasticSearch();
+ public void textShouldNotMatchOtherAddressesOfTheSameDomain() throws Exception {
- assertThat(Flux.from(messageManager.search(SearchQuery.of(SearchQuery.bodyContains("alice@apache.org")), session)).toStream())
- .isEmpty();
}
@Disabled("MAILBOX-401 '-' causes address matching to fail")
diff --git a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
index 8e7b4fe..e31852e 100644
--- a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
+++ b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
@@ -19,15 +19,29 @@
package org.apache.james.mailbox.lucene.search;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.nio.charset.StandardCharsets;
+
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MailboxSessionUtil;
+import org.apache.james.mailbox.MessageManager;
import org.apache.james.mailbox.inmemory.InMemoryId;
import org.apache.james.mailbox.inmemory.InMemoryMessageId;
import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
+import org.apache.james.mailbox.model.ComposedMessageId;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.model.SearchQuery;
import org.apache.james.mailbox.store.search.AbstractMessageSearchIndexTest;
+import org.apache.james.mime4j.dom.Message;
import org.apache.lucene.store.RAMDirectory;
import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import com.github.fge.lambdas.Throwing;
+import reactor.core.publisher.Flux;
+
class LuceneMessageSearchIndexTest extends AbstractMessageSearchIndexTest {
@Override
@@ -120,6 +134,12 @@ class LuceneMessageSearchIndexTest extends AbstractMessageSearchIndexTest {
public void mailsContainsShouldIncludeMailHavingAttachmentsMatchingTheRequest() {
}
+ @Disabled("Domain part search is not supported by Lucene")
+ @Test
+ @Override
+ public void textShouldMatchEmailAddressDomainPart() throws Exception {
+ }
+
@Disabled("JAMES-1799: ignoring failing test after generalizing ElasticSearch test suite to other mailbox search backends")
@Override
public void modSeqGreaterThanShouldReturnUidsOfMessageHavingAGreaterModSeq() {
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
index 9492958..5cc5dba 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
@@ -37,6 +37,7 @@ import javax.mail.Flags;
import org.apache.james.core.Username;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MailboxSessionUtil;
import org.apache.james.mailbox.MessageIdManager;
import org.apache.james.mailbox.MessageManager;
import org.apache.james.mailbox.exception.MailboxException;
@@ -59,10 +60,12 @@ import org.apache.james.mime4j.dom.Multipart;
import org.apache.james.mime4j.message.BodyPartBuilder;
import org.apache.james.mime4j.message.MultipartBuilder;
import org.apache.james.mime4j.message.SingleBodyBuilder;
+import org.apache.james.mime4j.stream.RawField;
import org.apache.james.util.ClassLoaderUtils;
import org.awaitility.Awaitility;
import org.awaitility.Duration;
import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import com.google.common.collect.ImmutableList;
@@ -466,15 +469,97 @@ public abstract class AbstractMessageSearchIndexTest {
SearchQuery.address(AddressType.To, emailToSearch),
SearchQuery.address(AddressType.Cc, emailToSearch),
SearchQuery.address(AddressType.Bcc, emailToSearch),
- SearchQuery.headerContains("Subject", emailToSearch),
- SearchQuery.attachmentContains(emailToSearch),
- SearchQuery.bodyContains(emailToSearch))));
+ SearchQuery.headerContains("Subject", emailToSearch))));
assertThat(messageSearchIndex.search(session, mailbox, searchQuery).toStream())
.containsOnly(m11.getUid());
}
@Test
+ void textShouldMatchFullEmailAddress() throws Exception {
+ MailboxPath mailboxPath = MailboxPath.forUser(USERNAME, INBOX);
+ MailboxSession session = MailboxSessionUtil.create(USERNAME);
+ MessageManager messageManager = storeMailboxManager.getMailbox(mailboxPath, session);
+
+ ComposedMessageId messageId1 = messageManager.appendMessage(
+ MessageManager.AppendCommand.builder().build(
+ Message.Builder
+ .of()
+ .setSubject("test")
+ .setBody("benwa@apache.org email address do not exist", StandardCharsets.UTF_8)
+ .build()),
+ session).getId();
+
+ await();
+
+ assertThat(Flux.from(messageManager.search(SearchQuery.of(SearchQuery.bodyContains("benwa@apache.org")), session)).toStream())
+ .containsOnly(messageId1.getUid());
+ }
+
+ @Test
+ void textShouldMatchEmailAddressLocalPart() throws Exception {
+ MailboxPath mailboxPath = MailboxPath.forUser(USERNAME, INBOX);
+ MailboxSession session = MailboxSessionUtil.create(USERNAME);
+ MessageManager messageManager = storeMailboxManager.getMailbox(mailboxPath, session);
+
+ ComposedMessageId messageId1 = messageManager.appendMessage(
+ MessageManager.AppendCommand.builder().build(
+ Message.Builder
+ .of()
+ .setSubject("test")
+ .setBody("benwa@apache.org email address do not exist", StandardCharsets.UTF_8)
+ .build()),
+ session).getId();
+
+ await();
+
+ assertThat(Flux.from(messageManager.search(SearchQuery.of(SearchQuery.bodyContains("benwa")), session)).toStream())
+ .containsOnly(messageId1.getUid());
+ }
+
+ @Test
+ public void textShouldMatchEmailAddressDomainPart() throws Exception {
+ MailboxPath mailboxPath = MailboxPath.forUser(USERNAME, INBOX);
+ MailboxSession session = MailboxSessionUtil.create(USERNAME);
+ MessageManager messageManager = storeMailboxManager.getMailbox(mailboxPath, session);
+
+ ComposedMessageId messageId1 = messageManager.appendMessage(
+ MessageManager.AppendCommand.builder().build(
+ Message.Builder
+ .of()
+ .setSubject("test")
+ .setBody("benwa@mydomain.org email address do not exist", StandardCharsets.UTF_8)
+ .build()),
+ session).getId();
+
+ await();
+
+ assertThat(Flux.from(messageManager.search(SearchQuery.of(SearchQuery.bodyContains("mydomain.org")), session)).toStream())
+ .containsOnly(messageId1.getUid());
+ }
+
+ @Test
+ public void textShouldNotMatchOtherAddressesOfTheSameDomain() throws Exception {
+ MailboxPath mailboxPath = MailboxPath.forUser(USERNAME, INBOX);
+ MailboxSession session = MailboxSessionUtil.create(USERNAME);
+ MessageManager messageManager = storeMailboxManager.getMailbox(mailboxPath, session);
+
+ messageManager.appendMessage(
+ MessageManager.AppendCommand.builder().build(
+ Message.Builder
+ .of()
+ .setSubject("test")
+ .setBody("benwa@apache.org email address do not exist", StandardCharsets.UTF_8)
+ .build()),
+ session).getId();
+
+ await();
+
+ assertThat(Flux.from(messageManager.search(SearchQuery.of(SearchQuery.bodyContains("alice@apache.org")), session)).toStream())
+ .isEmpty();
+ }
+
+ @Test
void hasNoAttachmenShouldOnlyReturnMessageThatHasNoAttachmentWhichAreNotInline() throws MailboxException {
SearchQuery searchQuery = SearchQuery.of(SearchQuery.hasNoAttachment());
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[james-project] 10/10: JAMES-3481 MailboxDeletion event should
carry mailboxACL
Posted by rc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 7691aaeda0bef26c58d1397f923dacb449c16ed7
Author: LanKhuat <dl...@linagora.com>
AuthorDate: Fri Dec 18 17:40:47 2020 +0700
JAMES-3481 MailboxDeletion event should carry mailboxACL
---
.../james/mailbox/events/MailboxListener.java | 12 +-
.../apache/james/mailbox/MailboxListenerTest.java | 2 +-
.../scala/org/apache/james/event/json/DTOs.scala | 17 ++-
.../apache/james/event/json/EventSerializer.scala | 9 +-
.../json/MailboxDeletionSerializationTest.java | 126 ++++++++++++++++-----
.../james/mailbox/store/StoreMailboxManager.java | 1 +
.../james/mailbox/store/event/EventFactory.java | 18 ++-
.../store/event/MailboxAnnotationListenerTest.java | 2 +
.../james/jmap/api/change/MailboxChange.java | 21 +++-
.../contract/MailboxChangesMethodContract.scala | 3 +-
10 files changed, 164 insertions(+), 47 deletions(-)
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/events/MailboxListener.java b/mailbox/api/src/main/java/org/apache/james/mailbox/events/MailboxListener.java
index c810778..d305d82 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/events/MailboxListener.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/events/MailboxListener.java
@@ -34,6 +34,7 @@ import org.apache.james.core.quota.QuotaSizeUsage;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MessageUid;
import org.apache.james.mailbox.acl.ACLDiff;
+import org.apache.james.mailbox.model.MailboxACL;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageId;
@@ -308,13 +309,15 @@ public interface MailboxListener {
* Indicates that mailbox has been deleted.
*/
class MailboxDeletion extends MailboxEvent {
+ private final MailboxACL mailboxACL;
private final QuotaRoot quotaRoot;
private final QuotaCountUsage deletedMessageCount;
private final QuotaSizeUsage totalDeletedSize;
- public MailboxDeletion(MailboxSession.SessionId sessionId, Username username, MailboxPath path, QuotaRoot quotaRoot, QuotaCountUsage deletedMessageCount, QuotaSizeUsage totalDeletedSize,
+ public MailboxDeletion(MailboxSession.SessionId sessionId, Username username, MailboxPath path, MailboxACL mailboxACL, QuotaRoot quotaRoot, QuotaCountUsage deletedMessageCount, QuotaSizeUsage totalDeletedSize,
MailboxId mailboxId, EventId eventId) {
super(sessionId, username, path, mailboxId, eventId);
+ this.mailboxACL = mailboxACL;
this.quotaRoot = quotaRoot;
this.deletedMessageCount = deletedMessageCount;
this.totalDeletedSize = totalDeletedSize;
@@ -325,6 +328,10 @@ public interface MailboxListener {
return false;
}
+ public MailboxACL getMailboxACL() {
+ return mailboxACL;
+ }
+
public QuotaRoot getQuotaRoot() {
return quotaRoot;
}
@@ -346,6 +353,7 @@ public interface MailboxListener {
&& Objects.equals(this.sessionId, that.sessionId)
&& Objects.equals(this.username, that.username)
&& Objects.equals(this.path, that.path)
+ && Objects.equals(this.mailboxACL, that.mailboxACL)
&& Objects.equals(this.mailboxId, that.mailboxId)
&& Objects.equals(this.quotaRoot, that.quotaRoot)
&& Objects.equals(this.deletedMessageCount, that.deletedMessageCount)
@@ -356,7 +364,7 @@ public interface MailboxListener {
@Override
public final int hashCode() {
- return Objects.hash(eventId, sessionId, username, path, mailboxId, quotaRoot, deletedMessageCount, totalDeletedSize);
+ return Objects.hash(eventId, sessionId, username, path, mailboxACL, mailboxId, quotaRoot, deletedMessageCount, totalDeletedSize);
}
}
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxListenerTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxListenerTest.java
index 0036592..646af57 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxListenerTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxListenerTest.java
@@ -128,7 +128,7 @@ class MailboxListenerTest {
@Test
void removedShouldNotBeNoop() {
- MailboxListener.MailboxDeletion deletion = new MailboxListener.MailboxDeletion(SESSION_ID, BOB, PATH, QUOTA_ROOT,
+ MailboxListener.MailboxDeletion deletion = new MailboxListener.MailboxDeletion(SESSION_ID, BOB, PATH, new MailboxACL(), QUOTA_ROOT,
QUOTA_COUNT, QUOTA_SIZE, MAILBOX_ID, Event.EventId.random());
assertThat(deletion.isNoop()).isFalse();
diff --git a/mailbox/event/json/src/main/scala/org/apache/james/event/json/DTOs.scala b/mailbox/event/json/src/main/scala/org/apache/james/event/json/DTOs.scala
index 22e52e8..08ab9e3 100644
--- a/mailbox/event/json/src/main/scala/org/apache/james/event/json/DTOs.scala
+++ b/mailbox/event/json/src/main/scala/org/apache/james/event/json/DTOs.scala
@@ -28,7 +28,7 @@ import org.apache.james.core.Username
import org.apache.james.core.quota.{QuotaLimitValue, QuotaUsageValue}
import org.apache.james.event.json.DTOs.SystemFlag.SystemFlag
import org.apache.james.mailbox.acl.{ACLDiff => JavaACLDiff}
-import org.apache.james.mailbox.model.{MailboxACL, MessageId, MailboxPath => JavaMailboxPath, MessageMetaData => JavaMessageMetaData, Quota => JavaQuota, UpdatedFlags => JavaUpdatedFlags}
+import org.apache.james.mailbox.model.{MessageId, MailboxACL => JavaMailboxACL, MailboxPath => JavaMailboxPath, MessageMetaData => JavaMessageMetaData, Quota => JavaQuota, UpdatedFlags => JavaUpdatedFlags}
import org.apache.james.mailbox.{FlagsBuilder, MessageUid, ModSeq}
import scala.jdk.CollectionConverters._
@@ -48,6 +48,11 @@ object DTOs {
javaMailboxPath.getName)
}
+ object MailboxACL {
+ def fromJava(javaMailboxACL: JavaMailboxACL): Option[MailboxACL] =
+ Option(javaMailboxACL).map(mailboxACL => MailboxACL(mailboxACL.getEntries.asScala.toMap))
+ }
+
object Quota {
def toScala[T <: QuotaLimitValue[T], U <: QuotaUsageValue[U, T]](java: JavaQuota[T, U]): Quota[T, U] = Quota(
used = java.getUsed,
@@ -55,15 +60,19 @@ object DTOs {
limits = java.getLimitByScope.asScala.toMap)
}
- case class ACLDiff(oldACL: Map[MailboxACL.EntryKey, MailboxACL.Rfc4314Rights],
- newACL: Map[MailboxACL.EntryKey, MailboxACL.Rfc4314Rights]) {
- def toJava: JavaACLDiff = new JavaACLDiff(new MailboxACL(oldACL.asJava), new MailboxACL(newACL.asJava))
+ case class ACLDiff(oldACL: Map[JavaMailboxACL.EntryKey, JavaMailboxACL.Rfc4314Rights],
+ newACL: Map[JavaMailboxACL.EntryKey, JavaMailboxACL.Rfc4314Rights]) {
+ def toJava: JavaACLDiff = new JavaACLDiff(new JavaMailboxACL(oldACL.asJava), new JavaMailboxACL(newACL.asJava))
}
case class MailboxPath(namespace: Option[String], user: Option[Username], name: String) {
def toJava: JavaMailboxPath = new JavaMailboxPath(namespace.orNull, user.orNull, name)
}
+ case class MailboxACL(entries: Map[JavaMailboxACL.EntryKey, JavaMailboxACL.Rfc4314Rights]) {
+ def toJava: JavaMailboxACL = new JavaMailboxACL(entries.asJava)
+ }
+
case class Quota[T <: QuotaLimitValue[T], U <: QuotaUsageValue[U, T]](used: U, limit: T, limits: Map[JavaQuota.Scope, T]) {
def toJava: JavaQuota[T, U] =
JavaQuota.builder[T, U]
diff --git a/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala b/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
index a75c75c..92f0160 100644
--- a/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
+++ b/mailbox/event/json/src/main/scala/org/apache/james/event/json/EventSerializer.scala
@@ -25,7 +25,7 @@ import java.util.{TreeMap => JavaTreeMap}
import javax.inject.Inject
import julienrf.json.derived
import org.apache.james.core.Username
-import org.apache.james.core.quota.{QuotaCountLimit, QuotaCountUsage, QuotaLimitValue, QuotaSizeLimit, QuotaSizeUsage, QuotaUsageValue}
+import org.apache.james.core.quota.{QuotaCountLimit, QuotaCountUsage, QuotaSizeLimit, QuotaSizeUsage}
import org.apache.james.event.json.DTOs.SystemFlag.SystemFlag
import org.apache.james.event.json.DTOs._
import org.apache.james.mailbox.MailboxSession.SessionId
@@ -52,9 +52,9 @@ private object DTO {
override def toJava: JavaEvent = new JavaMailboxAdded(sessionId, user, mailboxPath.toJava, mailboxId, eventId)
}
- case class MailboxDeletion(eventId: EventId, sessionId: SessionId, user: Username, path: MailboxPath, quotaRoot: QuotaRoot,
+ case class MailboxDeletion(eventId: EventId, sessionId: SessionId, user: Username, path: MailboxPath, mailboxACL: Option[MailboxACL], quotaRoot: QuotaRoot,
deletedMessageCount: QuotaCountUsage, totalDeletedSize: QuotaSizeUsage, mailboxId: MailboxId) extends Event {
- override def toJava: JavaEvent = new JavaMailboxDeletion(sessionId, user, path.toJava, quotaRoot, deletedMessageCount,
+ override def toJava: JavaEvent = new JavaMailboxDeletion(sessionId, user, path.toJava, mailboxACL.map(mailboxACL => mailboxACL.toJava).getOrElse(new JavaMailboxACL()), quotaRoot, deletedMessageCount,
totalDeletedSize, mailboxId, eventId)
}
@@ -136,6 +136,7 @@ private object ScalaConverter {
user = event.getUsername,
quotaRoot = event.getQuotaRoot,
path = MailboxPath.fromJava(event.getMailboxPath),
+ mailboxACL = MailboxACL.fromJava(event.getMailboxACL),
deletedMessageCount = event.getDeletedMessageCount,
totalDeletedSize = event.getTotalDeletedSize,
mailboxId = event.getMailboxId)
@@ -217,6 +218,7 @@ class JsonSerialize(mailboxIdFactory: MailboxId.Factory, messageIdFactory: Messa
implicit val sessionIdWrites: Writes[SessionId] = value => JsNumber(value.getValue)
implicit val aclEntryKeyWrites: Writes[JavaMailboxACL.EntryKey] = value => JsString(value.serialize())
implicit val aclRightsWrites: Writes[JavaMailboxACL.Rfc4314Rights] = value => JsString(value.serialize())
+ implicit val mailboxACLWrites: Writes[MailboxACL] = Json.writes[MailboxACL]
implicit val aclDiffWrites: Writes[ACLDiff] = Json.writes[ACLDiff]
implicit val messageIdWrites: Writes[MessageId] = value => JsString(value.serialize())
implicit val messageUidWrites: Writes[MessageUid] = value => JsNumber(value.asLong())
@@ -333,6 +335,7 @@ class JsonSerialize(mailboxIdFactory: MailboxId.Factory, messageIdFactory: Messa
implicit val quotaCReads: Reads[DTOs.Quota[QuotaCountLimit, QuotaCountUsage]] = Json.reads[DTOs.Quota[QuotaCountLimit, QuotaCountUsage]]
implicit val quotaSReads: Reads[DTOs.Quota[QuotaSizeLimit, QuotaSizeUsage]] = Json.reads[DTOs.Quota[QuotaSizeLimit, QuotaSizeUsage]]
implicit val mailboxPathReads: Reads[DTOs.MailboxPath] = Json.reads[DTOs.MailboxPath]
+ implicit val mailboxACLReads: Reads[DTOs.MailboxACL] = Json.reads[DTOs.MailboxACL]
implicit val messageMetaDataReads: Reads[DTOs.MessageMetaData] = Json.reads[DTOs.MessageMetaData]
implicit val updatedFlagsReads: Reads[DTOs.UpdatedFlags] = Json.reads[DTOs.UpdatedFlags]
diff --git a/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java b/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java
index 068d866..d4ca296 100644
--- a/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java
+++ b/mailbox/event/json/src/test/java/org/apache/james/event/json/MailboxDeletionSerializationTest.java
@@ -29,12 +29,14 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
import java.util.NoSuchElementException;
import java.util.Optional;
+import org.apache.commons.lang3.tuple.Pair;
import org.apache.james.core.Domain;
import org.apache.james.core.Username;
import org.apache.james.core.quota.QuotaCountUsage;
import org.apache.james.core.quota.QuotaSizeUsage;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.events.MailboxListener;
+import org.apache.james.mailbox.model.MailboxACL;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.QuotaRoot;
@@ -55,46 +57,114 @@ class MailboxDeletionSerializationTest {
SESSION_ID,
USERNAME,
MAILBOX_PATH,
+ new MailboxACL(Pair.of(MailboxACL.EntryKey.createUserEntryKey(USERNAME), new MailboxACL.Rfc4314Rights(MailboxACL.Right.allRights))),
QUOTA_ROOT,
DELETED_MESSAGE_COUNT,
TOTAL_DELETED_SIZE,
MAILBOX_ID,
EVENT_ID);
- private static final String DEFAULT_EVEN_JSON =
+ private static final MailboxListener.MailboxDeletion EMPTY_ACL_MAILBOX_DELETION_EVENT = new MailboxListener.MailboxDeletion(
+ SESSION_ID,
+ USERNAME,
+ MAILBOX_PATH,
+ new MailboxACL(),
+ QUOTA_ROOT,
+ DELETED_MESSAGE_COUNT,
+ TOTAL_DELETED_SIZE,
+ MAILBOX_ID,
+ EVENT_ID);
+
+ private static final String DEFAULT_EVENT_JSON =
"{" +
- " \"MailboxDeletion\":{" +
- " \"eventId\":\"6e0dd59d-660e-4d9b-b22f-0354479f47b4\"," +
- " \"sessionId\":3652," +
- " \"user\":\"user\"," +
- " \"path\":{" +
- " \"namespace\":\"#private\"," +
- " \"user\":\"user\"," +
- " \"name\":\"mailboxName\"" +
- " }," +
- " \"quotaRoot\":\"#private&user@domain\"," +
- " \"deletedMessageCount\":60," +
- " \"totalDeletedSize\":100," +
- " \"mailboxId\":\"789\"" +
- " }" +
- "}";
+ " \"MailboxDeletion\":{" +
+ " \"eventId\":\"6e0dd59d-660e-4d9b-b22f-0354479f47b4\"," +
+ " \"mailboxACL\":{" +
+ " \"entries\": {" +
+ " \"user\":\"aeiklprstwx\"" +
+ " }" +
+ " }," +
+ " \"sessionId\":3652," +
+ " \"user\":\"user\"," +
+ " \"path\":{" +
+ " \"namespace\":\"#private\"," +
+ " \"user\":\"user\"," +
+ " \"name\":\"mailboxName\"" +
+ " }," +
+ " \"quotaRoot\":\"#private&user@domain\"," +
+ " \"deletedMessageCount\":60," +
+ " \"totalDeletedSize\":100," +
+ " \"mailboxId\":\"789\"" +
+ " }" +
+ "}";
+
+ private static final String EVENT_WITH_EMPTY_ACL_JSON =
+ "{" +
+ " \"MailboxDeletion\":{" +
+ " \"eventId\":\"6e0dd59d-660e-4d9b-b22f-0354479f47b4\"," +
+ " \"mailboxACL\":{" +
+ " \"entries\": {}" +
+ " }," +
+ " \"sessionId\":3652," +
+ " \"user\":\"user\"," +
+ " \"path\":{" +
+ " \"namespace\":\"#private\"," +
+ " \"user\":\"user\"," +
+ " \"name\":\"mailboxName\"" +
+ " }," +
+ " \"quotaRoot\":\"#private&user@domain\"," +
+ " \"deletedMessageCount\":60," +
+ " \"totalDeletedSize\":100," +
+ " \"mailboxId\":\"789\"" +
+ " }" +
+ "}";
+
+ private static final String LEGACY_EVENT_JSON =
+ "{" +
+ " \"MailboxDeletion\":{" +
+ " \"eventId\":\"6e0dd59d-660e-4d9b-b22f-0354479f47b4\"," +
+ " \"sessionId\":3652," +
+ " \"user\":\"user\"," +
+ " \"path\":{" +
+ " \"namespace\":\"#private\"," +
+ " \"user\":\"user\"," +
+ " \"name\":\"mailboxName\"" +
+ " }," +
+ " \"quotaRoot\":\"#private&user@domain\"," +
+ " \"deletedMessageCount\":60," +
+ " \"totalDeletedSize\":100," +
+ " \"mailboxId\":\"789\"" +
+ " }" +
+ "}";
@Test
- void mailboxAddedShouldBeWellSerialized() {
+ void mailboxDeletionShouldBeWellSerialized() {
assertThatJson(EVENT_SERIALIZER.toJson(DEFAULT_MAILBOX_DELETION_EVENT))
- .isEqualTo(DEFAULT_EVEN_JSON);
+ .isEqualTo(DEFAULT_EVENT_JSON);
}
@Test
- void mailboxAddedShouldBeWellDeSerialized() {
- assertThat(EVENT_SERIALIZER.fromJson(DEFAULT_EVEN_JSON).get())
+ void mailboxDeletionShouldBeWellDeSerialized() {
+ assertThat(EVENT_SERIALIZER.fromJson(DEFAULT_EVENT_JSON).get())
.isEqualTo(DEFAULT_MAILBOX_DELETION_EVENT);
}
+ @Test
+ void mailboxDeletionWithEmptyACLShouldBeWellSerialized() {
+ assertThatJson(EVENT_SERIALIZER.toJson(EMPTY_ACL_MAILBOX_DELETION_EVENT))
+ .isEqualTo(EVENT_WITH_EMPTY_ACL_JSON);
+ }
+
+ @Test
+ void legacyMailboxDeletionShouldBeWellDeSerialized() {
+ assertThat(EVENT_SERIALIZER.fromJson(LEGACY_EVENT_JSON).get())
+ .isEqualTo(EMPTY_ACL_MAILBOX_DELETION_EVENT);
+ }
+
@Nested
class DeserializationErrors {
@Test
- void mailboxAddedShouldThrowWhenMissingSessionId() {
+ void mailboxDeletionShouldThrowWhenMissingSessionId() {
assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
"{" +
" \"MailboxDeletion\":{" +
@@ -115,7 +185,7 @@ class MailboxDeletionSerializationTest {
}
@Test
- void mailboxAddedShouldThrowWhenMissingEventId() {
+ void mailboxDeletionShouldThrowWhenMissingEventId() {
assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
"{" +
" \"MailboxDeletion\":{" +
@@ -136,7 +206,7 @@ class MailboxDeletionSerializationTest {
}
@Test
- void mailboxAddedShouldThrowWhenMissingUser() {
+ void mailboxDeletionShouldThrowWhenMissingUser() {
assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
"{" +
" \"MailboxDeletion\":{" +
@@ -157,7 +227,7 @@ class MailboxDeletionSerializationTest {
}
@Test
- void mailboxAddedShouldThrowWhenMissingQuotaRoot() {
+ void mailboxDeletionShouldThrowWhenMissingQuotaRoot() {
assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
"{" +
" \"MailboxDeletion\":{" +
@@ -178,7 +248,7 @@ class MailboxDeletionSerializationTest {
}
@Test
- void mailboxAddedShouldThrowWhenMissingQuotaCount() {
+ void mailboxDeletionShouldThrowWhenMissingQuotaCount() {
assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
"{" +
" \"MailboxDeletion\":{" +
@@ -199,7 +269,7 @@ class MailboxDeletionSerializationTest {
}
@Test
- void mailboxAddedShouldThrowWhenMissingQuotaSize() {
+ void mailboxDeletionShouldThrowWhenMissingQuotaSize() {
assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
"{" +
" \"MailboxDeletion\":{" +
@@ -220,7 +290,7 @@ class MailboxDeletionSerializationTest {
}
@Test
- void mailboxAddedShouldThrowWhenMissingMailboxId() {
+ void mailboxDeletionShouldThrowWhenMissingMailboxId() {
assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
"{" +
" \"MailboxDeletion\":{" +
@@ -241,7 +311,7 @@ class MailboxDeletionSerializationTest {
}
@Test
- void mailboxAddedShouldThrowWhenMissingPath() {
+ void mailboxDeletionShouldThrowWhenMissingPath() {
assertThatThrownBy(() -> EVENT_SERIALIZER.fromJson(
"{" +
" \"MailboxDeletion\":{" +
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
index aaf25a8..f51b780 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
@@ -451,6 +451,7 @@ public class StoreMailboxManager implements MailboxManager {
.mailboxSession(session)
.mailbox(mailbox)
.quotaRoot(quotaRootWithMessageCount.getT1())
+ .mailboxACL(mailbox.getACL())
.quotaCount(QuotaCountUsage.count(quotaRootWithMessageCount.getT2()))
.quotaSize(QuotaSizeUsage.size(totalSize))
.build(),
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
index 42f852c..ad2fbed 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
@@ -36,6 +36,7 @@ import org.apache.james.mailbox.events.Event;
import org.apache.james.mailbox.events.MailboxListener;
import org.apache.james.mailbox.events.MessageMoveEvent;
import org.apache.james.mailbox.model.Mailbox;
+import org.apache.james.mailbox.model.MailboxACL;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageMetaData;
@@ -88,6 +89,11 @@ public class EventFactory {
}
@FunctionalInterface
+ public interface RequireMailboxACL<T> {
+ T mailboxACL(MailboxACL mailboxACL);
+ }
+
+ @FunctionalInterface
public interface RequireMailbox<T> extends RequireMailboxId<RequirePath<T>> {
default T mailbox(Mailbox mailbox) {
return mailboxId(mailbox.getMailboxId())
@@ -294,6 +300,7 @@ public class EventFactory {
public static class MailboxDeletionFinalStage {
private final Event.EventId eventId;
private final MailboxPath path;
+ private final MailboxACL mailboxACL;
private final MailboxId mailboxId;
private final Username username;
private final MailboxSession.SessionId sessionId;
@@ -301,9 +308,10 @@ public class EventFactory {
private final QuotaCountUsage deletedMessageCount;
private final QuotaSizeUsage totalDeletedSize;
- MailboxDeletionFinalStage(Event.EventId eventId, MailboxPath path, MailboxId mailboxId, Username username, MailboxSession.SessionId sessionId, QuotaRoot quotaRoot, QuotaCountUsage deletedMessageCount, QuotaSizeUsage totalDeletedSize) {
+ MailboxDeletionFinalStage(Event.EventId eventId, MailboxPath path, MailboxACL mailboxACL, MailboxId mailboxId, Username username, MailboxSession.SessionId sessionId, QuotaRoot quotaRoot, QuotaCountUsage deletedMessageCount, QuotaSizeUsage totalDeletedSize) {
this.eventId = eventId;
this.path = path;
+ this.mailboxACL = mailboxACL;
this.mailboxId = mailboxId;
this.username = username;
this.sessionId = sessionId;
@@ -321,7 +329,7 @@ public class EventFactory {
Preconditions.checkNotNull(deletedMessageCount);
Preconditions.checkNotNull(totalDeletedSize);
- return new MailboxListener.MailboxDeletion(sessionId, username, path, quotaRoot, deletedMessageCount, totalDeletedSize, mailboxId, eventId);
+ return new MailboxListener.MailboxDeletion(sessionId, username, path, mailboxACL, quotaRoot, deletedMessageCount, totalDeletedSize, mailboxId, eventId);
}
}
@@ -421,9 +429,9 @@ public class EventFactory {
return eventId -> user -> sessionId -> mailboxId -> oldPath -> newPath -> new MailboxRenamedFinalStage(eventId, oldPath, mailboxId, user, sessionId, newPath);
}
- public static RequireMailboxEvent<RequireQuotaRoot<RequireQuotaCountValue<RequireQuotaSizeValue<MailboxDeletionFinalStage>>>> mailboxDeleted() {
- return eventId -> user -> sessionId -> mailboxId -> path -> quotaRoot -> quotaCount -> quotaSize -> new MailboxDeletionFinalStage(
- eventId, path, mailboxId, user, sessionId, quotaRoot, quotaCount, quotaSize);
+ public static RequireMailboxEvent<RequireQuotaRoot<RequireMailboxACL<RequireQuotaCountValue<RequireQuotaSizeValue<MailboxDeletionFinalStage>>>>> mailboxDeleted() {
+ return eventId -> user -> sessionId -> mailboxId -> path -> quotaRoot -> mailboxACL -> quotaCount -> quotaSize -> new MailboxDeletionFinalStage(
+ eventId, path, mailboxACL, mailboxId, user, sessionId, quotaRoot, quotaCount, quotaSize);
}
public static RequireMailboxEvent<MailboxAddedFinalStage> mailboxAdded() {
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java
index fbc85a3..18c9367 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java
@@ -39,6 +39,7 @@ import org.apache.james.mailbox.SessionProvider;
import org.apache.james.mailbox.events.Event;
import org.apache.james.mailbox.events.Group;
import org.apache.james.mailbox.events.MailboxListener;
+import org.apache.james.mailbox.model.MailboxACL;
import org.apache.james.mailbox.model.MailboxAnnotation;
import org.apache.james.mailbox.model.MailboxAnnotationKey;
import org.apache.james.mailbox.model.MailboxId;
@@ -88,6 +89,7 @@ class MailboxAnnotationListenerTest {
.mailboxId(mailboxId)
.mailboxPath(MailboxPath.forUser(USER, "name"))
.quotaRoot(QuotaRoot.quotaRoot("root", Optional.empty()))
+ .mailboxACL(new MailboxACL())
.quotaCount(QuotaCountUsage.count(123))
.quotaSize(QuotaSizeUsage.size(456))
.build();
diff --git a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/change/MailboxChange.java b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/change/MailboxChange.java
index ee5e1e7..4bdcb2c 100644
--- a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/change/MailboxChange.java
+++ b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/change/MailboxChange.java
@@ -247,12 +247,29 @@ public class MailboxChange {
if (event instanceof MailboxDeletion) {
MailboxDeletion mailboxDeletion = (MailboxDeletion) event;
- return ImmutableList.of(MailboxChange.builder()
+ MailboxChange ownerChange = MailboxChange.builder()
.accountId(AccountId.fromUsername(mailboxDeletion.getUsername()))
.state(stateFactory.generate())
.date(now)
.destroyed(ImmutableList.of(mailboxDeletion.getMailboxId()))
- .build());
+ .build();
+
+ Stream<MailboxChange> shareeChanges = mailboxDeletion.getMailboxACL()
+ .getEntries().keySet()
+ .stream()
+ .filter(rfc4314Rights -> !rfc4314Rights.isNegative())
+ .filter(rfc4314Rights -> rfc4314Rights.getNameType().equals(MailboxACL.NameType.user))
+ .map(MailboxACL.EntryKey::getName)
+ .map(name -> MailboxChange.builder()
+ .accountId(AccountId.fromString(name))
+ .state(stateFactory.generate())
+ .date(now)
+ .destroyed(ImmutableList.of(mailboxDeletion.getMailboxId()))
+ .delegated()
+ .build());
+
+ return Stream.concat(Stream.of(ownerChange), shareeChanges)
+ .collect(Guavate.toImmutableList());
}
if (event instanceof Added) {
Added messageAdded = (Added) event;
diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxChangesMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxChangesMethodContract.scala
index 36cdfad..a9ce132 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxChangesMethodContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxChangesMethodContract.scala
@@ -48,7 +48,7 @@ import org.apache.james.mime4j.dom.Message
import org.apache.james.modules.{ACLProbeImpl, MailboxProbeImpl}
import org.apache.james.utils.DataProbeImpl
import org.assertj.core.api.Assertions.assertThat
-import org.junit.jupiter.api.{BeforeEach, Disabled, Nested, Test}
+import org.junit.jupiter.api.{BeforeEach, Nested, Test}
import play.api.libs.json.{JsString, Json}
import scala.jdk.CollectionConverters._
@@ -883,7 +883,6 @@ trait MailboxChangesMethodContract {
}
@Test
- @Disabled("Not implemented yet")
def mailboxChangesShouldReturnUpdatedChangesWhenDestroyDelegatedMailbox(server: GuiceJamesServer): Unit = {
val mailboxProbe: MailboxProbeImpl = server.getProbe(classOf[MailboxProbeImpl])
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[james-project] 08/10: JAMES-3464 Mailbox/set should return
newState & oldState
Posted by rc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 44480e506efb3469ecb3b1ad23fef4d75dcbfde1
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Thu Dec 17 17:12:42 2020 +0700
JAMES-3464 Mailbox/set should return newState & oldState
---
.../contract/EmailQueryMethodContract.scala | 10 +-
.../contract/MailboxSetMethodContract.scala | 608 ++++++++++++++-------
.../james/jmap/method/MailboxSetMethod.scala | 19 +-
3 files changed, 415 insertions(+), 222 deletions(-)
diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailQueryMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailQueryMethodContract.scala
index 182da77..4bafa75 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailQueryMethodContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/EmailQueryMethodContract.scala
@@ -251,7 +251,9 @@ trait EmailQueryMethodContract {
.getMailboxId("#private", BOB.asString(), "myMailbox")
.serialize
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
@@ -259,7 +261,6 @@ trait EmailQueryMethodContract {
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "created": {
| "C42": {
| "id": "${mailboxId}",
@@ -348,7 +349,9 @@ trait EmailQueryMethodContract {
.getMailboxId("#private", BOB.asString(), "myMailbox")
.serialize
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
@@ -356,7 +359,6 @@ trait EmailQueryMethodContract {
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "created": {
| "C42": {
| "id": "${mailboxId}",
diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala
index 2d58022..cc19ef6 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala
@@ -147,13 +147,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -201,13 +202,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -255,13 +257,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -309,13 +312,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -363,13 +367,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -417,13 +422,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize()}": {
| "type": "invalidArguments",
@@ -472,13 +478,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notCreated": {
| "C42": {
| "type": "invalidArguments",
@@ -526,13 +533,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -580,13 +588,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -634,13 +643,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -688,13 +698,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -743,14 +754,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notCreated": {
| "C42": {
| "type": "invalidArguments",
@@ -799,14 +811,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notCreated": {
| "C42": {
| "type": "invalidArguments",
@@ -855,14 +868,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notCreated": {
| "C42": {
| "type": "invalidArguments",
@@ -913,14 +927,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notCreated": {
| "C42": {
| "type": "invalidArguments",
@@ -971,14 +986,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notCreated": {
| "C42": {
| "type": "invalidArguments",
@@ -1029,14 +1045,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notCreated": {
| "C42": {
| "type": "invalidArguments",
@@ -1171,13 +1188,14 @@ trait MailboxSetMethodContract {
.getMailboxId("#private", BOB.asString(), "myMailbox")
.serialize
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "created": {
| "C42": {
| "id": "${mailboxId}",
@@ -1337,14 +1355,13 @@ trait MailboxSetMethodContract {
.serialize
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState", "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "created": {
| "C42": {
| "id": "$mailboxId",
@@ -1423,13 +1440,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notCreated": {
| "C42": {
| "type": "invalidArguments",
@@ -1480,13 +1498,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notCreated": {
| "C42": {
| "type": "invalidArguments",
@@ -1546,14 +1565,13 @@ trait MailboxSetMethodContract {
.serialize
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState", "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "created": {
| "C42": {
| "id": "$mailboxId",
@@ -1677,14 +1695,15 @@ trait MailboxSetMethodContract {
.getMailboxId("#private", BOB.asString(), "myMailbox")
.serialize
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "created": {
| "C42": {
| "id": "$mailboxId",
@@ -1745,14 +1764,15 @@ trait MailboxSetMethodContract {
.getMailboxId("#private", BOB.asString(), "myMailbox")
.serialize
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "created": {
| "C42": {
| "id": "$mailboxId",
@@ -1817,14 +1837,15 @@ trait MailboxSetMethodContract {
.getMailboxId("#private", BOB.asString(), "myMailbox")
.serialize
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "created": {
| "C42": {
| "id": "$mailboxId",
@@ -1929,14 +1950,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notCreated": {
| "C42": {
| "type": "invalidArguments",
@@ -1986,14 +2008,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notCreated": {
| "C42": {
| "type": "invalidArguments",
@@ -2042,14 +2065,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notCreated": {
| "C42": {
| "type": "invalidArguments",
@@ -2104,14 +2128,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notCreated": {
| "C42": {
| "type": "forbidden",
@@ -2159,14 +2184,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "destroyed": ["${mailboxId.serialize}"]
| },
| "c1"]]
@@ -2362,14 +2388,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notDestroyed": {
| "${mailboxId.serialize}": {
| "type": "notFound",
@@ -2423,14 +2450,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notDestroyed": {
| "${mailboxId.serialize}": {
| "type": "mailboxHasEmail",
@@ -2477,14 +2505,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notDestroyed": {
| "${mailboxId.serialize}": {
| "type": "mailboxHasChild",
@@ -2533,14 +2562,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notDestroyed": {
| "${mailboxId.serialize}": {
| "type": "notFound",
@@ -2584,14 +2614,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notDestroyed": {
| "invalid": {
| "type": "invalidArguments",
@@ -2696,7 +2727,10 @@ trait MailboxSetMethodContract {
.getMailboxId("#private", BOB.asString(), "parent.child")
.serialize
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState",
+ "methodResponses[1][1].newState", "methodResponses[1][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
@@ -2704,7 +2738,6 @@ trait MailboxSetMethodContract {
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "created": {
| "C42": {
| "id": "$parentId",
@@ -2734,7 +2767,6 @@ trait MailboxSetMethodContract {
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "created": {
| "C43": {
| "id": "$childId",
@@ -2808,13 +2840,15 @@ trait MailboxSetMethodContract {
.getMailboxId("#private", BOB.asString(), "myMailbox")
.serialize
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState",
+ "methodResponses[1][1].newState", "methodResponses[1][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notDestroyed": {
| "#C42": {
| "type": "invalidArguments",
@@ -2824,7 +2858,6 @@ trait MailboxSetMethodContract {
| }, "c2"],
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "created": {
| "C42": {
| "id": "$mailboxId",
@@ -2882,13 +2915,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notDestroyed": {
| "#C42": {
| "type": "invalidArguments",
@@ -2931,13 +2965,14 @@ trait MailboxSetMethodContract {
.asString
val message = "# is not a mailboxId: # was not used in previously defined creationIds"
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notDestroyed": {
| "#": {
| "type": "invalidArguments",
@@ -2994,14 +3029,13 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[1][1].state", "methodResponses[0][1].newState", "methodResponses[0][1].oldState")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -3067,13 +3101,15 @@ trait MailboxSetMethodContract {
.getMailboxId("#private", BOB.asString(), "newName")
.serialize
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState",
+ "methodResponses[1][1].oldState", "methodResponses[1][1].newState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "created": {
| "C43": {
| "id": "$mailboxId",
@@ -3099,7 +3135,6 @@ trait MailboxSetMethodContract {
| }, "c1"],
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "$mailboxId": {}
| }
@@ -3185,13 +3220,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId1.serialize}": {
| "type": "invalidArguments",
@@ -3238,13 +3274,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId1.serialize}": {
| "type": "invalidArguments",
@@ -3291,13 +3328,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId1.serialize}": {
| "type": "invalidArguments",
@@ -3344,13 +3382,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId1.serialize}": {
| "type": "invalidArguments",
@@ -3398,13 +3437,14 @@ trait MailboxSetMethodContract {
.asString
val message = "Invalid property specified in a patch object: Predicate isEmpty() did not fail."
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId1.serialize}": {
| "type": "invalidPatch",
@@ -3450,13 +3490,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId1.serialize}": {
| "type": "invalidArguments",
@@ -3503,13 +3544,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId1.serialize}": {
| "type": "notFound",
@@ -3558,13 +3600,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId1.serialize}": {
| "type": "notFound",
@@ -3611,13 +3654,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -3661,13 +3705,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notDestroyed": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -3727,14 +3772,13 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState", "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${childId.serialize}": {}
| }
@@ -3801,14 +3845,13 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState", "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${parentId.serialize}": {}
| }
@@ -3869,14 +3912,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "destroyed": ["${mailboxId.serialize}"]
| },
| "c1"]]
@@ -4060,14 +4104,15 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [[
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notDestroyed": {
| "${mailboxId.serialize}": {
| "type": "mailboxHasEmail",
@@ -4124,14 +4169,14 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -4202,21 +4247,21 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[2][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].oldState", "methodResponses[1][1].newState",
+ "methodResponses[2][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
| }, "c2"],
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -4277,14 +4322,14 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -4350,14 +4395,13 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[1][1].state", "methodResponses[0][1].oldState", "methodResponses[0][1].newState")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -4433,21 +4477,21 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[2][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].oldState", "methodResponses[1][1].newState",
+ "methodResponses[2][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
| }, "c2"],
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -4499,13 +4543,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId1.serialize}": {
| "type": "invalidArguments",
@@ -4575,7 +4620,6 @@ trait MailboxSetMethodContract {
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${andreId.serialize}": {},
| "${bobId.serialize}": {}
@@ -4655,21 +4699,21 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[2][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].oldState", "methodResponses[1][1].newState",
+ "methodResponses[2][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
| }, "c2"],
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -4764,13 +4808,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -4866,7 +4911,9 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
@@ -4874,7 +4921,6 @@ trait MailboxSetMethodContract {
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -4926,7 +4972,9 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
@@ -4934,7 +4982,6 @@ trait MailboxSetMethodContract {
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -4986,7 +5033,9 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
@@ -4994,7 +5043,6 @@ trait MailboxSetMethodContract {
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -5057,14 +5105,14 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -5139,14 +5187,14 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -5219,14 +5267,14 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -5295,13 +5343,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "notFound",
@@ -5355,13 +5404,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -5424,21 +5474,20 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
| }, "c1"],
| ["Mailbox/get", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "state": "${INSTANCE.value}",
| "list": [{
| "id": "${mailboxId.serialize}",
| "rights": {
@@ -5491,13 +5540,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidPatch",
@@ -5548,7 +5598,9 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
@@ -5556,7 +5608,6 @@ trait MailboxSetMethodContract {
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -5615,7 +5666,9 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
@@ -5623,7 +5676,6 @@ trait MailboxSetMethodContract {
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidPatch",
@@ -5677,13 +5729,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "notFound",
@@ -5742,13 +5795,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -5813,14 +5867,14 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -5876,7 +5930,9 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
@@ -5884,7 +5940,6 @@ trait MailboxSetMethodContract {
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -5941,7 +5996,9 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
@@ -5949,7 +6006,6 @@ trait MailboxSetMethodContract {
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -6167,14 +6223,14 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -6240,14 +6296,14 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -6314,14 +6370,14 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -6387,14 +6443,13 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[1][1].state", "methodResponses[0][1].newState", "methodResponses[0][1].oldState")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -6459,14 +6514,14 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -6532,14 +6587,14 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -6602,14 +6657,14 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -6674,14 +6729,14 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -6761,14 +6816,15 @@ trait MailboxSetMethodContract {
.serialize
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[2][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState",
+ "methodResponses[1][1].oldState", "methodResponses[1][1].newState",
+ "methodResponses[2][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "created": {
| "C42": {
| "id": "$parentId",
@@ -6794,7 +6850,6 @@ trait MailboxSetMethodContract {
| }, "c1"],
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -6849,13 +6904,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -6905,13 +6961,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -6962,13 +7019,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "notFound",
@@ -7019,13 +7077,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -7078,13 +7137,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "invalidArguments",
@@ -7142,13 +7202,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "notFound",
@@ -7204,13 +7265,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "notFound",
@@ -7266,13 +7328,14 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "${mailboxId.serialize}": {
| "type": "notFound",
@@ -7336,14 +7399,13 @@ trait MailboxSetMethodContract {
.asString
assertThatJson(response)
- .whenIgnoringPaths("methodResponses[1][1].state")
+ .whenIgnoringPaths("methodResponses[0][1].oldState", "methodResponses[0][1].newState", "methodResponses[1][1].state")
.isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
| ["Mailbox/set", {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
| "${mailboxId.serialize}": {}
| }
@@ -7403,7 +7465,9 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
@@ -7411,11 +7475,8 @@ trait MailboxSetMethodContract {
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "updated": {
- | "${mailboxId.serialize}": {
- |
- | }
+ | "${mailboxId.serialize}": {}
| }
| },
| "c1"
@@ -7535,7 +7596,9 @@ trait MailboxSetMethodContract {
.body
.asString
- assertThatJson(response).isEqualTo(
+ assertThatJson(response)
+ .whenIgnoringPaths("methodResponses[0][1].newState", "methodResponses[0][1].oldState")
+ .isEqualTo(
s"""{
| "sessionState": "${SESSION_STATE.value}",
| "methodResponses": [
@@ -7543,7 +7606,6 @@ trait MailboxSetMethodContract {
| "Mailbox/set",
| {
| "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
- | "newState": "${INSTANCE.value}",
| "notUpdated": {
| "#invalid": {
| "type": "invalidArguments",
@@ -7556,4 +7618,126 @@ trait MailboxSetMethodContract {
| ]
|}""".stripMargin)
}
+
+ @Test
+ def newStateShouldBeUpToDate(server: GuiceJamesServer): Unit = {
+ val mailboxId: MailboxId = server.getProbe(classOf[MailboxProbeImpl])
+ .createMailbox(MailboxPath.forUser(BOB, "mailbox"))
+ val request =
+ s"""
+ |{
+ | "using": [ "urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail" ],
+ | "methodCalls": [
+ | [
+ | "Mailbox/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "update": {
+ | "${mailboxId.serialize}": {
+ | "name": "newName"
+ | }
+ | }
+ | }, "c1"],
+ | [ "Mailbox/changes",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "#sinceState": {
+ | "resultOf":"c1",
+ | "name":"Mailbox/set",
+ | "path":"newState"
+ | }
+ | },
+ | "c2"]
+ | ]
+ |}
+ |""".stripMargin
+
+ val response = `given`
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(request)
+ .when
+ .post
+ .`then`
+ .log().ifValidationFails()
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response)
+ .withOptions(new Options(Option.IGNORING_ARRAY_ORDER))
+ .whenIgnoringPaths("methodResponses[1][1].oldState", "methodResponses[1][1].newState")
+ .inPath("methodResponses[1][1]")
+ .isEqualTo(
+ s"""{
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "hasMoreChanges": false,
+ | "updatedProperties": [],
+ | "created": [],
+ | "updated": [],
+ | "destroyed": []
+ |}""".stripMargin)
+ }
+
+ @Test
+ def oldStateShouldIncludeSetChanges(server: GuiceJamesServer): Unit = {
+ val mailboxId: MailboxId = server.getProbe(classOf[MailboxProbeImpl])
+ .createMailbox(MailboxPath.forUser(BOB, "mailbox"))
+ val request =
+ s"""
+ |{
+ | "using": [ "urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail" ],
+ | "methodCalls": [
+ | [
+ | "Mailbox/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "update": {
+ | "${mailboxId.serialize}": {
+ | "name": "newName"
+ | }
+ | }
+ | }, "c1"],
+ | [ "Mailbox/changes",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "#sinceState": {
+ | "resultOf":"c1",
+ | "name":"Mailbox/set",
+ | "path":"oldState"
+ | }
+ | },
+ | "c2"]
+ | ]
+ |}
+ |""".stripMargin
+
+ val response = `given`
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(request)
+ .when
+ .post
+ .`then`
+ .log().ifValidationFails()
+ .statusCode(SC_OK)
+ .contentType(JSON)
+ .extract
+ .body
+ .asString
+
+ assertThatJson(response)
+ .withOptions(new Options(Option.IGNORING_ARRAY_ORDER))
+ .whenIgnoringPaths("methodResponses[1][1].oldState", "methodResponses[1][1].newState")
+ .inPath("methodResponses[1][1]")
+ .isEqualTo(
+ s"""{
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6",
+ | "hasMoreChanges": false,
+ | "updatedProperties": [],
+ | "created": [],
+ | "updated": ["${mailboxId.serialize}"],
+ | "destroyed": []
+ |}""".stripMargin)
+ }
}
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala
index 6b6952c..d4a8520 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala
@@ -21,6 +21,8 @@ package org.apache.james.jmap.method
import eu.timepit.refined.auto._
import javax.inject.Inject
+import org.apache.james.jmap.api.change.MailboxChangeRepository
+import org.apache.james.jmap.api.model.{AccountId => JavaAccountId}
import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_CORE, JMAP_MAIL}
import org.apache.james.jmap.core.Invocation.{Arguments, MethodName}
import org.apache.james.jmap.core.{Invocation, SetError, State}
@@ -46,16 +48,20 @@ class MailboxSetMethod @Inject()(serializer: MailboxSerializer,
createPerformer: MailboxSetCreatePerformer,
deletePerformer: MailboxSetDeletePerformer,
updatePerformer: MailboxSetUpdatePerformer,
+ mailboxChangeRepository: MailboxChangeRepository,
val metricFactory: MetricFactory,
val sessionSupplier: SessionSupplier) extends MethodRequiringAccountId[MailboxSetRequest] {
override val methodName: MethodName = MethodName("Mailbox/set")
override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_CORE, JMAP_MAIL)
override def doProcess(capabilities: Set[CapabilityIdentifier], invocation: InvocationWithContext, mailboxSession: MailboxSession, request: MailboxSetRequest): SMono[InvocationWithContext] = for {
- creationResultsWithUpdatedProcessingContext <- createPerformer.createMailboxes(mailboxSession, request, invocation.processingContext)
+ oldState <- SMono(mailboxChangeRepository.getLatestState(JavaAccountId.fromUsername(mailboxSession.getUser))).map(State.fromJava)
+ creationResults <- createPerformer.createMailboxes(mailboxSession, request, invocation.processingContext)
deletionResults <- deletePerformer.deleteMailboxes(mailboxSession, request)
updateResults <- updatePerformer.updateMailboxes(mailboxSession, request, capabilities)
- } yield InvocationWithContext(createResponse(capabilities, invocation.invocation, request, creationResultsWithUpdatedProcessingContext._1, deletionResults, updateResults), creationResultsWithUpdatedProcessingContext._2)
+ newState <- SMono(mailboxChangeRepository.getLatestState(JavaAccountId.fromUsername(mailboxSession.getUser))).map(State.fromJava)
+ response = createResponse(capabilities, invocation.invocation, request, creationResults._1, deletionResults, updateResults, oldState, newState)
+ } yield InvocationWithContext(response, creationResults._2)
override def getRequest(mailboxSession: MailboxSession, invocation: Invocation): Either[IllegalArgumentException, MailboxSetRequest] =
serializer.deserializeMailboxSetRequest(invocation.arguments.value) match {
@@ -68,11 +74,13 @@ class MailboxSetMethod @Inject()(serializer: MailboxSerializer,
mailboxSetRequest: MailboxSetRequest,
creationResults: MailboxCreationResults,
deletionResults: MailboxDeletionResults,
- updateResults: MailboxUpdateResults): Invocation = {
+ updateResults: MailboxUpdateResults,
+ oldState: State,
+ newState: State): Invocation = {
val response = MailboxSetResponse(
mailboxSetRequest.accountId,
- oldState = None,
- newState = State.INSTANCE,
+ oldState = Some(oldState),
+ newState = newState,
destroyed = Some(deletionResults.destroyed).filter(_.nonEmpty),
created = Some(creationResults.retrieveCreated).filter(_.nonEmpty),
notCreated = Some(creationResults.retrieveErrors).filter(_.nonEmpty),
@@ -84,5 +92,4 @@ class MailboxSetMethod @Inject()(serializer: MailboxSerializer,
Arguments(serializer.serialize(response, capabilities).as[JsObject]),
invocation.methodCallId)
}
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[james-project] 03/10: MAILBOX-403 From, To, Cc,
Bcc fields do not need to be nested
Posted by rc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit c83d74a53d2eab20369eae0c386d9652b5f8c349
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Dec 22 08:41:45 2020 +0700
MAILBOX-403 From, To, Cc, Bcc fields do not need to be nested
Nested fields leads to the indexation of extra documents
---
.../james/mailbox/elasticsearch/MailboxMappingFactory.java | 4 ----
.../james/mailbox/elasticsearch/query/CriterionConverter.java | 10 ++++------
.../james/mailbox/elasticsearch/query/SortConverter.java | 11 +++++------
3 files changed, 9 insertions(+), 16 deletions(-)
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
index 629f292..088a288 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
@@ -159,7 +159,6 @@ public class MailboxMappingFactory {
.endObject()
.startObject(FROM)
- .field(TYPE, NESTED)
.startObject(PROPERTIES)
.startObject(EMailer.NAME)
.field(TYPE, TEXT)
@@ -210,7 +209,6 @@ public class MailboxMappingFactory {
.endObject()
.startObject(TO)
- .field(TYPE, NESTED)
.startObject(PROPERTIES)
.startObject(EMailer.NAME)
.field(TYPE, TEXT)
@@ -237,7 +235,6 @@ public class MailboxMappingFactory {
.endObject()
.startObject(CC)
- .field(TYPE, NESTED)
.startObject(PROPERTIES)
.startObject(EMailer.NAME)
.field(TYPE, TEXT)
@@ -264,7 +261,6 @@ public class MailboxMappingFactory {
.endObject()
.startObject(BCC)
- .field(TYPE, NESTED)
.startObject(PROPERTIES)
.startObject(EMailer.NAME)
.field(TYPE, TEXT)
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/CriterionConverter.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/CriterionConverter.java
index 8937807..031dd47 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/CriterionConverter.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/CriterionConverter.java
@@ -278,12 +278,10 @@ public class CriterionConverter {
}
private QueryBuilder manageAddressFields(String headerName, String value) {
- return nestedQuery(getFieldNameFromHeaderName(headerName),
- boolQuery()
- .should(matchQuery(getFieldNameFromHeaderName(headerName) + "." + JsonMessageConstants.EMailer.NAME, value))
- .should(matchQuery(getFieldNameFromHeaderName(headerName) + "." + JsonMessageConstants.EMailer.ADDRESS, value))
- .should(matchQuery(getFieldNameFromHeaderName(headerName) + "." + JsonMessageConstants.EMailer.ADDRESS + "." + RAW, value)),
- ScoreMode.Avg);
+ return boolQuery()
+ .should(matchQuery(getFieldNameFromHeaderName(headerName) + "." + JsonMessageConstants.EMailer.NAME, value))
+ .should(matchQuery(getFieldNameFromHeaderName(headerName) + "." + JsonMessageConstants.EMailer.ADDRESS, value))
+ .should(matchQuery(getFieldNameFromHeaderName(headerName) + "." + JsonMessageConstants.EMailer.ADDRESS + "." + RAW, value));
}
private String getFieldNameFromHeaderName(String headerName) {
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
index 29323b7..0dcc02c 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
@@ -23,7 +23,6 @@ import org.apache.james.backends.es.NodeMappingFactory;
import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
import org.apache.james.mailbox.model.SearchQuery;
import org.elasticsearch.search.sort.FieldSortBuilder;
-import org.elasticsearch.search.sort.NestedSortBuilder;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortMode;
import org.elasticsearch.search.sort.SortOrder;
@@ -44,13 +43,13 @@ public class SortConverter {
return SortBuilders.fieldSort(JsonMessageConstants.DATE);
case MailboxCc :
return SortBuilders.fieldSort(JsonMessageConstants.CC + PATH_SEPARATOR + JsonMessageConstants.EMailer.ADDRESS
- + PATH_SEPARATOR + NodeMappingFactory.RAW).setNestedSort(new NestedSortBuilder(JsonMessageConstants.CC));
+ + PATH_SEPARATOR + NodeMappingFactory.RAW);
case MailboxFrom :
return SortBuilders.fieldSort(JsonMessageConstants.FROM + PATH_SEPARATOR + JsonMessageConstants.EMailer.ADDRESS
- + PATH_SEPARATOR + NodeMappingFactory.RAW).setNestedSort(new NestedSortBuilder(JsonMessageConstants.FROM));
+ + PATH_SEPARATOR + NodeMappingFactory.RAW);
case MailboxTo :
return SortBuilders.fieldSort(JsonMessageConstants.TO + PATH_SEPARATOR + JsonMessageConstants.EMailer.ADDRESS
- + PATH_SEPARATOR + NodeMappingFactory.RAW).setNestedSort(new NestedSortBuilder(JsonMessageConstants.TO));
+ + PATH_SEPARATOR + NodeMappingFactory.RAW);
case BaseSubject :
return SortBuilders.fieldSort(JsonMessageConstants.SUBJECT + PATH_SEPARATOR + NodeMappingFactory.RAW);
case Size :
@@ -61,10 +60,10 @@ public class SortConverter {
return SortBuilders.fieldSort(JsonMessageConstants.UID);
case DisplayFrom:
return SortBuilders.fieldSort(JsonMessageConstants.FROM + PATH_SEPARATOR + JsonMessageConstants.EMailer.NAME
- + PATH_SEPARATOR + NodeMappingFactory.RAW).setNestedSort(new NestedSortBuilder(JsonMessageConstants.FROM));
+ + PATH_SEPARATOR + NodeMappingFactory.RAW);
case DisplayTo:
return SortBuilders.fieldSort(JsonMessageConstants.TO + PATH_SEPARATOR + JsonMessageConstants.EMailer.NAME
- + PATH_SEPARATOR + NodeMappingFactory.RAW).setNestedSort(new NestedSortBuilder(JsonMessageConstants.TO));
+ + PATH_SEPARATOR + NodeMappingFactory.RAW);
case Id:
return SortBuilders.fieldSort(JsonMessageConstants.MESSAGE_ID);
default:
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[james-project] 04/10: MAILBOX-403 Functional tests for Body
address matching
Posted by rc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 9caa18bb6eab5a3edc534002990320d649f5f9ab
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Dec 22 12:24:20 2020 +0700
MAILBOX-403 Functional tests for Body address matching
---
.../ElasticSearchIntegrationTest.java | 86 ++++++++++++++++++++++
1 file changed, 86 insertions(+)
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
index 5ae6e4c..b25c05e 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
@@ -296,6 +296,92 @@ class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest {
.containsOnly(messageId2.getUid());
}
+ @Test
+ void textShouldMatchFullEmailAddress() throws Exception {
+ MailboxPath mailboxPath = MailboxPath.forUser(USERNAME, INBOX);
+ MailboxSession session = MailboxSessionUtil.create(USERNAME);
+ MessageManager messageManager = storeMailboxManager.getMailbox(mailboxPath, session);
+
+
+ ComposedMessageId messageId1 = messageManager.appendMessage(
+ MessageManager.AppendCommand.builder().build(
+ Message.Builder
+ .of()
+ .setSubject("test")
+ .setBody("benwa@apache.org email address do not exist", StandardCharsets.UTF_8)
+ .build()),
+ session).getId();
+
+ elasticSearch.awaitForElasticSearch();
+
+ assertThat(Flux.from(messageManager.search(SearchQuery.of(SearchQuery.bodyContains("benwa@apache.org")), session)).toStream())
+ .containsOnly(messageId1.getUid());
+ }
+
+ @Test
+ void textShouldMatchEmailAddressLocalPart() throws Exception {
+ MailboxPath mailboxPath = MailboxPath.forUser(USERNAME, INBOX);
+ MailboxSession session = MailboxSessionUtil.create(USERNAME);
+ MessageManager messageManager = storeMailboxManager.getMailbox(mailboxPath, session);
+
+ ComposedMessageId messageId1 = messageManager.appendMessage(
+ MessageManager.AppendCommand.builder().build(
+ Message.Builder
+ .of()
+ .setSubject("test")
+ .setBody("benwa@apache.org email address do not exist", StandardCharsets.UTF_8)
+ .build()),
+ session).getId();
+
+ elasticSearch.awaitForElasticSearch();
+
+ assertThat(Flux.from(messageManager.search(SearchQuery.of(SearchQuery.bodyContains("benwa")), session)).toStream())
+ .containsOnly(messageId1.getUid());
+ }
+
+ @Test
+ void textShouldMatchEmailAddressDomainPart() throws Exception {
+ MailboxPath mailboxPath = MailboxPath.forUser(USERNAME, INBOX);
+ MailboxSession session = MailboxSessionUtil.create(USERNAME);
+ MessageManager messageManager = storeMailboxManager.getMailbox(mailboxPath, session);
+
+ ComposedMessageId messageId1 = messageManager.appendMessage(
+ MessageManager.AppendCommand.builder().build(
+ Message.Builder
+ .of()
+ .setSubject("test")
+ .setBody("benwa@apache.org email address do not exist", StandardCharsets.UTF_8)
+ .build()),
+ session).getId();
+
+ elasticSearch.awaitForElasticSearch();
+
+ assertThat(Flux.from(messageManager.search(SearchQuery.of(SearchQuery.bodyContains("apache.org")), session)).toStream())
+ .containsOnly(messageId1.getUid());
+ }
+
+ @Test
+ void textShouldNotMatchOtherAddressesOfTheSameDomain() throws Exception {
+ MailboxPath mailboxPath = MailboxPath.forUser(USERNAME, INBOX);
+ MailboxSession session = MailboxSessionUtil.create(USERNAME);
+ MessageManager messageManager = storeMailboxManager.getMailbox(mailboxPath, session);
+
+ messageManager.appendMessage(
+ MessageManager.AppendCommand.builder().build(
+ Message.Builder
+ .of()
+ .setSubject("test")
+ .setBody("benwa@apache.org email address do not exist", StandardCharsets.UTF_8)
+ .build()),
+ session).getId();
+
+
+ elasticSearch.awaitForElasticSearch();
+
+ assertThat(Flux.from(messageManager.search(SearchQuery.of(SearchQuery.bodyContains("alice@apache.org")), session)).toStream())
+ .isEmpty();
+ }
+
@Disabled("MAILBOX-401 '-' causes address matching to fail")
@Test
void localPartShouldBeMatchedWhenHyphen() throws Exception {
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[james-project] 07/10: JAMES-3483 ValidRcptHandler need to log
errors at the ERROR level
Posted by rc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 4492d1795e755015004bfdbe963088c0a3226a2c
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Dec 21 21:53:20 2020 +0700
JAMES-3483 ValidRcptHandler need to log errors at the ERROR level
---
.../java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
index c6bcd73..6ca60ed 100644
--- a/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
+++ b/server/protocols/protocols-smtp/src/main/java/org/apache/james/smtpserver/fastfail/ValidRcptHandler.java
@@ -73,7 +73,7 @@ public class ValidRcptHandler extends AbstractValidRcptHandler implements Protoc
return supportsRecipientRewriteTable && isRedirected(recipient, username.asString());
}
} catch (UsersRepositoryException e) {
- LOGGER.info("Unable to access UsersRepository", e);
+ LOGGER.error("Unable to access UsersRepository", e);
return false;
}
}
@@ -90,7 +90,7 @@ public class ValidRcptHandler extends AbstractValidRcptHandler implements Protoc
} catch (ErrorMappingException e) {
return true;
} catch (RecipientRewriteTableException e) {
- LOGGER.info("Unable to access RecipientRewriteTable", e);
+ LOGGER.error("Unable to access RecipientRewriteTable", e);
return false;
}
return false;
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[james-project] 02/10: MAILBOX-403 Consider headername as keyword
Posted by rc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 187c13e4a0587f8f78454a53870f6f1c8917a13b
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Dec 21 18:41:33 2020 +0700
MAILBOX-403 Consider headername as keyword
This decrease the space being used (no analysis) given that the field were always
queried as keyword
---
.../org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
index 944c4a7..629f292 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
@@ -189,8 +189,7 @@ public class MailboxMappingFactory {
.field(TYPE, NESTED)
.startObject(PROPERTIES)
.startObject(HEADER.NAME)
- .field(TYPE, TEXT)
- .field(ANALYZER, KEYWORD)
+ .field(TYPE, KEYWORD)
.endObject()
.startObject(HEADER.VALUE)
.field(TYPE, TEXT)
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[james-project] 06/10: MAILBOX-403 Remove unneeded display sort
forFrom, To, Cc, Bcc fields
Posted by rc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 6acaaa1b88bb52b0a152266298742e75af760f7c
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Dec 22 09:16:54 2020 +0700
MAILBOX-403 Remove unneeded display sort forFrom, To, Cc, Bcc fields
Functionally unneeded as no protocol actually uses this feature,
we end up keeping sorting un-analyzed fields in ElasticSearch,
leading to a minor impact on index size and thus search
performance.
---
.../apache/james/mailbox/model/SearchQuery.java | 14 ----------
.../elasticsearch/MailboxMappingFactory.java | 24 ----------------
.../mailbox/elasticsearch/query/SortConverter.java | 6 ----
.../lucene/search/LuceneMessageSearchIndex.java | 10 -------
.../LuceneMailboxMessageSearchIndexTest.java | 32 ----------------------
.../search/LuceneMessageSearchIndexTest.java | 5 ----
.../store/search/SimpleMessageSearchIndexTest.java | 10 -------
.../search/comparator/CombinedComparator.java | 4 ---
.../search/AbstractMessageSearchIndexTest.java | 32 ----------------------
.../store/search/CombinedComparatorTest.java | 12 --------
10 files changed, 149 deletions(-)
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/SearchQuery.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/SearchQuery.java
index c82f2d6..e3daeeb 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/model/SearchQuery.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/SearchQuery.java
@@ -139,20 +139,6 @@ public class SearchQuery implements Serializable {
SentDate,
/**
- * addr-name of the first "From" address
- *
- * This MUST BE converted to uppercase before doing the sort
- */
- DisplayFrom,
-
- /**
- * addr-name of the first "To" address
- *
- * This MUST BE converted to uppercase before doing the sort
- */
- DisplayTo,
-
- /**
* Uid of the message. This is the DEFAULT if no other is specified
*/
Uid,
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
index 9d74266..af9e096 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
@@ -162,12 +162,6 @@ public class MailboxMappingFactory {
.startObject(EMailer.NAME)
.field(TYPE, TEXT)
.field(ANALYZER, KEEP_MAIL_AND_URL)
- .startObject(FIELDS)
- .startObject(RAW)
- .field(TYPE, KEYWORD)
- .field(NORMALIZER, CASE_INSENSITIVE)
- .endObject()
- .endObject()
.endObject()
.startObject(EMailer.ADDRESS)
.field(TYPE, TEXT)
@@ -212,12 +206,6 @@ public class MailboxMappingFactory {
.startObject(EMailer.NAME)
.field(TYPE, TEXT)
.field(ANALYZER, KEEP_MAIL_AND_URL)
- .startObject(FIELDS)
- .startObject(RAW)
- .field(TYPE, KEYWORD)
- .field(NORMALIZER, CASE_INSENSITIVE)
- .endObject()
- .endObject()
.endObject()
.startObject(EMailer.ADDRESS)
.field(TYPE, TEXT)
@@ -238,12 +226,6 @@ public class MailboxMappingFactory {
.startObject(EMailer.NAME)
.field(TYPE, TEXT)
.field(ANALYZER, KEEP_MAIL_AND_URL)
- .startObject(FIELDS)
- .startObject(RAW)
- .field(TYPE, KEYWORD)
- .field(NORMALIZER, CASE_INSENSITIVE)
- .endObject()
- .endObject()
.endObject()
.startObject(EMailer.ADDRESS)
.field(TYPE, TEXT)
@@ -264,12 +246,6 @@ public class MailboxMappingFactory {
.startObject(EMailer.NAME)
.field(TYPE, TEXT)
.field(ANALYZER, KEEP_MAIL_AND_URL)
- .startObject(FIELDS)
- .startObject(RAW)
- .field(TYPE, KEYWORD)
- .field(NORMALIZER, CASE_INSENSITIVE)
- .endObject()
- .endObject()
.endObject()
.startObject(EMailer.ADDRESS)
.field(TYPE, TEXT)
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
index 0dcc02c..bc19b73 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
@@ -58,12 +58,6 @@ public class SortConverter {
return SortBuilders.fieldSort(JsonMessageConstants.SENT_DATE);
case Uid :
return SortBuilders.fieldSort(JsonMessageConstants.UID);
- case DisplayFrom:
- return SortBuilders.fieldSort(JsonMessageConstants.FROM + PATH_SEPARATOR + JsonMessageConstants.EMailer.NAME
- + PATH_SEPARATOR + NodeMappingFactory.RAW);
- case DisplayTo:
- return SortBuilders.fieldSort(JsonMessageConstants.TO + PATH_SEPARATOR + JsonMessageConstants.EMailer.NAME
- + PATH_SEPARATOR + NodeMappingFactory.RAW);
case Id:
return SortBuilders.fieldSort(JsonMessageConstants.MESSAGE_ID);
default:
diff --git a/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java b/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
index 0304099..6d76bea 100644
--- a/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
+++ b/mailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndex.java
@@ -1036,16 +1036,6 @@ public class LuceneMessageSearchIndex extends ListeningMessageSearchIndex {
return UID_SORT_REVERSE;
}
return UID_SORT;
- case DisplayFrom:
- if (reverse) {
- return FIRST_FROM_MAILBOX_DISPLAY_SORT_REVERSE;
- }
- return FIRST_FROM_MAILBOX_DISPLAY_SORT;
- case DisplayTo:
- if (reverse) {
- return FIRST_TO_MAILBOX_DISPLAY_SORT_REVERSE;
- }
- return FIRST_TO_MAILBOX_DISPLAY_SORT;
default:
return null;
}
diff --git a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
index 32813af..5ef86c7 100644
--- a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
+++ b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java
@@ -550,38 +550,6 @@ class LuceneMailboxMessageSearchIndexTest {
}
@Test
- void sortOnDisplayToShouldReturnWellOrderedResults() throws Exception {
- SearchQuery query = SearchQuery.allSortedWith(new Sort(SortClause.DisplayTo, Order.NATURAL));
-
- Stream<MessageUid> result = index.search(session, mailbox, query).toStream();
- assertThat(result).containsExactly(uid4, uid1, uid3);
- }
-
- @Test
- void reverseSortOnDisplayToShouldReturnWellOrderedResults() throws Exception {
- SearchQuery query = SearchQuery.allSortedWith(new Sort(SortClause.DisplayTo, Order.REVERSE));
-
- Stream<MessageUid> result = index.search(session, mailbox, query).toStream();
- assertThat(result).containsExactly(uid3, uid1, uid4);
- }
-
- @Test
- void sortOnDisplayFromShouldReturnWellOrderedResults() throws Exception {
- SearchQuery query = SearchQuery.allSortedWith(new Sort(SortClause.DisplayFrom, Order.NATURAL));
-
- Stream<MessageUid> result = index.search(session, mailbox, query).toStream();
- assertThat(result).containsExactly(uid3, uid4, uid1);
- }
-
- @Test
- void reverseSortOnDisplayFromShouldReturnWellOrderedResults() throws Exception {
- SearchQuery query = SearchQuery.allSortedWith(new Sort(SortClause.DisplayFrom, Order.REVERSE));
-
- Stream<MessageUid> result = index.search(session, mailbox, query).toStream();
- assertThat(result).containsExactly(uid1, uid4, uid3);
- }
-
- @Test
void sortOnArrivalDateShouldReturnWellOrderedResults() throws Exception {
SearchQuery query = SearchQuery.allSortedWith(new Sort(SortClause.Arrival, Order.NATURAL));
diff --git a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
index e31852e..d274a37 100644
--- a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
+++ b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMessageSearchIndexTest.java
@@ -126,11 +126,6 @@ class LuceneMessageSearchIndexTest extends AbstractMessageSearchIndexTest {
@Disabled("JAMES-1799: ignoring failing test after generalizing ElasticSearch test suite to other mailbox search backends")
@Override
- public void sortOnDisplayFromShouldWork() {
- }
-
- @Disabled("JAMES-1799: ignoring failing test after generalizing ElasticSearch test suite to other mailbox search backends")
- @Override
public void mailsContainsShouldIncludeMailHavingAttachmentsMatchingTheRequest() {
}
diff --git a/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
index 34f767c..d29a492 100644
--- a/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
+++ b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
@@ -127,11 +127,6 @@ class SimpleMessageSearchIndexTest extends AbstractMessageSearchIndexTest {
@Disabled("JAMES-1799: ignoring failing test after generalizing ElasticSearch test suite to other mailbox search backends")
@Override
- public void sortOnDisplayToShouldWork() {
- }
-
- @Disabled("JAMES-1799: ignoring failing test after generalizing ElasticSearch test suite to other mailbox search backends")
- @Override
public void flagIsUnSetShouldReturnUidOfMessageNotMarkedAsRecentWhenUsedWithFlagRecent() {
}
@@ -157,11 +152,6 @@ class SimpleMessageSearchIndexTest extends AbstractMessageSearchIndexTest {
@Disabled("JAMES-1799: ignoring failing test after generalizing ElasticSearch test suite to other mailbox search backends")
@Override
- public void sortOnDisplayFromShouldWork() {
- }
-
- @Disabled("JAMES-1799: ignoring failing test after generalizing ElasticSearch test suite to other mailbox search backends")
- @Override
public void revertSortingShouldReturnElementsInAReversedOrder() {
}
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/comparator/CombinedComparator.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/comparator/CombinedComparator.java
index cb44353..849f2e9 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/comparator/CombinedComparator.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/comparator/CombinedComparator.java
@@ -66,10 +66,6 @@ public class CombinedComparator implements Comparator<MailboxMessage> {
return MessageComparators.UID_COMPARATOR;
case SentDate:
return SentDateComparator.SENTDATE;
- case DisplayFrom:
- return HeaderDisplayComparator.FROM_COMPARATOR;
- case DisplayTo:
- return HeaderDisplayComparator.TO_COMPARATOR;
case Id:
return MessageComparators.MESSAGE_ID_COMPARATOR;
default:
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
index 5cc5dba..30f1ac1 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
@@ -1268,38 +1268,6 @@ public abstract class AbstractMessageSearchIndexTest {
}
@Test
- protected void sortOnDisplayFromShouldWork() throws Exception {
- SearchQuery.UidRange[] numericRanges = {new SearchQuery.UidRange(m2.getUid(), m5.getUid())};
- SearchQuery searchQuery = SearchQuery.builder()
- .andCriteria(SearchQuery.uid(numericRanges))
- .sorts(new Sort(SortClause.DisplayFrom))
- .build();
-
- assertThat(messageSearchIndex.search(session, mailbox, searchQuery).toStream())
- .containsExactly(m4.getUid(), m3.getUid(), m5.getUid(), m2.getUid());
- // 2 : Tellier Benoit (JIRA)
- // 3 : efij
- // 4 : abcd
- // 5 : Eric Charles (JIRA)
- }
-
- @Test
- void sortOnDisplayToShouldWork() throws Exception {
- SearchQuery.UidRange[] numericRanges = {new SearchQuery.UidRange(m2.getUid(), m5.getUid())};
- SearchQuery searchQuery = SearchQuery.builder()
- .andCriteria(SearchQuery.uid(numericRanges))
- .sorts(new Sort(SortClause.DisplayTo))
- .build();
-
- assertThat(messageSearchIndex.search(session, mailbox, searchQuery).toStream())
- .containsExactly(m3.getUid(), m2.getUid(), m4.getUid(), m5.getUid());
- // 2 : abc
- // 3 : aaa
- // 4 : server
- // 5 : zzz
- }
-
- @Test
void sortOnSentDateShouldWork() throws Exception {
SearchQuery.UidRange[] numericRanges = {new SearchQuery.UidRange(m2.getUid(), m5.getUid())};
SearchQuery searchQuery = SearchQuery.builder()
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/CombinedComparatorTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/CombinedComparatorTest.java
index 07f511f..79aade8 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/CombinedComparatorTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/CombinedComparatorTest.java
@@ -105,18 +105,6 @@ class CombinedComparatorTest {
}
@Test
- void createShouldConvertDisplayTo() {
- assertThat(CombinedComparator.create(ImmutableList.of(new Sort(SortClause.DisplayTo))).getComparators())
- .containsOnly(HeaderDisplayComparator.TO_COMPARATOR);
- }
-
- @Test
- void createShouldConvertDisplayFrom() {
- assertThat(CombinedComparator.create(ImmutableList.of(new Sort(SortClause.DisplayFrom))).getComparators())
- .containsOnly(HeaderDisplayComparator.FROM_COMPARATOR);
- }
-
- @Test
void createShouldConvertId() {
assertThat(CombinedComparator.create(ImmutableList.of(new Sort(SortClause.Id))).getComparators())
.containsOnly(MessageComparators.MESSAGE_ID_COMPARATOR);
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[james-project] 01/10: MAILBOX-403 Email main body is also indexed
as an attachment
Posted by rc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 22b5bbac6abf7f47c1cb00d0f971da1c3df9606f
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Dec 21 18:40:37 2020 +0700
MAILBOX-403 Email main body is also indexed as an attachment
---
.../james/mailbox/elasticsearch/json/MimePart.java | 3 +-
.../search/AbstractMessageSearchIndexTest.java | 15 ++++++++++
mailbox/store/src/test/resources/eml/htmlMail.json | 19 +------------
.../store/src/test/resources/eml/nonTextual.json | 8 ------
.../src/test/resources/eml/recursiveMail.json | 32 ----------------------
5 files changed, 18 insertions(+), 59 deletions(-)
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MimePart.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MimePart.java
index 6f94526..e283267 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MimePart.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MimePart.java
@@ -303,7 +303,8 @@ public class MimePart {
@JsonIgnore
public Stream<MimePart> getAttachmentsStream() {
return attachments.stream()
- .flatMap((mimePart) -> Stream.concat(Stream.of(mimePart), mimePart.getAttachmentsStream()));
+ .flatMap(mimePart -> Stream.concat(Stream.of(mimePart), mimePart.getAttachmentsStream()))
+ .filter(mimePart -> mimePart.contentDisposition.isPresent());
}
}
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
index b0500ef..9492958 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
@@ -1273,6 +1273,21 @@ public abstract class AbstractMessageSearchIndexTest {
}
@Test
+ void searchWithTextAttachmentShouldNotMatchMessageBody() throws Exception {
+ assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Attachment));
+ myFolderMessageManager.appendMessage(
+ MessageManager.AppendCommand.builder()
+ .build(ClassLoader.getSystemResourceAsStream("eml/emailWithTextAttachment.eml")),
+ session).getId();
+ await();
+
+ SearchQuery searchQuery = SearchQuery.of(SearchQuery.attachmentContains("message"));
+
+ assertThat(messageSearchIndex.search(session, mailbox2, searchQuery).toStream())
+ .isEmpty();
+ }
+
+ @Test
void searchWithPDFAttachmentShouldReturnMailsWhenAttachmentContentMatches() throws Exception {
assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Attachment));
byte[] attachmentContent = ClassLoaderUtils.getSystemResourceAsByteArray("eml/attachment.pdf");
diff --git a/mailbox/store/src/test/resources/eml/htmlMail.json b/mailbox/store/src/test/resources/eml/htmlMail.json
index 45445d2..85bb47a 100644
--- a/mailbox/store/src/test/resources/eml/htmlMail.json
+++ b/mailbox/store/src/test/resources/eml/htmlMail.json
@@ -115,24 +115,7 @@
"Text and Html not similar"
],
"sentDate":"2015-06-04T07:36:08+0000",
- "attachments":[
- {
- "textContent":"The text/plain part is not matching the html one.\r\n",
- "mediaType":"text",
- "subtype":"plain",
- "fileName":null,
- "fileExtension":null,
- "contentDisposition":null
- },
- {
- "textContent":"<html>\r\n <head>\r\n\r\n <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n </head>\r\n <body bgcolor=\"#FFFFFF\" text=\"#000000\">\r\n <i>This is a mail with <b>beautifull</b> html content which contains a banana.</i><br>\r\n </body>\r\n</html>\r\n",
- "mediaType":"text",
- "subtype":"html",
- "fileName":null,
- "fileExtension":null,
- "contentDisposition":null
- }
- ],
+ "attachments":[],
"textBody": "The text/plain part is not matching the html one.\r\n",
"htmlBody": "<html>\r\n <head>\r\n\r\n <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\r\n </head>\r\n <body bgcolor=\"#FFFFFF\" text=\"#000000\">\r\n <i>This is a mail with <b>beautifull</b> html content which contains a banana.</i><br>\r\n </body>\r\n</html>\r\n",
"isDeleted":true,
diff --git a/mailbox/store/src/test/resources/eml/nonTextual.json b/mailbox/store/src/test/resources/eml/nonTextual.json
index 121434e..5fc73cf 100644
--- a/mailbox/store/src/test/resources/eml/nonTextual.json
+++ b/mailbox/store/src/test/resources/eml/nonTextual.json
@@ -1,14 +1,6 @@
{
"attachments": [
{
- "mediaType":"text",
- "subtype":"plain",
- "fileName":null,
- "fileExtension":null,
- "contentDisposition":null,
- "textContent":"This mail have a non textual attachment !\r\n"
- },
- {
"mediaType":"application",
"subtype":"vnd.oasis.opendocument.text",
"fileName":"toto.odt","fileExtension":"odt",
diff --git a/mailbox/store/src/test/resources/eml/recursiveMail.json b/mailbox/store/src/test/resources/eml/recursiveMail.json
index e59b266..73121e0 100644
--- a/mailbox/store/src/test/resources/eml/recursiveMail.json
+++ b/mailbox/store/src/test/resources/eml/recursiveMail.json
@@ -78,38 +78,6 @@
"sentDate": "2015-06-10T10:45:27+02:00",
"attachments": [
{
- "textContent": "Forward as attachment !\n\n\n",
- "mediaType": "text",
- "subtype": "plain",
- "fileName": null,
- "fileExtension": null,
- "contentDisposition": null
- },
- {
- "textContent": null,
- "mediaType": null,
- "subtype": null,
- "fileName": null,
- "fileExtension": null,
- "contentDisposition": null
- },
- {
- "textContent": null,
- "mediaType": null,
- "subtype": null,
- "fileName": null,
- "fileExtension": null,
- "contentDisposition": null
- },
- {
- "textContent": "Textual content of one attachment ( mail signature )\n",
- "mediaType": "text",
- "subtype": "plain",
- "fileName": null,
- "fileExtension": null,
- "contentDisposition": null
- },
- {
"textContent": null,
"mediaType": "application",
"subtype": "vnd.oasis.opendocument.spreadsheet",
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
[james-project] 09/10: JAMES-3464 Mailbox/get+set state properties
should respect specified SHARES capability
Posted by rc...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
rcordier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit cac509bc99167f9587009609e4e1146664dc54c8
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Mon Dec 21 15:18:06 2020 +0700
JAMES-3464 Mailbox/get+set state properties should respect specified SHARES capability
If the SHARE capability is specified by the client, the server can include state generated within
delegated mailboxes for Mailbox/get state and Mailbox/set oldState & newState properties.
If omitted we should filter these changes out and return the last change within a
personal mailbox.
---
.../change/CassandraMailboxChangeRepository.java | 5 ++
.../jmap/api/change/MailboxChangeRepository.java | 2 +
.../change/MemoryMailboxChangeRepository.java | 9 ++
.../change/MailboxChangeRepositoryContract.java | 68 +++++++++++++++
.../contract/MailboxGetMethodContract.scala | 97 +++++++++++++++++++++
.../contract/MailboxSetMethodContract.scala | 99 +++++++++++++++++++++-
.../james/jmap/method/MailboxGetMethod.scala | 16 +++-
.../james/jmap/method/MailboxSetMethod.scala | 15 +++-
8 files changed, 303 insertions(+), 8 deletions(-)
diff --git a/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/change/CassandraMailboxChangeRepository.java b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/change/CassandraMailboxChangeRepository.java
index 72410b6..b17175a 100644
--- a/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/change/CassandraMailboxChangeRepository.java
+++ b/server/data/data-jmap-cassandra/src/main/java/org/apache/james/jmap/cassandra/change/CassandraMailboxChangeRepository.java
@@ -50,4 +50,9 @@ public class CassandraMailboxChangeRepository implements MailboxChangeRepository
public Mono<MailboxChange.State> getLatestState(AccountId accountId) {
return Mono.just(MailboxChange.State.INITIAL);
}
+
+ @Override
+ public Mono<MailboxChange.State> getLatestStateWithDelegation(AccountId accountId) {
+ return Mono.just(MailboxChange.State.INITIAL);
+ }
}
diff --git a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/change/MailboxChangeRepository.java b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/change/MailboxChangeRepository.java
index 201e022..39779b6 100644
--- a/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/change/MailboxChangeRepository.java
+++ b/server/data/data-jmap/src/main/java/org/apache/james/jmap/api/change/MailboxChangeRepository.java
@@ -36,4 +36,6 @@ public interface MailboxChangeRepository {
Mono<MailboxChanges> getSinceStateWithDelegation(AccountId accountId, State state, Optional<Limit> maxChanges);
Mono<State> getLatestState(AccountId accountId);
+
+ Mono<State> getLatestStateWithDelegation(AccountId accountId);
}
diff --git a/server/data/data-jmap/src/main/java/org/apache/james/jmap/memory/change/MemoryMailboxChangeRepository.java b/server/data/data-jmap/src/main/java/org/apache/james/jmap/memory/change/MemoryMailboxChangeRepository.java
index ab91994..44e5aee 100644
--- a/server/data/data-jmap/src/main/java/org/apache/james/jmap/memory/change/MemoryMailboxChangeRepository.java
+++ b/server/data/data-jmap/src/main/java/org/apache/james/jmap/memory/change/MemoryMailboxChangeRepository.java
@@ -103,6 +103,15 @@ public class MemoryMailboxChangeRepository implements MailboxChangeRepository {
@Override
public Mono<State> getLatestState(AccountId accountId) {
return Flux.fromIterable(mailboxChangeMap.get(accountId))
+ .filter(change -> !change.isDelegated())
+ .sort(Comparator.comparing(MailboxChange::getDate))
+ .map(MailboxChange::getState)
+ .last(State.INITIAL);
+ }
+
+ @Override
+ public Mono<State> getLatestStateWithDelegation(AccountId accountId) {
+ return Flux.fromIterable(mailboxChangeMap.get(accountId))
.sort(Comparator.comparing(MailboxChange::getDate))
.map(MailboxChange::getState)
.last(State.INITIAL);
diff --git a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/change/MailboxChangeRepositoryContract.java b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/change/MailboxChangeRepositoryContract.java
index 5a65347..922d0e9 100644
--- a/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/change/MailboxChangeRepositoryContract.java
+++ b/server/data/data-jmap/src/test/java/org/apache/james/jmap/api/change/MailboxChangeRepositoryContract.java
@@ -81,6 +81,74 @@ public interface MailboxChangeRepositoryContract {
}
@Test
+ default void getLatestStateShouldNotReturnDelegated() {
+ MailboxChangeRepository repository = mailboxChangeRepository();
+ State.Factory stateFactory = stateFactory();
+
+ MailboxChange change1 = MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(2)).created(ImmutableList.of(TestId.of(2))).build();
+ MailboxChange change2 = MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).created(ImmutableList.of(TestId.of(3))).build();
+ MailboxChange change3 = MailboxChange.builder()
+ .accountId(ACCOUNT_ID)
+ .state(stateFactory.generate())
+ .date(DATE)
+ .created(ImmutableList.of(TestId.of(4)))
+ .delegated()
+ .build();
+ repository.save(change1).block();
+ repository.save(change2).block();
+ repository.save(change3).block();
+
+ assertThat(repository.getLatestState(ACCOUNT_ID).block())
+ .isEqualTo(change2.getState());
+ }
+
+ @Test
+ default void getLatestStateWithDelegationShouldReturnInitialWhenEmpty() {
+ MailboxChangeRepository repository = mailboxChangeRepository();
+
+ assertThat(repository.getLatestStateWithDelegation(ACCOUNT_ID).block())
+ .isEqualTo(State.INITIAL);
+ }
+
+ @Test
+ default void getLatestStateWithDelegationShouldReturnLastPersistedState() {
+ MailboxChangeRepository repository = mailboxChangeRepository();
+ State.Factory stateFactory = stateFactory();
+
+ MailboxChange change1 = MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(2)).created(ImmutableList.of(TestId.of(2))).build();
+ MailboxChange change2 = MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).created(ImmutableList.of(TestId.of(3))).build();
+ MailboxChange change3 = MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE).created(ImmutableList.of(TestId.of(4))).build();
+ repository.save(change1).block();
+ repository.save(change2).block();
+ repository.save(change3).block();
+
+ assertThat(repository.getLatestStateWithDelegation(ACCOUNT_ID).block())
+ .isEqualTo(change3.getState());
+ }
+
+ @Test
+ default void getLatestStateWithDelegationShouldReturnDelegated() {
+ MailboxChangeRepository repository = mailboxChangeRepository();
+ State.Factory stateFactory = stateFactory();
+
+ MailboxChange change1 = MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(2)).created(ImmutableList.of(TestId.of(2))).build();
+ MailboxChange change2 = MailboxChange.builder().accountId(ACCOUNT_ID).state(stateFactory.generate()).date(DATE.minusHours(1)).created(ImmutableList.of(TestId.of(3))).build();
+ MailboxChange change3 = MailboxChange.builder()
+ .accountId(ACCOUNT_ID)
+ .state(stateFactory.generate())
+ .date(DATE)
+ .created(ImmutableList.of(TestId.of(4)))
+ .delegated()
+ .build();
+ repository.save(change1).block();
+ repository.save(change2).block();
+ repository.save(change3).block();
+
+ assertThat(repository.getLatestStateWithDelegation(ACCOUNT_ID).block())
+ .isEqualTo(change3.getState());
+ }
+
+ @Test
default void saveChangeShouldFailWhenNoAccountId() {
MailboxChangeRepository repository = mailboxChangeRepository();
State.Factory stateFactory = stateFactory();
diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxGetMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxGetMethodContract.scala
index dce8b7d..b26a148 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxGetMethodContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxGetMethodContract.scala
@@ -1592,4 +1592,101 @@ trait MailboxGetMethodContract {
| "destroyed": []
|}""".stripMargin)
}
+
+ @Test
+ def stateShouldNotTakeIntoAccountDelegationWhenNoCapability(server: GuiceJamesServer): Unit = {
+ val state: String = `with`()
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(
+ s"""{
+ | "using": ["urn:ietf:params:jmap:core","urn:ietf:params:jmap:mail"],
+ | "methodCalls": [[
+ | "Mailbox/get",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6"
+ | },
+ | "c1"]]
+ |}""".stripMargin)
+ .post
+ .`then`()
+ .extract()
+ .jsonPath()
+ .get("methodResponses[0][1].state")
+
+ val sharedMailboxName = "AndreShared"
+ val andreMailboxPath = MailboxPath.forUser(ANDRE, sharedMailboxName)
+ server.getProbe(classOf[MailboxProbeImpl])
+ .createMailbox(andreMailboxPath)
+ .serialize
+ server.getProbe(classOf[ACLProbeImpl])
+ .replaceRights(andreMailboxPath, BOB.asString, new MailboxACL.Rfc4314Rights(Right.Lookup))
+
+ `given`
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(s"""{
+ | "using": [
+ | "urn:ietf:params:jmap:core",
+ | "urn:ietf:params:jmap:mail"],
+ | "methodCalls": [[
+ | "Mailbox/get",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6"
+ | },
+ | "c1"]]
+ |}""".stripMargin)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .body(s"$ARGUMENTS.state", equalTo(state))
+ }
+
+ @Test
+ def stateShouldTakeIntoAccountDelegationWhenCapability(server: GuiceJamesServer): Unit = {
+ val state: String = `with`()
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(
+ s"""{
+ | "using": ["urn:ietf:params:jmap:core","urn:ietf:params:jmap:mail", "urn:apache:james:params:jmap:mail:shares"],
+ | "methodCalls": [[
+ | "Mailbox/get",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6"
+ | },
+ | "c1"]]
+ |}""".stripMargin)
+ .post
+ .`then`()
+ .extract()
+ .jsonPath()
+ .get("methodResponses[0][1].state")
+
+ val sharedMailboxName = "AndreShared"
+ val andreMailboxPath = MailboxPath.forUser(ANDRE, sharedMailboxName)
+ server.getProbe(classOf[MailboxProbeImpl])
+ .createMailbox(andreMailboxPath)
+ .serialize
+ server.getProbe(classOf[ACLProbeImpl])
+ .replaceRights(andreMailboxPath, BOB.asString, new MailboxACL.Rfc4314Rights(Right.Lookup))
+
+ `given`
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(s"""{
+ | "using": [
+ | "urn:ietf:params:jmap:core",
+ | "urn:ietf:params:jmap:mail",
+ | "urn:apache:james:params:jmap:mail:shares"],
+ | "methodCalls": [[
+ | "Mailbox/get",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6"
+ | },
+ | "c1"]]
+ |}""".stripMargin)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .body(s"$ARGUMENTS.state", not(equalTo(state)))
+ }
}
diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala
index cc19ef6..3e034fd 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/MailboxSetMethodContract.scala
@@ -35,6 +35,7 @@ import org.apache.james.jmap.core.State.INSTANCE
import org.apache.james.jmap.draft.MessageIdProbe
import org.apache.james.jmap.http.UserCredential
import org.apache.james.jmap.rfc8621.contract.Fixture.{ACCEPT_RFC8621_VERSION_HEADER, ANDRE, BOB, BOB_PASSWORD, CEDRIC, DAVID, DOMAIN, authScheme, baseRequestSpecBuilder}
+import org.apache.james.jmap.rfc8621.contract.MailboxGetMethodContract.ARGUMENTS
import org.apache.james.jmap.rfc8621.contract.tags.CategoryTags
import org.apache.james.mailbox.MessageManager.AppendCommand
import org.apache.james.mailbox.model.MailboxACL.{EntryKey, Right}
@@ -45,7 +46,7 @@ import org.apache.james.util.concurrency.ConcurrentTestRunner
import org.apache.james.utils.DataProbeImpl
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.{Assertions, SoftAssertions}
-import org.hamcrest.Matchers.{equalTo, hasSize}
+import org.hamcrest.Matchers.{equalTo, hasSize, not}
import org.junit.jupiter.api.{BeforeEach, Disabled, RepeatedTest, Tag, Test}
trait MailboxSetMethodContract {
@@ -7740,4 +7741,100 @@ trait MailboxSetMethodContract {
| "destroyed": []
|}""".stripMargin)
}
+
+ @Test
+ def stateShouldNotTakeIntoAccountDelegationWhenNoCapability(server: GuiceJamesServer): Unit = {
+ val state: String = `with`()
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(
+ s"""{
+ | "using": ["urn:ietf:params:jmap:core","urn:ietf:params:jmap:mail"],
+ | "methodCalls": [[
+ | "Mailbox/get",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6"
+ | },
+ | "c1"]]
+ |}""".stripMargin)
+ .post
+ .`then`()
+ .extract()
+ .jsonPath()
+ .get("methodResponses[0][1].state")
+
+ val sharedMailboxName = "AndreShared"
+ val andreMailboxPath = MailboxPath.forUser(ANDRE, sharedMailboxName)
+ server.getProbe(classOf[MailboxProbeImpl])
+ .createMailbox(andreMailboxPath)
+ .serialize
+ server.getProbe(classOf[ACLProbeImpl])
+ .replaceRights(andreMailboxPath, BOB.asString, new MailboxACL.Rfc4314Rights(Right.Lookup))
+
+ `given`
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(s"""{
+ | "using": [
+ | "urn:ietf:params:jmap:core",
+ | "urn:ietf:params:jmap:mail"],
+ | "methodCalls": [[
+ | "Mailbox/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6"
+ | }, "c1"]]
+ |}""".stripMargin)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .body("methodResponses[0][1].oldState", equalTo(state))
+ }
+
+ @Test
+ def stateShouldTakeIntoAccountDelegationWhenCapability(server: GuiceJamesServer): Unit = {
+ val state: String = `with`()
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(
+ s"""{
+ | "using": ["urn:ietf:params:jmap:core","urn:ietf:params:jmap:mail", "urn:apache:james:params:jmap:mail:shares"],
+ | "methodCalls": [[
+ | "Mailbox/get",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6"
+ | },
+ | "c1"]]
+ |}""".stripMargin)
+ .post
+ .`then`()
+ .extract()
+ .jsonPath()
+ .get("methodResponses[0][1].state")
+
+ val sharedMailboxName = "AndreShared"
+ val andreMailboxPath = MailboxPath.forUser(ANDRE, sharedMailboxName)
+ server.getProbe(classOf[MailboxProbeImpl])
+ .createMailbox(andreMailboxPath)
+ .serialize
+ server.getProbe(classOf[ACLProbeImpl])
+ .replaceRights(andreMailboxPath, BOB.asString, new MailboxACL.Rfc4314Rights(Right.Lookup))
+
+ `given`
+ .header(ACCEPT.toString, ACCEPT_RFC8621_VERSION_HEADER)
+ .body(s"""{
+ | "using": [
+ | "urn:ietf:params:jmap:core",
+ | "urn:ietf:params:jmap:mail",
+ | "urn:apache:james:params:jmap:mail:shares"],
+ | "methodCalls": [[
+ | "Mailbox/set",
+ | {
+ | "accountId": "29883977c13473ae7cb7678ef767cbfbaffc8a44a6e463d971d23a65c1dc4af6"
+ | },
+ | "c1"]]
+ |}""".stripMargin)
+ .when
+ .post
+ .`then`
+ .statusCode(SC_OK)
+ .body("methodResponses[0][1].oldState", not(equalTo(state)))
+ }
}
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala
index 9f2b735..dc7f123 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxGetMethod.scala
@@ -23,9 +23,8 @@ import eu.timepit.refined.auto._
import javax.inject.Inject
import org.apache.james.jmap.api.change.MailboxChangeRepository
import org.apache.james.jmap.api.model.{AccountId => JavaAccountId}
-import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_CORE, JMAP_MAIL}
+import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JAMES_SHARES, JMAP_CORE, JMAP_MAIL}
import org.apache.james.jmap.core.Invocation.{Arguments, MethodName}
-import org.apache.james.jmap.core.State.INSTANCE
import org.apache.james.jmap.core.{AccountId, CapabilityIdentifier, ErrorCode, Invocation, Properties, State}
import org.apache.james.jmap.http.MailboxesProvisioner
import org.apache.james.jmap.json.{MailboxSerializer, ResponseSerializer}
@@ -81,8 +80,8 @@ class MailboxGetMethod @Inject() (serializer: MailboxSerializer,
(requestedProperties -- Mailbox.allProperties match {
case invalidProperties if invalidProperties.isEmpty() => getMailboxes(capabilities, request, mailboxSession)
.reduce(MailboxGetResults.empty(), MailboxGetResults.merge)
- .flatMap(mailboxes => SMono(mailboxChangeRepository.getLatestState(JavaAccountId.fromUsername(mailboxSession.getUser)))
- .map(state => mailboxes.asResponse(request.accountId, State.fromJava(state))))
+ .flatMap(mailboxes => retrieveState(capabilities, mailboxSession)
+ .map(state => mailboxes.asResponse(request.accountId, state)))
.map(mailboxGetResponse => Invocation(
methodName = methodName,
arguments = Arguments(serializer.serialize(mailboxGetResponse, requestedProperties, capabilities).as[JsObject]),
@@ -95,6 +94,15 @@ class MailboxGetMethod @Inject() (serializer: MailboxSerializer,
}
+ private def retrieveState(capabilities: Set[CapabilityIdentifier], mailboxSession: MailboxSession): SMono[State] =
+ if (capabilities.contains(JAMES_SHARES)) {
+ SMono(mailboxChangeRepository.getLatestStateWithDelegation(JavaAccountId.fromUsername(mailboxSession.getUser)))
+ .map(State.fromJava)
+ } else {
+ SMono(mailboxChangeRepository.getLatestState(JavaAccountId.fromUsername(mailboxSession.getUser)))
+ .map(State.fromJava)
+ }
+
override def getRequest(mailboxSession: MailboxSession, invocation: Invocation): Either[IllegalArgumentException, MailboxGetRequest] =
serializer.deserializeMailboxGetRequest(invocation.arguments.value) match {
case JsSuccess(mailboxGetRequest, _) => Right(mailboxGetRequest)
diff --git a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala
index d4a8520..1bb2110 100644
--- a/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala
+++ b/server/protocols/jmap-rfc-8621/src/main/scala/org/apache/james/jmap/method/MailboxSetMethod.scala
@@ -23,7 +23,7 @@ import eu.timepit.refined.auto._
import javax.inject.Inject
import org.apache.james.jmap.api.change.MailboxChangeRepository
import org.apache.james.jmap.api.model.{AccountId => JavaAccountId}
-import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JMAP_CORE, JMAP_MAIL}
+import org.apache.james.jmap.core.CapabilityIdentifier.{CapabilityIdentifier, JAMES_SHARES, JMAP_CORE, JMAP_MAIL}
import org.apache.james.jmap.core.Invocation.{Arguments, MethodName}
import org.apache.james.jmap.core.{Invocation, SetError, State}
import org.apache.james.jmap.json.{MailboxSerializer, ResponseSerializer}
@@ -55,11 +55,11 @@ class MailboxSetMethod @Inject()(serializer: MailboxSerializer,
override val requiredCapabilities: Set[CapabilityIdentifier] = Set(JMAP_CORE, JMAP_MAIL)
override def doProcess(capabilities: Set[CapabilityIdentifier], invocation: InvocationWithContext, mailboxSession: MailboxSession, request: MailboxSetRequest): SMono[InvocationWithContext] = for {
- oldState <- SMono(mailboxChangeRepository.getLatestState(JavaAccountId.fromUsername(mailboxSession.getUser))).map(State.fromJava)
+ oldState <- retrieveState(capabilities, mailboxSession)
creationResults <- createPerformer.createMailboxes(mailboxSession, request, invocation.processingContext)
deletionResults <- deletePerformer.deleteMailboxes(mailboxSession, request)
updateResults <- updatePerformer.updateMailboxes(mailboxSession, request, capabilities)
- newState <- SMono(mailboxChangeRepository.getLatestState(JavaAccountId.fromUsername(mailboxSession.getUser))).map(State.fromJava)
+ newState <- retrieveState(capabilities, mailboxSession)
response = createResponse(capabilities, invocation.invocation, request, creationResults._1, deletionResults, updateResults, oldState, newState)
} yield InvocationWithContext(response, creationResults._2)
@@ -92,4 +92,13 @@ class MailboxSetMethod @Inject()(serializer: MailboxSerializer,
Arguments(serializer.serialize(response, capabilities).as[JsObject]),
invocation.methodCallId)
}
+
+ private def retrieveState(capabilities: Set[CapabilityIdentifier], mailboxSession: MailboxSession): SMono[State] =
+ if (capabilities.contains(JAMES_SHARES)) {
+ SMono(mailboxChangeRepository.getLatestStateWithDelegation(JavaAccountId.fromUsername(mailboxSession.getUser)))
+ .map(State.fromJava)
+ } else {
+ SMono(mailboxChangeRepository.getLatestState(JavaAccountId.fromUsername(mailboxSession.getUser)))
+ .map(State.fromJava)
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org