fix(syncing-serve): removing other users from shared vault

This commit is contained in:
Karol Sójko
2023-07-26 12:39:24 +02:00
parent d93916b159
commit 6b2389cdc3
2 changed files with 6 additions and 4 deletions
@@ -45,12 +45,13 @@ describe('RemoveUserFromSharedVault', () => {
it('should remove user from shared vault', async () => {
const useCase = createUseCase()
await useCase.execute({
const result = await useCase.execute({
originatorUuid: '00000000-0000-0000-0000-000000000000',
sharedVaultUuid: '00000000-0000-0000-0000-000000000000',
userUuid: '00000000-0000-0000-0000-000000000001',
})
expect(result.isFailed()).toBeFalsy()
expect(sharedVaultUserRepository.remove).toHaveBeenCalledWith(sharedVaultUser)
})
@@ -99,7 +100,7 @@ describe('RemoveUserFromSharedVault', () => {
})
expect(result.isFailed()).toBe(true)
expect(result.getError()).toBe('Only owner can remove users from shared vault')
expect(result.getError()).toBe('Only owner can remove other users from shared vault')
})
it('should remove shared vault user if user is owner and is being force removed', async () => {
@@ -37,8 +37,9 @@ export class RemoveUserFromSharedVault implements UseCaseInterface<void> {
}
const originatorIsOwner = sharedVault.props.userUuid.equals(originatorUuid)
if (!originatorIsOwner) {
return Result.fail('Only owner can remove users from shared vault')
const removingSomeoneElseWhenNotOwner = !originatorIsOwner && userUuid !== originatorUuid
if (removingSomeoneElseWhenNotOwner) {
return Result.fail('Only owner can remove other users from shared vault')
}
const removingOwner = sharedVault.props.userUuid.equals(userUuid)