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 2023/03/19 14:36:10 UTC

[james-project] branch master updated: JAMES-3885 Harden delegation migration tests (#1488)

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

btellier 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 1e64d7d505 JAMES-3885 Harden delegation migration tests (#1488)
1e64d7d505 is described below

commit 1e64d7d505b3e99668a983499ee5ff54816dc3b6
Author: Trần Hồng Quân <55...@users.noreply.github.com>
AuthorDate: Sun Mar 19 21:36:05 2023 +0700

    JAMES-3885 Harden delegation migration tests (#1488)
---
 .../DelegationUsernameChangeTaskStepTest.java      | 24 ++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/server/data/data-memory/src/test/java/org/apache/james/user/memory/DelegationUsernameChangeTaskStepTest.java b/server/data/data-memory/src/test/java/org/apache/james/user/memory/DelegationUsernameChangeTaskStepTest.java
index 1ba073e6d2..b3d07030f1 100644
--- a/server/data/data-memory/src/test/java/org/apache/james/user/memory/DelegationUsernameChangeTaskStepTest.java
+++ b/server/data/data-memory/src/test/java/org/apache/james/user/memory/DelegationUsernameChangeTaskStepTest.java
@@ -23,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.core.Username;
 import org.apache.james.user.api.DelegationUsernameChangeTaskStep;
+import org.assertj.core.api.SoftAssertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
@@ -32,6 +33,7 @@ import reactor.core.publisher.Mono;
 class DelegationUsernameChangeTaskStepTest {
     private static final Username ALICE_OLD = Username.of("alice-old@domain.tld");
     private static final Username ALICE_NEW = Username.of("alice-new@domain.tld");
+    private static final Username ANDRE = Username.of("andre@domain.tld");
     private static final Username BOB = Username.of("bob@domain.tld");
 
     private MemoryDelegationStore delegationStore;
@@ -57,14 +59,32 @@ class DelegationUsernameChangeTaskStepTest {
 
     @Test
     void shouldRemoveDelegationForOldUser() {
+        // ALICE_OLD delegates BOB to access her account
         Mono.from(delegationStore.addAuthorizedUser(BOB)
             .forUser(ALICE_OLD))
             .block();
 
+        // ALICE_OLD can access ANDRE account
+        Mono.from(delegationStore.addAuthorizedUser(ALICE_OLD)
+            .forUser(ANDRE))
+            .block();
+
         Mono.from(testee.changeUsername(ALICE_OLD, ALICE_NEW)).block();
 
-        assertThat(Flux.from(delegationStore.authorizedUsers(ALICE_OLD)).collectList().block())
-            .isEmpty();
+        SoftAssertions.assertSoftly(softly -> {
+            // Check delegatees of ALICE_OLD (make sure it is truncated)
+            softly.assertThat(Flux.from(delegationStore.authorizedUsers(ALICE_OLD)).collectList().block())
+                .isEmpty();
+            // Check delegators of ALICE_OLD (make sure it is truncated)
+            softly.assertThat(Flux.from(delegationStore.delegatedUsers(ALICE_OLD)).collectList().block())
+                .isEmpty();
+            // Check delegatees of ANDRE (make sure ANDRE delegatees do not contain ALICE_OLD)
+            softly.assertThat(Flux.from(delegationStore.authorizedUsers(ANDRE)).collectList().block())
+                .doesNotContain(ALICE_OLD);
+            // Check delegators of BOB (make sure BOB delegators do not contain ALICE_OLD)
+            softly.assertThat(Flux.from(delegationStore.delegatedUsers(BOB)).collectList().block())
+                .doesNotContain(ALICE_OLD);
+        });
     }
 
     @Test


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