JAMES-1925 Split user provisioning and mailboxes provisioning filters
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/844efe2a Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/844efe2a Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/844efe2a Branch: refs/heads/master Commit: 844efe2a5a731299caf207f254916c7a26d23816 Parents: dea8f2e Author: Antoine Duprat <[email protected]> Authored: Tue Feb 7 11:20:31 2017 +0100 Committer: Antoine Duprat <[email protected]> Committed: Thu Feb 9 09:44:50 2017 +0100 ---------------------------------------------------------------------- .../james/jmap/VacationIntegrationTest.java | 16 +- .../integration/GetMailboxesMethodTest.java | 94 ++++--- .../integration/GetMessageListMethodTest.java | 23 +- .../integration/SetMailboxesMethodTest.java | 233 ++++++++-------- .../integration/SetMessagesMethodTest.java | 116 +++----- .../cucumber/GetMessagesMethodStepdefs.java | 3 +- .../test/resources/cucumber/DownloadGet.feature | 10 +- .../resources/cucumber/DownloadPost.feature | 4 +- .../test/resources/cucumber/GetMessages.feature | 44 +-- .../org/apache/james/jmap/DefaultMailboxes.java | 36 +++ .../DefaultMailboxesProvisioningFilter.java | 106 ++++++++ .../java/org/apache/james/jmap/JMAPServer.java | 3 +- .../james/jmap/UserProvisioningFilter.java | 32 +-- ...ltMailboxesProvisioningFilterThreadTest.java | 268 +++++++++++++++++++ .../james/jmap/UserProvisioningFilterTest.java | 4 +- .../jmap/UserProvisioningFilterThreadTest.java | 207 +------------- 16 files changed, 655 insertions(+), 544 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java index 0ad710d..d3221f0 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/VacationIntegrationTest.java @@ -79,11 +79,11 @@ public abstract class VacationIntegrationTest { guiceJamesServer.serverProbe().addDomain(DOMAIN); guiceJamesServer.serverProbe().addUser(USER_1, PASSWORD); guiceJamesServer.serverProbe().addUser(USER_2, PASSWORD); - guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_2, "outbox"); - guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_1, "sent"); - guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_2, "sent"); - guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_1, "INBOX"); - guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_2, "INBOX"); + guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_2, DefaultMailboxes.OUTBOX); + guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_1, DefaultMailboxes.SENT); + guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_2, DefaultMailboxes.SENT); + guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_1, DefaultMailboxes.INBOX); + guiceJamesServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USER_2, DefaultMailboxes.INBOX); await(); jmapGuiceProbe = guiceJamesServer.getJmapProbe(); @@ -436,16 +436,16 @@ public abstract class VacationIntegrationTest { } private String getOutboxId(AccessToken accessToken) { - return getMailboxIdByRole(accessToken, "outbox"); + return getMailboxIdByRole(accessToken, DefaultMailboxes.OUTBOX); } private String getInboxId(AccessToken accessToken) { - return getMailboxIdByRole(accessToken, "inbox"); + return getMailboxIdByRole(accessToken, DefaultMailboxes.INBOX); } private String getMailboxIdByRole(AccessToken accessToken, String role) { return getAllMailboxesIds(accessToken).stream() - .filter(x -> x.get("role").equals(role)) + .filter(x -> x.get("role").equalsIgnoreCase(role)) .map(x -> x.get("id")) .findFirst() .get(); http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java index e75167d..49caa3e 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMailboxesMethodTest.java @@ -24,6 +24,7 @@ import static com.jayway.restassured.config.EncoderConfig.encoderConfig; import static com.jayway.restassured.config.RestAssuredConfig.newConfig; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasItems; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.isEmptyOrNullString; @@ -32,14 +33,18 @@ import static org.hamcrest.Matchers.nullValue; import java.io.ByteArrayInputStream; import java.util.Date; +import java.util.List; +import java.util.Locale; import javax.mail.Flags; import org.apache.http.client.utils.URIBuilder; import org.apache.james.JmapJamesServer; +import org.apache.james.jmap.DefaultMailboxes; import org.apache.james.jmap.HttpJmapAuthentication; import org.apache.james.jmap.api.access.AccessToken; import org.apache.james.mailbox.model.MailboxConstants; +import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.store.mail.model.Mailbox; import org.junit.After; @@ -47,6 +52,7 @@ import org.junit.Before; import org.junit.Test; import com.google.common.base.Charsets; +import com.google.common.collect.ImmutableList; import com.jayway.restassured.RestAssured; import com.jayway.restassured.builder.RequestSpecBuilder; import com.jayway.restassured.http.ContentType; @@ -142,10 +148,10 @@ public abstract class GetMailboxesMethodTest { @Test public void getMailboxesShouldReturnMailboxesWhenIdsMatch() throws Exception { - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.INBOX); jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.INBOX); Mailbox mailbox2 = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox"); String mailboxId = mailbox.getMailboxId().serialize(); @@ -166,10 +172,10 @@ public abstract class GetMailboxesMethodTest { @Test public void getMailboxesShouldReturnOnlyMatchingMailboxesWhenIdsGiven() throws Exception { - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.INBOX); jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.INBOX); String mailboxId = mailbox.getMailboxId().serialize(); @@ -187,7 +193,7 @@ public abstract class GetMailboxesMethodTest { @Test public void getMailboxesShouldReturnEmptyWhenIdsIsEmpty() throws Exception { - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.INBOX); given() .header("Authorization", accessToken.serialize()) @@ -202,15 +208,14 @@ public abstract class GetMailboxesMethodTest { @Test public void getMailboxesShouldReturnAllMailboxesWhenIdsIsNull() throws Exception { - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX"); jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox2"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "INBOX"); - Mailbox mailbox2 = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myMailbox"); - - String mailboxId = mailbox.getMailboxId().serialize(); - String mailboxId2 = mailbox2.getMailboxId().serialize(); - + List<String> expectedMailboxes = ImmutableList.<String> builder() + .addAll(DefaultMailboxes.DEFAULT_MAILBOXES) + .add("myMailbox") + .add("myMailbox2") + .build(); given() .header("Authorization", accessToken.serialize()) .body("[[\"getMailboxes\", {\"ids\": null}, \"#0\"]]") @@ -219,9 +224,8 @@ public abstract class GetMailboxesMethodTest { .then() .statusCode(200) .body(NAME, equalTo("mailboxes")) - .body(ARGUMENTS + ".list", hasSize(2)) - .body(ARGUMENTS + ".list[0].id", equalTo(mailboxId)) - .body(ARGUMENTS + ".list[1].id", equalTo(mailboxId2)); + .body(ARGUMENTS + ".list", hasSize(7)) + .body(ARGUMENTS + ".list.name", hasItems(expectedMailboxes.toArray())); } @Test @@ -240,19 +244,6 @@ public abstract class GetMailboxesMethodTest { } @Test - public void getMailboxesShouldReturnEmptyListWhenNoMailboxes() throws Exception { - given() - .header("Authorization", accessToken.serialize()) - .body("[[\"getMailboxes\", {}, \"#0\"]]") - .when() - .post("/jmap") - .then() - .statusCode(200) - .body(NAME, equalTo("mailboxes")) - .body(ARGUMENTS + ".list", empty()); - } - - @Test public void getMailboxesShouldReturnDefaultMailboxesWhenAuthenticatedUserDoesntHaveAnAccountYet() throws Exception { String token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMzM3QGRvbWFpbi50bGQiLCJuYW1lIjoiTmV3IFVzZXIif" @@ -269,8 +260,8 @@ public abstract class GetMailboxesMethodTest { .then() .statusCode(200) .body(NAME, equalTo("mailboxes")) - .body(ARGUMENTS + ".list", hasSize(4)) - .body(ARGUMENTS + ".list.name", hasItems("INBOX", "Outbox", "Sent", "Trash")); + .body(ARGUMENTS + ".list", hasSize(5)) + .body(ARGUMENTS + ".list.name", hasItems(DefaultMailboxes.DEFAULT_MAILBOXES.toArray())); } @Test @@ -306,7 +297,26 @@ public abstract class GetMailboxesMethodTest { .then() .statusCode(200) .body(NAME, equalTo("mailboxes")) - .body(ARGUMENTS + ".list[0].name", equalTo("name")) + .body(ARGUMENTS + ".list.name", hasItem("name")); + } + + @Test + public void getMailboxesShouldReturnMailboxPropertiesWhenAvailable() throws Exception { + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "name"); + + jmapServer.serverProbe().appendMessage(username, new MailboxPath(MailboxConstants.USER_NAMESPACE, username, "name"), + new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags()); + + MailboxId mailboxId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "name").getMailboxId(); + given() + .header("Authorization", accessToken.serialize()) + .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() + "\"]}, \"#0\"]]") + .when() + .post("/jmap") + .then() + .statusCode(200) + .body(NAME, equalTo("mailboxes")) + .body(ARGUMENTS + ".list.name", hasItem("name")) .body(ARGUMENTS + ".list[0].parentId", nullValue()) .body(ARGUMENTS + ".list[0].role", nullValue()) .body(ARGUMENTS + ".list[0].sortOrder", equalTo(1000)) @@ -326,9 +336,10 @@ public abstract class GetMailboxesMethodTest { public void getMailboxesShouldReturnFilteredMailboxesPropertiesWhenRequestContainsFilterProperties() throws Exception { jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "name"); + MailboxId mailboxId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "name").getMailboxId(); given() .header("Authorization", accessToken.serialize()) - .body("[[\"getMailboxes\", {\"properties\" : [\"unreadMessages\", \"sortOrder\"]}, \"#0\"]]") + .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() + "\"], \"properties\" : [\"unreadMessages\", \"sortOrder\"]}, \"#0\"]]") .when() .post("/jmap") .then() @@ -385,38 +396,41 @@ public abstract class GetMailboxesMethodTest { @Test public void getMailboxesShouldReturnMailboxesWithSortOrder() throws Exception { - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "inbox"); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "trash"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.INBOX); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.TRASH); + MailboxId inboxId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.INBOX).getMailboxId(); + MailboxId trashId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.TRASH).getMailboxId(); given() .header("Authorization", accessToken.serialize()) - .body("[[\"getMailboxes\", {}, \"#0\"]]") + .body("[[\"getMailboxes\", {\"ids\": [\"" + inboxId.serialize() + "\", \"" + trashId.serialize() + "\"]}, \"#0\"]]") .when() .post("/jmap") .then() .statusCode(200) .body(NAME, equalTo("mailboxes")) .body(ARGUMENTS + ".list", hasSize(2)) - .body(ARGUMENTS + ".list[0].name", equalTo("inbox")) + .body(ARGUMENTS + ".list[0].name", equalTo(DefaultMailboxes.INBOX)) .body(ARGUMENTS + ".list[0].sortOrder", equalTo(10)) - .body(ARGUMENTS + ".list[1].name", equalTo("trash")) + .body(ARGUMENTS + ".list[1].name", equalTo(DefaultMailboxes.TRASH)) .body(ARGUMENTS + ".list[1].sortOrder", equalTo(60)); } @Test public void getMailboxesShouldReturnMailboxesWithRolesInLowerCase() throws Exception { - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "outbox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.OUTBOX); + MailboxId mailboxId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, DefaultMailboxes.OUTBOX).getMailboxId(); given() .header("Authorization", accessToken.serialize()) - .body("[[\"getMailboxes\", {}, \"#0\"]]") + .body("[[\"getMailboxes\", {\"ids\": [\"" + mailboxId.serialize() + "\"]}, \"#0\"]]") .when() .post("/jmap") .then() .statusCode(200) .body(NAME, equalTo("mailboxes")) .body(ARGUMENTS + ".list", hasSize(1)) - .body(ARGUMENTS + ".list[0].role", equalTo("outbox")); + .body(ARGUMENTS + ".list[0].role", equalTo(DefaultMailboxes.OUTBOX.toLowerCase(Locale.US))); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java index ff7d30a..be275d9 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/GetMessageListMethodTest.java @@ -20,7 +20,6 @@ package org.apache.james.jmap.methods.integration; import static com.jayway.restassured.RestAssured.given; -import static com.jayway.restassured.RestAssured.with; import static com.jayway.restassured.config.EncoderConfig.encoderConfig; import static com.jayway.restassured.config.RestAssuredConfig.newConfig; import static org.hamcrest.Matchers.contains; @@ -33,7 +32,6 @@ import java.io.ByteArrayInputStream; import java.time.LocalDate; import java.time.ZoneId; import java.util.Date; -import java.util.List; import javax.mail.Flags; @@ -221,16 +219,11 @@ public abstract class GetMessageListMethodTest { new ByteArrayInputStream("Subject: test\r\n\r\ntestmail".getBytes()), new Date(), false, new Flags()); await(); - String mailboxId = - with() - .header("Authorization", accessToken.serialize()) - .body("[[\"getMailboxes\", {}, \"#0\"]]") - .post("/jmap") - .path("[0][1].list[0].id"); + MailboxId mailboxId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox").getMailboxId(); given() .header("Authorization", accessToken.serialize()) - .body("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"" + mailboxId + "\"]}}, \"#0\"]]") + .body("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"" + mailboxId.serialize() + "\"]}}, \"#0\"]]") .when() .post("/jmap") .then() @@ -248,16 +241,12 @@ public abstract class GetMessageListMethodTest { jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2"); await(); - List<String> mailboxIds = - with() - .header("Authorization", accessToken.serialize()) - .body("[[\"getMailboxes\", {}, \"#0\"]]") - .post("/jmap") - .path("[0][1].list.id"); - + MailboxId mailboxId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox").getMailboxId(); + MailboxId mailboxId2 = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "mailbox2").getMailboxId(); + given() .header("Authorization", accessToken.serialize()) - .body(String.format("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"%s\", \"%s\"]}}, \"#0\"]]", mailboxIds.get(0), mailboxIds.get(1))) + .body(String.format("[[\"getMessageList\", {\"filter\":{\"inMailboxes\":[\"%s\", \"%s\"]}}, \"#0\"]]", mailboxId.serialize(), mailboxId2.serialize())) .when() .post("/jmap") .then() http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java index 1e67427..3a310f0 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMailboxesMethodTest.java @@ -29,7 +29,7 @@ import static org.hamcrest.Matchers.containsInAnyOrder; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.hasEntry; -import static org.hamcrest.Matchers.hasItems; +import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasKey; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.isEmptyOrNullString; @@ -40,6 +40,7 @@ import static org.hamcrest.collection.IsMapWithSize.aMapWithSize; import org.apache.commons.lang3.StringUtils; import org.apache.http.client.utils.URIBuilder; import org.apache.james.JmapJamesServer; +import org.apache.james.jmap.DefaultMailboxes; import org.apache.james.jmap.HttpJmapAuthentication; import org.apache.james.jmap.api.access.AccessToken; import org.apache.james.mailbox.model.MailboxConstants; @@ -88,7 +89,7 @@ public abstract class SetMailboxesMethodTest { String password = "password"; jmapServer.serverProbe().addDomain(USERS_DOMAIN); jmapServer.serverProbe().addUser(username, password); - jmapServer.serverProbe().createMailbox("#private", username, "inbox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX); accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), username, password); await(); @@ -143,8 +144,8 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldNotUpdateMailboxWhenOverLimitName() { String overLimitName = StringUtils.repeat("a", MAILBOX_NAME_LENGTH_64K); - jmapServer.serverProbe().createMailbox("#private", username, "myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = "[" + @@ -205,8 +206,8 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldUpdateMailboxWhenOverLimitName() throws Exception { String overLimitName = StringUtils.repeat("a", MAILBOX_NAME_LENGTH_64K); - jmapServer.serverProbe().createMailbox("#private", username, "myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = "[" + @@ -265,16 +266,7 @@ public abstract class SetMailboxesMethodTest { @Test public void userShouldBeSubscribedOnCreatedMailboxWhenCreateChildOfInboxMailbox() throws Exception { - String inboxId = - with() - .header("Authorization", this.accessToken.serialize()) - .body("[[\"getMailboxes\", {}, \"#0\"]]") - .when() - .post("/jmap") - .then() - .extract() - .jsonPath() - .getString(ARGUMENTS + ".list[0].id"); + MailboxId inboxId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX).getMailboxId(); String requestBody = "[" + @@ -283,7 +275,7 @@ public abstract class SetMailboxesMethodTest { " \"create\": {" + " \"create-id01\" : {" + " \"name\" : \"foo\"," + - " \"parentId\" : \"" + inboxId + "\"" + + " \"parentId\" : \"" + inboxId.serialize() + "\"" + " }" + " }" + " }," + @@ -297,15 +289,15 @@ public abstract class SetMailboxesMethodTest { .when() .post("/jmap"); - assertThat(jmapServer.serverProbe().listSubscriptions(username)).containsOnly("inbox.foo"); + assertThat(jmapServer.serverProbe().listSubscriptions(username)).containsOnly(DefaultMailboxes.INBOX + ".foo"); } @Test public void subscriptionUserShouldBeChangedWhenUpdateMailbox() throws Exception { - jmapServer.serverProbe().createMailbox("#private", username, "root"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root"); - jmapServer.serverProbe().createMailbox("#private", username, "root.myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "root.myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = @@ -355,7 +347,7 @@ public abstract class SetMailboxesMethodTest { .body(NAME, equalTo("mailboxesSet")) .body(ARGUMENTS + ".created", hasKey("create-id01")); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "foo"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "foo"); String mailboxId = mailbox.getMailboxId().serialize(); requestBody = @@ -382,8 +374,8 @@ public abstract class SetMailboxesMethodTest { @Test public void subscriptionUserShouldBeDeletedWhenDestroyMailbox() throws Exception { - jmapServer.serverProbe().createMailbox("#private", username, "myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + @@ -431,7 +423,7 @@ public abstract class SetMailboxesMethodTest { .body(NAME, equalTo("mailboxesSet")) .body(ARGUMENTS + ".created", hasKey("create-id01")); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "foo"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "foo"); requestBody = "[" + @@ -567,8 +559,7 @@ public abstract class SetMailboxesMethodTest { .then() .statusCode(200) .body(NAME, equalTo("mailboxes")) - .body(ARGUMENTS + ".list", hasSize(2)) - .body(ARGUMENTS + ".list.name", hasItems("foo")); + .body(ARGUMENTS + ".list.name", hasItem("foo")); } @Test @@ -615,16 +606,7 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldCreateMailboxWhenChildOfInboxMailbox() { - String inboxId = - with() - .header("Authorization", this.accessToken.serialize()) - .body("[[\"getMailboxes\", {}, \"#0\"]]") - .when() - .post("/jmap") - .then() - .extract() - .jsonPath() - .getString(ARGUMENTS + ".list[0].id"); + MailboxId inboxId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX).getMailboxId(); String requestBody = "[" + @@ -633,7 +615,7 @@ public abstract class SetMailboxesMethodTest { " \"create\": {" + " \"create-id01\" : {" + " \"name\" : \"foo\"," + - " \"parentId\" : \"" + inboxId + "\"" + + " \"parentId\" : \"" + inboxId.serialize() + "\"" + " }" + " }" + " }," + @@ -655,8 +637,7 @@ public abstract class SetMailboxesMethodTest { .then() .statusCode(200) .body(NAME, equalTo("mailboxes")) - .body(ARGUMENTS + ".list", hasSize(2)) - .body(ARGUMENTS + ".list.name", hasItems("foo")); + .body(ARGUMENTS + ".list.name", hasItem("foo")); } @Test @@ -766,7 +747,7 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnNotCreatedWhenMailboxAlreadyExists() { - jmapServer.serverProbe().createMailbox("#private", username, "myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + @@ -868,8 +849,8 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnDestroyedMailbox() { - jmapServer.serverProbe().createMailbox("#private", username, "myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = "[" + @@ -894,8 +875,8 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldDestroyMailbox() { - jmapServer.serverProbe().createMailbox("#private", username, "myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String requestBody = "[" + " [ \"setMailboxes\"," + @@ -922,7 +903,7 @@ public abstract class SetMailboxesMethodTest { .then() .statusCode(200) .body(NAME, equalTo("mailboxes")) - .body(ARGUMENTS + ".list", hasSize(1)); + .body(ARGUMENTS + ".list.name", not(hasItem("myBox"))); } @Test @@ -954,9 +935,9 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnNotDestroyedWhenMailboxHasChild() { - jmapServer.serverProbe().createMailbox("#private", username, "myBox"); - jmapServer.serverProbe().createMailbox("#private", username, "myBox.child"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox.child"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = "[" + @@ -984,7 +965,7 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnNotDestroyedWhenSystemMailbox() { - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "inbox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = "[" + @@ -1012,11 +993,11 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnDestroyedWhenParentThenChildMailboxes() { - jmapServer.serverProbe().createMailbox("#private", username, "parent"); - Mailbox parentMailbox = jmapServer.serverProbe().getMailbox("#private", username, "parent"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "parent"); + Mailbox parentMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "parent"); String parentMailboxId = parentMailbox.getMailboxId().serialize(); - jmapServer.serverProbe().createMailbox("#private", username, "parent.child"); - Mailbox childMailbox = jmapServer.serverProbe().getMailbox("#private", username, "parent.child"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "parent.child"); + Mailbox childMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "parent.child"); String childMailboxId = childMailbox.getMailboxId().serialize(); String requestBody = "[" + @@ -1041,11 +1022,11 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnDestroyedWhenChildThenParentMailboxes() { - jmapServer.serverProbe().createMailbox("#private", username, "parent"); - Mailbox parentMailbox = jmapServer.serverProbe().getMailbox("#private", username, "parent"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "parent"); + Mailbox parentMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "parent"); String parentMailboxId = parentMailbox.getMailboxId().serialize(); - jmapServer.serverProbe().createMailbox("#private", username, "parent.child"); - Mailbox childMailbox = jmapServer.serverProbe().getMailbox("#private", username, "parent.child"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "parent.child"); + Mailbox childMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "parent.child"); String childMailboxId = childMailbox.getMailboxId().serialize(); String requestBody = "[" + @@ -1107,8 +1088,8 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnUpdatedMailboxIdWhenNoUpdateAskedOnExistingMailbox() { - jmapServer.serverProbe().createMailbox("#private", username, "myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = "[" + @@ -1136,8 +1117,8 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnUpdatedWhenNameUpdateAskedOnExistingMailbox() { - jmapServer.serverProbe().createMailbox("#private", username, "myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = "[" + @@ -1166,8 +1147,8 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldUpdateMailboxNameWhenNameUpdateAskedOnExistingMailbox() { - jmapServer.serverProbe().createMailbox("#private", username, "myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = "[" + @@ -1202,12 +1183,12 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnMailboxIdWhenMovingToAnotherParentMailbox() { - jmapServer.serverProbe().createMailbox("#private", username, "myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String mailboxId = mailbox.getMailboxId().serialize(); - jmapServer.serverProbe().createMailbox("#private", username, "myChosenParentBox"); - Mailbox chosenMailboxParent = jmapServer.serverProbe().getMailbox("#private", username, "myChosenParentBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myChosenParentBox"); + Mailbox chosenMailboxParent = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myChosenParentBox"); String chosenMailboxParentId = chosenMailboxParent.getMailboxId().serialize(); String requestBody = @@ -1237,12 +1218,12 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldUpdateMailboxParentIdWhenMovingToAnotherParentMailbox() { - jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox.myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myPreviousParentBox.myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); String mailboxId = mailbox.getMailboxId().serialize(); - jmapServer.serverProbe().createMailbox("#private", username, "myNewParentBox"); - Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox("#private", username, "myNewParentBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); + Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); String newParentMailboxId = newParentMailbox.getMailboxId().serialize(); String requestBody = @@ -1278,14 +1259,14 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnMailboxIdWhenParentIdUpdateAskedOnExistingMailbox() { - jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); - jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox.myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myPreviousParentBox.myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); String mailboxId = mailbox.getMailboxId().serialize(); - jmapServer.serverProbe().createMailbox("#private", username, "myNewParentBox"); - Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox("#private", username, "myNewParentBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); + Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); String newParentMailboxId = newParentMailbox.getMailboxId().serialize(); String requestBody = @@ -1315,14 +1296,14 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldUpdateMailboxParentIdWhenParentIdUpdateAskedOnExistingMailbox() { - jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); - jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox.myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myPreviousParentBox.myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); String mailboxId = mailbox.getMailboxId().serialize(); - jmapServer.serverProbe().createMailbox("#private", username, "myNewParentBox"); - Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox("#private", username, "myNewParentBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); + Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); String newParentMailboxId = newParentMailbox.getMailboxId().serialize(); String requestBody = @@ -1358,10 +1339,10 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnMailboxIdWhenParentIdUpdateAskedAsOrphanForExistingMailbox() { - jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); - jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox.myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myPreviousParentBox.myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = @@ -1391,10 +1372,10 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldUpdateParentIdWhenAskedAsOrphanForExistingMailbox() { - jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); - jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox.myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myPreviousParentBox.myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = @@ -1430,14 +1411,14 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnMailboxIdWhenNameAndParentIdUpdateForExistingMailbox() { - jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); - jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox.myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myPreviousParentBox.myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); String mailboxId = mailbox.getMailboxId().serialize(); - jmapServer.serverProbe().createMailbox("#private", username, "myNewParentBox"); - Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox("#private", username, "myNewParentBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); + Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); String newParentMailboxId = newParentMailbox.getMailboxId().serialize(); String requestBody = @@ -1468,14 +1449,14 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShoulUpdateMailboxIAndParentIddWhenBothUpdatedForExistingMailbox() { - jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox"); - jmapServer.serverProbe().createMailbox("#private", username, "myPreviousParentBox.myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myPreviousParentBox.myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myPreviousParentBox.myBox"); String mailboxId = mailbox.getMailboxId().serialize(); - jmapServer.serverProbe().createMailbox("#private", username, "myNewParentBox"); - Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox("#private", username, "myNewParentBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); + Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); String newParentMailboxId = newParentMailbox.getMailboxId().serialize(); String requestBody = @@ -1513,8 +1494,8 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnNotUpdatedWhenNameContainsPathDelimiter() { - jmapServer.serverProbe().createMailbox("#private", username, "myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = "[" + @@ -1545,8 +1526,8 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnNotUpdatedWhenNewParentDoesntExist() { - jmapServer.serverProbe().createMailbox("#private", username, "myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String mailboxId = mailbox.getMailboxId().serialize(); String badParentId = getRemovedMailboxId().serialize(); String requestBody = @@ -1578,16 +1559,16 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnNotUpdatedWhenUpdatingParentIdOfAParentMailbox() { - jmapServer.serverProbe().createMailbox("#private", username, "root"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root"); - jmapServer.serverProbe().createMailbox("#private", username, "root.myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "root.myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); String mailboxId = mailbox.getMailboxId().serialize(); - jmapServer.serverProbe().createMailbox("#private", username, "root.myBox.child"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox.child"); - jmapServer.serverProbe().createMailbox("#private", username, "myNewParentBox"); - Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox("#private", username, "myNewParentBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); + Mailbox newParentMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myNewParentBox"); String newParentMailboxId = newParentMailbox.getMailboxId().serialize(); @@ -1620,11 +1601,11 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnNotUpdatedWhenRenamingAMailboxToAnAlreadyExistingMailbox() { - jmapServer.serverProbe().createMailbox("#private", username, "myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String mailboxId = mailbox.getMailboxId().serialize(); - jmapServer.serverProbe().createMailbox("#private", username, "mySecondBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "mySecondBox"); String requestBody = "[" + @@ -1655,10 +1636,10 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnUpdatedWhenRenamingAChildMailbox() { - jmapServer.serverProbe().createMailbox("#private", username, "root"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root"); - jmapServer.serverProbe().createMailbox("#private", username, "root.myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "root.myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = @@ -1688,10 +1669,10 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldUpdateMailboxNameWhenRenamingAChildMailbox() { - jmapServer.serverProbe().createMailbox("#private", username, "root"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root"); - jmapServer.serverProbe().createMailbox("#private", username, "root.myBox"); - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "root.myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "root.myBox"); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = @@ -1728,7 +1709,7 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnNotUpdatedWhenRenamingSystemMailbox() { - Mailbox mailbox = jmapServer.serverProbe().getMailbox("#private", username, "inbox"); + Mailbox mailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, MailboxConstants.INBOX); String mailboxId = mailbox.getMailboxId().serialize(); String requestBody = @@ -1761,8 +1742,8 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnNotUpdatedWhenRenameToSystemMailboxName() { - jmapServer.serverProbe().createMailbox("#private", username, "myBox"); - Mailbox mailboxMyBox = jmapServer.serverProbe().getMailbox("#private", username, "myBox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); + Mailbox mailboxMyBox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "myBox"); String mailboxIdMyBox = mailboxMyBox.getMailboxId().serialize(); String requestBody = @@ -1795,15 +1776,15 @@ public abstract class SetMailboxesMethodTest { @Test public void setMailboxesShouldReturnNotUpdatedErrorWhenMovingMailboxTriggersNameConflict() { - jmapServer.serverProbe().createMailbox("#private", username, "A"); - Mailbox mailboxRootA = jmapServer.serverProbe().getMailbox("#private", username, "A"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "A"); + Mailbox mailboxRootA = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "A"); String mailboxRootAId = mailboxRootA.getMailboxId().serialize(); - jmapServer.serverProbe().createMailbox("#private", username, "A.B"); - jmapServer.serverProbe().createMailbox("#private", username, "A.C"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "A.B"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "A.C"); - jmapServer.serverProbe().createMailbox("#private", username, "A.B.C"); - Mailbox mailboxChildToMoveC = jmapServer.serverProbe().getMailbox("#private", username, "A.B.C"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, username, "A.B.C"); + Mailbox mailboxChildToMoveC = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, username, "A.B.C"); String mailboxChildToMoveCId = mailboxChildToMoveC.getMailboxId().serialize(); String requestBody = http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java index 82b052a..1fd27ad 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/SetMessagesMethodTest.java @@ -53,6 +53,7 @@ import javax.mail.Flags; import org.apache.commons.io.IOUtils; import org.apache.http.client.utils.URIBuilder; import org.apache.james.JmapJamesServer; +import org.apache.james.jmap.DefaultMailboxes; import org.apache.james.jmap.HttpJmapAuthentication; import org.apache.james.jmap.api.access.AccessToken; import org.apache.james.jmap.model.mailbox.Role; @@ -122,12 +123,12 @@ public abstract class SetMessagesMethodTest { String password = "password"; jmapServer.serverProbe().addDomain(USERS_DOMAIN); jmapServer.serverProbe().addUser(USERNAME, password); - jmapServer.serverProbe().createMailbox("#private", USERNAME, "inbox"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, DefaultMailboxes.INBOX); accessToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), USERNAME, password); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "outbox"); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "trash"); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "draft"); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, DefaultMailboxes.OUTBOX); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, DefaultMailboxes.TRASH); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, DefaultMailboxes.DRAFTS); await(); Duration slowPacedPollInterval = Duration.FIVE_HUNDRED_MILLISECONDS; @@ -154,7 +155,7 @@ public abstract class SetMessagesMethodTest { private String getMailboxId(AccessToken accessToken, Role role) { return getAllMailboxesIds(accessToken).stream() - .filter(x -> x.get("role").equals(role.serialize())) + .filter(x -> x.get("role").equalsIgnoreCase(role.serialize())) .map(x -> x.get("id")) .findFirst().get(); } @@ -899,7 +900,6 @@ public abstract class SetMessagesMethodTest { @Test public void setMessagesShouldMoveMessageInSentWhenMessageIsSent() throws MailboxException { // Given - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); String sentMailboxId = getMailboxId(accessToken, Role.SENT); String fromAddress = USERNAME; @@ -1098,7 +1098,6 @@ public abstract class SetMessagesMethodTest { @Test public void setMessagesShouldMoveToSentWhenSendingMessageWithOnlyFromAddress() { - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); String sentMailboxId = getMailboxId(accessToken, Role.SENT); String messageCreationId = "creationId1337"; @@ -1203,13 +1202,10 @@ public abstract class SetMessagesMethodTest { @Test public void setMessagesShouldDeliverMessageToRecipient() throws Exception { // Sender - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); // Recipient String recipientAddress = "recipient" + "@" + USERS_DOMAIN; String password = "password"; jmapServer.serverProbe().addUser(recipientAddress, password); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox"); - await(); AccessToken recipientToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), recipientAddress, password); String messageCreationId = "creationId1337"; @@ -1245,16 +1241,12 @@ public abstract class SetMessagesMethodTest { @Test public void setMessagesShouldStripBccFromDeliveredEmail() throws Exception { - // Sender - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); // Recipient String recipientAddress = "recipient" + "@" + USERS_DOMAIN; String bccRecipient = "bob@" + USERS_DOMAIN; String password = "password"; jmapServer.serverProbe().addUser(recipientAddress, password); jmapServer.serverProbe().addUser(bccRecipient, password); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox"); - await(); AccessToken recipientToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), recipientAddress, password); String messageCreationId = "creationId1337"; @@ -1303,14 +1295,12 @@ public abstract class SetMessagesMethodTest { @Test public void setMessagesShouldKeepBccInSentMailbox() throws Exception { // Sender - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); String sentMailboxId = getMailboxId(accessToken, Role.SENT); // Recipient String recipientAddress = "recipient" + "@" + USERS_DOMAIN; String password = "password"; jmapServer.serverProbe().addUser(recipientAddress, password); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox"); await(); String messageCreationId = "creationId1337"; @@ -1359,17 +1349,14 @@ public abstract class SetMessagesMethodTest { @Test public void setMessagesShouldSendMessageToBcc() throws Exception { // Sender - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); // Recipient String recipientAddress = "recipient" + "@" + USERS_DOMAIN; String password = "password"; jmapServer.serverProbe().addUser(recipientAddress, password); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox"); String bccAddress = "bob" + "@" + USERS_DOMAIN; jmapServer.serverProbe().addUser(bccAddress, password); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, bccAddress, "inbox"); await(); AccessToken bccToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), bccAddress, password); @@ -1438,12 +1425,10 @@ public abstract class SetMessagesMethodTest { @Test public void setMessagesShouldSendAReadableHtmlMessage() throws Exception { // Sender - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); // Recipient String recipientAddress = "recipient" + "@" + USERS_DOMAIN; String password = "password"; jmapServer.serverProbe().addUser(recipientAddress, password); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox"); await(); AccessToken recipientToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), recipientAddress, password); @@ -1480,14 +1465,9 @@ public abstract class SetMessagesMethodTest { @Test public void setMessagesWhenSavingToDraftsShouldNotSendMessage() throws Exception { - String sender = USERNAME; - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, sender, "sent"); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, sender, "drafts"); String recipientAddress = "recipient" + "@" + USERS_DOMAIN; String recipientPassword = "password"; jmapServer.serverProbe().addUser(recipientAddress, recipientPassword); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox"); - await(); AccessToken recipientToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), recipientAddress, recipientPassword); String senderDraftsMailboxId = getMailboxId(accessToken, Role.DRAFTS); @@ -1529,8 +1509,6 @@ public abstract class SetMessagesMethodTest { @Test public void setMessagesWhenSavingToRegularMailboxShouldNotSendMessage() throws Exception { String sender = USERNAME; - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, sender, "sent"); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, sender, "drafts"); jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, sender, "regular"); Mailbox regularMailbox = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, sender, "regular"); String recipientAddress = "recipient" + "@" + USERS_DOMAIN; @@ -1592,14 +1570,10 @@ public abstract class SetMessagesMethodTest { @Test public void setMessagesShouldSendAReadableTextPlusHtmlMessage() throws Exception { - // Sender - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); // Recipient String recipientAddress = "recipient" + "@" + USERS_DOMAIN; String password = "password"; jmapServer.serverProbe().addUser(recipientAddress, password); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, recipientAddress, "inbox"); - await(); AccessToken recipientToken = HttpJmapAuthentication.authenticateJamesUser(baseUri(), recipientAddress, password); String messageCreationId = "creationId1337"; @@ -1655,7 +1629,7 @@ public abstract class SetMessagesMethodTest { @Test public void mailboxIdsShouldReturnUpdatedWhenNoChange() throws Exception { ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); - ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"), + ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags()); String messageToMoveId = message.getMessageId().serialize(); @@ -1685,12 +1659,12 @@ public abstract class SetMessagesMethodTest { @Test public void mailboxIdsShouldBeInDestinationWhenUsingForMove() throws Exception { String newMailboxName = "heartFolder"; - jmapServer.serverProbe().createMailbox("#private", USERNAME, newMailboxName); - Mailbox heartFolder = jmapServer.serverProbe().getMailbox("#private", USERNAME, newMailboxName); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); + Mailbox heartFolder = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); String heartFolderId = heartFolder.getMailboxId().serialize(); ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); - ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"), + ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags()); String messageToMoveId = message.getMessageId().serialize(); @@ -1729,14 +1703,14 @@ public abstract class SetMessagesMethodTest { @Test public void mailboxIdsShouldBeInDestinationWhenUsingForMoveWithoutTrashFolder() throws Exception { - jmapServer.serverProbe().deleteMailbox("#private", USERNAME, "trash"); + jmapServer.serverProbe().deleteMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, DefaultMailboxes.TRASH); String newMailboxName = "heartFolder"; - jmapServer.serverProbe().createMailbox("#private", USERNAME, newMailboxName); - Mailbox heartFolder = jmapServer.serverProbe().getMailbox("#private", USERNAME, newMailboxName); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); + Mailbox heartFolder = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); String heartFolderId = heartFolder.getMailboxId().serialize(); ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); - ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"), + ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags()); String messageToMoveId = message.getMessageId().serialize(); @@ -1775,12 +1749,12 @@ public abstract class SetMessagesMethodTest { @Test public void mailboxIdsShouldNotBeAnymoreInSourceWhenUsingForMove() throws Exception { String newMailboxName = "heartFolder"; - jmapServer.serverProbe().createMailbox("#private", USERNAME, newMailboxName); - Mailbox heartFolder = jmapServer.serverProbe().getMailbox("#private", USERNAME, newMailboxName); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); + Mailbox heartFolder = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); String heartFolderId = heartFolder.getMailboxId().serialize(); ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); - ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"), + ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags()); String messageToMoveId = message.getMessageId().serialize(); @@ -1820,12 +1794,12 @@ public abstract class SetMessagesMethodTest { @Test public void mailboxIdsShouldBeInBothMailboxWhenUsingForCopy() throws Exception { String newMailboxName = "heartFolder"; - jmapServer.serverProbe().createMailbox("#private", USERNAME, newMailboxName); - Mailbox heartFolder = jmapServer.serverProbe().getMailbox("#private", USERNAME, newMailboxName); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); + Mailbox heartFolder = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); String heartFolderId = heartFolder.getMailboxId().serialize(); ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); - ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"), + ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags()); String messageToMoveId = message.getMessageId().serialize(); @@ -1865,7 +1839,7 @@ public abstract class SetMessagesMethodTest { @Test public void mailboxIdsShouldBeInOriginalMailboxWhenNoChange() throws Exception { ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); - ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"), + ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags()); String messageToMoveId = message.getMessageId().serialize(); @@ -1905,7 +1879,7 @@ public abstract class SetMessagesMethodTest { @Test public void mailboxIdsShouldReturnErrorWhenMovingToADeletedMailbox() throws Exception { ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); - ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"), + ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags()); jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "any"); @@ -1944,7 +1918,7 @@ public abstract class SetMessagesMethodTest { @Test public void mailboxIdsShouldReturnErrorWhenSetToEmpty() throws Exception { ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); - ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"), + ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags()); String messageToMoveId = message.getMessageId().serialize(); @@ -1979,12 +1953,12 @@ public abstract class SetMessagesMethodTest { @Test public void updateShouldNotReturnErrorWithFlagsAndMailboxUpdate() throws Exception { String newMailboxName = "heartFolder"; - jmapServer.serverProbe().createMailbox("#private", USERNAME, newMailboxName); - Mailbox heartFolder = jmapServer.serverProbe().getMailbox("#private", USERNAME, newMailboxName); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); + Mailbox heartFolder = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); String heartFolderId = heartFolder.getMailboxId().serialize(); ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); - ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"), + ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags()); String messageToMoveId = message.getMessageId().serialize(); @@ -2014,12 +1988,12 @@ public abstract class SetMessagesMethodTest { @Test public void updateShouldWorkWithFlagsAndMailboxUpdate() throws Exception { String newMailboxName = "heartFolder"; - jmapServer.serverProbe().createMailbox("#private", USERNAME, newMailboxName); - Mailbox heartFolder = jmapServer.serverProbe().getMailbox("#private", USERNAME, newMailboxName); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); + Mailbox heartFolder = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); String heartFolderId = heartFolder.getMailboxId().serialize(); ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); - ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"), + ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags()); String messageToMoveId = message.getMessageId().serialize(); @@ -2059,10 +2033,10 @@ public abstract class SetMessagesMethodTest { @Test public void setMessagesShouldWorkForMoveToTrash() throws Exception { - String trashId = jmapServer.serverProbe().getMailbox("#private", USERNAME, "trash").getMailboxId().serialize(); + String trashId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, DefaultMailboxes.TRASH).getMailboxId().serialize(); ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); - ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"), + ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags()); String messageToMoveId = message.getMessageId().serialize(); @@ -2094,11 +2068,11 @@ public abstract class SetMessagesMethodTest { @Test public void copyToTrashShouldWork() throws Exception { String newMailboxName = "heartFolder"; - jmapServer.serverProbe().createMailbox("#private", USERNAME, newMailboxName); - String trashId = jmapServer.serverProbe().getMailbox("#private", USERNAME, "trash").getMailboxId().serialize(); + jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, newMailboxName); + String trashId = jmapServer.serverProbe().getMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, DefaultMailboxes.TRASH).getMailboxId().serialize(); ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); - ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath("#private", USERNAME, "inbox"), + ComposedMessageId message = jmapServer.serverProbe().appendMessage(USERNAME, new MailboxPath(MailboxConstants.USER_NAMESPACE, USERNAME, MailboxConstants.INBOX), new ByteArrayInputStream("Subject: my test subject\r\n\r\ntestmail".getBytes(Charsets.UTF_8)), Date.from(dateTime.toInstant()), false, new Flags()); String messageToMoveId = message.getMessageId().serialize(); @@ -2137,8 +2111,6 @@ public abstract class SetMessagesMethodTest { @Test public void setMessagesShouldReturnAttachmentsNotFoundWhenBlobIdDoesntExist() throws Exception { - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); - await(); String messageCreationId = "creationId"; String fromAddress = USERNAME; String outboxId = getOutboxId(accessToken); @@ -2180,8 +2152,6 @@ public abstract class SetMessagesMethodTest { @Test public void setMessagesShouldReturnAttachmentsWhenMessageHasAttachment() throws Exception { - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); - Attachment attachment = Attachment.builder() .bytes("attachment".getBytes(Charsets.UTF_8)) .type("application/octet-stream") @@ -2251,8 +2221,6 @@ public abstract class SetMessagesMethodTest { @Test public void setMessagesShouldReturnAttachmentsWithNonASCIINames() throws Exception { - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); - Attachment attachment = Attachment.builder() .bytes("attachment".getBytes(Charsets.UTF_8)) .type("application/octet-stream") @@ -2339,8 +2307,6 @@ public abstract class SetMessagesMethodTest { @Test public void filenamesAttachmentsWithNonASCIICharactersShouldBeRetrievedWhenChainingSetMessagesAndGetMessages() throws Exception { - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); - Attachment attachment = Attachment.builder() .bytes("attachment".getBytes(Charsets.UTF_8)) .type("application/octet-stream") @@ -2463,8 +2429,6 @@ public abstract class SetMessagesMethodTest { @Test public void attachmentsShouldBeRetrievedWhenChainingSetMessagesAndGetMessagesBinaryAttachment() throws Exception { - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); - byte[] rawBytes = new byte[]{-128,-127,-126,-125,-124,-123,-122,-121,-120,-119,-118,-117,-116,-115,-114,-113,-112,-111,-110,-109,-108,-107,-106,-105,-104,-103,-102,-101,-100, -99,-98,-97,-96,-95,-94,-93,-92,-91,-90,-89,-88,-87,-86,-85,-84,-83,-82,-81,-80,-79,-78,-77,-76,-75,-74,-73,-72,-71,-70,-69,-68,-67,-66,-65,-64,-63,-62,-61,-60,-59,-58,-57,-56,-55,-54,-53,-52,-51, -50,-49,-48,-47,-46,-45,-44,-43,-42,-41,-40,-39,-38,-37,-36,-35,-34,-33,-32,-31,-30,-29,-28,-27,-26,-25,-24,-23,-22,-21,-20,-19,-18,-17,-16,-15,-14,-13,-12,-11,-10,-9,-8,-7,-6,-5,-4,-3,-2,-1, @@ -2543,8 +2507,6 @@ public abstract class SetMessagesMethodTest { @Test public void attachmentsShouldBeRetrievedWhenChainingSetMessagesAndGetMessagesTextAttachment() throws Exception { - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); - Attachment attachment = Attachment.builder() .bytes(ByteStreams.toByteArray(new ZeroedInputStream(_1MB))) .type("application/octet-stream") @@ -2636,8 +2598,6 @@ public abstract class SetMessagesMethodTest { @Test public void attachmentsAndBodysShouldBeRetrievedWhenChainingSetMessagesAndGetMessagesWithMixedTextAndHtmlBodyAndHtmlAttachment() throws Exception { - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); - Attachment attachment = Attachment.builder() .bytes(("<html>\n" + " <body>attachment</body>\n" + // needed indentation, else restassured is adding some @@ -2712,8 +2672,6 @@ public abstract class SetMessagesMethodTest { @Test public void attachmentsAndBodyShouldBeRetrievedWhenChainingSetMessagesAndGetMessagesWithTextBodyAndHtmlAttachment() throws Exception { - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); - Attachment attachment = Attachment.builder() .bytes(("<html>\n" + " <body>attachment</body>\n" + // needed indentation, else restassured is adding some @@ -2786,8 +2744,6 @@ public abstract class SetMessagesMethodTest { } @Test public void attachmentAndEmptyBodyShouldBeRetrievedWhenChainingSetMessagesAndGetMessagesWithTextAttachmentWithoutMailBody() throws Exception { - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); - Attachment attachment = Attachment.builder() .bytes(("some text").getBytes(Charsets.UTF_8)) .type("text/plain; charset=UTF-8") @@ -2860,9 +2816,7 @@ public abstract class SetMessagesMethodTest { String toUsername = "username1@" + USERS_DOMAIN; String password = "password"; jmapServer.serverProbe().addUser(toUsername, password); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, toUsername, "inbox"); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); String messageCreationId = "creationId1337"; String fromAddress = USERNAME; String requestBody = "[" + @@ -2898,9 +2852,7 @@ public abstract class SetMessagesMethodTest { String toUsername = "username1@" + USERS_DOMAIN; String password = "password"; jmapServer.serverProbe().addUser(toUsername, password); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, toUsername, "inbox"); - jmapServer.serverProbe().createMailbox(MailboxConstants.USER_NAMESPACE, USERNAME, "sent"); String messageCreationId = "creationId1337"; String fromAddress = USERNAME; String requestBody = "[" + http://git-wip-us.apache.org/repos/asf/james-project/blob/844efe2a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java index e84b91b..9d91811 100644 --- a/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java +++ b/server/protocols/jmap-integration-testing/jmap-integration-testing-common/src/test/java/org/apache/james/jmap/methods/integration/cucumber/GetMessagesMethodStepdefs.java @@ -39,6 +39,7 @@ import javax.mail.Flags; import org.apache.commons.lang3.StringEscapeUtils; import org.apache.http.HttpResponse; import org.apache.http.client.fluent.Request; +import org.apache.james.jmap.DefaultMailboxes; import org.apache.james.jmap.methods.integration.cucumber.util.TableRow; import org.apache.james.mailbox.model.MailboxConstants; import org.apache.james.mailbox.model.MailboxId; @@ -203,7 +204,7 @@ public class GetMessagesMethodStepdefs { private void appendMessage(String messageName, String emlFileName) throws Exception { ZonedDateTime dateTime = ZonedDateTime.parse("2014-10-30T14:12:00Z"); MessageId id = mainStepdefs.jmapServer.serverProbe().appendMessage(userStepdefs.lastConnectedUser, - new MailboxPath(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, "inbox"), + new MailboxPath(MailboxConstants.USER_NAMESPACE, userStepdefs.lastConnectedUser, DefaultMailboxes.INBOX), ClassLoader.getSystemResourceAsStream(emlFileName), Date.from(dateTime.toInstant()), false, new Flags()) .getMessageId(); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
