refactor: key rotation (#2383)
This commit is contained in:
@@ -56,6 +56,14 @@ describe('mutator service', () => {
|
||||
return mutatorService.insertItem(note)
|
||||
}
|
||||
|
||||
describe('insertItem', () => {
|
||||
it('should throw if attempting to insert already inserted item', async () => {
|
||||
const note = await insertNote('hello')
|
||||
|
||||
expect(mutatorService.insertItem(note)).rejects.toThrow()
|
||||
})
|
||||
})
|
||||
|
||||
describe('note modifications', () => {
|
||||
it('pinning should not update timestamps', async () => {
|
||||
const note = await insertNote('hello')
|
||||
|
||||
@@ -358,6 +358,11 @@ export class MutatorService extends AbstractService implements MutatorClientInte
|
||||
}
|
||||
|
||||
public async insertItem<T extends DecryptedItemInterface>(item: DecryptedItemInterface, setDirty = true): Promise<T> {
|
||||
const existingItem = this.itemManager.findItem<T>(item.uuid)
|
||||
if (existingItem) {
|
||||
throw Error('Attempting to insert item that already exists')
|
||||
}
|
||||
|
||||
if (setDirty) {
|
||||
const mutator = CreateDecryptedMutatorForItem(item, MutationType.UpdateUserTimestamps)
|
||||
const dirtiedPayload = mutator.getResult()
|
||||
|
||||
Reference in New Issue
Block a user