First batch: remove deprecated calls on MatrixClient
(#28207)
* Remove `initCrypto` mocking * Remove `MatrixClient.downloadKeys` mocking * Remove `MatrixClient.getStoredDevice` mocking * Replace `MatrixClient.setGlobalBlacklistUnverifiedDevices` by `MatrixClient.CryptoApi.globalBlacklistUnverifiedDevices` * Remove `MatrixClient.getStoredCrossSigningForUser` mocking * Replace `MatrixClient.legacyDeviceVerification` by `MatrixClient.CryptoApi.requestDeviceVerification` * Remove `MatrixClient.isCrossSigningReady` mock * Replace `MatrixClient.bootstrapCrossSigning` by `MatrixClient.getCrypto.bootstrapCrossSigning` * Replace `MatrixClient.getCryptoTrustCrossSignedDevices` by `MatrixClient.getCrypto.getTrustCrossSignedDevices` * Replace `MatrixClient.hasSecretStorageKey` by `MatrixClient.SecretStorage.hasKey` * Replace `MatrixClient.getDefaultSecretStorageKeyId` by `MatrixClient.SecretStorage.getDefaultKeyId` * Remove `MatrixClient.encryptAndSendToDevices` call
This commit is contained in:
parent
26a98e5e30
commit
46d13921d0
17 changed files with 22 additions and 55 deletions
|
@ -17,7 +17,6 @@ import {
|
|||
waitForElementToBeRemoved,
|
||||
within,
|
||||
} from "jest-matrix-react";
|
||||
import { DeviceInfo } from "matrix-js-sdk/src/crypto/deviceinfo";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { CryptoApi, DeviceVerificationStatus, VerificationRequest } from "matrix-js-sdk/src/crypto-api";
|
||||
import { defer, sleep } from "matrix-js-sdk/src/utils";
|
||||
|
@ -205,7 +204,6 @@ describe("<SessionManagerTab />", () => {
|
|||
...mockClientMethodsServer(),
|
||||
getCrypto: jest.fn().mockReturnValue(mockCrypto),
|
||||
getDevices: jest.fn(),
|
||||
getStoredDevice: jest.fn(),
|
||||
getDeviceId: jest.fn().mockReturnValue(deviceId),
|
||||
deleteMultipleDevices: jest.fn(),
|
||||
generateClientSecret: jest.fn(),
|
||||
|
@ -220,10 +218,6 @@ describe("<SessionManagerTab />", () => {
|
|||
});
|
||||
jest.clearAllMocks();
|
||||
jest.spyOn(logger, "error").mockRestore();
|
||||
mockClient.getStoredDevice.mockImplementation((_userId, id) => {
|
||||
const device = [alicesDevice, alicesMobileDevice].find((device) => device.device_id === id);
|
||||
return device ? new DeviceInfo(device.device_id) : null;
|
||||
});
|
||||
mockCrypto.getDeviceVerificationStatus.mockReset().mockResolvedValue(new DeviceVerificationStatus({}));
|
||||
|
||||
mockClient.getDevices.mockReset().mockResolvedValue({ devices: [alicesDevice, alicesMobileDevice] });
|
||||
|
@ -292,7 +286,6 @@ describe("<SessionManagerTab />", () => {
|
|||
mockClient.getDevices.mockResolvedValue({
|
||||
devices: [alicesDevice, alicesMobileDevice, alicesOlderMobileDevice],
|
||||
});
|
||||
mockClient.getStoredDevice.mockImplementation((_userId, deviceId) => new DeviceInfo(deviceId));
|
||||
mockCrypto.getDeviceVerificationStatus.mockImplementation(async (_userId, deviceId) => {
|
||||
// alices device is trusted
|
||||
if (deviceId === alicesDevice.device_id) {
|
||||
|
@ -464,7 +457,6 @@ describe("<SessionManagerTab />", () => {
|
|||
mockClient.getDevices.mockResolvedValue({
|
||||
devices: [alicesDevice, alicesMobileDevice],
|
||||
});
|
||||
mockClient.getStoredDevice.mockImplementation(() => new DeviceInfo(alicesDevice.device_id));
|
||||
mockCrypto.getDeviceVerificationStatus.mockResolvedValue(
|
||||
new DeviceVerificationStatus({ crossSigningVerified: true, localVerified: true }),
|
||||
);
|
||||
|
@ -568,7 +560,6 @@ describe("<SessionManagerTab />", () => {
|
|||
mockClient.getDevices.mockResolvedValue({
|
||||
devices: [alicesDevice, alicesMobileDevice],
|
||||
});
|
||||
mockClient.getStoredDevice.mockImplementation((_userId, deviceId) => new DeviceInfo(deviceId));
|
||||
mockCrypto.getDeviceVerificationStatus.mockImplementation(async (_userId, deviceId) => {
|
||||
if (deviceId === alicesDevice.device_id) {
|
||||
return new DeviceVerificationStatus({ crossSigningVerified: true, localVerified: true });
|
||||
|
@ -595,7 +586,6 @@ describe("<SessionManagerTab />", () => {
|
|||
mockClient.getDevices.mockResolvedValue({
|
||||
devices: [alicesDevice, alicesMobileDevice],
|
||||
});
|
||||
mockClient.getStoredDevice.mockImplementation((_userId, deviceId) => new DeviceInfo(deviceId));
|
||||
mockCrypto.getDeviceVerificationStatus.mockImplementation(async (_userId, deviceId) => {
|
||||
// current session verified = able to verify other sessions
|
||||
if (deviceId === alicesDevice.device_id) {
|
||||
|
@ -629,7 +619,6 @@ describe("<SessionManagerTab />", () => {
|
|||
mockClient.getDevices.mockResolvedValue({
|
||||
devices: [alicesDevice, alicesMobileDevice],
|
||||
});
|
||||
mockClient.getStoredDevice.mockImplementation((_userId, deviceId) => new DeviceInfo(deviceId));
|
||||
mockCrypto.getDeviceVerificationStatus.mockImplementation(async (_userId, deviceId) => {
|
||||
if (deviceId === alicesDevice.device_id) {
|
||||
return new DeviceVerificationStatus({ crossSigningVerified: true, localVerified: true });
|
||||
|
@ -667,7 +656,6 @@ describe("<SessionManagerTab />", () => {
|
|||
mockClient.getDevices.mockResolvedValue({
|
||||
devices: [alicesDevice, alicesMobileDevice, alicesDehydratedDevice],
|
||||
});
|
||||
mockClient.getStoredDevice.mockImplementation((_userId, deviceId) => new DeviceInfo(deviceId));
|
||||
|
||||
const devicesMap = new Map<string, Device>([
|
||||
[alicesDeviceObj.deviceId, alicesDeviceObj],
|
||||
|
@ -708,7 +696,6 @@ describe("<SessionManagerTab />", () => {
|
|||
mockClient.getDevices.mockResolvedValue({
|
||||
devices: [alicesDevice, alicesMobileDevice, alicesDehydratedDevice],
|
||||
});
|
||||
mockClient.getStoredDevice.mockImplementation((_userId, deviceId) => new DeviceInfo(deviceId));
|
||||
|
||||
const devicesMap = new Map<string, Device>([
|
||||
[alicesDeviceObj.deviceId, alicesDeviceObj],
|
||||
|
@ -749,7 +736,6 @@ describe("<SessionManagerTab />", () => {
|
|||
mockClient.getDevices.mockResolvedValue({
|
||||
devices: [alicesDevice, alicesMobileDevice, alicesDehydratedDevice, alicesOtherDehydratedDevice],
|
||||
});
|
||||
mockClient.getStoredDevice.mockImplementation((_userId, deviceId) => new DeviceInfo(deviceId));
|
||||
|
||||
const devicesMap = new Map<string, Device>([
|
||||
[alicesDeviceObj.deviceId, alicesDeviceObj],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue