mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
[PM-10361] Remove Group.AccessAll from code (#4614)
* Remove Group.AccessAll from code * Add shadow property config and migration
This commit is contained in:
@ -23,9 +23,6 @@ public class CreateGroupCommandTests
|
||||
[Theory, OrganizationCustomize(UseGroups = true), BitAutoData]
|
||||
public async Task CreateGroup_Success(SutProvider<CreateGroupCommand> sutProvider, Organization organization, Group group)
|
||||
{
|
||||
// Deprecated with Flexible Collections
|
||||
group.AccessAll = false;
|
||||
|
||||
await sutProvider.Sut.CreateGroupAsync(group, organization);
|
||||
|
||||
await sutProvider.GetDependency<IGroupRepository>().Received(1).CreateAsync(group);
|
||||
@ -38,9 +35,6 @@ public class CreateGroupCommandTests
|
||||
[Theory, OrganizationCustomize(UseGroups = true), BitAutoData]
|
||||
public async Task CreateGroup_WithCollections_Success(SutProvider<CreateGroupCommand> sutProvider, Organization organization, Group group, List<CollectionAccessSelection> collections)
|
||||
{
|
||||
// Deprecated with Flexible Collections
|
||||
group.AccessAll = false;
|
||||
|
||||
// Arrange list of collections to make sure Manage is mutually exclusive
|
||||
for (var i = 0; i < collections.Count; i++)
|
||||
{
|
||||
@ -62,9 +56,6 @@ public class CreateGroupCommandTests
|
||||
[Theory, OrganizationCustomize(UseGroups = true), BitAutoData]
|
||||
public async Task CreateGroup_WithEventSystemUser_Success(SutProvider<CreateGroupCommand> sutProvider, Organization organization, Group group, EventSystemUser eventSystemUser)
|
||||
{
|
||||
// Deprecated with Flexible Collections
|
||||
group.AccessAll = false;
|
||||
|
||||
await sutProvider.Sut.CreateGroupAsync(group, organization, eventSystemUser);
|
||||
|
||||
await sutProvider.GetDependency<IGroupRepository>().Received(1).CreateAsync(group);
|
||||
@ -77,9 +68,6 @@ public class CreateGroupCommandTests
|
||||
[Theory, OrganizationCustomize(UseGroups = true), BitAutoData]
|
||||
public async Task CreateGroup_WithNullOrganization_Throws(SutProvider<CreateGroupCommand> sutProvider, Group group, EventSystemUser eventSystemUser)
|
||||
{
|
||||
// Deprecated with Flexible Collections
|
||||
group.AccessAll = false;
|
||||
|
||||
var exception = await Assert.ThrowsAsync<BadRequestException>(async () => await sutProvider.Sut.CreateGroupAsync(group, null, eventSystemUser));
|
||||
|
||||
Assert.Contains("Organization not found", exception.Message);
|
||||
@ -92,9 +80,6 @@ public class CreateGroupCommandTests
|
||||
[Theory, OrganizationCustomize(UseGroups = false), BitAutoData]
|
||||
public async Task CreateGroup_WithUseGroupsAsFalse_Throws(SutProvider<CreateGroupCommand> sutProvider, Organization organization, Group group, EventSystemUser eventSystemUser)
|
||||
{
|
||||
// Deprecated with Flexible Collections
|
||||
group.AccessAll = false;
|
||||
|
||||
var exception = await Assert.ThrowsAsync<BadRequestException>(async () => await sutProvider.Sut.CreateGroupAsync(group, organization, eventSystemUser));
|
||||
|
||||
Assert.Contains("This organization cannot use groups", exception.Message);
|
||||
@ -103,19 +88,4 @@ public class CreateGroupCommandTests
|
||||
await sutProvider.GetDependency<IEventService>().DidNotReceiveWithAnyArgs().LogGroupEventAsync(default, default, default);
|
||||
await sutProvider.GetDependency<IReferenceEventService>().DidNotReceiveWithAnyArgs().RaiseEventAsync(default);
|
||||
}
|
||||
|
||||
[Theory, OrganizationCustomize(UseGroups = true), BitAutoData]
|
||||
public async Task CreateGroup_WithAccessAll_Throws(
|
||||
SutProvider<CreateGroupCommand> sutProvider, Organization organization, Group group)
|
||||
{
|
||||
group.AccessAll = true;
|
||||
|
||||
var exception =
|
||||
await Assert.ThrowsAsync<BadRequestException>(async () => await sutProvider.Sut.CreateGroupAsync(group, organization));
|
||||
Assert.Contains("AccessAll property has been deprecated", exception.Message);
|
||||
|
||||
await sutProvider.GetDependency<IGroupRepository>().DidNotReceiveWithAnyArgs().CreateAsync(default);
|
||||
await sutProvider.GetDependency<IEventService>().DidNotReceiveWithAnyArgs().LogGroupEventAsync(default, default, default);
|
||||
await sutProvider.GetDependency<IReferenceEventService>().DidNotReceiveWithAnyArgs().RaiseEventAsync(default);
|
||||
}
|
||||
}
|
||||
|
@ -104,30 +104,10 @@ public class UpdateGroupCommandTests
|
||||
await sutProvider.GetDependency<IEventService>().DidNotReceiveWithAnyArgs().LogGroupEventAsync(default, default, default);
|
||||
}
|
||||
|
||||
[Theory, OrganizationCustomize(UseGroups = true), BitAutoData]
|
||||
public async Task UpdateGroup_WithAccessAll_Throws(
|
||||
SutProvider<UpdateGroupCommand> sutProvider, Organization organization, Group group, Group oldGroup)
|
||||
{
|
||||
ArrangeGroup(sutProvider, group, oldGroup);
|
||||
ArrangeUsers(sutProvider, group);
|
||||
ArrangeCollections(sutProvider, group);
|
||||
|
||||
group.AccessAll = true;
|
||||
|
||||
var exception =
|
||||
await Assert.ThrowsAsync<BadRequestException>(async () => await sutProvider.Sut.UpdateGroupAsync(group, organization));
|
||||
Assert.Contains("AccessAll property has been deprecated", exception.Message);
|
||||
|
||||
await sutProvider.GetDependency<IGroupRepository>().DidNotReceiveWithAnyArgs().CreateAsync(default);
|
||||
await sutProvider.GetDependency<IEventService>().DidNotReceiveWithAnyArgs().LogGroupEventAsync(default, default, default);
|
||||
}
|
||||
|
||||
|
||||
[Theory, OrganizationCustomize(UseGroups = true), BitAutoData]
|
||||
public async Task UpdateGroup_GroupBelongsToDifferentOrganization_Throws(SutProvider<UpdateGroupCommand> sutProvider,
|
||||
Group group, Group oldGroup, Organization organization)
|
||||
{
|
||||
group.AccessAll = false;
|
||||
ArrangeGroup(sutProvider, group, oldGroup);
|
||||
ArrangeUsers(sutProvider, group);
|
||||
ArrangeCollections(sutProvider, group);
|
||||
@ -142,7 +122,6 @@ public class UpdateGroupCommandTests
|
||||
public async Task UpdateGroup_CollectionsBelongsToDifferentOrganization_Throws(SutProvider<UpdateGroupCommand> sutProvider,
|
||||
Group group, Group oldGroup, Organization organization, List<CollectionAccessSelection> collectionAccess)
|
||||
{
|
||||
group.AccessAll = false;
|
||||
ArrangeGroup(sutProvider, group, oldGroup);
|
||||
ArrangeUsers(sutProvider, group);
|
||||
|
||||
@ -159,7 +138,6 @@ public class UpdateGroupCommandTests
|
||||
public async Task UpdateGroup_CollectionsDoNotExist_Throws(SutProvider<UpdateGroupCommand> sutProvider,
|
||||
Group group, Group oldGroup, Organization organization, List<CollectionAccessSelection> collectionAccess)
|
||||
{
|
||||
group.AccessAll = false;
|
||||
ArrangeGroup(sutProvider, group, oldGroup);
|
||||
ArrangeUsers(sutProvider, group);
|
||||
|
||||
@ -182,7 +160,6 @@ public class UpdateGroupCommandTests
|
||||
public async Task UpdateGroup_MemberBelongsToDifferentOrganization_Throws(SutProvider<UpdateGroupCommand> sutProvider,
|
||||
Group group, Group oldGroup, Organization organization, IEnumerable<Guid> userAccess)
|
||||
{
|
||||
group.AccessAll = false;
|
||||
ArrangeGroup(sutProvider, group, oldGroup);
|
||||
ArrangeCollections(sutProvider, group);
|
||||
|
||||
@ -219,7 +196,6 @@ public class UpdateGroupCommandTests
|
||||
|
||||
private void ArrangeGroup(SutProvider<UpdateGroupCommand> sutProvider, Group group, Group oldGroup)
|
||||
{
|
||||
group.AccessAll = false;
|
||||
oldGroup.OrganizationId = group.OrganizationId;
|
||||
oldGroup.Id = group.Id;
|
||||
sutProvider.GetDependency<IGroupRepository>().GetByIdAsync(group.Id).Returns(oldGroup);
|
||||
|
@ -8,7 +8,6 @@ public class GroupCompare : IEqualityComparer<Group>
|
||||
public bool Equals(Group x, Group y)
|
||||
{
|
||||
return x.Name == y.Name &&
|
||||
x.AccessAll == y.AccessAll &&
|
||||
x.ExternalId == y.ExternalId;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user