JAMES-2184 Show LIST do not return shared mailboxes

Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/6c6efcd1
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/6c6efcd1
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/6c6efcd1

Branch: refs/heads/master
Commit: 6c6efcd12b806ac448fa499af96728dbbc590242
Parents: 65d3ac3
Author: quynhn <qngu...@linagora.com>
Authored: Wed Oct 11 16:17:37 2017 +0700
Committer: benwa <btell...@linagora.com>
Committed: Wed Oct 18 09:02:26 2017 +0700

----------------------------------------------------------------------
 .../mpt/script/ImapScriptedTestProtocol.java    | 30 +++++++--
 .../CassandraListingWithSharingTest.java        | 55 +++++++++++++++++
 .../suite/ListingWithSharingTest.java           | 64 ++++++++++++++++++++
 .../imap/scripts/ListWithSharedMailbox.test     | 32 ++++++++++
 .../InMemoryListingWithSharingTest.java         | 52 ++++++++++++++++
 5 files changed, 229 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/6c6efcd1/mpt/core/src/main/java/org/apache/james/mpt/script/ImapScriptedTestProtocol.java
----------------------------------------------------------------------
diff --git 
a/mpt/core/src/main/java/org/apache/james/mpt/script/ImapScriptedTestProtocol.java
 
b/mpt/core/src/main/java/org/apache/james/mpt/script/ImapScriptedTestProtocol.java
index cc11c0e..cc32d1b 100644
--- 
a/mpt/core/src/main/java/org/apache/james/mpt/script/ImapScriptedTestProtocol.java
+++ 
b/mpt/core/src/main/java/org/apache/james/mpt/script/ImapScriptedTestProtocol.java
@@ -19,12 +19,12 @@
 
 package org.apache.james.mpt.script;
 
+import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mpt.api.ImapHostSystem;
 
 public class ImapScriptedTestProtocol extends 
