mirror of
https://github.com/bitwarden/server.git
synced 2024-11-25 12:45:18 +01:00
Actually correcting the test and logic.
This commit is contained in:
parent
95bb1f4167
commit
eb693a8be0
@ -90,7 +90,7 @@ public class RevokeNonCompliantOrganizationUserCommand(IOrganizationUserReposito
|
||||
return result;
|
||||
}
|
||||
|
||||
if (IsNonOwnerRevokingAnOwner(userToRevoke, request.ActionPerformedBy))
|
||||
if (NonOwnersCannotRevokeOwners(userToRevoke, request.ActionPerformedBy))
|
||||
{
|
||||
result.ErrorMessages.Add($"{OnlyOwnersCanRevokeOtherOwners}");
|
||||
return result;
|
||||
@ -105,13 +105,9 @@ public class RevokeNonCompliantOrganizationUserCommand(IOrganizationUserReposito
|
||||
private static bool IsAlreadyRevoked(OrganizationUserUserDetails organizationUser) =>
|
||||
organizationUser is { Status: OrganizationUserStatusType.Revoked };
|
||||
|
||||
private static bool IsNonOwnerRevokingAnOwner(OrganizationUserUserDetails organizationUser,
|
||||
IActingUser requestingUser) => requestingUser is StandardUser standardUser &&
|
||||
!IsActingUserAllowedToRevokeOwner(organizationUser, standardUser) &&
|
||||
!IsActingUserRevokingNonOwner(organizationUser);
|
||||
|
||||
private static bool IsActingUserRevokingNonOwner(OrganizationUserUserDetails organizationUser) =>
|
||||
organizationUser is not { Type: OrganizationUserType.Owner };
|
||||
private static bool NonOwnersCannotRevokeOwners(OrganizationUserUserDetails organizationUser,
|
||||
IActingUser actingUser) =>
|
||||
actingUser is StandardUser { IsOrganizationOwner: false } && organizationUser.Type == OrganizationUserType.Owner;
|
||||
|
||||
private static bool IsActingUserAllowedToRevokeOwner(OrganizationUserUserDetails organizationUser,
|
||||
StandardUser requestingOrganizationUser) => organizationUser is { Type: OrganizationUserType.Owner }
|
||||
|
@ -148,9 +148,10 @@ public class RevokeNonCompliantOrganizationUserCommandTests
|
||||
SutProvider<RevokeNonCompliantOrganizationUserCommand> sutProvider)
|
||||
{
|
||||
userToRevoke.OrganizationId = organizationId;
|
||||
userToRevoke.Type = OrganizationUserType.Admin;
|
||||
|
||||
var command = new RevokeOrganizationUsers(organizationId, userToRevoke,
|
||||
new StandardUser(Guid.NewGuid(), true));
|
||||
new StandardUser(Guid.NewGuid(), false));
|
||||
|
||||
sutProvider.GetDependency<IHasConfirmedOwnersExceptQuery>()
|
||||
.HasConfirmedOwnersExceptAsync(organizationId, Arg.Any<IEnumerable<Guid>>())
|
||||
|
Loading…
Reference in New Issue
Block a user