mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
Add UpdateCiphersAsync Test (#5543)
* Add UpdateCiphersAsync Test * Fix UpdateCiphersAsync * Fix #2 * Fix SQL Server * Formatting
This commit is contained in:
@ -883,4 +883,33 @@ public class CipherRepositoryTests
|
||||
Assert.Contains(user2TaskCiphers, t => t.CipherId == manageCipher1.Id && t.TaskId == securityTasks[0].Id);
|
||||
Assert.Contains(user2TaskCiphers, t => t.CipherId == manageCipher2.Id && t.TaskId == securityTasks[1].Id);
|
||||
}
|
||||
|
||||
[DatabaseTheory, DatabaseData]
|
||||
public async Task UpdateCiphersAsync_Works(ICipherRepository cipherRepository, IUserRepository userRepository)
|
||||
{
|
||||
var user = await userRepository.CreateAsync(new User
|
||||
{
|
||||
Name = "Test User",
|
||||
Email = $"test+{Guid.NewGuid()}@email.com",
|
||||
ApiKey = "TEST",
|
||||
SecurityStamp = "stamp",
|
||||
});
|
||||
|
||||
var cipher1 = await CreatePersonalCipher(user, cipherRepository);
|
||||
var cipher2 = await CreatePersonalCipher(user, cipherRepository);
|
||||
|
||||
cipher1.Type = CipherType.SecureNote;
|
||||
cipher2.Attachments = "new_attachments";
|
||||
|
||||
await cipherRepository.UpdateCiphersAsync(user.Id, [cipher1, cipher2]);
|
||||
|
||||
var updatedCipher1 = await cipherRepository.GetByIdAsync(cipher1.Id);
|
||||
var updatedCipher2 = await cipherRepository.GetByIdAsync(cipher2.Id);
|
||||
|
||||
Assert.NotNull(updatedCipher1);
|
||||
Assert.NotNull(updatedCipher2);
|
||||
|
||||
Assert.Equal(CipherType.SecureNote, updatedCipher1.Type);
|
||||
Assert.Equal("new_attachments", updatedCipher2.Attachments);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user