chore: vault tests refactors and lint (#2374)

This commit is contained in:
Karol Sójko
2023-08-02 00:23:56 +02:00
committed by GitHub
parent a0bc1d2488
commit 247daddf5a
96 changed files with 1463 additions and 751 deletions

View File

@@ -17,7 +17,7 @@ describe('shared vault crypto', function () {
beforeEach(async function () {
localStorage.clear()
context = await Factory.createAppContextWithRealCrypto()
context = await Factory.createVaultsContextWithRealCrypto()
await context.launch()
await context.register()
@@ -28,11 +28,13 @@ describe('shared vault crypto', function () {
const appIdentifier = context.identifier
await context.deinit()
let recreatedContext = await Factory.createAppContextWithRealCrypto(appIdentifier)
let recreatedContext = await Factory.createVaultsContextWithRealCrypto(appIdentifier)
await recreatedContext.launch()
expect(recreatedContext.encryption.getKeyPair()).to.not.be.undefined
expect(recreatedContext.encryption.getSigningKeyPair()).to.not.be.undefined
await recreatedContext.deinit()
})
it('changing user password should re-encrypt all key system root keys and contacts with new user root key', async () => {
@@ -90,11 +92,13 @@ describe('shared vault crypto', function () {
await deinitContactContext()
})
it.skip('encrypting an item into storage then loading it should verify authenticity of original content rather than most recent symmetric signature', async () => {
it('encrypting an item into storage then loading it should verify authenticity of original content rather than most recent symmetric signature', async () => {
const { note, contactContext, deinitContactContext } =
await Collaboration.createSharedVaultWithAcceptedInviteAndNote(context)
await contactContext.changeNoteTitleAndSync(note, 'new title')
const contactNote = contactContext.items.findItem(note.uuid)
await contactContext.changeNoteTitleAndSync(contactNote, 'new title')
/** Override decrypt result to return failing signature */
const objectToSpy = context.encryption
@@ -103,6 +107,7 @@ describe('shared vault crypto', function () {
const decryptedPayloads = await objectToSpy.decryptSplit(split)
expect(decryptedPayloads.length).to.equal(1)
expect(decryptedPayloads[0].content_type).to.equal(ContentType.TYPES.Note)
const payload = decryptedPayloads[0]
const mutatedPayload = new DecryptedPayload({
@@ -118,6 +123,7 @@ describe('shared vault crypto', function () {
return [mutatedPayload]
})
await context.sync()
let updatedNote = context.items.findItem(note.uuid)
@@ -127,7 +133,7 @@ describe('shared vault crypto', function () {
const appIdentifier = context.identifier
await context.deinit()
let recreatedContext = await Factory.createAppContextWithRealCrypto(appIdentifier)
let recreatedContext = await Factory.createVaultsContextWithRealCrypto(appIdentifier)
await recreatedContext.launch()
updatedNote = recreatedContext.items.findItem(note.uuid)
@@ -140,7 +146,7 @@ describe('shared vault crypto', function () {
await recreatedContext.deinit()
recreatedContext = await Factory.createAppContextWithRealCrypto(appIdentifier)
recreatedContext = await Factory.createVaultsContextWithRealCrypto(appIdentifier)
await recreatedContext.launch()
/** Decrypting from storage will now verify current user symmetric signature only */