chore: remove phased out storage encryption policy (#2323)
This commit is contained in:
@@ -1,145 +0,0 @@
|
||||
/**
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
|
||||
import { SNLog } from './../Log'
|
||||
import { PureCryptoInterface } from '@standardnotes/sncrypto-common'
|
||||
import { AlertService, DeviceInterface, namespacedKey, RawStorageKey } from '@standardnotes/services'
|
||||
import { Environment, Platform } from '@standardnotes/models'
|
||||
import { SNApplication } from './Application'
|
||||
|
||||
describe('application', () => {
|
||||
// eslint-disable-next-line no-console
|
||||
SNLog.onLog = console.log
|
||||
SNLog.onError = console.error
|
||||
|
||||
let application: SNApplication
|
||||
let device: DeviceInterface
|
||||
let crypto: PureCryptoInterface
|
||||
|
||||
beforeEach(async () => {
|
||||
const identifier = '123'
|
||||
|
||||
crypto = {} as jest.Mocked<PureCryptoInterface>
|
||||
crypto.initialize = jest.fn()
|
||||
|
||||
device = {} as jest.Mocked<DeviceInterface>
|
||||
device.openDatabase = jest.fn().mockResolvedValue(true)
|
||||
device.getAllDatabaseEntries = jest.fn().mockReturnValue([])
|
||||
device.setRawStorageValue = jest.fn()
|
||||
device.getRawStorageValue = jest.fn().mockImplementation((key) => {
|
||||
if (key === namespacedKey(identifier, RawStorageKey.SnjsVersion)) {
|
||||
return '10.0.0'
|
||||
}
|
||||
return undefined
|
||||
})
|
||||
|
||||
application = new SNApplication({
|
||||
environment: Environment.Mobile,
|
||||
platform: Platform.Ios,
|
||||
deviceInterface: device,
|
||||
crypto: crypto,
|
||||
alertService: {} as jest.Mocked<AlertService>,
|
||||
identifier: identifier,
|
||||
defaultHost: 'localhost',
|
||||
appVersion: '1.0',
|
||||
})
|
||||
|
||||
await application.prepareForLaunch({ receiveChallenge: jest.fn() })
|
||||
})
|
||||
|
||||
it('diagnostics', async () => {
|
||||
const diagnostics = await application.getDiagnostics()
|
||||
|
||||
expect(diagnostics).toEqual(
|
||||
expect.objectContaining({
|
||||
application: expect.objectContaining({
|
||||
appVersion: '1.0',
|
||||
environment: 3,
|
||||
platform: 1,
|
||||
}),
|
||||
payloads: {
|
||||
integrityPayloads: [],
|
||||
nonDeletedItemCount: 0,
|
||||
invalidPayloadsCount: 0,
|
||||
},
|
||||
items: { allIds: [] },
|
||||
storage: {
|
||||
storagePersistable: false,
|
||||
persistencePolicy: 'Default',
|
||||
encryptionPolicy: 'Default',
|
||||
needsPersist: false,
|
||||
currentPersistPromise: false,
|
||||
isStorageWrapped: false,
|
||||
allRawPayloadsCount: 0,
|
||||
},
|
||||
encryption: expect.objectContaining({
|
||||
getLatestVersion: '004',
|
||||
hasAccount: false,
|
||||
getUserVersion: undefined,
|
||||
upgradeAvailable: false,
|
||||
accountUpgradeAvailable: false,
|
||||
passcodeUpgradeAvailable: false,
|
||||
hasPasscode: false,
|
||||
isPasscodeLocked: false,
|
||||
itemsEncryption: expect.objectContaining({
|
||||
itemsKeysIds: [],
|
||||
}),
|
||||
rootKeyEncryption: expect.objectContaining({
|
||||
hasRootKey: false,
|
||||
keyMode: 'RootKeyNone',
|
||||
hasRootKeyWrapper: false,
|
||||
hasAccount: false,
|
||||
hasPasscode: false,
|
||||
}),
|
||||
}),
|
||||
api: {
|
||||
hasSession: false,
|
||||
user: undefined,
|
||||
registering: false,
|
||||
authenticating: false,
|
||||
changing: false,
|
||||
refreshingSession: false,
|
||||
filesHost: undefined,
|
||||
host: 'localhost',
|
||||
},
|
||||
session: {
|
||||
isSessionRenewChallengePresented: false,
|
||||
online: false,
|
||||
offline: true,
|
||||
isSignedIn: false,
|
||||
isSignedIntoFirstPartyServer: false,
|
||||
},
|
||||
sync: {
|
||||
syncToken: undefined,
|
||||
cursorToken: undefined,
|
||||
lastSyncDate: undefined,
|
||||
outOfSync: false,
|
||||
completedOnlineDownloadFirstSync: false,
|
||||
clientLocked: false,
|
||||
databaseLoaded: false,
|
||||
syncLock: false,
|
||||
dealloced: false,
|
||||
itemsNeedingSync: [],
|
||||
itemsNeedingSyncCount: 0,
|
||||
pendingRequestCount: 0,
|
||||
},
|
||||
protections: expect.objectContaining({
|
||||
getLastSessionLength: undefined,
|
||||
hasProtectionSources: false,
|
||||
hasUnprotectedAccessSession: true,
|
||||
hasBiometricsEnabled: false,
|
||||
}),
|
||||
keyRecovery: { queueLength: 0, isProcessingQueue: false },
|
||||
features: {
|
||||
roles: [],
|
||||
features: [],
|
||||
enabledExperimentalFeatures: [],
|
||||
needsInitialFeaturesUpdate: true,
|
||||
completedSuccessfulFeaturesRetrieval: false,
|
||||
},
|
||||
migrations: { activeMigrations: [] },
|
||||
}),
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -1079,15 +1079,6 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
|
||||
return this.userService.changePasscode(newPasscode, origination)
|
||||
}
|
||||
|
||||
public getStorageEncryptionPolicy(): ExternalServices.StorageEncryptionPolicy {
|
||||
return this.diskStorageService.getStorageEncryptionPolicy()
|
||||
}
|
||||
|
||||
public setStorageEncryptionPolicy(encryptionPolicy: ExternalServices.StorageEncryptionPolicy): Promise<void> {
|
||||
this.diskStorageService.setEncryptionPolicy(encryptionPolicy)
|
||||
return this.protocolService.repersistAllItems()
|
||||
}
|
||||
|
||||
public enableEphemeralPersistencePolicy(): Promise<void> {
|
||||
return this.diskStorageService.setPersistencePolicy(ExternalServices.StoragePersistencePolicies.Ephemeral)
|
||||
}
|
||||
@@ -1527,7 +1518,6 @@ export class SNApplication implements ApplicationInterface, AppGroupManagedAppli
|
||||
this.diskStorageService = new InternalServices.DiskStorageService(
|
||||
this.deviceInterface,
|
||||
this.identifier,
|
||||
this.environment,
|
||||
this.internalEventBus,
|
||||
)
|
||||
this.services.push(this.diskStorageService)
|
||||
|
||||
Reference in New Issue
Block a user