refactor: import/export use cases (#2397)
This commit is contained in:
@@ -22,6 +22,7 @@ describe('asymmetric messages', function () {
|
||||
await context.deinit()
|
||||
localStorage.clear()
|
||||
sinon.restore()
|
||||
context = undefined
|
||||
})
|
||||
|
||||
it('should not trust message if the trusted payload data recipientUuid does not match the message user uuid', async () => {
|
||||
|
||||
@@ -22,6 +22,7 @@ describe('shared vault conflicts', function () {
|
||||
await context.deinit()
|
||||
localStorage.clear()
|
||||
sinon.restore()
|
||||
context = undefined
|
||||
})
|
||||
|
||||
it('after being removed from shared vault, attempting to sync previous vault item should result in SharedVaultNotMemberError. The item should be duplicated then removed.', async () => {
|
||||
|
||||
@@ -22,6 +22,7 @@ describe('contacts', function () {
|
||||
await context.deinit()
|
||||
localStorage.clear()
|
||||
sinon.restore()
|
||||
context = undefined
|
||||
})
|
||||
|
||||
it('should create contact', async () => {
|
||||
|
||||
@@ -22,6 +22,7 @@ describe('shared vault crypto', function () {
|
||||
await context.deinit()
|
||||
localStorage.clear()
|
||||
sinon.restore()
|
||||
context = undefined
|
||||
})
|
||||
|
||||
describe('root key', () => {
|
||||
|
||||
@@ -8,7 +8,6 @@ describe('shared vault deletion', function () {
|
||||
this.timeout(Factory.TwentySecondTimeout)
|
||||
|
||||
let context
|
||||
let sharedVaults
|
||||
|
||||
beforeEach(async function () {
|
||||
localStorage.clear()
|
||||
@@ -17,14 +16,13 @@ describe('shared vault deletion', function () {
|
||||
|
||||
await context.launch()
|
||||
await context.register()
|
||||
|
||||
sharedVaults = context.sharedVaults
|
||||
})
|
||||
|
||||
afterEach(async function () {
|
||||
await context.deinit()
|
||||
localStorage.clear()
|
||||
sinon.restore()
|
||||
context = undefined
|
||||
})
|
||||
|
||||
it('should remove item from all user devices when item is deleted permanently', async () => {
|
||||
@@ -72,7 +70,7 @@ describe('shared vault deletion', function () {
|
||||
const { sharedVault, note, contactContext, deinitContactContext } =
|
||||
await Collaboration.createSharedVaultWithAcceptedInviteAndNote(context)
|
||||
|
||||
await sharedVaults.deleteSharedVault(sharedVault)
|
||||
await context.sharedVaults.deleteSharedVault(sharedVault)
|
||||
await contactContext.sync()
|
||||
|
||||
const originatorNote = context.items.findItem(note.uuid)
|
||||
|
||||
@@ -9,7 +9,6 @@ describe('shared vault files', function () {
|
||||
this.timeout(Factory.TwentySecondTimeout)
|
||||
|
||||
let context
|
||||
let vaults
|
||||
|
||||
beforeEach(async function () {
|
||||
localStorage.clear()
|
||||
@@ -19,7 +18,6 @@ describe('shared vault files', function () {
|
||||
await context.launch()
|
||||
await context.register()
|
||||
|
||||
vaults = context.vaults
|
||||
await context.activatePaidSubscriptionForUser()
|
||||
})
|
||||
|
||||
@@ -27,6 +25,7 @@ describe('shared vault files', function () {
|
||||
await context.deinit()
|
||||
localStorage.clear()
|
||||
sinon.restore()
|
||||
context = undefined
|
||||
})
|
||||
|
||||
describe('private vaults', () => {
|
||||
@@ -68,7 +67,7 @@ describe('shared vault files', function () {
|
||||
const uploadedFile = await Files.uploadFile(context.files, buffer, 'my-file', 'md', 1000)
|
||||
|
||||
const sharedVault = await Collaboration.createSharedVault(context)
|
||||
const addedFile = await vaults.moveItemToVault(sharedVault, uploadedFile)
|
||||
const addedFile = await context.vaults.moveItemToVault(sharedVault, uploadedFile)
|
||||
|
||||
const downloadedBytes = await Files.downloadFile(context.files, addedFile)
|
||||
expect(downloadedBytes).to.eql(buffer)
|
||||
@@ -82,7 +81,7 @@ describe('shared vault files', function () {
|
||||
const uploadedFile = await Files.uploadFile(context.files, buffer, 'my-file', 'md', 1000, firstVault)
|
||||
|
||||
const secondVault = await Collaboration.createSharedVault(context)
|
||||
const movedFile = await vaults.moveItemToVault(secondVault, uploadedFile)
|
||||
const movedFile = await context.vaults.moveItemToVault(secondVault, uploadedFile)
|
||||
|
||||
const downloadedBytes = await Files.downloadFile(context.files, movedFile)
|
||||
expect(downloadedBytes).to.eql(buffer)
|
||||
@@ -96,7 +95,7 @@ describe('shared vault files', function () {
|
||||
const uploadedFile = await Files.uploadFile(context.files, buffer, 'my-file', 'md', 1000, firstVault)
|
||||
const privateVault = await Collaboration.createPrivateVault(context)
|
||||
|
||||
const addedFile = await vaults.moveItemToVault(privateVault, uploadedFile)
|
||||
const addedFile = await context.vaults.moveItemToVault(privateVault, uploadedFile)
|
||||
|
||||
const downloadedBytes = await Files.downloadFile(context.files, addedFile)
|
||||
expect(downloadedBytes).to.eql(buffer)
|
||||
@@ -112,14 +111,14 @@ describe('shared vault files', function () {
|
||||
|
||||
const sharedVault = await Collaboration.createSharedVault(context)
|
||||
|
||||
vaults.alerts.confirmV2 = () => Promise.resolve(true)
|
||||
context.vaults.alerts.confirmV2 = () => Promise.resolve(true)
|
||||
|
||||
await vaults.moveItemToVault(sharedVault, note)
|
||||
await context.vaults.moveItemToVault(sharedVault, note)
|
||||
|
||||
const latestFile = context.items.findItem(updatedFile.uuid)
|
||||
|
||||
expect(vaults.getItemVault(latestFile).uuid).to.equal(sharedVault.uuid)
|
||||
expect(vaults.getItemVault(context.items.findItem(note.uuid)).uuid).to.equal(sharedVault.uuid)
|
||||
expect(context.vaults.getItemVault(latestFile).uuid).to.equal(sharedVault.uuid)
|
||||
expect(context.vaults.getItemVault(context.items.findItem(note.uuid)).uuid).to.equal(sharedVault.uuid)
|
||||
|
||||
const downloadedBytes = await Files.downloadFile(context.files, latestFile)
|
||||
expect(downloadedBytes).to.eql(buffer)
|
||||
@@ -132,7 +131,7 @@ describe('shared vault files', function () {
|
||||
const sharedVault = await Collaboration.createSharedVault(context)
|
||||
const uploadedFile = await Files.uploadFile(context.files, buffer, 'my-file', 'md', 1000, sharedVault)
|
||||
|
||||
const removedFile = await vaults.removeItemFromVault(uploadedFile)
|
||||
const removedFile = await context.vaults.removeItemFromVault(uploadedFile)
|
||||
expect(removedFile.key_system_identifier).to.not.be.ok
|
||||
|
||||
const downloadedBytes = await Files.downloadFile(context.files, removedFile)
|
||||
@@ -226,7 +225,7 @@ describe('shared vault files', function () {
|
||||
const response = await fetch('/mocha/assets/small_file.md')
|
||||
const buffer = new Uint8Array(await response.arrayBuffer())
|
||||
const uploadedFile = await Files.uploadFile(context.files, buffer, 'my-file', 'md', 1000)
|
||||
const addedFile = await vaults.moveItemToVault(sharedVault, uploadedFile)
|
||||
const addedFile = await context.vaults.moveItemToVault(sharedVault, uploadedFile)
|
||||
|
||||
await contactContext.sync()
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import * as Collaboration from '../lib/Collaboration.js'
|
||||
chai.use(chaiAsPromised)
|
||||
const expect = chai.expect
|
||||
|
||||
describe.skip('vault importing', function () {
|
||||
describe('vault importing', function () {
|
||||
this.timeout(Factory.TwentySecondTimeout)
|
||||
|
||||
let context
|
||||
@@ -15,45 +15,181 @@ describe.skip('vault importing', function () {
|
||||
context = await Factory.createVaultsContextWithRealCrypto()
|
||||
|
||||
await context.launch()
|
||||
await context.register()
|
||||
})
|
||||
|
||||
afterEach(async function () {
|
||||
await context.deinit()
|
||||
localStorage.clear()
|
||||
sinon.restore()
|
||||
context = undefined
|
||||
})
|
||||
|
||||
it('should import vaulted items with synced root key', async () => {
|
||||
console.error('TODO: implement')
|
||||
describe('exports', () => {
|
||||
describe('no account and no passcode', () => {
|
||||
it('should throw if attempting to create encrypted backup', async () => {
|
||||
const vault = await context.vaults.createUserInputtedPasswordVault({
|
||||
name: 'test vault',
|
||||
userInputtedPassword: 'test password',
|
||||
storagePreference: KeySystemRootKeyStorageMode.Ephemeral,
|
||||
})
|
||||
|
||||
const note = await context.createSyncedNote('foo', 'bar')
|
||||
await Collaboration.moveItemToVault(context, vault, note)
|
||||
|
||||
await context.application.vaultLocks.lockNonPersistentVault(vault)
|
||||
|
||||
await Factory.expectThrowsAsync(
|
||||
() => context.application.createEncryptedBackupFile.execute(),
|
||||
'Attempting root key encryption with no root key',
|
||||
)
|
||||
})
|
||||
|
||||
it('decrypted backups should export unlocked password vaulted items as decrypted and locked as encrypted', async () => {
|
||||
const lockedVault = await context.vaults.createUserInputtedPasswordVault({
|
||||
name: 'test vault',
|
||||
userInputtedPassword: 'test password',
|
||||
storagePreference: KeySystemRootKeyStorageMode.Ephemeral,
|
||||
})
|
||||
const lockedVaultNote = await context.createSyncedNote('foo', 'bar')
|
||||
await Collaboration.moveItemToVault(context, lockedVault, lockedVaultNote)
|
||||
await context.application.vaultLocks.lockNonPersistentVault(lockedVault)
|
||||
|
||||
const unlockedVault = await context.vaults.createUserInputtedPasswordVault({
|
||||
name: 'test vault',
|
||||
userInputtedPassword: 'test password',
|
||||
storagePreference: KeySystemRootKeyStorageMode.Ephemeral,
|
||||
})
|
||||
const unlockedVaultNote = await context.createSyncedNote('har', 'zar')
|
||||
await Collaboration.moveItemToVault(context, unlockedVault, unlockedVaultNote)
|
||||
|
||||
const backupData = (await context.application.createDecryptedBackupFile.execute()).getValue()
|
||||
|
||||
const backupLockedVaultNote = backupData.items.find((item) => item.uuid === lockedVaultNote.uuid)
|
||||
expect(isEncryptedPayload(backupLockedVaultNote)).to.be.true
|
||||
|
||||
const backupUnlockedVaultNote = backupData.items.find((item) => item.uuid === unlockedVaultNote.uuid)
|
||||
expect(isEncryptedPayload(backupUnlockedVaultNote)).to.be.false
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('should import vaulted items with non-present root key', async () => {
|
||||
const vault = await context.vaults.createUserInputtedPasswordVault({
|
||||
name: 'test vault',
|
||||
userInputtedPassword: 'test password',
|
||||
storagePreference: KeySystemRootKeyStorageMode.Ephemeral,
|
||||
describe('imports', () => {
|
||||
describe('password vaults', () => {
|
||||
it('should import password vaulted items with non-present root key as-is without decrypting', async () => {
|
||||
await context.register()
|
||||
|
||||
const vault = await context.vaults.createUserInputtedPasswordVault({
|
||||
name: 'test vault',
|
||||
userInputtedPassword: 'test password',
|
||||
storagePreference: KeySystemRootKeyStorageMode.Ephemeral,
|
||||
})
|
||||
|
||||
const note = await context.createSyncedNote('foo', 'bar')
|
||||
await Collaboration.moveItemToVault(context, vault, note)
|
||||
|
||||
const backupData = (
|
||||
await context.application.createEncryptedBackupFile.execute({ skipAuthorization: true })
|
||||
).getValue()
|
||||
|
||||
const otherContext = await Factory.createVaultsContextWithRealCrypto()
|
||||
otherContext.password = context.password
|
||||
await otherContext.launch()
|
||||
|
||||
await otherContext.application.importData(backupData)
|
||||
|
||||
const expectedImportedItems = ['vault-items-key', 'note']
|
||||
const invalidItems = otherContext.items.invalidItems
|
||||
expect(invalidItems.length).to.equal(expectedImportedItems.length)
|
||||
|
||||
const encryptedItemsKey = invalidItems.find((item) => item.content_type === ContentType.TYPES.KeySystemItemsKey)
|
||||
expect(encryptedItemsKey.key_system_identifier).to.equal(vault.systemIdentifier)
|
||||
expect(encryptedItemsKey.errorDecrypting).to.be.true
|
||||
|
||||
const encryptedNote = invalidItems.find((item) => item.content_type === ContentType.TYPES.Note)
|
||||
expect(encryptedNote.key_system_identifier).to.equal(vault.systemIdentifier)
|
||||
expect(encryptedNote.errorDecrypting).to.be.true
|
||||
expect(encryptedNote.uuid).to.equal(note.uuid)
|
||||
|
||||
await otherContext.deinit()
|
||||
})
|
||||
})
|
||||
|
||||
const note = await context.createSyncedNote('foo', 'bar')
|
||||
await Collaboration.moveItemToVault(context, vault, note)
|
||||
describe('randomized vaults', () => {
|
||||
it('should import backup file for randomized vault created without account or passcode', async () => {
|
||||
const vault = await context.vaults.createRandomizedVault({
|
||||
name: 'test vault',
|
||||
})
|
||||
|
||||
const backupData = await context.application.createEncryptedBackupFileForAutomatedDesktopBackups()
|
||||
const note = await context.createSyncedNote('foo', 'bar')
|
||||
await Collaboration.moveItemToVault(context, vault, note)
|
||||
|
||||
const otherContext = await Factory.createVaultsContextWithRealCrypto()
|
||||
await otherContext.launch()
|
||||
const backupData = (await context.application.createDecryptedBackupFile.execute()).getValue()
|
||||
|
||||
await otherContext.application.importData(backupData)
|
||||
const otherContext = await Factory.createVaultsContextWithRealCrypto()
|
||||
otherContext.password = context.password
|
||||
await otherContext.launch()
|
||||
|
||||
const expectedImportedItems = ['vault-items-key', 'note']
|
||||
const invalidItems = otherContext.items.invalidItems
|
||||
expect(invalidItems.length).to.equal(expectedImportedItems.length)
|
||||
const result = (await otherContext.application.importData(backupData)).getValue()
|
||||
|
||||
const encryptedItem = invalidItems[0]
|
||||
expect(encryptedItem.key_system_identifier).to.equal(vault.systemIdentifier)
|
||||
expect(encryptedItem.errorDecrypting).to.be.true
|
||||
expect(encryptedItem.uuid).to.equal(note.uuid)
|
||||
const invalidItems = otherContext.items.invalidItems
|
||||
expect(invalidItems.length).to.equal(0)
|
||||
|
||||
await otherContext.deinit()
|
||||
expect(result.affectedItems.length).to.equal(backupData.items.length)
|
||||
|
||||
const itemsKey = result.affectedItems.find((item) => item.content_type === ContentType.TYPES.KeySystemItemsKey)
|
||||
expect(itemsKey.key_system_identifier).to.equal(vault.systemIdentifier)
|
||||
|
||||
const importedNote = result.affectedItems.find((item) => item.content_type === ContentType.TYPES.Note)
|
||||
expect(importedNote.key_system_identifier).to.equal(vault.systemIdentifier)
|
||||
expect(importedNote.uuid).to.equal(note.uuid)
|
||||
|
||||
const importedRootKey = result.affectedItems.find(
|
||||
(item) => item.content_type === ContentType.TYPES.KeySystemRootKey,
|
||||
)
|
||||
expect(importedRootKey.systemIdentifier).to.equal(vault.systemIdentifier)
|
||||
|
||||
await otherContext.deinit()
|
||||
})
|
||||
|
||||
it('should import synced-key vaulted items by decrypting', async () => {
|
||||
await context.register()
|
||||
|
||||
const vault = await context.vaults.createRandomizedVault({
|
||||
name: 'test vault',
|
||||
})
|
||||
|
||||
const note = await context.createSyncedNote('foo', 'bar')
|
||||
await Collaboration.moveItemToVault(context, vault, note)
|
||||
|
||||
const backupData = (
|
||||
await context.application.createEncryptedBackupFile.execute({ skipAuthorization: true })
|
||||
).getValue()
|
||||
|
||||
const otherContext = await Factory.createVaultsContextWithRealCrypto()
|
||||
otherContext.password = context.password
|
||||
await otherContext.launch()
|
||||
|
||||
const result = (await otherContext.application.importData(backupData)).getValue()
|
||||
|
||||
const invalidItems = otherContext.items.invalidItems
|
||||
expect(invalidItems.length).to.equal(0)
|
||||
|
||||
expect(result.affectedItems.length).to.equal(backupData.items.length)
|
||||
|
||||
const itemsKey = result.affectedItems.find((item) => item.content_type === ContentType.TYPES.KeySystemItemsKey)
|
||||
expect(itemsKey.key_system_identifier).to.equal(vault.systemIdentifier)
|
||||
|
||||
const importedNote = result.affectedItems.find((item) => item.content_type === ContentType.TYPES.Note)
|
||||
expect(importedNote.key_system_identifier).to.equal(vault.systemIdentifier)
|
||||
expect(importedNote.uuid).to.equal(note.uuid)
|
||||
|
||||
const importedRootKey = result.affectedItems.find(
|
||||
(item) => item.content_type === ContentType.TYPES.KeySystemRootKey,
|
||||
)
|
||||
expect(importedRootKey.systemIdentifier).to.equal(vault.systemIdentifier)
|
||||
|
||||
await otherContext.deinit()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -21,6 +21,7 @@ describe('shared vault invites', function () {
|
||||
await context.deinit()
|
||||
localStorage.clear()
|
||||
sinon.restore()
|
||||
context = undefined
|
||||
})
|
||||
|
||||
it('should invite contact to vault', async () => {
|
||||
|
||||
@@ -22,6 +22,7 @@ describe('shared vault items', function () {
|
||||
await context.deinit()
|
||||
localStorage.clear()
|
||||
sinon.restore()
|
||||
context = undefined
|
||||
})
|
||||
|
||||
it('should add item to shared vault with no other members', async () => {
|
||||
|
||||
@@ -21,6 +21,7 @@ describe('vault key management', function () {
|
||||
await context.deinit()
|
||||
localStorage.clear()
|
||||
sinon.restore()
|
||||
context = undefined
|
||||
})
|
||||
|
||||
describe('locking', () => {
|
||||
|
||||
@@ -22,6 +22,7 @@ describe('vault key rotation', function () {
|
||||
await context.deinit()
|
||||
localStorage.clear()
|
||||
sinon.restore()
|
||||
context = undefined
|
||||
})
|
||||
|
||||
it('should reencrypt all items keys belonging to key system', async () => {
|
||||
|
||||
@@ -22,6 +22,7 @@ describe('vault key sharing', function () {
|
||||
await context.deinit()
|
||||
localStorage.clear()
|
||||
sinon.restore()
|
||||
context = undefined
|
||||
})
|
||||
|
||||
it('sharing a vault with user inputted and ephemeral password should share the key as synced for the recipient', async () => {
|
||||
|
||||
@@ -22,6 +22,7 @@ describe('keypair change', function () {
|
||||
await context.deinit()
|
||||
localStorage.clear()
|
||||
sinon.restore()
|
||||
context = undefined
|
||||
})
|
||||
|
||||
it('contacts should be able to handle receiving multiple keypair changed messages and trust them in order', async () => {
|
||||
|
||||
@@ -22,6 +22,7 @@ describe('shared vault limits', function () {
|
||||
await context.deinit()
|
||||
localStorage.clear()
|
||||
sinon.restore()
|
||||
context = undefined
|
||||
})
|
||||
|
||||
describe('free users', () => {
|
||||
|
||||
@@ -22,6 +22,7 @@ describe('shared vault permissions', function () {
|
||||
await context.deinit()
|
||||
localStorage.clear()
|
||||
sinon.restore()
|
||||
context = undefined
|
||||
})
|
||||
|
||||
it('non-admin user should not be able to invite user', async () => {
|
||||
|
||||
@@ -20,9 +20,7 @@ describe('public key cryptography', function () {
|
||||
afterEach(async () => {
|
||||
await context.deinit()
|
||||
localStorage.clear()
|
||||
|
||||
sinon.restore()
|
||||
|
||||
context = undefined
|
||||
})
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ describe('shared vaults', function () {
|
||||
this.timeout(Factory.TwentySecondTimeout)
|
||||
|
||||
let context
|
||||
let vaults
|
||||
|
||||
beforeEach(async function () {
|
||||
localStorage.clear()
|
||||
@@ -17,8 +16,6 @@ describe('shared vaults', function () {
|
||||
|
||||
await context.launch()
|
||||
await context.register()
|
||||
|
||||
vaults = context.vaults
|
||||
})
|
||||
|
||||
afterEach(async function () {
|
||||
@@ -39,7 +36,7 @@ describe('shared vaults', function () {
|
||||
description: 'new vault description',
|
||||
})
|
||||
|
||||
const updatedVault = vaults.getVault({ keySystemIdentifier: sharedVault.systemIdentifier })
|
||||
const updatedVault = context.vaults.getVault({ keySystemIdentifier: sharedVault.systemIdentifier })
|
||||
expect(updatedVault.name).to.equal('new vault name')
|
||||
expect(updatedVault.description).to.equal('new vault description')
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ describe('vaults', function () {
|
||||
this.timeout(Factory.TwentySecondTimeout)
|
||||
|
||||
let context
|
||||
let vaults
|
||||
|
||||
beforeEach(async function () {
|
||||
localStorage.clear()
|
||||
@@ -15,8 +14,6 @@ describe('vaults', function () {
|
||||
context = await Factory.createVaultsContextWithFakeCrypto()
|
||||
|
||||
await context.launch()
|
||||
|
||||
vaults = context.vaults
|
||||
})
|
||||
|
||||
afterEach(async function () {
|
||||
@@ -24,12 +21,11 @@ describe('vaults', function () {
|
||||
localStorage.clear()
|
||||
sinon.restore()
|
||||
context = undefined
|
||||
vaults = undefined
|
||||
})
|
||||
|
||||
describe('offline', function () {
|
||||
it('should be able to create an offline vault', async () => {
|
||||
const vault = await vaults.createRandomizedVault({
|
||||
const vault = await context.vaults.createRandomizedVault({
|
||||
name: 'My Vault',
|
||||
})
|
||||
|
||||
@@ -45,7 +41,7 @@ describe('vaults', function () {
|
||||
|
||||
it('should be able to create an offline vault with app passcode', async () => {
|
||||
await context.application.addPasscode('123')
|
||||
const vault = await vaults.createRandomizedVault({
|
||||
const vault = await context.vaults.createRandomizedVault({
|
||||
name: 'My Vault',
|
||||
})
|
||||
|
||||
@@ -60,12 +56,12 @@ describe('vaults', function () {
|
||||
})
|
||||
|
||||
it('should add item to offline vault', async () => {
|
||||
const vault = await vaults.createRandomizedVault({
|
||||
const vault = await context.vaults.createRandomizedVault({
|
||||
name: 'My Vault',
|
||||
})
|
||||
const item = await context.createSyncedNote()
|
||||
|
||||
await vaults.moveItemToVault(vault, item)
|
||||
await context.vaults.moveItemToVault(vault, item)
|
||||
|
||||
const updatedItem = context.items.findItem(item.uuid)
|
||||
expect(updatedItem.key_system_identifier).to.equal(vault.systemIdentifier)
|
||||
@@ -73,11 +69,11 @@ describe('vaults', function () {
|
||||
|
||||
it('should load data in the correct order at startup to allow vault items and their keys to decrypt', async () => {
|
||||
const appIdentifier = context.identifier
|
||||
const vault = await vaults.createRandomizedVault({
|
||||
const vault = await context.vaults.createRandomizedVault({
|
||||
name: 'My Vault',
|
||||
})
|
||||
const note = await context.createSyncedNote('foo', 'bar')
|
||||
await vaults.moveItemToVault(vault, note)
|
||||
await context.vaults.moveItemToVault(vault, note)
|
||||
await context.deinit()
|
||||
|
||||
const recreatedContext = await Factory.createVaultsContextWithFakeCrypto(appIdentifier)
|
||||
@@ -93,11 +89,11 @@ describe('vaults', function () {
|
||||
describe('porting from offline to online', () => {
|
||||
it('should maintain vault system identifiers across items after registration', async () => {
|
||||
const appIdentifier = context.identifier
|
||||
const vault = await vaults.createRandomizedVault({
|
||||
const vault = await context.vaults.createRandomizedVault({
|
||||
name: 'My Vault',
|
||||
})
|
||||
const note = await context.createSyncedNote('foo', 'bar')
|
||||
await vaults.moveItemToVault(vault, note)
|
||||
await context.vaults.moveItemToVault(vault, note)
|
||||
|
||||
await context.register()
|
||||
await context.sync()
|
||||
@@ -120,11 +116,11 @@ describe('vaults', function () {
|
||||
|
||||
it('should decrypt vault items', async () => {
|
||||
const appIdentifier = context.identifier
|
||||
const vault = await vaults.createRandomizedVault({
|
||||
const vault = await context.vaults.createRandomizedVault({
|
||||
name: 'My Vault',
|
||||
})
|
||||
const note = await context.createSyncedNote('foo', 'bar')
|
||||
await vaults.moveItemToVault(vault, note)
|
||||
await context.vaults.moveItemToVault(vault, note)
|
||||
|
||||
await context.register()
|
||||
await context.sync()
|
||||
@@ -149,7 +145,7 @@ describe('vaults', function () {
|
||||
})
|
||||
|
||||
it('should create a vault', async () => {
|
||||
const vault = await vaults.createRandomizedVault({
|
||||
const vault = await context.vaults.createRandomizedVault({
|
||||
name: 'My Vault',
|
||||
})
|
||||
expect(vault).to.not.be.undefined
|
||||
@@ -164,11 +160,11 @@ describe('vaults', function () {
|
||||
|
||||
it('should add item to vault', async () => {
|
||||
const note = await context.createSyncedNote('foo', 'bar')
|
||||
const vault = await vaults.createRandomizedVault({
|
||||
const vault = await context.vaults.createRandomizedVault({
|
||||
name: 'My Vault',
|
||||
})
|
||||
|
||||
await vaults.moveItemToVault(vault, note)
|
||||
await context.vaults.moveItemToVault(vault, note)
|
||||
|
||||
const updatedNote = context.items.findItem(note.uuid)
|
||||
expect(updatedNote.key_system_identifier).to.equal(vault.systemIdentifier)
|
||||
@@ -177,11 +173,11 @@ describe('vaults', function () {
|
||||
describe('client timing', () => {
|
||||
it('should load data in the correct order at startup to allow vault items and their keys to decrypt', async () => {
|
||||
const appIdentifier = context.identifier
|
||||
const vault = await vaults.createRandomizedVault({
|
||||
const vault = await context.vaults.createRandomizedVault({
|
||||
name: 'My Vault',
|
||||
})
|
||||
const note = await context.createSyncedNote('foo', 'bar')
|
||||
await vaults.moveItemToVault(vault, note)
|
||||
await context.vaults.moveItemToVault(vault, note)
|
||||
await context.deinit()
|
||||
|
||||
const recreatedContext = await Factory.createVaultsContextWithFakeCrypto(appIdentifier)
|
||||
@@ -197,13 +193,13 @@ describe('vaults', function () {
|
||||
|
||||
describe('key system root key rotation', () => {
|
||||
it('rotating a key system root key should create a new vault items key', async () => {
|
||||
const vault = await vaults.createRandomizedVault({
|
||||
const vault = await context.vaults.createRandomizedVault({
|
||||
name: 'My Vault',
|
||||
})
|
||||
|
||||
const keySystemItemsKey = context.keys.getKeySystemItemsKeys(vault.systemIdentifier)[0]
|
||||
|
||||
await vaults.rotateVaultRootKey(vault)
|
||||
await context.vaults.rotateVaultRootKey(vault)
|
||||
|
||||
const updatedKeySystemItemsKey = context.keys.getKeySystemItemsKeys(vault.systemIdentifier)[0]
|
||||
|
||||
@@ -212,13 +208,13 @@ describe('vaults', function () {
|
||||
})
|
||||
|
||||
it('deleting a vault should delete all its items', async () => {
|
||||
const vault = await vaults.createRandomizedVault({
|
||||
const vault = await context.vaults.createRandomizedVault({
|
||||
name: 'My Vault',
|
||||
})
|
||||
const note = await context.createSyncedNote('foo', 'bar')
|
||||
await vaults.moveItemToVault(vault, note)
|
||||
await context.vaults.moveItemToVault(vault, note)
|
||||
|
||||
await vaults.deleteVault(vault)
|
||||
await context.vaults.deleteVault(vault)
|
||||
|
||||
const updatedNote = context.items.findItem(note.uuid)
|
||||
expect(updatedNote).to.be.undefined
|
||||
|
||||
Reference in New Issue
Block a user