You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2019/06/17 13:02:24 UTC

[james-project] branch master updated (860f726 -> e738cd3)

This is an automated email from the ASF dual-hosted git repository.

rouazana pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git.


    from 860f726  JAMES-2146 Allow JamesServerBuilder to override guice modules
     new 4455766  JAMES-2788 release threads in TaskRoutesTest
     new 5d316ee  JAMES-2788 release threads in MemoryTaskManagerTest
     new 9fe02e5  JAMES-2621 MailboxManager doesn't throw when creating a mailbox containing another user path
     new 1d6849e  JAMES-2621 MailboxManager should throw when creating a mailbox containing another user path
     new e738cd3  Merge remote-tracking branch 'trantienduchn/JAMES-2621'

The 5 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:
 .../apache/james/mailbox/MailboxManagerTest.java   | 21 ++++++++-
 .../mailbox/backup/DefaultMailboxBackupTest.java   |  2 +-
 .../james/mailbox/store/StoreMailboxManager.java   | 11 +++++
 .../mailets/delivery/MailboxAppenderTest.java      |  2 +-
 .../james/webadmin/routes/TasksRoutesTest.java     | 22 ++++++---
 .../apache/james/task/MemoryTaskManagerTest.java   | 54 ++++++++--------------
 6 files changed, 68 insertions(+), 44 deletions(-)


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


[james-project] 03/05: JAMES-2788 release threads in TaskRoutesTest

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 44557665bc3d754bb5b805557e4774cb9575c44f
Author: Rémi Kowalski <rk...@linagora.com>
AuthorDate: Tue Jun 11 15:53:38 2019 +0200

    JAMES-2788 release threads in TaskRoutesTest
---
 .../james/webadmin/routes/TasksRoutesTest.java     | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/TasksRoutesTest.java b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/TasksRoutesTest.java
