You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2023/02/07 02:46:10 UTC

[james-project] branch master updated: JAMES-3867 - Fix Bug: Missing IMAP LOGOUT Command Parser in ImapPackage

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 72b5ab66e5 JAMES-3867 - Fix Bug: Missing IMAP LOGOUT Command Parser in ImapPackage
72b5ab66e5 is described below

commit 72b5ab66e5f149f7e9a23db3352aa240e846bfee
Author: Tung Tran <vt...@linagora.com>
AuthorDate: Thu Feb 2 12:56:07 2023 +0700

    JAMES-3867 - Fix Bug: Missing IMAP LOGOUT Command Parser in ImapPackage
---
 .../java/org/apache/james/IMAPIntegrationTest.java | 71 ++++++++++++++++++++++
 .../james/modules/protocols/ImapPackage.java       |  4 +-
 2 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/server/apps/memory-app/src/test/java/org/apache/james/IMAPIntegrationTest.java b/server/apps/memory-app/src/test/java/org/apache/james/IMAPIntegrationTest.java
new file mode 100644
index 0000000000..5eeef109ad
--- /dev/null
+++ b/server/apps/memory-app/src/test/java/org/apache/james/IMAPIntegrationTest.java
@@ -0,0 +1,71 @@
+/****************************************************************
+ * 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;
+
+import static org.apache.james.data.UsersRepositoryModuleChooser.Implementation.DEFAULT;
+import static org.apache.james.jmap.JMAPTestingConstants.BOB;
+import static org.apache.james.jmap.JMAPTestingConstants.BOB_PASSWORD;
+import static org.apache.james.jmap.JMAPTestingConstants.DOMAIN;
+import static org.apache.james.jmap.JMAPTestingConstants.LOCALHOST_IP;
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.james.mailbox.model.MailboxConstants;
+import org.apache.james.modules.TestJMAPServerModule;
+import org.apache.james.modules.protocols.ImapGuiceProbe;
+import org.apache.james.utils.DataProbeImpl;
+import org.apache.james.utils.TestIMAPClient;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.RegisterExtension;
+
+public class IMAPIntegrationTest {
+
+    @RegisterExtension
+    static JamesServerExtension jamesServerExtension = new JamesServerBuilder<MemoryJamesConfiguration>(tmpDir ->
+        MemoryJamesConfiguration.builder()
+            .workingDirectory(tmpDir)
+            .configurationFromClasspath()
+            .usersRepository(DEFAULT)
+            .build())
+        .server(configuration -> MemoryJamesServerMain.createServer(configuration)
+            .overrideWith(new TestJMAPServerModule()))
+        .lifeCycle(JamesServerExtension.Lifecycle.PER_CLASS)
+        .build();
+
+    @BeforeEach
+    void setUp(GuiceJamesServer server) throws Exception {
+        server.getProbe(DataProbeImpl.class).fluent()
+            .addDomain(DOMAIN)
+            .addUser(BOB.asString(), BOB_PASSWORD);
+    }
+
+    @Test
+    void logoutCommandShouldWork(GuiceJamesServer guiceJamesServer) throws Exception {
+        TestIMAPClient testIMAPClient = new TestIMAPClient();
+        long messageCount = testIMAPClient.connect(LOCALHOST_IP, guiceJamesServer.getProbe(ImapGuiceProbe.class).getImapPort())
+            .login(BOB.asString(), BOB_PASSWORD)
+            .getMessageCount(MailboxConstants.INBOX);
+
+        assertThat(messageCount).isEqualTo(0L);
+        assertThat(testIMAPClient.sendCommand("LOGOUT"))
+            .contains("OK LOGOUT completed.");
+    }
+
+}
diff --git a/server/container/guice/protocols/imap/src/main/java/org/apache/james/modules/protocols/ImapPackage.java b/server/container/guice/protocols/imap/src/main/java/org/apache/james/modules/protocols/ImapPackage.java
index ed65657a61..720b63eb7f 100644
--- a/server/container/guice/protocols/imap/src/main/java/org/apache/james/modules/protocols/ImapPackage.java
+++ b/server/container/guice/protocols/imap/src/main/java/org/apache/james/modules/protocols/ImapPackage.java
@@ -44,6 +44,7 @@ import org.apache.james.imap.decode.parser.IdleCommandParser;
 import org.apache.james.imap.decode.parser.ListCommandParser;
 import org.apache.james.imap.decode.parser.ListRightsCommandParser;
 import org.apache.james.imap.decode.parser.LoginCommandParser;
+import org.apache.james.imap.decode.parser.LogoutCommandParser;
 import org.apache.james.imap.decode.parser.LsubCommandParser;
 import org.apache.james.imap.decode.parser.MoveCommandParser;
 import org.apache.james.imap.decode.parser.MyRightsCommandParser;
@@ -285,7 +286,8 @@ public interface ImapPackage {
                     GetQuotaCommandParser.class,
                     SetQuotaCommandParser.class,
                     SetAnnotationCommandParser.class,
-                    GetMetadataCommandParser.class)
+                    GetMetadataCommandParser.class,
+                    LogoutCommandParser.class)
                     .stream()
                     .map(clazz -> new ClassName(clazz.getCanonicalName()))
                     .collect(ImmutableList.toImmutableList()),


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