You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2026/07/15 10:17:34 UTC
(james-project) 19/39: [BUILD] CorsHeaderAPITest: isolate using different users
This is an automated email from the ASF dual-hosted git repository.
chibenwa pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git
commit 2b999fde7137bd981555d89f087da4f39454d4bd
Author: Quan Tran <hq...@linagora.com>
AuthorDate: Mon Jul 13 22:58:38 2026 +0700
[BUILD] CorsHeaderAPITest: isolate using different users
---
.../distributed/DistributedCorsHeaderAPITest.java | 2 +-
.../jmap/rfc8621/contract/CorsHeaderAPITest.scala | 26 ++++++++++++++++++----
.../rfc8621/memory/MemoryCorsHeaderAPITest.java | 2 +-
3 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedCorsHeaderAPITest.java b/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedCorsHeaderAPITest.java
index 2acfcd8913..374405dcb6 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedCorsHeaderAPITest.java
+++ b/server/protocols/jmap-rfc-8621-integration-tests/distributed-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/distributed/DistributedCorsHeaderAPITest.java
@@ -21,6 +21,6 @@ package org.apache.james.jmap.rfc8621.distributed;
import org.apache.james.jmap.rfc8621.contract.CorsHeaderAPITest;
-public class DistributedCorsHeaderAPITest extends DistributedBase implements CorsHeaderAPITest {
+public class DistributedCorsHeaderAPITest extends PerClassDistributedBase implements CorsHeaderAPITest {
}
diff --git a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/CorsHeaderAPITest.scala b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/CorsHeaderAPITest.scala
index 60c3484333..1317b09508 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/CorsHeaderAPITest.scala
+++ b/server/protocols/jmap-rfc-8621-integration-tests/jmap-rfc-8621-integration-tests-common/src/main/scala/org/apache/james/jmap/rfc8621/contract/CorsHeaderAPITest.scala
@@ -19,26 +19,44 @@
package org.apache.james.jmap.rfc8621.contract
+import java.nio.charset.StandardCharsets
+import java.util.UUID
+
+import com.google.common.hash.Hashing
import io.netty.handler.codec.http.HttpHeaderNames.ACCEPT
import io.restassured.RestAssured
import io.restassured.RestAssured.`given`
import org.apache.james.GuiceJamesServer
+import org.apache.james.core.Username
import org.apache.james.jmap.JMAPTestingConstants.DOMAIN
import org.apache.james.jmap.http.UserCredential
-import org.apache.james.jmap.rfc8621.contract.Fixture.{ACCEPT_RFC8621_VERSION_HEADER, ACCOUNT_ID, BOB, BOB_PASSWORD, authScheme, baseRequestSpecBuilder}
+import org.apache.james.jmap.rfc8621.contract.Fixture.{ACCEPT_RFC8621_VERSION_HEADER, BOB_PASSWORD, authScheme, baseRequestSpecBuilder}
import org.apache.james.utils.DataProbeImpl
import org.junit.jupiter.api.{BeforeEach, Test}
+object CorsHeaderAPITestContext {
+ case class TestContext(bobUsername: Username, bobAccountId: String)
+ val currentContext: java.util.concurrent.atomic.AtomicReference[TestContext] = new java.util.concurrent.atomic.AtomicReference[TestContext]()
+}
+
trait CorsHeaderAPITest {
+ import CorsHeaderAPITestContext.currentContext
+
+ def bobUsername: Username = currentContext.get().bobUsername
+ def bobAccountId: String = currentContext.get().bobAccountId
+
@BeforeEach
def setUp(server: GuiceJamesServer): Unit = {
+ val bob = Username.fromLocalPartWithDomain(s"bob${UUID.randomUUID().toString.replace("-", "").take(8)}", DOMAIN)
+ currentContext.set(CorsHeaderAPITestContext.TestContext(
+ bob, Hashing.sha256().hashString(bob.asString(), StandardCharsets.UTF_8).toString))
server.getProbe(classOf[DataProbeImpl])
.fluent
.addDomain(DOMAIN)
- .addUser(BOB.asString, BOB_PASSWORD)
+ .addUser(bobUsername.asString, BOB_PASSWORD)
RestAssured.requestSpecification = baseRequestSpecBuilder(server)
- .setAuth(authScheme(UserCredential(BOB, BOB_PASSWORD)))
+ .setAuth(authScheme(UserCredential(bobUsername, BOB_PASSWORD)))
.build
}
@@ -53,7 +71,7 @@ trait CorsHeaderAPITest {
| "methodCalls": [[
| "Mailbox/get",
| {
- | "accountId": "$ACCOUNT_ID"
+ | "accountId": "$bobAccountId"
| },
| "c1"]]
|}""".stripMargin)
diff --git a/server/protocols/jmap-rfc-8621-integration-tests/memory-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/memory/MemoryCorsHeaderAPITest.java b/server/protocols/jmap-rfc-8621-integration-tests/memory-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/memory/MemoryCorsHeaderAPITest.java
index 44d779990e..309abc6962 100644
--- a/server/protocols/jmap-rfc-8621-integration-tests/memory-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/memory/MemoryCorsHeaderAPITest.java
+++ b/server/protocols/jmap-rfc-8621-integration-tests/memory-jmap-rfc-8621-integration-tests/src/test/java/org/apache/james/jmap/rfc8621/memory/MemoryCorsHeaderAPITest.java
@@ -21,6 +21,6 @@ package org.apache.james.jmap.rfc8621.memory;
import org.apache.james.jmap.rfc8621.contract.CorsHeaderAPITest;
-public class MemoryCorsHeaderAPITest extends MemoryBase implements CorsHeaderAPITest {
+public class MemoryCorsHeaderAPITest extends PerClassMemoryBase implements CorsHeaderAPITest {
}
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org