1
0
mirror of https://github.com/bitwarden/server.git synced 2024-11-21 12:05:42 +01:00

[AC-2881] Remove Organization.FlexibleCollections from code (#4552)

* Remove Organization.FlexibleCollections from code

* Drop Organization.FlexibleCollections column in EF databases
(MSSQL column to be retained for 1 additional deployment to support rollback in cloud)
This commit is contained in:
Thomas Rittson 2024-07-26 15:07:33 +10:00 committed by GitHub
parent f9a1a6fc95
commit ffdc40b21c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
25 changed files with 8188 additions and 87 deletions

View File

@ -613,7 +613,7 @@ public class ProviderServiceTests
await sutProvider.GetDependency<IEventService>().DidNotReceiveWithAnyArgs().LogProviderOrganizationEventsAsync(default); await sutProvider.GetDependency<IEventService>().DidNotReceiveWithAnyArgs().LogProviderOrganizationEventsAsync(default);
} }
[Theory, OrganizationCustomize(FlexibleCollections = false), BitAutoData] [Theory, OrganizationCustomize, BitAutoData]
public async Task CreateOrganizationAsync_Success(Provider provider, OrganizationSignup organizationSignup, public async Task CreateOrganizationAsync_Success(Provider provider, OrganizationSignup organizationSignup,
Organization organization, string clientOwnerEmail, User user, SutProvider<ProviderService> sutProvider) Organization organization, string clientOwnerEmail, User user, SutProvider<ProviderService> sutProvider)
{ {
@ -641,7 +641,7 @@ public class ProviderServiceTests
t.First().Item2 == null)); t.First().Item2 == null));
} }
[Theory, OrganizationCustomize(FlexibleCollections = false), BitAutoData] [Theory, OrganizationCustomize, BitAutoData]
public async Task CreateOrganizationAsync_ConsolidatedBillingEnabled_InvalidPlanType_ThrowsBadRequestException( public async Task CreateOrganizationAsync_ConsolidatedBillingEnabled_InvalidPlanType_ThrowsBadRequestException(
Provider provider, Provider provider,
OrganizationSignup organizationSignup, OrganizationSignup organizationSignup,
@ -670,7 +670,7 @@ public class ProviderServiceTests
await providerOrganizationRepository.DidNotReceiveWithAnyArgs().CreateAsync(default); await providerOrganizationRepository.DidNotReceiveWithAnyArgs().CreateAsync(default);
} }
[Theory, OrganizationCustomize(FlexibleCollections = false), BitAutoData] [Theory, OrganizationCustomize, BitAutoData]
public async Task CreateOrganizationAsync_ConsolidatedBillingEnabled_InvokeSignupClientAsync( public async Task CreateOrganizationAsync_ConsolidatedBillingEnabled_InvokeSignupClientAsync(
Provider provider, Provider provider,
OrganizationSignup organizationSignup, OrganizationSignup organizationSignup,

View File

@ -194,10 +194,6 @@ public class OrganizationEditModel : OrganizationViewModel
var newOrg = new Organization var newOrg = new Organization
{ {
// Flexible Collections MVP is fully released and all organizations must always have this setting enabled.
// AC-1714 will remove this flag after all old code has been removed.
FlexibleCollections = true,
// This is a transitional setting that defaults to ON until Flexible Collections v1 is released // This is a transitional setting that defaults to ON until Flexible Collections v1 is released
// (to preserve existing behavior) and defaults to OFF after release (enabling new behavior) // (to preserve existing behavior) and defaults to OFF after release (enabling new behavior)
AllowAdminAccessToAllCollectionItems = !flexibleCollectionsV1Enabled AllowAdminAccessToAllCollectionItems = !flexibleCollectionsV1Enabled

View File

@ -99,12 +99,6 @@ public class Organization : ITableObject<Guid>, IStorableSubscriber, IRevisable,
/// If set to false, users generally need collection-level permissions to read/write a collection or its items. /// If set to false, users generally need collection-level permissions to read/write a collection or its items.
/// </summary> /// </summary>
public bool AllowAdminAccessToAllCollectionItems { get; set; } public bool AllowAdminAccessToAllCollectionItems { get; set; }
/// <summary>
/// This is an organization-level feature flag (not controlled via LaunchDarkly) to onboard organizations to the
/// Flexible Collections MVP changes. This has been fully released and must always be set to TRUE for all organizations.
/// AC-1714 will remove this flag after all old code has been removed.
/// </summary>
public bool FlexibleCollections { get; set; }
public void SetNewId() public void SetNewId()
{ {
@ -275,7 +269,6 @@ public class Organization : ITableObject<Guid>, IStorableSubscriber, IRevisable,
// The following properties are intentionally excluded from being updated: // The following properties are intentionally excluded from being updated:
// - Id - self-hosted org will have its own unique Guid // - Id - self-hosted org will have its own unique Guid
// - MaxStorageGb - not enforced for self-hosted because we're not providing the storage // - MaxStorageGb - not enforced for self-hosted because we're not providing the storage
// - FlexibleCollections - the self-hosted organization must do its own data migration to set this property, it cannot be updated from cloud
Name = license.Name; Name = license.Name;
BusinessName = license.BusinessName; BusinessName = license.BusinessName;

View File

@ -56,5 +56,4 @@ public class OrganizationUserOrganizationDetails
public int? SmServiceAccounts { get; set; } public int? SmServiceAccounts { get; set; }
public bool LimitCollectionCreationDeletion { get; set; } public bool LimitCollectionCreationDeletion { get; set; }
public bool AllowAdminAccessToAllCollectionItems { get; set; } public bool AllowAdminAccessToAllCollectionItems { get; set; }
public bool FlexibleCollections { get; set; }
} }

View File

@ -42,5 +42,4 @@ public class ProviderUserOrganizationDetails
public PlanType PlanType { get; set; } public PlanType PlanType { get; set; }
public bool LimitCollectionCreationDeletion { get; set; } public bool LimitCollectionCreationDeletion { get; set; }
public bool AllowAdminAccessToAllCollectionItems { get; set; } public bool AllowAdminAccessToAllCollectionItems { get; set; }
public bool FlexibleCollections { get; set; }
} }

View File

@ -478,10 +478,6 @@ public class OrganizationService : IOrganizationService
// Secrets Manager not available for purchase with Consolidated Billing. // Secrets Manager not available for purchase with Consolidated Billing.
UseSecretsManager = false, UseSecretsManager = false,
// Flexible Collections MVP is fully released and all organizations must always have this setting enabled.
// AC-1714 will remove this flag after all old code has been removed.
FlexibleCollections = true,
// This is a transitional setting that defaults to ON until Flexible Collections v1 is released // This is a transitional setting that defaults to ON until Flexible Collections v1 is released
// (to preserve existing behavior) and defaults to OFF after release (enabling new behavior) // (to preserve existing behavior) and defaults to OFF after release (enabling new behavior)
AllowAdminAccessToAllCollectionItems = !flexibleCollectionsV1Enabled AllowAdminAccessToAllCollectionItems = !flexibleCollectionsV1Enabled
@ -568,10 +564,6 @@ public class OrganizationService : IOrganizationService
UsePasswordManager = true, UsePasswordManager = true,
UseSecretsManager = signup.UseSecretsManager, UseSecretsManager = signup.UseSecretsManager,
// Flexible Collections MVP is fully released and all organizations must always have this setting enabled.
// AC-1714 will remove this flag after all old code has been removed.
FlexibleCollections = true,
// This is a transitional setting that defaults to ON until Flexible Collections v1 is released // This is a transitional setting that defaults to ON until Flexible Collections v1 is released
// (to preserve existing behavior) and defaults to OFF after release (enabling new behavior) // (to preserve existing behavior) and defaults to OFF after release (enabling new behavior)
AllowAdminAccessToAllCollectionItems = !flexibleCollectionsV1IsEnabled AllowAdminAccessToAllCollectionItems = !flexibleCollectionsV1IsEnabled
@ -696,10 +688,6 @@ public class OrganizationService : IOrganizationService
SmServiceAccounts = license.SmServiceAccounts, SmServiceAccounts = license.SmServiceAccounts,
LimitCollectionCreationDeletion = license.LimitCollectionCreationDeletion, LimitCollectionCreationDeletion = license.LimitCollectionCreationDeletion,
AllowAdminAccessToAllCollectionItems = license.AllowAdminAccessToAllCollectionItems, AllowAdminAccessToAllCollectionItems = license.AllowAdminAccessToAllCollectionItems,
// This feature flag indicates that new organizations should be automatically onboarded to
// Flexible Collections enhancements
FlexibleCollections = true,
}; };
var result = await SignUpAsync(organization, owner.Id, ownerKey, collectionName, false); var result = await SignUpAsync(organization, owner.Id, ownerKey, collectionName, false);
@ -2554,13 +2542,9 @@ public class OrganizationService : IOrganizationService
if (!string.IsNullOrWhiteSpace(collectionName)) if (!string.IsNullOrWhiteSpace(collectionName))
{ {
// If using Flexible Collections, give the owner Can Manage access over the default collection // give the owner Can Manage access over the default collection
List<CollectionAccessSelection> defaultOwnerAccess = null; List<CollectionAccessSelection> defaultOwnerAccess =
if (org.FlexibleCollections) [new CollectionAccessSelection { Id = organizationUserId, HidePasswords = false, ReadOnly = false, Manage = true }];
{
defaultOwnerAccess =
[new CollectionAccessSelection { Id = organizationUserId, HidePasswords = false, ReadOnly = false, Manage = true }];
}
var defaultCollection = new Collection var defaultCollection = new Collection
{ {

View File

@ -68,7 +68,6 @@ public class OrganizationUserOrganizationDetailsViewQuery : IQuery<OrganizationU
SmServiceAccounts = o.SmServiceAccounts, SmServiceAccounts = o.SmServiceAccounts,
LimitCollectionCreationDeletion = o.LimitCollectionCreationDeletion, LimitCollectionCreationDeletion = o.LimitCollectionCreationDeletion,
AllowAdminAccessToAllCollectionItems = o.AllowAdminAccessToAllCollectionItems, AllowAdminAccessToAllCollectionItems = o.AllowAdminAccessToAllCollectionItems,
FlexibleCollections = o.FlexibleCollections
}; };
return query; return query;
} }

