tests: fix memory leaks (#2389)
This commit is contained in:
@@ -1,61 +1,60 @@
|
||||
/* eslint-disable no-unused-expressions */
|
||||
/* eslint-disable no-undef */
|
||||
import * as Factory from './lib/factory.js'
|
||||
|
||||
chai.use(chaiAsPromised)
|
||||
const expect = chai.expect
|
||||
|
||||
describe('protocol', function () {
|
||||
let application
|
||||
|
||||
beforeEach(async function () {
|
||||
localStorage.clear()
|
||||
this.application = await Factory.createInitAppWithFakeCrypto()
|
||||
this.email = UuidGenerator.GenerateUuid()
|
||||
this.password = UuidGenerator.GenerateUuid()
|
||||
application = await Factory.createInitAppWithFakeCrypto()
|
||||
})
|
||||
|
||||
afterEach(async function () {
|
||||
await Factory.safeDeinit(this.application)
|
||||
this.application = null
|
||||
await Factory.safeDeinit(application)
|
||||
application = null
|
||||
localStorage.clear()
|
||||
})
|
||||
|
||||
it('checks version to make sure its 004', function () {
|
||||
expect(this.application.encryption.getLatestVersion()).to.equal('004')
|
||||
expect(application.encryption.getLatestVersion()).to.equal('004')
|
||||
})
|
||||
|
||||
it('checks supported versions to make sure it includes 001, 002, 003, 004', function () {
|
||||
expect(this.application.encryption.supportedVersions()).to.eql(['001', '002', '003', '004'])
|
||||
expect(application.encryption.supportedVersions()).to.eql(['001', '002', '003', '004'])
|
||||
})
|
||||
|
||||
it('platform derivation support', function () {
|
||||
expect(
|
||||
this.application.encryption.platformSupportsKeyDerivation({
|
||||
application.encryption.platformSupportsKeyDerivation({
|
||||
version: '001',
|
||||
}),
|
||||
).to.equal(true)
|
||||
expect(
|
||||
this.application.encryption.platformSupportsKeyDerivation({
|
||||
application.encryption.platformSupportsKeyDerivation({
|
||||
version: '002',
|
||||
}),
|
||||
).to.equal(true)
|
||||
expect(
|
||||
this.application.encryption.platformSupportsKeyDerivation({
|
||||
application.encryption.platformSupportsKeyDerivation({
|
||||
version: '003',
|
||||
}),
|
||||
).to.equal(true)
|
||||
expect(
|
||||
this.application.encryption.platformSupportsKeyDerivation({
|
||||
application.encryption.platformSupportsKeyDerivation({
|
||||
version: '004',
|
||||
}),
|
||||
).to.equal(true)
|
||||
expect(
|
||||
this.application.encryption.platformSupportsKeyDerivation({
|
||||
application.encryption.platformSupportsKeyDerivation({
|
||||
version: '005',
|
||||
}),
|
||||
).to.equal(true)
|
||||
})
|
||||
|
||||
it('key params versions <= 002 should include pw_cost in portable value', function () {
|
||||
const keyParams002 = this.application.encryption.createKeyParams({
|
||||
const keyParams002 = application.encryption.createKeyParams({
|
||||
version: '002',
|
||||
pw_cost: 5000,
|
||||
})
|
||||
@@ -63,15 +62,15 @@ describe('protocol', function () {
|
||||
})
|
||||
|
||||
it('version comparison of 002 should be older than library version', function () {
|
||||
expect(this.application.encryption.isVersionNewerThanLibraryVersion('002')).to.equal(false)
|
||||
expect(application.encryption.isVersionNewerThanLibraryVersion('002')).to.equal(false)
|
||||
})
|
||||
|
||||
it('version comparison of 005 should be newer than library version', function () {
|
||||
expect(this.application.encryption.isVersionNewerThanLibraryVersion('005')).to.equal(true)
|
||||
expect(application.encryption.isVersionNewerThanLibraryVersion('005')).to.equal(true)
|
||||
})
|
||||
|
||||
it('library version should not be outdated', function () {
|
||||
var currentVersion = this.application.encryption.getLatestVersion()
|
||||
var currentVersion = application.encryption.getLatestVersion()
|
||||
expect(isProtocolVersionExpired(currentVersion)).to.equal(false)
|
||||
})
|
||||
|
||||
@@ -91,7 +90,7 @@ describe('protocol', function () {
|
||||
const payload = Factory.createNotePayload()
|
||||
let error
|
||||
try {
|
||||
await this.application.encryption.decryptSplitSingle({
|
||||
await application.encryption.decryptSplitSingle({
|
||||
usesItemsKeyWithKeyLookup: {
|
||||
items: [payload],
|
||||
},
|
||||
@@ -103,10 +102,10 @@ describe('protocol', function () {
|
||||
})
|
||||
|
||||
it('ejected payload should not have meta fields', async function () {
|
||||
await this.application.addPasscode('123')
|
||||
await application.addPasscode('123')
|
||||
const payload = Factory.createNotePayload()
|
||||
const result = CreateEncryptedServerSyncPushPayload(
|
||||
await this.application.encryption.encryptSplitSingle({
|
||||
await application.encryption.encryptSplitSingle({
|
||||
usesItemsKeyWithKeyLookup: {
|
||||
items: [payload],
|
||||
},
|
||||
@@ -121,7 +120,7 @@ describe('protocol', function () {
|
||||
it('encrypted payload for server should include duplicate_of field', async function () {
|
||||
const payload = Factory.createNotePayload('Test')
|
||||
const encryptedPayload = CreateEncryptedServerSyncPushPayload(
|
||||
await this.application.encryption.encryptSplitSingle({
|
||||
await application.encryption.encryptSplitSingle({
|
||||
usesItemsKeyWithKeyLookup: {
|
||||
items: [payload],
|
||||
},
|
||||
@@ -134,7 +133,7 @@ describe('protocol', function () {
|
||||
it('ejected payload for server should include duplicate_of field', async function () {
|
||||
const payload = Factory.createNotePayload('Test')
|
||||
const encryptedPayload = CreateEncryptedServerSyncPushPayload(
|
||||
await this.application.encryption.encryptSplitSingle({
|
||||
await application.encryption.encryptSplitSingle({
|
||||
usesItemsKeyWithKeyLookup: {
|
||||
items: [payload],
|
||||
},
|
||||
@@ -147,7 +146,7 @@ describe('protocol', function () {
|
||||
it('encrypted payload for storage should include duplicate_of field', async function () {
|
||||
const payload = Factory.createNotePayload('Test')
|
||||
const encryptedPayload = CreateEncryptedLocalStorageContextPayload(
|
||||
await this.application.encryption.encryptSplitSingle({
|
||||
await application.encryption.encryptSplitSingle({
|
||||
usesItemsKeyWithKeyLookup: {
|
||||
items: [payload],
|
||||
},
|
||||
@@ -160,7 +159,7 @@ describe('protocol', function () {
|
||||
it('ejected payload for storage should include duplicate_of field', async function () {
|
||||
const payload = Factory.createNotePayload('Test')
|
||||
const encryptedPayload = CreateEncryptedLocalStorageContextPayload(
|
||||
await this.application.encryption.encryptSplitSingle({
|
||||
await application.encryption.encryptSplitSingle({
|
||||
usesItemsKeyWithKeyLookup: {
|
||||
items: [payload],
|
||||
},
|
||||
@@ -173,7 +172,7 @@ describe('protocol', function () {
|
||||
it('encrypted payload for file should include duplicate_of field', async function () {
|
||||
const payload = Factory.createNotePayload('Test')
|
||||
const encryptedPayload = CreateEncryptedBackupFileContextPayload(
|
||||
await this.application.encryption.encryptSplitSingle({
|
||||
await application.encryption.encryptSplitSingle({
|
||||
usesItemsKeyWithKeyLookup: {
|
||||
items: [payload],
|
||||
},
|
||||
@@ -186,7 +185,7 @@ describe('protocol', function () {
|
||||
it('ejected payload for file should include duplicate_of field', async function () {
|
||||
const payload = Factory.createNotePayload('Test')
|
||||
const encryptedPayload = CreateEncryptedBackupFileContextPayload(
|
||||
await this.application.encryption.encryptSplitSingle({
|
||||
await application.encryption.encryptSplitSingle({
|
||||
usesItemsKeyWithKeyLookup: {
|
||||
items: [payload],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user