Switch to Rust crypto stack for all logins (#12630)
* Use Rust crypto stack universally Ignore the `feature_rust_crypto` and `RustCrypto.staged_rollout_percent` settings, and just use RustCrypto everywhere. * Remove labs setting for rust crypto * Remove support for legacy crypto stack in `StorageManager` We're not going to use the legacy stack any more. * Update docs on `Features.RustCrypto` * Remove now-unreachable `tryToUnlockSecretStorageWithDehydrationKey` * Comment out test which doesn't work * fix typo
This commit is contained in:
parent
2843545d1e
commit
9c862907f9
11 changed files with 96 additions and 931 deletions
|
@ -20,7 +20,6 @@ import { IDBFactory } from "fake-indexeddb";
|
|||
import { IndexedDBCryptoStore } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import * as StorageManager from "../../src/utils/StorageManager";
|
||||
import SettingsStore from "../../src/settings/SettingsStore";
|
||||
|
||||
const LEGACY_CRYPTO_STORE_NAME = "matrix-js-sdk:crypto";
|
||||
const RUST_CRYPTO_STORE_NAME = "matrix-js-sdk::matrix-sdk-crypto";
|
||||
|
@ -77,99 +76,55 @@ describe("StorageManager", () => {
|
|||
indexedDB = new IDBFactory();
|
||||
});
|
||||
|
||||
describe("with `feature_rust_crypto` enabled", () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(SettingsStore, "getValue").mockImplementation(async (key) => {
|
||||
if (key === "feature_rust_crypto") {
|
||||
return true;
|
||||
}
|
||||
throw new Error(`Unknown key ${key}`);
|
||||
});
|
||||
});
|
||||
|
||||
it("should not be ok if sync store but no crypto store", async () => {
|
||||
const result = await StorageManager.checkConsistency();
|
||||
expect(result.healthy).toBe(true);
|
||||
expect(result.dataInCryptoStore).toBe(false);
|
||||
});
|
||||
|
||||
it("should be ok if sync store and a rust crypto store", async () => {
|
||||
await createDB(RUST_CRYPTO_STORE_NAME);
|
||||
|
||||
const result = await StorageManager.checkConsistency();
|
||||
expect(result.healthy).toBe(true);
|
||||
expect(result.dataInCryptoStore).toBe(true);
|
||||
});
|
||||
|
||||
describe("without rust store", () => {
|
||||
it("should be ok if there is non migrated legacy crypto store", async () => {
|
||||
await populateLegacyStore(undefined);
|
||||
|
||||
const result = await StorageManager.checkConsistency();
|
||||
expect(result.healthy).toBe(true);
|
||||
expect(result.dataInCryptoStore).toBe(true);
|
||||
});
|
||||
|
||||
it("should be ok if legacy store in MigrationState `NOT_STARTED`", async () => {
|
||||
await populateLegacyStore(0 /* MigrationState.NOT_STARTED*/);
|
||||
|
||||
const result = await StorageManager.checkConsistency();
|
||||
expect(result.healthy).toBe(true);
|
||||
expect(result.dataInCryptoStore).toBe(true);
|
||||
});
|
||||
|
||||
it("should not be ok if MigrationState greater than `NOT_STARTED`", async () => {
|
||||
await populateLegacyStore(1 /*INITIAL_DATA_MIGRATED*/);
|
||||
|
||||
const result = await StorageManager.checkConsistency();
|
||||
expect(result.healthy).toBe(true);
|
||||
expect(result.dataInCryptoStore).toBe(false);
|
||||
});
|
||||
|
||||
it("should not be healthy if no indexeddb", async () => {
|
||||
// eslint-disable-next-line no-global-assign
|
||||
indexedDB = {} as IDBFactory;
|
||||
|
||||
const result = await StorageManager.checkConsistency();
|
||||
expect(result.healthy).toBe(false);
|
||||
|
||||
// eslint-disable-next-line no-global-assign
|
||||
indexedDB = new IDBFactory();
|
||||
});
|
||||
});
|
||||
it("should not be ok if sync store but no crypto store", async () => {
|
||||
const result = await StorageManager.checkConsistency();
|
||||
expect(result.healthy).toBe(true);
|
||||
expect(result.dataInCryptoStore).toBe(false);
|
||||
});
|
||||
|
||||
describe("with `feature_rust_crypto` disabled", () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(SettingsStore, "getValue").mockImplementation(async (key) => {
|
||||
if (key === "feature_rust_crypto") {
|
||||
return false;
|
||||
}
|
||||
throw new Error(`Unknown key ${key}`);
|
||||
});
|
||||
});
|
||||
it("should be ok if sync store and a rust crypto store", async () => {
|
||||
await createDB(RUST_CRYPTO_STORE_NAME);
|
||||
|
||||
it("should not be ok if sync store but no crypto store", async () => {
|
||||
const result = await StorageManager.checkConsistency();
|
||||
expect(result.healthy).toBe(true);
|
||||
expect(result.dataInCryptoStore).toBe(false);
|
||||
});
|
||||
const result = await StorageManager.checkConsistency();
|
||||
expect(result.healthy).toBe(true);
|
||||
expect(result.dataInCryptoStore).toBe(true);
|
||||
});
|
||||
|
||||
it("should not be ok if sync store but no crypto store and a rust store", async () => {
|
||||
await createDB(RUST_CRYPTO_STORE_NAME);
|
||||
|
||||
const result = await StorageManager.checkConsistency();
|
||||
expect(result.healthy).toBe(true);
|
||||
expect(result.dataInCryptoStore).toBe(false);
|
||||
});
|
||||
|
||||
it("should be healthy if sync store and a legacy crypto store", async () => {
|
||||
await createDB(LEGACY_CRYPTO_STORE_NAME);
|
||||
describe("without rust store", () => {
|
||||
it("should be ok if there is non migrated legacy crypto store", async () => {
|
||||
await populateLegacyStore(undefined);
|
||||
|
||||
const result = await StorageManager.checkConsistency();
|
||||
expect(result.healthy).toBe(true);
|
||||
expect(result.dataInCryptoStore).toBe(true);
|
||||
});
|
||||
|
||||
it("should be ok if legacy store in MigrationState `NOT_STARTED`", async () => {
|
||||
await populateLegacyStore(0 /* MigrationState.NOT_STARTED*/);
|
||||
|
||||
const result = await StorageManager.checkConsistency();
|
||||
expect(result.healthy).toBe(true);
|
||||
expect(result.dataInCryptoStore).toBe(true);
|
||||
});
|
||||
|
||||
it("should not be ok if MigrationState greater than `NOT_STARTED`", async () => {
|
||||
await populateLegacyStore(1 /*INITIAL_DATA_MIGRATED*/);
|
||||
|
||||
const result = await StorageManager.checkConsistency();
|
||||
expect(result.healthy).toBe(true);
|
||||
expect(result.dataInCryptoStore).toBe(false);
|
||||
});
|
||||
|
||||
it("should not be healthy if no indexeddb", async () => {
|
||||
// eslint-disable-next-line no-global-assign
|
||||
indexedDB = {} as IDBFactory;
|
||||
|
||||
const result = await StorageManager.checkConsistency();
|
||||
expect(result.healthy).toBe(false);
|
||||
|
||||
// eslint-disable-next-line no-global-assign
|
||||
indexedDB = new IDBFactory();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue