This is an automated email from the ASF dual-hosted git repository. quantranhong1999 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 2f7706bdd18df7eb2d35388d46b3424305aa0da2 Author: Quan Tran <[email protected]> AuthorDate: Tue Jul 7 09:23:06 2026 +0700 JAMES-4210 Cover IMAP SASL delegated channel reporting Add WebAdmin regression coverage proving IMAP SASL authentication preserves loggedInUser, including delegated authentication where the connected username and logged-in user differ. --- .../MemoryWebAdminServerIntegrationTest.java | 30 ++++++++++++++++++++++ .../src/test/resources/imapserver.xml | 5 ++++ 2 files changed, 35 insertions(+) diff --git a/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryWebAdminServerIntegrationTest.java b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryWebAdminServerIntegrationTest.java index c63833fb9e..2341714eea 100644 --- a/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryWebAdminServerIntegrationTest.java +++ b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/java/org/apache/james/webadmin/integration/memory/MemoryWebAdminServerIntegrationTest.java @@ -22,8 +22,12 @@ package org.apache.james.webadmin.integration.memory; import static io.restassured.RestAssured.when; import static org.apache.james.data.UsersRepositoryModuleChooser.Implementation.DEFAULT; import static org.apache.james.jmap.JMAPTestingConstants.LOCALHOST_IP; +import static org.assertj.core.api.Assertions.assertThat; import static org.hamcrest.Matchers.is; +import java.nio.charset.StandardCharsets; +import java.util.Base64; + import org.apache.james.GuiceJamesServer; import org.apache.james.JamesServerBuilder; import org.apache.james.JamesServerExtension; @@ -40,6 +44,7 @@ import org.junit.jupiter.api.extension.RegisterExtension; class MemoryWebAdminServerIntegrationTest extends WebAdminServerIntegrationTest { private static final String DOMAIN = "domain"; private static final String USERNAME = "bob@" + DOMAIN; + private static final String ADMIN_USERNAME = "admin@" + DOMAIN; private static final String PASSWORD = "password"; @RegisterExtension @@ -79,4 +84,29 @@ class MemoryWebAdminServerIntegrationTest extends WebAdminServerIntegrationTest .body("[0].protocolSpecificInformation.userAgent", is("{name=Thunderbird, version=102.7.1}")) .body("[0].protocolSpecificInformation.requestCount", is("3")); } + + @Test + void shouldDescribeDelegatedImapChannels(GuiceJamesServer server) throws Exception { + int imapPort = server.getProbe(ImapGuiceProbe.class).getImapPort(); + + server.getProbe(DataProbeImpl.class).addUser(USERNAME, PASSWORD); + server.getProbe(DataProbeImpl.class).addUser(ADMIN_USERNAME, PASSWORD); + + String initialClientResponse = Base64.getEncoder() + .encodeToString((USERNAME + "\0" + ADMIN_USERNAME + "\0" + PASSWORD).getBytes(StandardCharsets.US_ASCII)); + + testIMAPClient.connect(LOCALHOST_IP, imapPort); + String authenticateResponse = testIMAPClient.sendCommand("AUTHENTICATE PLAIN " + initialClientResponse); + testIMAPClient.select("INBOX"); + + assertThat(authenticateResponse).contains("OK AUTHENTICATE completed."); + + // loggedInUser should be well recorded for delegation + when() + .get("/servers/channels/" + USERNAME) + .then() + .statusCode(HttpStatus.OK_200) + .body("[0].username", is(USERNAME)) + .body("[0].protocolSpecificInformation.loggedInUser", is(ADMIN_USERNAME)); + } } \ No newline at end of file diff --git a/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/imapserver.xml b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/imapserver.xml index f30afe0b24..c77b813a5c 100644 --- a/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/imapserver.xml +++ b/server/protocols/webadmin-integration-test/memory-webadmin-integration-test/src/test/resources/imapserver.xml @@ -36,6 +36,11 @@ under the License. <connectionLimit>0</connectionLimit> <connectionLimitPerIP>0</connectionLimitPerIP> <plainAuthDisallowed>false</plainAuthDisallowed> + <auth> + <adminUsers> + <adminUser>admin@domain</adminUser> + </adminUsers> + </auth> <gracefulShutdown>false</gracefulShutdown> <trafficShaping> <writeTrafficPerSecond>0</writeTrafficPerSecond> --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
