Avoid using accessSecretStorage to create 4S (#30244)
* remove resetCrossSigning flag, which is no longer in use * drop unnecessary check for cross-signing The only place where verifyUser is called already checks that cross-signing is set up. (The function name is also incorrect, since it checks for the cross-signing key, and not for 4S.) * avoid calling accessSecretStorage to set up cross-signing or 4S Send the user to the Encryption settings tab instead * only create secret storage when specifically asked to * deprecate using accessSecretStorage to create new 4S * also remove the obsolete snapshot * add tests * Tweak comment Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --------- Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
This commit is contained in:
co-authored by
Richard van der Hoff
parent
66d7c6a100
commit
9095ebdb1b
@@ -10,10 +10,13 @@ import React from "react";
|
||||
import { mocked, type MockedObject } from "jest-mock";
|
||||
import { type MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import { type CryptoApi, type KeyBackupInfo } from "matrix-js-sdk/src/crypto-api";
|
||||
import { fireEvent, render, type RenderResult, screen } from "jest-matrix-react";
|
||||
import { fireEvent, render, type RenderResult, screen, waitFor } from "jest-matrix-react";
|
||||
|
||||
import { filterConsole, getMockClientWithEventEmitter, mockClientMethodsCrypto } from "../../../../test-utils";
|
||||
import LogoutDialog from "../../../../../src/components/views/dialogs/LogoutDialog";
|
||||
import dispatch from "../../../../../src/dispatcher/dispatcher";
|
||||
import { Action } from "../../../../../src/dispatcher/actions";
|
||||
import { UserTab } from "../../../../../src/components/views/dialogs/UserTab";
|
||||
|
||||
describe("LogoutDialog", () => {
|
||||
let mockClient: MockedObject<MatrixClient>;
|
||||
@@ -56,17 +59,26 @@ describe("LogoutDialog", () => {
|
||||
await rendered.findByText("You'll lose access to your encrypted messages");
|
||||
});
|
||||
|
||||
it("Prompts user to connect backup if there is a backup on the server", async () => {
|
||||
it("Prompts user to go to settings if there is a backup on the server", async () => {
|
||||
mockCrypto.getKeyBackupInfo.mockResolvedValue({} as KeyBackupInfo);
|
||||
const rendered = renderComponent();
|
||||
await rendered.findByText("Connect this session to Key Backup");
|
||||
await rendered.findByText("Go to Settings");
|
||||
expect(rendered.container).toMatchSnapshot();
|
||||
|
||||
jest.spyOn(dispatch, "dispatch");
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Go to Settings" }));
|
||||
await waitFor(() =>
|
||||
expect(dispatch.dispatch).toHaveBeenCalledWith({
|
||||
action: Action.ViewUserSettings,
|
||||
initialTabId: UserTab.Encryption,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("Prompts user to set up backup if there is no backup on the server", async () => {
|
||||
it("Prompts user to go to settings if there is no backup on the server", async () => {
|
||||
mockCrypto.getKeyBackupInfo.mockResolvedValue(null);
|
||||
const rendered = renderComponent();
|
||||
await rendered.findByText("Start using Key Backup");
|
||||
await rendered.findByText("Go to Settings");
|
||||
expect(rendered.container).toMatchSnapshot();
|
||||
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Manually export keys" }));
|
||||
@@ -75,12 +87,12 @@ describe("LogoutDialog", () => {
|
||||
|
||||
describe("when there is an error fetching backups", () => {
|
||||
filterConsole("Unable to fetch key backup status");
|
||||
it("prompts user to set up backup", async () => {
|
||||
it("prompts user to go to settings", async () => {
|
||||
mockCrypto.getKeyBackupInfo.mockImplementation(async () => {
|
||||
throw new Error("beep");
|
||||
});
|
||||
const rendered = renderComponent();
|
||||
await rendered.findByText("Start using Key Backup");
|
||||
await rendered.findByText("Go to Settings");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user