Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Remove deprecated calls to client#hasSecretStorageKey #12112

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update test
  • Loading branch information
BillCarsonFr committed Jan 5, 2024
commit 45c9f25db6ac0b585f87fea9d1161ebf8fa1a13d
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,18 @@ export default class CreateKeyBackupDialog extends React.PureComponent<IProps, I
// Secret storage exists, we need to ensure that we can write to it before
// we create a new backup version. It ensures that we can write to it and keep it in sync.
await withSecretStorageKeyCache(async () => {
const crypto = cli.getCrypto();
if (!crypto) {
throw new Error("End-to-end encryption is disabled - unable to create backup.");
}

// this is the secret that will need to be updated, ensure that we can access it.
// This will ask the user to enter their passphrase/key.
await cli.secretStorage.get("m.megolm_backup.v1");
// if we get here, we can access the secret storage, so we can create a backup version.
// We don't reset if we can't access the secret storage, as the secret storage will then
// have an outdated secret for backup that future sessions will not be able to use.
await cli.getCrypto()?.resetKeyBackup();
await crypto.resetKeyBackup();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { MatrixClientPeg } from "../../../../../src/MatrixClientPeg";

jest.mock("../../../../../src/SecurityManager", () => ({
accessSecretStorage: jest.fn().mockResolvedValue(undefined),
withSecretStorageKeyCache: jest.fn().mockImplementation((fn) => fn()),
}));

describe("CreateKeyBackupDialog", () => {
Expand Down
5 changes: 5 additions & 0 deletions test/test-utils/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import { EnhancedMap } from "../../src/utils/maps";
import { AsyncStoreWithClient } from "../../src/stores/AsyncStoreWithClient";
import MatrixClientBackedSettingsHandler from "../../src/settings/handlers/MatrixClientBackedSettingsHandler";
import { ServerSideSecretStorage } from "../../../matrix-js-sdk/src/secret-storage";

Check failure on line 59 in test/test-utils/test-utils.ts

View workflow job for this annotation

GitHub Actions / Typescript Syntax Check

Cannot find module '../../../matrix-js-sdk/src/secret-storage' or its corresponding type declarations.

/**
* Stub out the MatrixClient, and configure the MatrixClientPeg object to
Expand Down Expand Up @@ -116,6 +117,10 @@
bootstrapCrossSigning: jest.fn(),
hasSecretStorageKey: jest.fn(),

secretStorage: {
get: jest.fn(),
} as unknown as ServerSideSecretStorage,

store: {
getPendingEvents: jest.fn().mockResolvedValue([]),
setPendingEvents: jest.fn().mockResolvedValue(undefined),
Expand Down
Loading