From 067e338b4b33c83f222b733e562c752175c86b7c Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Tue, 3 Oct 2023 14:44:15 +0200 Subject: [PATCH] Cypress: Check that the new verified device is connected to key backup (#11686) * Check that the new verified device is connected to key backup * Review changes. Extract key backup verification in its own function and chang parameter order of bot `bootstrapSecretStorage` call. --- cypress/e2e/crypto/utils.ts | 13 +++++++++++++ cypress/e2e/crypto/verification.spec.ts | 20 +++++++++++++++++++- cypress/support/bot.ts | 1 + 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/cypress/e2e/crypto/utils.ts b/cypress/e2e/crypto/utils.ts index d2101aaa17..7372508601 100644 --- a/cypress/e2e/crypto/utils.ts +++ b/cypress/e2e/crypto/utils.ts @@ -97,6 +97,19 @@ export function checkDeviceIsCrossSigned(): void { }); } +/** + * Check that the current device is connected to the key backup. + */ +export function checkDeviceIsConnectedKeyBackup() { + cy.findByRole("button", { name: "User menu" }).click(); + cy.get(".mx_UserMenu_contextMenu").within(() => { + cy.findByRole("menuitem", { name: "Security & Privacy" }).click(); + }); + cy.get(".mx_Dialog").within(() => { + cy.findByRole("button", { name: "Restore from Backup" }).should("exist"); + }); +} + /** * Fill in the login form in element with the given creds. * diff --git a/cypress/e2e/crypto/verification.spec.ts b/cypress/e2e/crypto/verification.spec.ts index d221a39df7..0649366507 100644 --- a/cypress/e2e/crypto/verification.spec.ts +++ b/cypress/e2e/crypto/verification.spec.ts @@ -21,7 +21,13 @@ import type { VerificationRequest, Verifier } from "matrix-js-sdk/src/crypto-api import { CypressBot } from "../../support/bot"; import { HomeserverInstance } from "../../plugins/utils/homeserver"; import { emitPromise } from "../../support/util"; -import { checkDeviceIsCrossSigned, doTwoWaySasVerification, logIntoElement, waitForVerificationRequest } from "./utils"; +import { + checkDeviceIsConnectedKeyBackup, + checkDeviceIsCrossSigned, + doTwoWaySasVerification, + logIntoElement, + waitForVerificationRequest, +} from "./utils"; import { getToast } from "../../support/toasts"; import { UserCredentials } from "../../support/login"; @@ -111,6 +117,9 @@ describe("Device verification", () => { // Check that our device is now cross-signed checkDeviceIsCrossSigned(); + + // Check that the current device is connected to key backup + checkDeviceIsConnectedKeyBackup(); }); it("Verify device during login with QR code", () => { @@ -148,6 +157,9 @@ describe("Device verification", () => { // Check that our device is now cross-signed checkDeviceIsCrossSigned(); + + // Check that the current device is connected to key backup + checkDeviceIsConnectedKeyBackup(); }); it("Verify device during login with Security Phrase", () => { @@ -170,6 +182,9 @@ describe("Device verification", () => { // Check that our device is now cross-signed checkDeviceIsCrossSigned(); + + // Check that the current device is connected to key backup + checkDeviceIsConnectedKeyBackup(); }); it("Verify device during login with Security Key", () => { @@ -193,6 +208,9 @@ describe("Device verification", () => { // Check that our device is now cross-signed checkDeviceIsCrossSigned(); + + // Check that the current device is connected to key backup + checkDeviceIsConnectedKeyBackup(); }); it("Handle incoming verification request with SAS", () => { diff --git a/cypress/support/bot.ts b/cypress/support/bot.ts index 34e5c858a9..c1e1e9221b 100644 --- a/cypress/support/bot.ts +++ b/cypress/support/bot.ts @@ -225,6 +225,7 @@ function setupBotClient( await cli.getCrypto()!.bootstrapSecretStorage({ setupNewSecretStorage: true, + setupNewKeyBackup: true, createSecretStorageKey: () => Promise.resolve(recoveryKey), }); }