View File

@ -46,7 +46,6 @@ public class ProviderUserOrganizationDetailsViewQuery : IQuery<ProviderUserOrgan
PlanType = x.o.PlanType, PlanType = x.o.PlanType,
LimitCollectionCreationDeletion = x.o.LimitCollectionCreationDeletion, LimitCollectionCreationDeletion = x.o.LimitCollectionCreationDeletion,
AllowAdminAccessToAllCollectionItems = x.o.AllowAdminAccessToAllCollectionItems, AllowAdminAccessToAllCollectionItems = x.o.AllowAdminAccessToAllCollectionItems,
FlexibleCollections = x.o.FlexibleCollections
}); });
} }
} }

View File

@ -23,9 +23,6 @@ public class GroupsControllerTests
[BitAutoData] [BitAutoData]
public async Task Post_Success(Organization organization, GroupCreateUpdateRequestModel groupRequestModel, SutProvider<GroupsController> sutProvider) public async Task Post_Success(Organization organization, GroupCreateUpdateRequestModel groupRequestModel, SutProvider<GroupsController> sutProvider)
{ {
// Organization has migrated
organization.FlexibleCollections = true;
// Contains at least one can manage // Contains at least one can manage
groupRequestModel.Collections.First().Manage = true; groupRequestModel.Collections.First().Manage = true;
@ -50,9 +47,6 @@ public class GroupsControllerTests
[BitAutoData] [BitAutoData]
public async Task Put_Success(Organization organization, Group group, GroupCreateUpdateRequestModel groupRequestModel, SutProvider<GroupsController> sutProvider) public async Task Put_Success(Organization organization, Group group, GroupCreateUpdateRequestModel groupRequestModel, SutProvider<GroupsController> sutProvider)
{ {
// Organization has migrated
organization.FlexibleCollections = true;
// Contains at least one can manage // Contains at least one can manage
groupRequestModel.Collections.First().Manage = true; groupRequestModel.Collections.First().Manage = true;

View File

@ -19,7 +19,6 @@ namespace Bit.Core.Test.AutoFixture.OrganizationFixtures;
public class OrganizationCustomization : ICustomization public class OrganizationCustomization : ICustomization
{ {
public bool UseGroups { get; set; } public bool UseGroups { get; set; }
public bool FlexibleCollections { get; set; }
public PlanType PlanType { get; set; } public PlanType PlanType { get; set; }
public void Customize(IFixture fixture) public void Customize(IFixture fixture)
@ -36,7 +35,6 @@ public class OrganizationCustomization : ICustomization
.With(o => o.Id, organizationId) .With(o => o.Id, organizationId)
.With(o => o.MaxCollections, maxCollections) .With(o => o.MaxCollections, maxCollections)
.With(o => o.UseGroups, UseGroups) .With(o => o.UseGroups, UseGroups)
.With(o => o.FlexibleCollections, FlexibleCollections)
.With(o => o.PlanType, PlanType) .With(o => o.PlanType, PlanType)
.With(o => o.Seats, seats) .With(o => o.Seats, seats)
.With(o => o.SmSeats, smSeats)); .With(o => o.SmSeats, smSeats));
@ -198,12 +196,10 @@ internal class TeamsMonthlyWithAddOnsOrganizationCustomization : ICustomization
public class OrganizationCustomizeAttribute : BitCustomizeAttribute public class OrganizationCustomizeAttribute : BitCustomizeAttribute
{ {
public bool UseGroups { get; set; } public bool UseGroups { get; set; }
public bool FlexibleCollections { get; set; }
public PlanType PlanType { get; set; } = PlanType.EnterpriseAnnually; public PlanType PlanType { get; set; } = PlanType.EnterpriseAnnually;
public override ICustomization GetCustomization() => new OrganizationCustomization() public override ICustomization GetCustomization() => new OrganizationCustomization()
{ {
UseGroups = UseGroups, UseGroups = UseGroups,
FlexibleCollections = FlexibleCollections,
PlanType = PlanType PlanType = PlanType
}; };
} }

View File

@ -109,7 +109,6 @@ public class CreateGroupCommandTests
SutProvider<CreateGroupCommand> sutProvider, Organization organization, Group group) SutProvider<CreateGroupCommand> sutProvider, Organization organization, Group group)
{ {
group.AccessAll = true; group.AccessAll = true;
organization.FlexibleCollections = true;
var exception = var exception =
await Assert.ThrowsAsync<BadRequestException>(async () => await sutProvider.Sut.CreateGroupAsync(group, organization)); await Assert.ThrowsAsync<BadRequestException>(async () => await sutProvider.Sut.CreateGroupAsync(group, organization));

View File

@ -123,7 +123,7 @@ public class UpdateGroupCommandTests
} }
[Theory, OrganizationCustomize(UseGroups = true, FlexibleCollections = true), BitAutoData] [Theory, OrganizationCustomize(UseGroups = true), BitAutoData]
public async Task UpdateGroup_GroupBelongsToDifferentOrganization_Throws(SutProvider<UpdateGroupCommand> sutProvider, public async Task UpdateGroup_GroupBelongsToDifferentOrganization_Throws(SutProvider<UpdateGroupCommand> sutProvider,
Group group, Group oldGroup, Organization organization) Group group, Group oldGroup, Organization organization)
{ {
@ -138,7 +138,7 @@ public class UpdateGroupCommandTests
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.UpdateGroupAsync(group, organization)); await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.UpdateGroupAsync(group, organization));
} }
[Theory, OrganizationCustomize(UseGroups = true, FlexibleCollections = true), BitAutoData] [Theory, OrganizationCustomize(UseGroups = true), BitAutoData]
public async Task UpdateGroup_CollectionsBelongsToDifferentOrganization_Throws(SutProvider<UpdateGroupCommand> sutProvider, public async Task UpdateGroup_CollectionsBelongsToDifferentOrganization_Throws(SutProvider<UpdateGroupCommand> sutProvider,
Group group, Group oldGroup, Organization organization, List<CollectionAccessSelection> collectionAccess) Group group, Group oldGroup, Organization organization, List<CollectionAccessSelection> collectionAccess)
{ {
@ -155,7 +155,7 @@ public class UpdateGroupCommandTests
() => sutProvider.Sut.UpdateGroupAsync(group, organization, collectionAccess)); () => sutProvider.Sut.UpdateGroupAsync(group, organization, collectionAccess));
} }
[Theory, OrganizationCustomize(UseGroups = true, FlexibleCollections = true), BitAutoData] [Theory, OrganizationCustomize(UseGroups = true), BitAutoData]
public async Task UpdateGroup_CollectionsDoNotExist_Throws(SutProvider<UpdateGroupCommand> sutProvider, public async Task UpdateGroup_CollectionsDoNotExist_Throws(SutProvider<UpdateGroupCommand> sutProvider,
Group group, Group oldGroup, Organization organization, List<CollectionAccessSelection> collectionAccess) Group group, Group oldGroup, Organization organization, List<CollectionAccessSelection> collectionAccess)
{ {
@ -178,7 +178,7 @@ public class UpdateGroupCommandTests
() => sutProvider.Sut.UpdateGroupAsync(group, organization, collectionAccess)); () => sutProvider.Sut.UpdateGroupAsync(group, organization, collectionAccess));
} }
[Theory, OrganizationCustomize(UseGroups = true, FlexibleCollections = true), BitAutoData] [Theory, OrganizationCustomize(UseGroups = true), BitAutoData]
public async Task UpdateGroup_MemberBelongsToDifferentOrganization_Throws(SutProvider<UpdateGroupCommand> sutProvider, public async Task UpdateGroup_MemberBelongsToDifferentOrganization_Throws(SutProvider<UpdateGroupCommand> sutProvider,
Group group, Group oldGroup, Organization organization, IEnumerable<Guid> userAccess) Group group, Group oldGroup, Organization organization, IEnumerable<Guid> userAccess)
{ {
@ -195,7 +195,7 @@ public class UpdateGroupCommandTests
() => sutProvider.Sut.UpdateGroupAsync(group, organization, null, userAccess)); () => sutProvider.Sut.UpdateGroupAsync(group, organization, null, userAccess));
} }
[Theory, OrganizationCustomize(UseGroups = true, FlexibleCollections = true), BitAutoData] [Theory, OrganizationCustomize(UseGroups = true), BitAutoData]
public async Task UpdateGroup_MemberDoesNotExist_Throws(SutProvider<UpdateGroupCommand> sutProvider, public async Task UpdateGroup_MemberDoesNotExist_Throws(SutProvider<UpdateGroupCommand> sutProvider,
Group group, Group oldGroup, Organization organization, IEnumerable<Guid> userAccess) Group group, Group oldGroup, Organization organization, IEnumerable<Guid> userAccess)
{ {

View File

@ -269,10 +269,6 @@ public class OrganizationServiceTests
var result = await sutProvider.Sut.SignUpAsync(signup); var result = await sutProvider.Sut.SignUpAsync(signup);
// Assert: Organization.FlexibleCollections is enabled
await sutProvider.GetDependency<IOrganizationRepository>().Received(1)
.CreateAsync(Arg.Is<Organization>(o => o.FlexibleCollections));
// Assert: AccessAll is not used // Assert: AccessAll is not used
await sutProvider.GetDependency<IOrganizationUserRepository>().Received(1).CreateAsync( await sutProvider.GetDependency<IOrganizationUserRepository>().Received(1).CreateAsync(
Arg.Is<OrganizationUser>(o => Arg.Is<OrganizationUser>(o =>
@ -464,7 +460,7 @@ public class OrganizationServiceTests
[Theory] [Theory]
[OrganizationInviteCustomize(InviteeUserType = OrganizationUserType.User, [OrganizationInviteCustomize(InviteeUserType = OrganizationUserType.User,
InvitorUserType = OrganizationUserType.Owner), OrganizationCustomize(FlexibleCollections = false), BitAutoData] InvitorUserType = OrganizationUserType.Owner), OrganizationCustomize, BitAutoData]
public async Task InviteUsers_NoEmails_Throws(Organization organization, OrganizationUser invitor, public async Task InviteUsers_NoEmails_Throws(Organization organization, OrganizationUser invitor,
OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider) OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
{ {
@ -477,7 +473,7 @@ public class OrganizationServiceTests
} }
[Theory] [Theory]
[OrganizationInviteCustomize, OrganizationCustomize(FlexibleCollections = false), BitAutoData] [OrganizationInviteCustomize, OrganizationCustomize, BitAutoData]
public async Task InviteUsers_DuplicateEmails_PassesWithoutDuplicates(Organization organization, OrganizationUser invitor, public async Task InviteUsers_DuplicateEmails_PassesWithoutDuplicates(Organization organization, OrganizationUser invitor,
[OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser owner, [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser owner,
OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider) OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
@ -520,7 +516,7 @@ public class OrganizationServiceTests
} }
[Theory] [Theory]
[OrganizationInviteCustomize, OrganizationCustomize(FlexibleCollections = false), BitAutoData] [OrganizationInviteCustomize, OrganizationCustomize, BitAutoData]
public async Task InviteUsers_SsoOrgWithNullSsoConfig_Passes(Organization organization, OrganizationUser invitor, public async Task InviteUsers_SsoOrgWithNullSsoConfig_Passes(Organization organization, OrganizationUser invitor,
[OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser owner, [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser owner,
OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider) OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
@ -568,7 +564,7 @@ public class OrganizationServiceTests
} }
[Theory] [Theory]
[OrganizationInviteCustomize, OrganizationCustomize(FlexibleCollections = false), BitAutoData] [OrganizationInviteCustomize, OrganizationCustomize, BitAutoData]
public async Task InviteUsers_SsoOrgWithNeverEnabledRequireSsoPolicy_Passes(Organization organization, SsoConfig ssoConfig, OrganizationUser invitor, public async Task InviteUsers_SsoOrgWithNeverEnabledRequireSsoPolicy_Passes(Organization organization, SsoConfig ssoConfig, OrganizationUser invitor,
[OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser owner, [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser owner,
OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider) OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
@ -621,7 +617,7 @@ OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
[OrganizationInviteCustomize( [OrganizationInviteCustomize(
InviteeUserType = OrganizationUserType.Admin, InviteeUserType = OrganizationUserType.Admin,
InvitorUserType = OrganizationUserType.Owner InvitorUserType = OrganizationUserType.Owner
), OrganizationCustomize(FlexibleCollections = false), BitAutoData] ), OrganizationCustomize, BitAutoData]
public async Task InviteUsers_NoOwner_Throws(Organization organization, OrganizationUser invitor, public async Task InviteUsers_NoOwner_Throws(Organization organization, OrganizationUser invitor,
OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider) OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
{ {
@ -637,7 +633,7 @@ OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
[OrganizationInviteCustomize( [OrganizationInviteCustomize(
InviteeUserType = OrganizationUserType.Owner, InviteeUserType = OrganizationUserType.Owner,
InvitorUserType = OrganizationUserType.Admin InvitorUserType = OrganizationUserType.Admin
), OrganizationCustomize(FlexibleCollections = false), BitAutoData] ), OrganizationCustomize, BitAutoData]
public async Task InviteUsers_NonOwnerConfiguringOwner_Throws(Organization organization, OrganizationUserInvite invite, public async Task InviteUsers_NonOwnerConfiguringOwner_Throws(Organization organization, OrganizationUserInvite invite,
OrganizationUser invitor, SutProvider<OrganizationService> sutProvider) OrganizationUser invitor, SutProvider<OrganizationService> sutProvider)
{ {
@ -656,7 +652,7 @@ OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
[OrganizationInviteCustomize( [OrganizationInviteCustomize(
InviteeUserType = OrganizationUserType.Custom, InviteeUserType = OrganizationUserType.Custom,
InvitorUserType = OrganizationUserType.User InvitorUserType = OrganizationUserType.User
), OrganizationCustomize(FlexibleCollections = false), BitAutoData] ), OrganizationCustomize, BitAutoData]
public async Task InviteUsers_NonAdminConfiguringAdmin_Throws(Organization organization, OrganizationUserInvite invite, public async Task InviteUsers_NonAdminConfiguringAdmin_Throws(Organization organization, OrganizationUserInvite invite,
OrganizationUser invitor, SutProvider<OrganizationService> sutProvider) OrganizationUser invitor, SutProvider<OrganizationService> sutProvider)
{ {
@ -677,7 +673,7 @@ OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
[OrganizationInviteCustomize( [OrganizationInviteCustomize(
InviteeUserType = OrganizationUserType.Custom, InviteeUserType = OrganizationUserType.Custom,
InvitorUserType = OrganizationUserType.Admin InvitorUserType = OrganizationUserType.Admin
), OrganizationCustomize(FlexibleCollections = false), BitAutoData] ), OrganizationCustomize, BitAutoData]
public async Task InviteUsers_WithCustomType_WhenUseCustomPermissionsIsFalse_Throws(Organization organization, OrganizationUserInvite invite, public async Task InviteUsers_WithCustomType_WhenUseCustomPermissionsIsFalse_Throws(Organization organization, OrganizationUserInvite invite,
OrganizationUser invitor, SutProvider<OrganizationService> sutProvider) OrganizationUser invitor, SutProvider<OrganizationService> sutProvider)
{ {
@ -704,7 +700,7 @@ OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
[OrganizationInviteCustomize( [OrganizationInviteCustomize(
InviteeUserType = OrganizationUserType.Custom, InviteeUserType = OrganizationUserType.Custom,
InvitorUserType = OrganizationUserType.Admin InvitorUserType = OrganizationUserType.Admin
), OrganizationCustomize(FlexibleCollections = false), BitAutoData] ), OrganizationCustomize, BitAutoData]
public async Task InviteUsers_WithCustomType_WhenUseCustomPermissionsIsTrue_Passes(Organization organization, OrganizationUserInvite invite, public async Task InviteUsers_WithCustomType_WhenUseCustomPermissionsIsTrue_Passes(Organization organization, OrganizationUserInvite invite,
OrganizationUser invitor, SutProvider<OrganizationService> sutProvider) OrganizationUser invitor, SutProvider<OrganizationService> sutProvider)
{ {
@ -762,7 +758,7 @@ OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
[OrganizationInviteCustomize( [OrganizationInviteCustomize(
InviteeUserType = OrganizationUserType.User, InviteeUserType = OrganizationUserType.User,
InvitorUserType = OrganizationUserType.Custom InvitorUserType = OrganizationUserType.Custom
), OrganizationCustomize(FlexibleCollections = false), BitAutoData] ), OrganizationCustomize, BitAutoData]
public async Task InviteUsers_CustomUserWithoutManageUsersConfiguringUser_Throws(Organization organization, OrganizationUserInvite invite, public async Task InviteUsers_CustomUserWithoutManageUsersConfiguringUser_Throws(Organization organization, OrganizationUserInvite invite,
OrganizationUser invitor, SutProvider<OrganizationService> sutProvider) OrganizationUser invitor, SutProvider<OrganizationService> sutProvider)
{ {
@ -790,7 +786,7 @@ OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
[OrganizationInviteCustomize( [OrganizationInviteCustomize(
InviteeUserType = OrganizationUserType.Admin, InviteeUserType = OrganizationUserType.Admin,
InvitorUserType = OrganizationUserType.Custom InvitorUserType = OrganizationUserType.Custom
), OrganizationCustomize(FlexibleCollections = false), BitAutoData] ), OrganizationCustomize, BitAutoData]
public async Task InviteUsers_CustomUserConfiguringAdmin_Throws(Organization organization, OrganizationUserInvite invite, public async Task InviteUsers_CustomUserConfiguringAdmin_Throws(Organization organization, OrganizationUserInvite invite,
OrganizationUser invitor, SutProvider<OrganizationService> sutProvider) OrganizationUser invitor, SutProvider<OrganizationService> sutProvider)
{ {
@ -816,7 +812,7 @@ OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
[OrganizationInviteCustomize( [OrganizationInviteCustomize(
InviteeUserType = OrganizationUserType.User, InviteeUserType = OrganizationUserType.User,
InvitorUserType = OrganizationUserType.Owner InvitorUserType = OrganizationUserType.Owner
), OrganizationCustomize(FlexibleCollections = false), BitAutoData] ), OrganizationCustomize, BitAutoData]
public async Task InviteUsers_NoPermissionsObject_Passes(Organization organization, OrganizationUserInvite invite, public async Task InviteUsers_NoPermissionsObject_Passes(Organization organization, OrganizationUserInvite invite,
OrganizationUser invitor, SutProvider<OrganizationService> sutProvider) OrganizationUser invitor, SutProvider<OrganizationService> sutProvider)
{ {
@ -892,7 +888,7 @@ OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
[OrganizationInviteCustomize( [OrganizationInviteCustomize(
InviteeUserType = OrganizationUserType.User, InviteeUserType = OrganizationUserType.User,
InvitorUserType = OrganizationUserType.Custom InvitorUserType = OrganizationUserType.Custom
), OrganizationCustomize(FlexibleCollections = false), BitAutoData] ), OrganizationCustomize, BitAutoData]
public async Task InviteUser_InvitingMoreThanOneUser_Throws(Organization organization, OrganizationUserInvite invite, string externalId, public async Task InviteUser_InvitingMoreThanOneUser_Throws(Organization organization, OrganizationUserInvite invite, string externalId,
OrganizationUser invitor, OrganizationUser invitor,
SutProvider<OrganizationService> sutProvider) SutProvider<OrganizationService> sutProvider)
@ -912,7 +908,7 @@ OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
[OrganizationInviteCustomize( [OrganizationInviteCustomize(
InviteeUserType = OrganizationUserType.User, InviteeUserType = OrganizationUserType.User,
InvitorUserType = OrganizationUserType.Custom InvitorUserType = OrganizationUserType.Custom
), OrganizationCustomize(FlexibleCollections = false), BitAutoData] ), OrganizationCustomize, BitAutoData]
public async Task InviteUser_UserAlreadyInvited_Throws(Organization organization, OrganizationUserInvite invite, string externalId, public async Task InviteUser_UserAlreadyInvited_Throws(Organization organization, OrganizationUserInvite invite, string externalId,
OrganizationUser invitor, OrganizationUser invitor,
[OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser owner, [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser owner,
@ -994,7 +990,7 @@ OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
[OrganizationInviteCustomize( [OrganizationInviteCustomize(
InviteeUserType = OrganizationUserType.User, InviteeUserType = OrganizationUserType.User,
InvitorUserType = OrganizationUserType.Custom InvitorUserType = OrganizationUserType.Custom
), OrganizationCustomize(FlexibleCollections = false), BitAutoData] ), OrganizationCustomize, BitAutoData]
public async Task InviteUsers_Passes(Organization organization, IEnumerable<(OrganizationUserInvite invite, string externalId)> invites, public async Task InviteUsers_Passes(Organization organization, IEnumerable<(OrganizationUserInvite invite, string externalId)> invites,
OrganizationUser invitor, OrganizationUser invitor,
[OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser owner, [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser owner,
@ -1041,7 +1037,7 @@ OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
[OrganizationInviteCustomize( [OrganizationInviteCustomize(
InviteeUserType = OrganizationUserType.User, InviteeUserType = OrganizationUserType.User,
InvitorUserType = OrganizationUserType.Custom InvitorUserType = OrganizationUserType.Custom
), OrganizationCustomize(FlexibleCollections = false), BitAutoData] ), OrganizationCustomize, BitAutoData]
public async Task InviteUsers_WithEventSystemUser_Passes(Organization organization, EventSystemUser eventSystemUser, IEnumerable<(OrganizationUserInvite invite, string externalId)> invites, public async Task InviteUsers_WithEventSystemUser_Passes(Organization organization, EventSystemUser eventSystemUser, IEnumerable<(OrganizationUserInvite invite, string externalId)> invites,
OrganizationUser invitor, OrganizationUser invitor,
[OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser owner, [OrganizationUser(OrganizationUserStatusType.Confirmed, OrganizationUserType.Owner)] OrganizationUser owner,
@ -1091,7 +1087,7 @@ OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
await sutProvider.GetDependency<IEventService>().Received(1).LogOrganizationUserEventsAsync(Arg.Any<IEnumerable<(OrganizationUser, EventType, EventSystemUser, DateTime?)>>()); await sutProvider.GetDependency<IEventService>().Received(1).LogOrganizationUserEventsAsync(Arg.Any<IEnumerable<(OrganizationUser, EventType, EventSystemUser, DateTime?)>>());
} }
[Theory, BitAutoData, OrganizationCustomize(FlexibleCollections = false), OrganizationInviteCustomize] [Theory, BitAutoData, OrganizationCustomize, OrganizationInviteCustomize]
public async Task InviteUsers_WithSecretsManager_Passes(Organization organization, public async Task InviteUsers_WithSecretsManager_Passes(Organization organization,
IEnumerable<(OrganizationUserInvite invite, string externalId)> invites, IEnumerable<(OrganizationUserInvite invite, string externalId)> invites,
OrganizationUser savingUser, SutProvider<OrganizationService> sutProvider) OrganizationUser savingUser, SutProvider<OrganizationService> sutProvider)
@ -1125,7 +1121,7 @@ OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
!update.MaxAutoscaleSmSeatsChanged)); !update.MaxAutoscaleSmSeatsChanged));
} }
[Theory, BitAutoData, OrganizationCustomize(FlexibleCollections = false), OrganizationInviteCustomize] [Theory, BitAutoData, OrganizationCustomize, OrganizationInviteCustomize]
public async Task InviteUsers_WithSecretsManager_WhenErrorIsThrown_RevertsAutoscaling(Organization organization, public async Task InviteUsers_WithSecretsManager_WhenErrorIsThrown_RevertsAutoscaling(Organization organization,
IEnumerable<(OrganizationUserInvite invite, string externalId)> invites, IEnumerable<(OrganizationUserInvite invite, string externalId)> invites,
OrganizationUser savingUser, SutProvider<OrganizationService> sutProvider) OrganizationUser savingUser, SutProvider<OrganizationService> sutProvider)

View File

@ -112,7 +112,6 @@ public class CollectionServiceTest
[CollectionAccessSelectionCustomize] IEnumerable<CollectionAccessSelection> users, SutProvider<CollectionService> sutProvider) [CollectionAccessSelectionCustomize] IEnumerable<CollectionAccessSelection> users, SutProvider<CollectionService> sutProvider)
{ {
collection.Id = default; collection.Id = default;
organization.FlexibleCollections = true;
sutProvider.GetDependency<IOrganizationRepository>().GetByIdAsync(organization.Id).Returns(organization); sutProvider.GetDependency<IOrganizationRepository>().GetByIdAsync(organization.Id).Returns(organization);
sutProvider.GetDependency<IFeatureService>() sutProvider.GetDependency<IFeatureService>()
.IsEnabled(FeatureFlagKeys.FlexibleCollectionsV1, Arg.Any<bool>()) .IsEnabled(FeatureFlagKeys.FlexibleCollectionsV1, Arg.Any<bool>())

View File

@ -35,7 +35,6 @@ public class CipherServiceTests
SutProvider<CipherService> sutProvider) SutProvider<CipherService> sutProvider)
{ {
organization.MaxCollections = null; organization.MaxCollections = null;
organization.FlexibleCollections = true;
importingOrganizationUser.OrganizationId = organization.Id; importingOrganizationUser.OrganizationId = organization.Id;
foreach (var collection in collections) foreach (var collection in collections)

View File

@ -252,6 +252,5 @@ public class OrganizationUserRepositoryTests
Assert.Equal(organization.SmServiceAccounts, result.SmServiceAccounts); Assert.Equal(organization.SmServiceAccounts, result.SmServiceAccounts);
Assert.Equal(organization.LimitCollectionCreationDeletion, result.LimitCollectionCreationDeletion); Assert.Equal(organization.LimitCollectionCreationDeletion, result.LimitCollectionCreationDeletion);
Assert.Equal(organization.AllowAdminAccessToAllCollectionItems, result.AllowAdminAccessToAllCollectionItems); Assert.Equal(organization.AllowAdminAccessToAllCollectionItems, result.AllowAdminAccessToAllCollectionItems);
Assert.Equal(organization.FlexibleCollections, result.FlexibleCollections);
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.MySqlMigrations.Migrations;
/// <inheritdoc />
public partial class DropOrganizationFlexibleCollections : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "FlexibleCollections",
table: "Organization");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "FlexibleCollections",
table: "Organization",
type: "tinyint(1)",
nullable: false,
defaultValue: false);
}
}

View File

@ -69,9 +69,6 @@ namespace Bit.MySqlMigrations.Migrations
b.Property<DateTime?>("ExpirationDate") b.Property<DateTime?>("ExpirationDate")
.HasColumnType("datetime(6)"); .HasColumnType("datetime(6)");
b.Property<bool>("FlexibleCollections")
.HasColumnType("tinyint(1)");
b.Property<byte?>("Gateway") b.Property<byte?>("Gateway")
.HasColumnType("tinyint unsigned"); .HasColumnType("tinyint unsigned");

View File

@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.PostgresMigrations.Migrations;
/// <inheritdoc />
public partial class DropOrganizationFlexibleCollections : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "FlexibleCollections",
table: "Organization");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "FlexibleCollections",
table: "Organization",
type: "boolean",
nullable: false,
defaultValue: false);
}
}

View File

@ -70,9 +70,6 @@ namespace Bit.PostgresMigrations.Migrations
b.Property<DateTime?>("ExpirationDate") b.Property<DateTime?>("ExpirationDate")
.HasColumnType("timestamp with time zone"); .HasColumnType("timestamp with time zone");
b.Property<bool>("FlexibleCollections")
.HasColumnType("boolean");
b.Property<byte?>("Gateway") b.Property<byte?>("Gateway")
.HasColumnType("smallint"); .HasColumnType("smallint");

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.SqliteMigrations.Migrations;
/// <inheritdoc />
public partial class DropOrganizationFlexibleCollections : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "FlexibleCollections",
table: "Organization");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "FlexibleCollections",
table: "Organization",
type: "INTEGER",
nullable: false,
defaultValue: false);
}
}

View File

@ -64,9 +64,6 @@ namespace Bit.SqliteMigrations.Migrations
b.Property<DateTime?>("ExpirationDate") b.Property<DateTime?>("ExpirationDate")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<bool>("FlexibleCollections")
.HasColumnType("INTEGER");
b.Property<byte?>("Gateway") b.Property<byte?>("Gateway")
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");