From e6bb6e1114b2defe7620c8054b5b5329d01fe747 Mon Sep 17 00:00:00 2001 From: Shane Melton Date: Mon, 22 Jan 2024 08:05:42 -0800 Subject: [PATCH] [PM-5788] Ensure Collection Service respects Flexible Collections falg (#3686) * [PM-5788] Ensure the organization has FC enabled before enforcing a user/group with Manage permissions * [PM-5788] Fix unit test --- src/Core/Services/Implementations/CollectionService.cs | 2 +- test/Core.Test/Services/CollectionServiceTests.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Core/Services/Implementations/CollectionService.cs b/src/Core/Services/Implementations/CollectionService.cs index 2941de2d56..26e59fd4d6 100644 --- a/src/Core/Services/Implementations/CollectionService.cs +++ b/src/Core/Services/Implementations/CollectionService.cs @@ -56,7 +56,7 @@ public class CollectionService : ICollectionService var usersList = users?.ToList(); // If using Flexible Collections - a collection should always have someone with Can Manage permissions - if (_featureService.IsEnabled(FeatureFlagKeys.FlexibleCollectionsV1)) + if (org.FlexibleCollections && _featureService.IsEnabled(FeatureFlagKeys.FlexibleCollectionsV1)) { var groupHasManageAccess = groupsList?.Any(g => g.Manage) ?? false; var userHasManageAccess = usersList?.Any(u => u.Manage) ?? false; diff --git a/test/Core.Test/Services/CollectionServiceTests.cs b/test/Core.Test/Services/CollectionServiceTests.cs index d57acebe3a..1981d681f3 100644 --- a/test/Core.Test/Services/CollectionServiceTests.cs +++ b/test/Core.Test/Services/CollectionServiceTests.cs @@ -112,6 +112,7 @@ public class CollectionServiceTest [CollectionAccessSelectionCustomize] IEnumerable users, SutProvider sutProvider) { collection.Id = default; + organization.FlexibleCollections = true; sutProvider.GetDependency().GetByIdAsync(organization.Id).Returns(organization); sutProvider.GetDependency() .IsEnabled(FeatureFlagKeys.FlexibleCollectionsV1, Arg.Any())