update archive ciphers command to allow org ciphers to be archived

This commit is contained in:
jaasen-livefront 2025-12-08 10:19:11 -08:00
parent 4144ae9ecc
commit e50fbfbc3e
No known key found for this signature in database
2 changed files with 5 additions and 5 deletions

View File

@ -37,7 +37,7 @@ public class ArchiveCiphersCommand : IArchiveCiphersCommand
} }
var archivingCiphers = ciphers var archivingCiphers = ciphers
.Where(c => cipherIdsSet.Contains(c.Id) && c is { Edit: true, OrganizationId: null, ArchivedDate: null }) .Where(c => cipherIdsSet.Contains(c.Id) && c is { Edit: true, ArchivedDate: null })
.ToList(); .ToList();
var revisionDate = await _cipherRepository.ArchiveAsync(archivingCiphers.Select(c => c.Id), archivingUserId); var revisionDate = await _cipherRepository.ArchiveAsync(archivingCiphers.Select(c => c.Id), archivingUserId);

View File

@ -20,7 +20,7 @@ public class ArchiveCiphersCommandTest
[BitAutoData(false, false, 1, 0, 1)] [BitAutoData(false, false, 1, 0, 1)]
[BitAutoData(false, true, 1, 0, 1)] [BitAutoData(false, true, 1, 0, 1)]
[BitAutoData(true, true, 1, 0, 1)] [BitAutoData(true, true, 1, 0, 1)]
public async Task ArchiveAsync_Works( public async Task ArchiveManyAsync_Works(
bool isEditable, bool hasOrganizationId, bool isEditable, bool hasOrganizationId,
int cipherRepoCalls, int resultCountFromQuery, int pushNotificationsCalls, int cipherRepoCalls, int resultCountFromQuery, int pushNotificationsCalls,
SutProvider<ArchiveCiphersCommand> sutProvider, CipherDetails cipher, User user) SutProvider<ArchiveCiphersCommand> sutProvider, CipherDetails cipher, User user)
@ -49,15 +49,15 @@ public class ArchiveCiphersCommandTest
[Theory] [Theory]
[BitAutoData] [BitAutoData]
public async Task ArchiveAsync_SetsArchivedDateOnReturnedCiphers( public async Task ArchiveManyAsync_SetsArchivedDateOnReturnedCiphers(
SutProvider<ArchiveCiphersCommand> sutProvider, SutProvider<ArchiveCiphersCommand> sutProvider,
CipherDetails cipher, CipherDetails cipher,
User user) User user)
{ {
// Arrange: make it archivable // Arrange: make it archivable
cipher.Edit = true; cipher.Edit = true;
cipher.OrganizationId = null; // Allow organization cipher to be archived in this test
cipher.ArchivedDate = null; cipher.OrganizationId = Guid.Parse("3f2504e0-4f89-11d3-9a0c-0305e82c3301");
sutProvider.GetDependency<ICipherRepository>() sutProvider.GetDependency<ICipherRepository>()
.GetManyByUserIdAsync(user.Id) .GetManyByUserIdAsync(user.Id)