How to use the fs-json-store-encryption-adapter.EncryptionAdapter.name function in fs-json-store-encryption-adapter

To help you get started, we’ve selected a few fs-json-store-encryption-adapter examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vladimiry / ElectronMail / src / electron-main / api / index.spec.ts View on Github external
readSettings: async (t) => {
        const {
            endpoints,
            mocks: {
                "src/electron-main/keytar": {setPassword: setPasswordSpy, deletePassword: deletePasswordSpy},
                "src/electron-main/storage-upgrade": {upgradeSettings: upgradeSettingsSpy},
                "src/electron-main/session": {initSessionByAccount: initSessionByAccountMock},
            },
        } = t.context;

        t.false(await t.context.ctx.settingsStore.readable(), "settings file does not exist");
        t.falsy(t.context.ctx.settingsStore.adapter, "adapter is not set");
        const initial = await readConfigAndSettings(endpoints, {password: OPTIONS.masterPassword, savePassword: false});
        t.is(0, upgradeSettingsSpy.callCount);
        t.is(t.context.ctx.settingsStore.adapter && t.context.ctx.settingsStore.adapter.constructor.name,
            EncryptionAdapter.name,
            "adapter is an EncryptionAdapter",
        );
        const initialExpected = {...t.context.ctx.initialStores.settings, ...{_rev: 0}};
        t.deepEqual(initial, initialExpected, "checking initial settings file");
        t.true(await t.context.ctx.settingsStore.readable(), "settings file exists");
        t.is(setPasswordSpy.callCount, 0);
        t.is(deletePasswordSpy.callCount, 1);
        t.true(deletePasswordSpy.alwaysCalledWithExactly());
        t.is(initial.accounts.length, initSessionByAccountMock.callCount);
        for (const {login} of initial.accounts) {
            t.true(initSessionByAccountMock.calledWithExactly(t.context.ctx, login));
        }

        const initialUpdated = await t.context.ctx.settingsStore.write(initial);
        const initialUpdatedExpected = {...initial, ...initialExpected, ...{_rev: initialExpected._rev + 1}};
        t.deepEqual(initialUpdated, initialUpdatedExpected, "saved initial settings file");

fs-json-store-encryption-adapter

Encryption adapter for the "fs-json-store" module

MIT
Latest version published 2 years ago

Package Health Score

42 / 100
Full package analysis