mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
[AC-2662] Remove FC MVP from CurrentContext (#4460)
* chore: remove EditAssignedCollections from current context, refs AC-2662 * chore: remove DeleteAssignedCollections from CurrentContext, refs AC-2662 * chore: remove ViewAssignedCollections from CurrentContext, refs AC-2662
This commit is contained in:
@ -979,9 +979,7 @@ OrganizationUserInvite invite, SutProvider<OrganizationService> sutProvider)
|
||||
currentContext.ManageSso(organization.Id).Returns(true);
|
||||
currentContext.AccessEventLogs(organization.Id).Returns(true);
|
||||
currentContext.AccessImportExport(organization.Id).Returns(true);
|
||||
currentContext.DeleteAssignedCollections(organization.Id).Returns(true);
|
||||
currentContext.EditAnyCollection(organization.Id).Returns(true);
|
||||
currentContext.EditAssignedCollections(organization.Id).Returns(true);
|
||||
currentContext.ManageResetPassword(organization.Id).Returns(true);
|
||||
currentContext.GetOrganization(organization.Id)
|
||||
.Returns(new CurrentContextOrganization()
|
||||
|
@ -181,27 +181,6 @@ public class CollectionServiceTest
|
||||
.LogOrganizationUserEventAsync(default, default);
|
||||
}
|
||||
|
||||
[Theory, BitAutoData]
|
||||
public async Task GetOrganizationCollectionsAsync_WithViewAssignedCollectionsTrue_ReturnsAssignedCollections(
|
||||
CollectionDetails collectionDetails, Guid organizationId, Guid userId, SutProvider<CollectionService> sutProvider)
|
||||
{
|
||||
collectionDetails.OrganizationId = organizationId;
|
||||
|
||||
sutProvider.GetDependency<ICurrentContext>().UserId.Returns(userId);
|
||||
sutProvider.GetDependency<ICollectionRepository>()
|
||||
.GetManyByUserIdAsync(userId, Arg.Any<bool>())
|
||||
.Returns(new List<CollectionDetails> { collectionDetails });
|
||||
sutProvider.GetDependency<ICurrentContext>().ViewAssignedCollections(organizationId).Returns(true);
|
||||
|
||||
var result = await sutProvider.Sut.GetOrganizationCollectionsAsync(organizationId);
|
||||
|
||||
Assert.Single(result);
|
||||
Assert.Equal(collectionDetails, result.First());
|
||||
|
||||
await sutProvider.GetDependency<ICollectionRepository>().DidNotReceiveWithAnyArgs().GetManyByOrganizationIdAsync(default);
|
||||
await sutProvider.GetDependency<ICollectionRepository>().Received(1).GetManyByUserIdAsync(userId, Arg.Any<bool>());
|
||||
}
|
||||
|
||||
[Theory, BitAutoData]
|
||||
public async Task GetOrganizationCollectionsAsync_WithViewAllCollectionsTrue_ReturnsAllOrganizationCollections(
|
||||
Collection collection, Guid organizationId, Guid userId, SutProvider<CollectionService> sutProvider)
|
||||
@ -210,7 +189,6 @@ public class CollectionServiceTest
|
||||
sutProvider.GetDependency<ICollectionRepository>()
|
||||
.GetManyByOrganizationIdAsync(organizationId)
|
||||
.Returns(new List<Collection> { collection });
|
||||
sutProvider.GetDependency<ICurrentContext>().ViewAssignedCollections(organizationId).Returns(true);
|
||||
sutProvider.GetDependency<ICurrentContext>().ViewAllCollections(organizationId).Returns(true);
|
||||
|
||||
var result = await sutProvider.Sut.GetOrganizationCollectionsAsync(organizationId);
|
||||
@ -226,8 +204,6 @@ public class CollectionServiceTest
|
||||
public async Task GetOrganizationCollectionsAsync_WithViewAssignedCollectionsFalse_ThrowsBadRequestException(
|
||||
Guid organizationId, SutProvider<CollectionService> sutProvider)
|
||||
{
|
||||
sutProvider.GetDependency<ICurrentContext>().ViewAssignedCollections(organizationId).Returns(false);
|
||||
|
||||
await Assert.ThrowsAsync<NotFoundException>(() => sutProvider.Sut.GetOrganizationCollectionsAsync(organizationId));
|
||||
|
||||
await sutProvider.GetDependency<ICollectionRepository>().DidNotReceiveWithAnyArgs().GetManyByOrganizationIdAsync(default);
|
||||
|
Reference in New Issue
Block a user