GenericSimpleScriptedTestProtocol<ImapHostSystem, ImapScriptedTestProtocol> {
 
-
     private static class CreateMailbox implements 
PrepareCommand<ImapHostSystem> {
 
         final MailboxPath mailboxPath;
@@ -32,18 +32,40 @@ public class ImapScriptedTestProtocol extends 
GenericSimpleScriptedTestProtocol<
         CreateMailbox(MailboxPath mailboxPath) {
             this.mailboxPath = mailboxPath;
         }
-        
+
+        @Override
         public void prepare(ImapHostSystem system) throws Exception {
             system.createMailbox(mailboxPath);
         }
     }
-    
+
+    private static class CreateRights implements 
PrepareCommand<ImapHostSystem> {
+
+        final MailboxPath mailboxPath;
+        final String userName;
+        final MailboxACL.Rfc4314Rights rights;
+
+        public CreateRights(MailboxPath mailboxPath, String userName, 
MailboxACL.Rfc4314Rights rights) {
+            this.mailboxPath = mailboxPath;
+            this.userName = userName;
+            this.rights = rights;
+        }
+
+        public void prepare(ImapHostSystem system) throws Exception {
+            system.grantRights(mailboxPath, userName, rights);
+        }
+    }
+
+
     public ImapScriptedTestProtocol(String scriptDirectory, ImapHostSystem 
hostSystem) throws Exception {
         super(scriptDirectory, hostSystem);
     }
-    
+
     public ImapScriptedTestProtocol withMailbox(MailboxPath mailboxPath) {
         return withPreparedCommand(new CreateMailbox(mailboxPath));
     }
 
+    public ImapScriptedTestProtocol withRights(MailboxPath mailboxPath, String 
userName, MailboxACL.Rfc4314Rights rights) {
+        return withPreparedCommand(new CreateRights(mailboxPath, userName, 
rights));
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/james-project/blob/6c6efcd1/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListingWithSharingTest.java
----------------------------------------------------------------------
diff --git 
a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListingWithSharingTest.java
 
b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListingWithSharingTest.java
new file mode 100644
index 0000000..6d7fb6d
--- /dev/null
+++ 
b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/CassandraListingWithSharingTest.java
@@ -0,0 +1,55 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mpt.imapmailbox.cassandra;
+
+import org.apache.james.backends.cassandra.DockerCassandraRule;
+import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.suite.ListingWithSharingTest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.ClassRule;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+public class CassandraListingWithSharingTest extends ListingWithSharingTest {
+    @ClassRule
+    public static DockerCassandraRule cassandraServer = new 
DockerCassandraRule();
+
+    private ImapHostSystem system;
+
+    @Before
+    public void setUp() throws Exception {
+        Injector injector = Guice.createInjector(new 
CassandraMailboxTestModule(cassandraServer.getIp(), 
cassandraServer.getBindingPort()));
+        system = injector.getInstance(ImapHostSystem.class);
+        system.beforeTest();
+        super.setUp();
+    }
+
+    @Override
+    protected ImapHostSystem createImapHostSystem() {
+        return system;
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        system.afterTest();
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/6c6efcd1/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ListingWithSharingTest.java
----------------------------------------------------------------------
diff --git 
a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ListingWithSharingTest.java
 
b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ListingWithSharingTest.java
new file mode 100644
index 0000000..64028dd
--- /dev/null
+++ 
b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ListingWithSharingTest.java
@@ -0,0 +1,64 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mpt.imapmailbox.suite;
+
+import java.util.Locale;
+
+import org.apache.james.mailbox.model.MailboxACL;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.ImapTestConstants;
+import org.apache.james.mpt.imapmailbox.suite.base.BasicImapCommands;
+import org.apache.james.mpt.script.ImapScriptedTestProtocol;
+import org.junit.Before;
+import org.junit.Test;
+
+public abstract class ListingWithSharingTest implements ImapTestConstants {
+    public static final String OTHER_USER_NAME = "Boby";
+    public static final String OTHER_USER_PASSWORD = "password";
+    public static final MailboxPath OTHER_USER_SHARED_MAILBOX = 
MailboxPath.forUser( OTHER_USER_NAME, "sharedMailbox");
+    public static final MailboxPath OTHER_USER_SHARED_MAILBOX_CHILD = 
MailboxPath.forUser( OTHER_USER_NAME, "sharedMailbox.child");
+
+    protected abstract ImapHostSystem createImapHostSystem();
+
+    private ImapHostSystem system;
+    private ImapScriptedTestProtocol scriptedTestProtocol;
+
+    @Before
+    public void setUp() throws Exception {
+        system = createImapHostSystem();
+        scriptedTestProtocol = new 
ImapScriptedTestProtocol("/org/apache/james/imap/scripts/", system)
+            .withUser(USER, PASSWORD)
+            .withUser(OTHER_USER_NAME, OTHER_USER_PASSWORD);
+        BasicImapCommands.welcome(scriptedTestProtocol);
+        BasicImapCommands.authenticate(scriptedTestProtocol);
+    }
+
+    @Test
+    public void testListWithSharedMailboxUS() throws Exception {
+        scriptedTestProtocol
+            .withMailbox(OTHER_USER_SHARED_MAILBOX)
+            .withMailbox(OTHER_USER_SHARED_MAILBOX_CHILD)
+            .withRights(OTHER_USER_SHARED_MAILBOX, USER, 
MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("r"))
+            .withRights(OTHER_USER_SHARED_MAILBOX_CHILD, USER, 
MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("r"))
+            .withLocale(Locale.US)
+            .run("ListWithSharedMailbox");
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/6c6efcd1/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/ListWithSharedMailbox.test
----------------------------------------------------------------------
diff --git 
a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/ListWithSharedMailbox.test
 
b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/ListWithSharedMailbox.test
new file mode 100644
index 0000000..2d01957
--- /dev/null
+++ 
b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/ListWithSharedMailbox.test
@@ -0,0 +1,32 @@
+################################################################
+# Licensed to the Apache Software Foundation (ASF) under one   #
+# or more contributor license agreements.  See the NOTICE file #
+# distributed with this work for additional information        #
+# regarding copyright ownership.  The ASF licenses this file   #
+# to you under the Apache License, Version 2.0 (the            #
+# "License"); you may not use this file except in compliance   #
+# with the License.  You may obtain a copy of the License at   #
+#                                                              #
+#   http://www.apache.org/licenses/LICENSE-2.0                 #
+#                                                              #
+# Unless required by applicable law or agreed to in writing,   #
+# software distributed under the License is distributed on an  #
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       #
+# KIND, either express or implied.  See the License for the    #
+# specific language governing permissions and limitations      #
+# under the License.                                           #
+################################################################
+
+# Shouw that #private.Boby.sharedMailbox and it's child are not displayed
+
+C: a0 LIST "" "*"
+S: \* LIST \(\\HasNoChildren\) \"\.\" \"INBOX\"
+S: a0 OK LIST completed.
+
+C: a1 LIST "#private" "%"
+S: \* LIST \(\\HasNoChildren\) \"\.\" \"#private.imapuser.INBOX\"
+S: a1 OK LIST completed.
+
+C: a3 LIST "#private" sharedMailbox*
+S: a3 OK LIST completed.
+

http://git-wip-us.apache.org/repos/asf/james-project/blob/6c6efcd1/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/InMemoryListingWithSharingTest.java
----------------------------------------------------------------------
diff --git 
a/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/InMemoryListingWithSharingTest.java
 
b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/InMemoryListingWithSharingTest.java
new file mode 100644
index 0000000..b5a54ee
--- /dev/null
+++ 
b/mpt/impl/imap-mailbox/inmemory/src/test/java/org/apache/james/mpt/imapmailbox/inmemory/InMemoryListingWithSharingTest.java
@@ -0,0 +1,52 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mpt.imapmailbox.inmemory;
+
+import org.apache.james.mpt.api.ImapHostSystem;
+import org.apache.james.mpt.imapmailbox.suite.ListingWithSharingTest;
+import org.junit.After;
+import org.junit.Before;
+
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+public class InMemoryListingWithSharingTest extends ListingWithSharingTest {
+
+    private ImapHostSystem system;
+
+    @Before
+    public void setUp() throws Exception {
+        Injector injector = Guice.createInjector(new 
InMemoryMailboxTestModule());
+        system = injector.getInstance(ImapHostSystem.class);
+        system.beforeTest();
+        super.setUp();
+    }
+    
+    @Override
+    protected ImapHostSystem createImapHostSystem() {
+        return system;
+    }
+
+    @After
+    public void tearDown() throws Exception {
+        system.afterTest();
+    }
+    
+}


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

Reply via email to