From c3d7560652fd268ec66e7eceff7b396461a994bc Mon Sep 17 00:00:00 2001 From: Christian Richter Date: Thu, 6 Nov 2025 17:39:56 +0100 Subject: [PATCH] rewrite test with multiple users Signed-off-by: Christian Richter --- .../graph/pkg/identity/cache/cache_test.go | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/services/graph/pkg/identity/cache/cache_test.go b/services/graph/pkg/identity/cache/cache_test.go index 5cf238a536..973ae9789b 100644 --- a/services/graph/pkg/identity/cache/cache_test.go +++ b/services/graph/pkg/identity/cache/cache_test.go @@ -58,21 +58,31 @@ var _ = Describe("Cache", func() { Expect(ru.GetDisplayName()).To(Equal(alan.GetDisplayName())) }) - It("should return an error, if the tenant id does not match", func() { - alan := &cs3User.User{ + It("should return the correct user if two users with the same uid and different tennant ids exist", func() { + alan1 := &cs3User.User{ Id: &cs3User.UserId{ OpaqueId: "alan", TenantId: "1234", }, - DisplayName: "Alan", + DisplayName: "Alan1", + } + + alan2 := &cs3User.User{ + Id: &cs3User.UserId{ + OpaqueId: "alan", + TenantId: "5678", + }, + DisplayName: "Alan2", } // Persist the user to the cache for 1 hour - idc.users.Set(alan.GetId().GetTenantId()+"|"+alan.GetId().GetOpaqueId(), alan, 3600) - _, err := idc.GetUser(ctx, "5678", "alan") - Expect(err).ToNot(BeNil()) + idc.users.Set(alan1.GetId().GetTenantId()+"|"+alan1.GetId().GetOpaqueId(), alan1, 3600) + idc.users.Set(alan2.GetId().GetTenantId()+"|"+alan2.GetId().GetOpaqueId(), alan2, 3600) + ru, err := idc.GetUser(ctx, "5678", "alan") + Expect(err).To(BeNil()) + Expect(ru.GetDisplayName()).To(Equal(alan2.GetDisplayName())) }) - It("should not return an errorr, if the tenant id does match", func() { + It("should not return an error, if the tenant id does match", func() { alan := &cs3User.User{ Id: &cs3User.UserId{ OpaqueId: "alan",