index 1a693dc..cb1becf 100644
--- a/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/TasksRoutesTest.java
+++ b/server/protocols/webadmin/webadmin-core/src/test/java/org/apache/james/webadmin/routes/TasksRoutesTest.java
@@ -49,6 +49,7 @@ class TasksRoutesTest {
 
     private MemoryTaskManager taskManager;
     private WebAdminServer webAdminServer;
+    private CountDownLatch waitingForResultLatch;
 
     @BeforeEach
     void setUp() {
@@ -60,10 +61,13 @@ class TasksRoutesTest {
         RestAssured.requestSpecification = WebAdminUtils.buildRequestSpecification(webAdminServer)
             .setBasePath(TasksRoutes.BASE)
             .build();
+
+        waitingForResultLatch = new CountDownLatch(1);
     }
 
     @AfterEach
     void tearDown() {
+        waitingForResultLatch.countDown();
         taskManager.stop();
         webAdminServer.destroy();
     }
@@ -81,7 +85,7 @@ class TasksRoutesTest {
         CountDownLatch taskInProgressLatch = new CountDownLatch(1);
         TaskId taskId = taskManager.submit(() -> {
             taskInProgressLatch.countDown();
-            await();
+            waitForResult();
             return Task.Result.COMPLETED;
         });
 
@@ -97,20 +101,24 @@ class TasksRoutesTest {
             .body("[0].class", is(not(empty())));
     }
 
-    private void await() {
+    private void await(CountDownLatch latch) {
         try {
-            new CountDownLatch(1).await();
+            latch.await();
         } catch (InterruptedException e) {
             throw new RuntimeException(e);
         }
     }
 
+    private void waitForResult() {
+        await(waitingForResultLatch);
+    }
+
     @Test
     void listShouldListTaskWhenStatusFilter() throws Exception {
         CountDownLatch inProgressLatch = new CountDownLatch(1);
         TaskId taskId = taskManager.submit(() -> {
             inProgressLatch.countDown();
-            await();
+            waitForResult();
             return Task.Result.COMPLETED;
         });
 
@@ -133,7 +141,7 @@ class TasksRoutesTest {
         CountDownLatch inProgressLatch = new CountDownLatch(1);
         taskManager.submit(() -> {
             inProgressLatch.countDown();
-            await();
+            waitForResult();
             return Task.Result.COMPLETED;
         });
 
@@ -153,7 +161,7 @@ class TasksRoutesTest {
         CountDownLatch inProgressLatch = new CountDownLatch(1);
         TaskId taskId = taskManager.submit(() -> {
             inProgressLatch.countDown();
-            await();
+            waitForResult();
             return Task.Result.COMPLETED;
         });
 
@@ -218,7 +226,7 @@ class TasksRoutesTest {
     @Test
     void deleteShouldReturnOk() {
         TaskId taskId = taskManager.submit(() -> {
-            await();
+            waitForResult();
             return Task.Result.COMPLETED;
         });
 


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


[james-project] 04/05: JAMES-2788 release threads in MemoryTaskManagerTest

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 5d316eedc646a08f0e9826c1de1f556ff57be2a3
Author: Rémi Kowalski <rk...@linagora.com>
AuthorDate: Tue Jun 11 16:04:37 2019 +0200

    JAMES-2788 release threads in MemoryTaskManagerTest
---
 .../apache/james/task/MemoryTaskManagerTest.java   | 54 ++++++++--------------
 1 file changed, 20 insertions(+), 34 deletions(-)

diff --git a/server/task/src/test/java/org/apache/james/task/MemoryTaskManagerTest.java b/server/task/src/test/java/org/apache/james/task/MemoryTaskManagerTest.java
index 3533eb3..c2166cd 100644
--- a/server/task/src/test/java/org/apache/james/task/MemoryTaskManagerTest.java
+++ b/server/task/src/test/java/org/apache/james/task/MemoryTaskManagerTest.java
@@ -41,14 +41,17 @@ import org.junit.jupiter.api.Test;
 class MemoryTaskManagerTest {
 
     private MemoryTaskManager memoryTaskManager;
+    private CountDownLatch waitingForResultLatch;
 
     @BeforeEach
     void setUp() {
         memoryTaskManager = new MemoryTaskManager();
+        waitingForResultLatch = new CountDownLatch(1);
     }
 
     @AfterEach
     void tearDown() {
+        waitingForResultLatch.countDown();
         memoryTaskManager.stop();
     }
 
@@ -70,10 +73,8 @@ class MemoryTaskManagerTest {
 
     @Test
     void getStatusShouldReturnWaitingWhenNotYetProcessed() {
-        CountDownLatch task1Latch = new CountDownLatch(1);
-
         memoryTaskManager.submit(() -> {
-            await(task1Latch);
+            waitForResult();
             return Task.Result.COMPLETED;
         });
 
@@ -86,19 +87,17 @@ class MemoryTaskManagerTest {
     @Test
     void taskCodeAfterCancelIsNotRun() {
         CountDownLatch waitForTaskToBeLaunched = new CountDownLatch(1);
-        CountDownLatch task1Latch = new CountDownLatch(1);
         AtomicInteger count = new AtomicInteger(0);
 
         TaskId id = memoryTaskManager.submit(() -> {
             waitForTaskToBeLaunched.countDown();
-            await(task1Latch);
+            waitForResult();
             count.incrementAndGet();
             return Task.Result.COMPLETED;
         });
 
         await(waitForTaskToBeLaunched);
         memoryTaskManager.cancel(id);
-        task1Latch.countDown();
 
         assertThat(count.get()).isEqualTo(0);
     }
@@ -177,10 +176,8 @@ class MemoryTaskManagerTest {
 
     @Test
     void cancelShouldBeIdempotent() {
-        CountDownLatch task1Latch = new CountDownLatch(1);
-
         TaskId id = memoryTaskManager.submit(() -> {
-            await(task1Latch);
+            waitForResult();
             return Task.Result.COMPLETED;
         });
         awaitUntilTaskHasStatus(id, TaskManager.Status.IN_PROGRESS);
@@ -191,21 +188,17 @@ class MemoryTaskManagerTest {
 
     @Test
     void getStatusShouldReturnInProgressWhenProcessingIsInProgress() {
-        CountDownLatch latch1 = new CountDownLatch(1);
-
         TaskId taskId = memoryTaskManager.submit(() -> {
-            await(latch1);
+            waitForResult();
             return Task.Result.COMPLETED;
         });
         awaitUntilTaskHasStatus(taskId, TaskManager.Status.IN_PROGRESS);
         assertThat(memoryTaskManager.getExecutionDetails(taskId).getStatus())
             .isEqualTo(TaskManager.Status.IN_PROGRESS);
-        latch1.countDown();
     }
 
     @Test
     void getStatusShouldReturnCompletedWhenRunSuccessfully() {
-
         TaskId taskId = memoryTaskManager.submit(
             () -> Task.Result.COMPLETED);
 
@@ -216,7 +209,6 @@ class MemoryTaskManagerTest {
 
     @Test
     void getStatusShouldReturnFailedWhenRunPartially() {
-
         TaskId taskId = memoryTaskManager.submit(
             () -> Task.Result.PARTIAL);
 
@@ -231,7 +223,6 @@ class MemoryTaskManagerTest {
         SoftAssertions softly = new SoftAssertions();
 
         CountDownLatch latch1 = new CountDownLatch(1);
-        CountDownLatch latch2 = new CountDownLatch(1);
 
         TaskId failedId = memoryTaskManager.submit(
             () -> Task.Result.PARTIAL);
@@ -240,7 +231,7 @@ class MemoryTaskManagerTest {
         TaskId inProgressId = memoryTaskManager.submit(
             () -> {
                 latch1.countDown();
-                await(latch2);
+                waitForResult();
                 return Task.Result.COMPLETED;
             });
         TaskId waitingId = memoryTaskManager.submit(
@@ -258,7 +249,6 @@ class MemoryTaskManagerTest {
             .isEqualTo(TaskManager.Status.COMPLETED);
         softly.assertThat(entryWithId(list, inProgressId))
             .isEqualTo(TaskManager.Status.IN_PROGRESS);
-        latch2.countDown();
     }
 
     private TaskManager.Status entryWithId(List<TaskExecutionDetails> list, TaskId taskId) {
@@ -272,7 +262,6 @@ class MemoryTaskManagerTest {
     void listShouldAllowToSeeWaitingTasks() throws Exception {
         CountDownLatch latch1 = new CountDownLatch(1);
         CountDownLatch latch2 = new CountDownLatch(1);
-        CountDownLatch latch3 = new CountDownLatch(1);
 
         memoryTaskManager.submit(
             () -> Task.Result.PARTIAL);
@@ -282,12 +271,12 @@ class MemoryTaskManagerTest {
             () -> {
                 await(latch1);
                 latch2.countDown();
-                await(latch3);
+                waitForResult();
                 return Task.Result.COMPLETED;
             });
         TaskId waitingId = memoryTaskManager.submit(
             () -> {
-                await(latch3);
+                waitForResult();
                 latch2.countDown();
                 return Task.Result.COMPLETED;
             });
@@ -298,14 +287,12 @@ class MemoryTaskManagerTest {
         assertThat(memoryTaskManager.list(TaskManager.Status.WAITING))
             .extracting(TaskExecutionDetails::getTaskId)
             .containsOnly(waitingId);
-        latch3.countDown();
     }
 
     @Test
     void listShouldAllowToSeeInProgressTasks() throws Exception {
         CountDownLatch latch1 = new CountDownLatch(1);
         CountDownLatch latch2 = new CountDownLatch(1);
-        CountDownLatch latch3 = new CountDownLatch(1);
 
         memoryTaskManager.submit(
             () -> Task.Result.PARTIAL);
@@ -315,12 +302,12 @@ class MemoryTaskManagerTest {
             () -> {
                 await(latch1);
                 latch2.countDown();
-                await(latch3);
+                waitForResult();
                 return Task.Result.COMPLETED;
             });
         memoryTaskManager.submit(
             () -> {
-                await(latch3);
+                waitForResult();
                 latch2.countDown();
                 return Task.Result.COMPLETED;
             });
@@ -331,14 +318,12 @@ class MemoryTaskManagerTest {
         assertThat(memoryTaskManager.list(TaskManager.Status.COMPLETED))
             .extracting(TaskExecutionDetails::getTaskId)
             .containsOnly(successfulId);
-        latch3.countDown();
     }
 
     @Test
     void listShouldAllowToSeeFailedTasks() throws Exception {
         CountDownLatch latch1 = new CountDownLatch(1);
         CountDownLatch latch2 = new CountDownLatch(1);
-        CountDownLatch latch3 = new CountDownLatch(1);
 
         TaskId failedId = memoryTaskManager.submit(
             () -> Task.Result.PARTIAL);
@@ -348,12 +333,12 @@ class MemoryTaskManagerTest {
             () -> {
                 await(latch1);
                 latch2.countDown();
-                await(latch3);
+                waitForResult();
                 return Task.Result.COMPLETED;
             });
         memoryTaskManager.submit(
             () -> {
-                await(latch3);
+                waitForResult();
                 latch2.countDown();
                 return Task.Result.COMPLETED;
             });
@@ -364,14 +349,12 @@ class MemoryTaskManagerTest {
         assertThat(memoryTaskManager.list(TaskManager.Status.FAILED))
             .extracting(TaskExecutionDetails::getTaskId)
             .containsOnly(failedId);
-        latch3.countDown();
     }
 
     @Test
     void listShouldAllowToSeeSuccessfulTasks() throws Exception {
         CountDownLatch latch1 = new CountDownLatch(1);
         CountDownLatch latch2 = new CountDownLatch(1);
-        CountDownLatch latch3 = new CountDownLatch(1);
 
         memoryTaskManager.submit(
             () -> Task.Result.PARTIAL);
@@ -381,12 +364,12 @@ class MemoryTaskManagerTest {
             () -> {
                 await(latch1);
                 latch2.countDown();
-                await(latch3);
+                waitForResult();
                 return Task.Result.COMPLETED;
             });
         memoryTaskManager.submit(
             () -> {
-                await(latch3);
+                waitForResult();
                 latch2.countDown();
                 return Task.Result.COMPLETED;
             });
@@ -397,7 +380,6 @@ class MemoryTaskManagerTest {
         assertThat(memoryTaskManager.list(TaskManager.Status.IN_PROGRESS))
             .extracting(TaskExecutionDetails::getTaskId)
             .containsOnly(inProgressId);
-        latch3.countDown();
     }
 
     @Test
@@ -503,6 +485,10 @@ class MemoryTaskManagerTest {
         }
     }
 
+    private void waitForResult() {
+        await(waitingForResultLatch);
+    }
+
     private void awaitUntilTaskHasStatus(TaskId id, TaskManager.Status status) {
         awaitAtMostOneSecond.until(() -> memoryTaskManager.getExecutionDetails(id).getStatus().equals(status));
     }


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


[james-project] 02/05: JAMES-2621 MailboxManager should throw when creating a mailbox containing another user path

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 1d6849e0dbe8829e70972dd0f52fcbc2d033df50
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Wed Jun 5 10:55:10 2019 +0700

    JAMES-2621 MailboxManager should throw when creating a mailbox containing
    another user path
---
 .../java/org/apache/james/mailbox/MailboxManagerTest.java     |  9 +++++----
 .../apache/james/mailbox/backup/DefaultMailboxBackupTest.java |  2 +-
 .../org/apache/james/mailbox/store/StoreMailboxManager.java   | 11 +++++++++++
 .../james/transport/mailets/delivery/MailboxAppenderTest.java |  2 +-
 4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
index 4661852..234f2e5 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
@@ -696,7 +696,8 @@ public abstract class MailboxManagerTest<T extends MailboxManager> {
         @Test
         void searchShouldNotReturnResultsFromOtherUsers() throws Exception {
             session = mailboxManager.createSystemSession(USER_1);
-            mailboxManager.createMailbox(MailboxPath.forUser(USER_2, "Other"), session);
+            MailboxSession session2 = mailboxManager.createSystemSession(USER_2);
+            mailboxManager.createMailbox(MailboxPath.forUser(USER_2, "Other"), session2);
             mailboxManager.createMailbox(MailboxPath.inbox(session), session);
             List<MailboxMetaData> metaDatas = mailboxManager.search(
                 MailboxQuery.privateMailboxesBuilder(session)
@@ -1336,12 +1337,12 @@ public abstract class MailboxManagerTest<T extends MailboxManager> {
         }
 
         @Test
-        void createMailboxDoesNotThrowWhenMailboxPathBelongsToAnotherUser() throws MailboxException {
+        void createMailboxShouldThrowWhenMailboxPathBelongsToAnotherUser() throws MailboxException {
             session = mailboxManager.createSystemSession(USER_1);
 
-            assertThatCode(() -> mailboxManager
+            assertThatThrownBy(() -> mailboxManager
                     .createMailbox(MailboxPath.forUser(USER_2, "mailboxName"), session))
-                .doesNotThrowAnyException();
+                .isInstanceOf(MailboxException.class);
         }
     }
 
diff --git a/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/DefaultMailboxBackupTest.java b/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/DefaultMailboxBackupTest.java
index 533150c..e47806f 100644
--- a/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/DefaultMailboxBackupTest.java
+++ b/mailbox/backup/src/test/java/org/apache/james/mailbox/backup/DefaultMailboxBackupTest.java
@@ -197,7 +197,7 @@ class DefaultMailboxBackupTest implements MailboxMessageFixture {
     @Test
     void restoringAccountInNonEmptyAccountShouldNotBeDone() throws Exception {
         createMailbox(sessionUser, MAILBOX_PATH_USER1_MAILBOX1);
-        createMailbox(sessionUser, MAILBOX_PATH_OTHER_USER_MAILBOX1);
+        createMailbox(sessionOtherUser, MAILBOX_PATH_OTHER_USER_MAILBOX1);
 
         ByteArrayOutputStream destination = new ByteArrayOutputStream(BUFFER_SIZE);
         backup.backupAccount(USER1, destination);
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 437b289..901efe6 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
@@ -43,6 +43,7 @@ import org.apache.james.mailbox.MetadataWithMailboxId;
 import org.apache.james.mailbox.StandardMailboxMetaDataComparator;
 import org.apache.james.mailbox.events.EventBus;
 import org.apache.james.mailbox.events.MailboxIdRegistrationKey;
+import org.apache.james.mailbox.exception.InsufficientRightsException;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxExistsException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
@@ -322,6 +323,9 @@ public class StoreMailboxManager implements MailboxManager {
     public Optional<MailboxId> createMailbox(MailboxPath mailboxPath, MailboxSession mailboxSession)
             throws MailboxException {
         LOGGER.debug("createMailbox {}", mailboxPath);
+
+        assertMailboxPathBelongToUser(mailboxSession, mailboxPath);
+
         if (mailboxPath.getName().isEmpty()) {
             LOGGER.warn("Ignoring mailbox with empty name");
         } else {
@@ -367,6 +371,13 @@ public class StoreMailboxManager implements MailboxManager {
         return Optional.empty();
     }
 
+    private void assertMailboxPathBelongToUser(MailboxSession mailboxSession, MailboxPath mailboxPath) throws MailboxException {
+        if (!mailboxPath.belongsTo(mailboxSession)) {
+            throw new InsufficientRightsException("mailboxPath '" + mailboxPath.asString() + "'"
+                + " does not belong to user '" + mailboxSession.getUser().asString() + "'");
+        }
+    }
+
     public boolean isMailboxNameTooLong(MailboxPath mailboxPath) {
         return mailboxPath.getName().length() > MAX_MAILBOX_NAME_LENGTH;
     }
diff --git a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailboxAppenderTest.java b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailboxAppenderTest.java
index 39f377e..c12aaf6 100644
--- a/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailboxAppenderTest.java
+++ b/server/mailet/mailets/src/test/java/org/apache/james/transport/mailets/delivery/MailboxAppenderTest.java
@@ -63,7 +63,7 @@ public class MailboxAppenderTest {
         mailboxManager = InMemoryIntegrationResources.defaultResources().getMailboxManager();
         testee = new MailboxAppender(mailboxManager);
 
-        session = mailboxManager.createSystemSession("TEST");
+        session = mailboxManager.createSystemSession(USER);
     }
 
     @Test


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


[james-project] 05/05: Merge remote-tracking branch 'trantienduchn/JAMES-2621'

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit e738cd3f9482b25c98e6489f7cb1395b92a70089
Merge: 5d316ee 1d6849e
Author: Raphael Ouazana <ra...@linagora.com>
AuthorDate: Mon Jun 17 15:01:28 2019 +0200

    Merge remote-tracking branch 'trantienduchn/JAMES-2621'

 .../apache/james/mailbox/MailboxManagerTest.java    | 21 ++++++++++++++++++++-
 .../mailbox/backup/DefaultMailboxBackupTest.java    |  2 +-
 .../james/mailbox/store/StoreMailboxManager.java    | 11 +++++++++++
 .../mailets/delivery/MailboxAppenderTest.java       |  2 +-
 4 files changed, 33 insertions(+), 3 deletions(-)


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


[james-project] 01/05: JAMES-2621 MailboxManager doesn't throw when creating a mailbox containing another user path

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rouazana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit 9fe02e525c6411179963e64b9c82f2ff4a92e25a
Author: Tran Tien Duc <dt...@linagora.com>
AuthorDate: Wed Jun 5 10:46:08 2019 +0700

    JAMES-2621 MailboxManager doesn't throw when creating a mailbox containing
    another user path
---
 .../org/apache/james/mailbox/MailboxManagerTest.java   | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
index c152e99..4661852 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
@@ -1325,6 +1325,24 @@ public abstract class MailboxManagerTest<T extends MailboxManager> {
             assertThatCode(() -> mailboxManager.copyMessages(MessageRange.all(), inbox, inbox, session))
                 .doesNotThrowAnyException();
         }
+
+        @Test
+        void createMailboxShouldNotThrowWhenMailboxPathBelongsToUser() throws MailboxException {
+            session = mailboxManager.createSystemSession(USER_1);
+            Optional<MailboxId> mailboxId = mailboxManager
+                .createMailbox(MailboxPath.forUser(USER_1, "mailboxName"), session);
+
+            assertThat(mailboxId).isNotEmpty();
+        }
+
+        @Test
+        void createMailboxDoesNotThrowWhenMailboxPathBelongsToAnotherUser() throws MailboxException {
+            session = mailboxManager.createSystemSession(USER_1);
+
+            assertThatCode(() -> mailboxManager
+                    .createMailbox(MailboxPath.forUser(USER_2, "mailboxName"), session))
+                .doesNotThrowAnyException();
+        }
     }
 
     @Nested


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