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

Commit

Permalink
Cypress: skip tests known to fail when using Rust crypto (#10873)
Browse files Browse the repository at this point in the history
* Cypress: skip tests known to fail when using Rust crypto

... which means we can then run the cypress test suite against Element Web R to
check we aren't introducing regressions.

* Update cypress/e2e/register/register.spec.ts

* Use env var to detect rust crypto

* Hoist `skipIfRustCrypto` call earlier
  • Loading branch information
richvdh committed May 24, 2023
1 parent 0c30f0c commit 2571f54
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
3 changes: 3 additions & 0 deletions cypress/e2e/crypto/complete-security.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import type { VerificationRequest } from "matrix-js-sdk/src/crypto/verification/
import { HomeserverInstance } from "../../plugins/utils/homeserver";
import { handleVerificationRequest, waitForVerificationRequest } from "./utils";
import { CypressBot } from "../../support/bot";
import { skipIfRustCrypto } from "../../support/util";

describe("Complete security", () => {
let homeserver: HomeserverInstance;
Expand Down Expand Up @@ -46,6 +47,8 @@ describe("Complete security", () => {
});

it("should walk through device verification if we have a signed device", () => {
skipIfRustCrypto();

// create a new user, and have it bootstrap cross-signing
let botClient: CypressBot;
cy.getBot(homeserver, { displayName: "Jeff" })
Expand Down
5 changes: 5 additions & 0 deletions cypress/e2e/crypto/crypto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type { CypressBot } from "../../support/bot";
import { HomeserverInstance } from "../../plugins/utils/homeserver";
import { UserCredentials } from "../../support/login";
import { EmojiMapping, handleVerificationRequest, waitForVerificationRequest } from "./utils";
import { skipIfRustCrypto } from "../../support/util";

interface CryptoTestContext extends Mocha.Context {
homeserver: HomeserverInstance;
Expand Down Expand Up @@ -152,6 +153,7 @@ describe("Cryptography", function () {
});

it("setting up secure key backup should work", () => {
skipIfRustCrypto();
cy.openUserSettings("Security & Privacy");
cy.findByRole("button", { name: "Set up Secure Backup" }).click();
cy.get(".mx_Dialog").within(() => {
Expand All @@ -175,6 +177,7 @@ describe("Cryptography", function () {
});

it("creating a DM should work, being e2e-encrypted / user verification", function (this: CryptoTestContext) {
skipIfRustCrypto();
cy.bootstrapCrossSigning(aliceCredentials);
startDMWithBob.call(this);
// send first message
Expand All @@ -196,6 +199,7 @@ describe("Cryptography", function () {
});

it("should allow verification when there is no existing DM", function (this: CryptoTestContext) {
skipIfRustCrypto();
cy.bootstrapCrossSigning(aliceCredentials);
autoJoin(this.bob);

Expand All @@ -214,6 +218,7 @@ describe("Cryptography", function () {
});

it("should show the correct shield on edited e2e events", function (this: CryptoTestContext) {
skipIfRustCrypto();
cy.bootstrapCrossSigning(aliceCredentials);

// bob has a second, not cross-signed, device
Expand Down
2 changes: 2 additions & 0 deletions cypress/e2e/crypto/decryption-failure.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import type { MatrixClient } from "matrix-js-sdk/src/matrix";
import { HomeserverInstance } from "../../plugins/utils/homeserver";
import { UserCredentials } from "../../support/login";
import { handleVerificationRequest } from "./utils";
import { skipIfRustCrypto } from "../../support/util";

const ROOM_NAME = "Test room";
const TEST_USER = "Alia";
Expand Down Expand Up @@ -67,6 +68,7 @@ describe("Decryption Failure Bar", () => {
let roomId: string;

beforeEach(function () {
skipIfRustCrypto();
cy.startHomeserver("default").then((hs: HomeserverInstance) => {
homeserver = hs;
cy.initTestUser(homeserver, TEST_USER)
Expand Down
4 changes: 3 additions & 1 deletion cypress/support/config.json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ limitations under the License.
* we make requests to the live `matrix.org`, which makes our tests dependent on matrix.org being up and responsive.
*/

import { isRustCryptoEnabled } from "./util";

const CONFIG_JSON = {
// This is deliberately quite a minimal config.json, so that we can test that the default settings
// actually work.
Expand All @@ -40,7 +42,7 @@ beforeEach(() => {
const configJson = CONFIG_JSON;

// configure element to use rust crypto if the env var tells us so
if (Cypress.env("RUST_CRYPTO")) {
if (isRustCryptoEnabled()) {
configJson["features"] = {
feature_rust_crypto: true,
};
Expand Down
19 changes: 17 additions & 2 deletions cypress/support/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,20 @@ cy.all = function all(commands): Cypress.Chainable {
return cy.wrap(resultArray, { log: false });
};

// Needed to make this file a module
export {};
/**
* Check if Cypress has been configured to enable rust crypto, and bail out if so.
*/
export function skipIfRustCrypto() {
if (isRustCryptoEnabled()) {
cy.log("Skipping due to rust crypto");
//@ts-ignore: 'state' is a secret internal command
cy.state("runnable").skip();
}
}

/**
* Determine if Cypress has been configured to enable rust crypto (by checking the environment variable)
*/
export function isRustCryptoEnabled(): boolean {
return !!Cypress.env("RUST_CRYPTO");
}

0 comments on commit 2571f54

Please sign in to comment.