This repository was archived by the owner on Oct 22, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 11
Force verification even for refreshed clients #44
Merged
Merged
Changes from 18 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
b1aaae7
Force verification even for refreshed cients
dbkr 2b10580
Hopefully make matrixchat tests pass?
dbkr 91207a9
Merge branch 'develop' into dbkr/really_force_verification
dbkr 255c7dc
Manual yarn.lock manipulation
dbkr e986562
Make final test pass(?)
dbkr 2cb9f8f
Merge branch 'develop' into dbkr/really_force_verification
dbkr 80c75d4
another waitFor
dbkr b07203e
death to flushPromises
dbkr f8c7db4
Put the logged in dispatch back
dbkr bc88a9a
Try displaying the screen in onClientStarted instead
dbkr bd2ca31
Put post login screen back in logged in
dbkr 1471862
Rejig more in the hope it does the right thing
dbkr e88d1e0
Make hook work before push rules are fetched
dbkr 579d507
Add test for unskippable verification
dbkr 60b8eaf
Add test for use case selection
dbkr 1e2525b
Fix test
dbkr 860dedd
Add playwright test for unskippable verification
dbkr ee7a3e8
Remove console log
dbkr c2c3e4a
Add log message to log line
dbkr 71249a3
Add tsdoc
dbkr 1b04bf6
Use useTypedEventEmitter
dbkr 677f616
Remove commented code
dbkr 4a84e3d
Use catch instead of empty then on unawaited promises
dbkr 707c8c7
Merge branch 'develop' into dbkr/really_force_verification
dbkr 3e11360
Add new mock
dbkr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,20 +6,85 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only | |
| Please see LICENSE files in the repository root for full details. | ||
| */ | ||
|
|
||
| import { Page } from "playwright-core"; | ||
|
|
||
| import { expect, test } from "../../element-web-test"; | ||
| import { doTokenRegistration } from "./utils"; | ||
| import { isDendrite } from "../../plugins/homeserver/dendrite"; | ||
| import { selectHomeserver } from "../utils"; | ||
| import { Credentials, HomeserverInstance } from "../../plugins/homeserver"; | ||
|
|
||
| const username = "user1234"; | ||
| const password = "p4s5W0rD"; | ||
|
|
||
| // Pre-generated dummy signing keys to create an account that has signing keys set. | ||
| // Note the signatures are specific to the username and must be valid or the HS will reject the keys. | ||
| const DEVICE_SIGNING_KEYS_BODY = { | ||
| master_key: { | ||
| keys: { | ||
| "ed25519:6qCouJsi2j7DzOmpxPTBALpvDTqa8p2mjrQR2P8wEbg": "6qCouJsi2j7DzOmpxPTBALpvDTqa8p2mjrQR2P8wEbg", | ||
| }, | ||
| signatures: { | ||
| "@user1234:localhost": { | ||
| "ed25519:6qCouJsi2j7DzOmpxPTBALpvDTqa8p2mjrQR2P8wEbg": | ||
| "mvwqsYiGa2gPH6ueJsiJnceHMrZhf1pqIMGxkvKisN3ucz8sU7LwyzndbYaLkUKEDx1JuOKFfZ9Mb3mqc7PMBQ", | ||
| "ed25519:SRHVWTNVBH": | ||
| "HVGmVIzsJe3d+Un/6S9tXPsU7YA8HjZPdxogVzdjEFIU8OjLyElccvjupow0rVWgkEqU8sO21LIHw9cWRZEmDw", | ||
| }, | ||
| }, | ||
| usage: ["master"], | ||
| user_id: "@user1234:localhost", | ||
| }, | ||
| self_signing_key: { | ||
| keys: { | ||
| "ed25519:eqzRly4S1GvTA36v48hOKokHMtYBLm02zXRgPHue5/8": "eqzRly4S1GvTA36v48hOKokHMtYBLm02zXRgPHue5/8", | ||
| }, | ||
| signatures: { | ||
| "@user1234:localhost": { | ||
| "ed25519:6qCouJsi2j7DzOmpxPTBALpvDTqa8p2mjrQR2P8wEbg": | ||
| "M2rt5xs+23egbVUwUcZuU7pMpn0chBNC5rpdyZGayfU3FDlx1DbopbakIcl5v4uOSGMbqUotyzkE6CchB+dgDw", | ||
| }, | ||
| }, | ||
| usage: ["self_signing"], | ||
| user_id: "@user1234:localhost", | ||
| }, | ||
| user_signing_key: { | ||
| keys: { | ||
| "ed25519:h6C7sonjKSSa/VMvmpmFnwMA02H2rKIMSYZ2ddwgJn4": "h6C7sonjKSSa/VMvmpmFnwMA02H2rKIMSYZ2ddwgJn4", | ||
| }, | ||
| signatures: { | ||
| "@user1234:localhost": { | ||
| "ed25519:6qCouJsi2j7DzOmpxPTBALpvDTqa8p2mjrQR2P8wEbg": | ||
| "5ZMJ7SG2qr76vU2nITKap88AxLZ/RZQmF/mBcAcVZ9Bknvos3WQp8qN9jKuiqOHCq/XpPORA6XBmiDIyPqTFAA", | ||
| }, | ||
| }, | ||
| usage: ["user_signing"], | ||
| user_id: "@user1234:localhost", | ||
| }, | ||
| auth: { | ||
| type: "m.login.password", | ||
| identifier: { type: "m.id.user", user: "@user1234:localhost" }, | ||
| password: password, | ||
| }, | ||
| }; | ||
|
|
||
| async function login(page: Page, homeserver: HomeserverInstance) { | ||
| await page.getByRole("link", { name: "Sign in" }).click(); | ||
| await selectHomeserver(page, homeserver.config.baseUrl); | ||
|
|
||
| await page.getByRole("textbox", { name: "Username" }).fill(username); | ||
| await page.getByPlaceholder("Password").fill(password); | ||
| await page.getByRole("button", { name: "Sign in" }).click(); | ||
| } | ||
|
|
||
| test.describe("Login", () => { | ||
| test.describe("Password login", () => { | ||
| test.use({ startHomeserverOpts: "consent" }); | ||
|
|
||
| const username = "user1234"; | ||
| const password = "p4s5W0rD"; | ||
| let creds: Credentials; | ||
|
|
||
| test.beforeEach(async ({ homeserver }) => { | ||
| await homeserver.registerUser(username, password); | ||
| creds = await homeserver.registerUser(username, password); | ||
| }); | ||
|
|
||
| test("Loads the welcome page by default; then logs in with an existing account and lands on the home screen", async ({ | ||
|
|
@@ -65,17 +130,97 @@ test.describe("Login", () => { | |
|
|
||
| test("Follows the original link after login", async ({ page, homeserver }) => { | ||
| await page.goto("/#/room/!room:id"); // should redirect to the welcome page | ||
| await page.getByRole("link", { name: "Sign in" }).click(); | ||
|
|
||
| await selectHomeserver(page, homeserver.config.baseUrl); | ||
|
|
||
| await page.getByRole("textbox", { name: "Username" }).fill(username); | ||
| await page.getByPlaceholder("Password").fill(password); | ||
| await page.getByRole("button", { name: "Sign in" }).click(); | ||
| await login(page, homeserver); | ||
|
|
||
| await expect(page).toHaveURL(/\/#\/room\/!room:id$/); | ||
| await expect(page.getByRole("button", { name: "Join the discussion" })).toBeVisible(); | ||
| }); | ||
|
|
||
| test.describe("verification after login", () => { | ||
| test("Shows verification prompt after login if signing keys are set up, skippable by default", async ({ | ||
| page, | ||
| homeserver, | ||
| request, | ||
| }) => { | ||
| const res = await request.post( | ||
| `${homeserver.config.baseUrl}/_matrix/client/v3/keys/device_signing/upload`, | ||
| { headers: { Authorization: `Bearer ${creds.accessToken}` }, data: DEVICE_SIGNING_KEYS_BODY }, | ||
| ); | ||
| if (res.status() / 100 !== 2) { | ||
| console.log(await res.json()); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remaining logging There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually these were intentional, but I can add a log line so it's more obvious. |
||
| expect(res.status() / 100).toEqual(2); | ||
|
|
||
| await page.goto("/"); | ||
| await login(page, homeserver); | ||
|
|
||
| await expect(page.getByRole("heading", { name: "Verify this device", level: 1 })).toBeVisible(); | ||
|
|
||
| await expect(page.getByRole("button", { name: "Skip verification for now" })).toBeVisible(); | ||
| }); | ||
|
|
||
| test.describe("with force_verification off", () => { | ||
| test.use({ | ||
| config: { | ||
| force_verification: false, | ||
| }, | ||
| }); | ||
|
|
||
| test("Shows skippable verification prompt after login if signing keys are set up", async ({ | ||
| page, | ||
| homeserver, | ||
| request, | ||
| }) => { | ||
| const res = await request.post( | ||
| `${homeserver.config.baseUrl}/_matrix/client/v3/keys/device_signing/upload`, | ||
| { headers: { Authorization: `Bearer ${creds.accessToken}` }, data: DEVICE_SIGNING_KEYS_BODY }, | ||
| ); | ||
| if (res.status() / 100 !== 2) { | ||
| console.log(await res.json()); | ||
| } | ||
dbkr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| expect(res.status() / 100).toEqual(2); | ||
|
|
||
| await page.goto("/"); | ||
| await login(page, homeserver); | ||
|
|
||
| await expect(page.getByRole("heading", { name: "Verify this device", level: 1 })).toBeVisible(); | ||
|
|
||
| await expect(page.getByRole("button", { name: "Skip verification for now" })).toBeVisible(); | ||
| }); | ||
| }); | ||
|
|
||
| test.describe("with force_verification on", () => { | ||
| test.use({ | ||
| config: { | ||
| force_verification: true, | ||
| }, | ||
| }); | ||
|
|
||
| test("Shows unskippable verification prompt after login if signing keys are set up", async ({ | ||
| page, | ||
| homeserver, | ||
| request, | ||
| }) => { | ||
| console.log(`uid ${creds.userId} body`, DEVICE_SIGNING_KEYS_BODY); | ||
| const res = await request.post( | ||
| `${homeserver.config.baseUrl}/_matrix/client/v3/keys/device_signing/upload`, | ||
| { headers: { Authorization: `Bearer ${creds.accessToken}` }, data: DEVICE_SIGNING_KEYS_BODY }, | ||
| ); | ||
| if (res.status() / 100 !== 2) { | ||
| console.log(await res.json()); | ||
| } | ||
dbkr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| expect(res.status() / 100).toEqual(2); | ||
|
|
||
| await page.goto("/"); | ||
| await login(page, homeserver); | ||
|
|
||
| const h1 = await page.getByRole("heading", { name: "Verify this device", level: 1 }); | ||
| await expect(h1).toBeVisible(); | ||
|
|
||
| expect(h1.locator(".mx_CompleteSecurity_skip")).not.toBeVisible(); | ||
| }); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| // tests for old-style SSO login, in which we exchange tokens with Synapse, and Synapse talks to an auth server | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.