Skip to content

Commit

Permalink
[PM-14378] Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
shane-melton committed Dec 12, 2024
1 parent ca15550 commit bcf3210
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ private async Task<bool> CipherBelongsToOrgAsync(CurrentContextOrganization org,
private bool HasAdminAccessToSecurityTasks(CurrentContextOrganization org)
{
return org is
{ Type: OrganizationUserType.Admin or OrganizationUserType.Owner } or
{ Type: OrganizationUserType.Custom, Permissions.AccessReports: true };
{ Type: OrganizationUserType.Admin or OrganizationUserType.Owner } or
{ Type: OrganizationUserType.Custom, Permissions.AccessReports: true };
}

private async Task<IDictionary<Guid, OrganizationCipherPermission>> GetCipherPermissionsForOrgAsync(CurrentContextOrganization organization)
Expand Down
3 changes: 2 additions & 1 deletion src/Core/Vault/Queries/GetCipherPermissionsForUserQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public async Task<IDictionary<Guid, OrganizationCipherPermission>> GetByOrganiza
cipher.Manage = true;
cipher.ViewPassword = true;
}
} else if (await CanAccessUnassignedCiphersAsync(org))
}
else if (await CanAccessUnassignedCiphersAsync(org))
{
foreach (var unassignedCipher in cipherPermissions.Where(c => c.Unassigned))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,10 @@ public async Task Create_Admin_Success(
Assert.True(context.HasSucceeded);
}

[Theory, CurrentContextOrganizationCustomize(Type = OrganizationUserType.User), BitAutoData]
[Theory, CurrentContextOrganizationCustomize(Type = OrganizationUserType.User), BitAutoData]
public async Task Update_User_CanEditCipher_Success(
CurrentContextOrganization organization,
SutProvider<SecurityTaskAuthorizationHandler> sutProvider)
CurrentContextOrganization organization,
SutProvider<SecurityTaskAuthorizationHandler> sutProvider)
{
var userId = Guid.NewGuid();
var task = new SecurityTask
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using Bit.Core.Enums;
using Bit.Core.Test.AdminConsole.AutoFixture;
using Bit.Core.Vault.Authorization.SecurityTasks;
using Bit.Core.Vault.Entities;
using Bit.Test.Common.AutoFixture;
using Bit.Test.Common.AutoFixture.Attributes;
using Microsoft.AspNetCore.Authorization;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using AutoFixture;
using Bit.Core.AdminConsole.Entities;
using Bit.Core.Context;
using Bit.Core.Context;
using Bit.Core.Enums;
using Bit.Core.Models.Data.Organizations;
using Bit.Core.Services;
Expand All @@ -24,7 +22,7 @@ public class GetCipherPermissionsForUserQueryTests
private static Guid _readExceptPasswordCipherId = Guid.NewGuid();
private static Guid _unassignedCipherId = Guid.NewGuid();

private static List<Guid> _cipherIds = new []
private static List<Guid> _cipherIds = new[]
{
_noAccessCipherId,
_readOnlyCipherId,
Expand Down Expand Up @@ -53,16 +51,16 @@ public async Task GetCipherPermissionsForUserQuery_Base(Guid userId, CurrentCont
var result = await sutProvider.Sut.GetByOrganization(organizationId);

Assert.Equal(6, result.Count);
Assert.All(result, x => Assert.True(_cipherIds.Contains(x.Key)));
Assert.Equal(false, result[_noAccessCipherId].Read);
Assert.Equal(true, result[_readOnlyCipherId].Read);
Assert.Equal(false, result[_readOnlyCipherId].Edit);
Assert.Equal(true, result[_editCipherId].Edit);
Assert.Equal(true, result[_manageCipherId].Manage);
Assert.Equal(true, result[_readExceptPasswordCipherId].Read);
Assert.Equal(false, result[_readExceptPasswordCipherId].ViewPassword);
Assert.Equal(true, result[_unassignedCipherId].Unassigned);
Assert.Equal(false, result[_unassignedCipherId].Read);
Assert.All(result, x => Assert.Contains(x.Key, _cipherIds));
Assert.False(result[_noAccessCipherId].Read);
Assert.True(result[_readOnlyCipherId].Read);
Assert.False(result[_readOnlyCipherId].Edit);
Assert.True(result[_editCipherId].Edit);
Assert.True(result[_manageCipherId].Manage);
Assert.True(result[_readExceptPasswordCipherId].Read);
Assert.False(result[_readExceptPasswordCipherId].ViewPassword);
Assert.True(result[_unassignedCipherId].Unassigned);
Assert.False(result[_unassignedCipherId].Read);
}

[Theory, BitAutoData]
Expand All @@ -83,7 +81,7 @@ public async Task GetCipherPermissionsForUserQuery_CanEditAllCiphers_CustomUser(
var result = await sutProvider.Sut.GetByOrganization(organizationId);

Assert.Equal(6, result.Count);
Assert.All(result, x => Assert.True(_cipherIds.Contains(x.Key)));
Assert.All(result, x => Assert.Contains(x.Key, _cipherIds));
Assert.All(result, x => Assert.True(x.Value.Read && x.Value.Edit && x.Value.Manage && x.Value.ViewPassword));
}

Expand All @@ -110,7 +108,7 @@ public async Task GetCipherPermissionsForUserQuery_CanEditAllCiphers_Admin(Guid
var result = await sutProvider.Sut.GetByOrganization(organizationId);

Assert.Equal(6, result.Count);
Assert.All(result, x => Assert.True(_cipherIds.Contains(x.Key)));
Assert.All(result, x => Assert.Contains(x.Key, _cipherIds));
Assert.All(result, x => Assert.True(x.Value.Read && x.Value.Edit && x.Value.Manage && x.Value.ViewPassword));
}

Expand All @@ -132,20 +130,20 @@ public async Task GetCipherPermissionsForUserQuery_CanEditUnassignedCiphers(Guid
var result = await sutProvider.Sut.GetByOrganization(organizationId);

Assert.Equal(6, result.Count);
Assert.All(result, x => Assert.True(_cipherIds.Contains(x.Key)));
Assert.Equal(false, result[_noAccessCipherId].Read);
Assert.Equal(true, result[_readOnlyCipherId].Read);
Assert.Equal(false, result[_readOnlyCipherId].Edit);
Assert.Equal(true, result[_editCipherId].Edit);
Assert.Equal(true, result[_manageCipherId].Manage);
Assert.Equal(true, result[_readExceptPasswordCipherId].Read);
Assert.Equal(false, result[_readExceptPasswordCipherId].ViewPassword);

Assert.Equal(true, result[_unassignedCipherId].Unassigned);
Assert.Equal(true, result[_unassignedCipherId].Read);
Assert.Equal(true, result[_unassignedCipherId].Edit);
Assert.Equal(true, result[_unassignedCipherId].ViewPassword);
Assert.Equal(true, result[_unassignedCipherId].Manage);
Assert.All(result, x => Assert.Contains(x.Key, _cipherIds));
Assert.False(result[_noAccessCipherId].Read);
Assert.True(result[_readOnlyCipherId].Read);
Assert.False(result[_readOnlyCipherId].Edit);
Assert.True(result[_editCipherId].Edit);
Assert.True(result[_manageCipherId].Manage);
Assert.True(result[_readExceptPasswordCipherId].Read);
Assert.False(result[_readExceptPasswordCipherId].ViewPassword);

Assert.True(result[_unassignedCipherId].Unassigned);
Assert.True(result[_unassignedCipherId].Read);
Assert.True(result[_unassignedCipherId].Edit);
Assert.True(result[_unassignedCipherId].ViewPassword);
Assert.True(result[_unassignedCipherId].Manage);
}

private List<OrganizationCipherPermission> CreateCipherPermissions()
Expand Down

0 comments on commit bcf3210

Please sign in to comment.