-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
e2e test: Check key backup with js-sdk api instead of relying of Security & Privacy
tab
#29066
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,12 +139,12 @@ export async function checkDeviceIsCrossSigned(app: ElementAppPage): Promise<voi | |
* Check that the current device is connected to the expected key backup. | ||
* Also checks that the decryption key is known and cached locally. | ||
* | ||
* @param page - the page to check | ||
* @param app - app page | ||
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. So that means that the check on the page is not up-to-date, but the check using the API is ok? 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. This UI section will be removed in #26468. The e2e tests were using this section to check if the key storage was in the expected state.
florianduros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* @param expectedBackupVersion - the version of the backup we expect to be connected to. | ||
* @param checkBackupKeyInCache - whether to check that the backup key is cached locally. | ||
florianduros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
export async function checkDeviceIsConnectedKeyBackup( | ||
page: Page, | ||
app: ElementAppPage, | ||
expectedBackupVersion: string, | ||
checkBackupKeyInCache: boolean, | ||
): Promise<void> { | ||
|
@@ -155,23 +155,41 @@ export async function checkDeviceIsConnectedKeyBackup( | |
); | ||
} | ||
|
||
await page.getByRole("button", { name: "User menu" }).click(); | ||
await page.locator(".mx_UserMenu_contextMenu").getByRole("menuitem", { name: "Security & Privacy" }).click(); | ||
await expect(page.locator(".mx_Dialog").getByRole("button", { name: "Restore from Backup" })).toBeVisible(); | ||
const backupData = await app.client.evaluate(async (client: MatrixClient) => { | ||
const crypto = client.getCrypto(); | ||
if (!crypto) return; | ||
|
||
// expand the advanced section to see the active version in the reports | ||
await page.locator(".mx_SecureBackupPanel_advanced").locator("..").click(); | ||
const backupInfo = await crypto.getKeyBackupInfo(); | ||
const backupKeyStored = Boolean(await client.isKeyBackupKeyStored()); | ||
florianduros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const backupKeyFromCache = await crypto.getSessionBackupPrivateKey(); | ||
florianduros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const backupKeyCached = Boolean(backupKeyFromCache); | ||
const backupKeyWellFormed = backupKeyFromCache instanceof Uint8Array; | ||
florianduros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const activeBackupVersion = await crypto.getActiveSessionBackupVersion(); | ||
|
||
if (checkBackupKeyInCache) { | ||
const cacheDecryptionKeyStatusElement = page.locator(".mx_SecureBackupPanel_statusList tr:nth-child(2) td"); | ||
await expect(cacheDecryptionKeyStatusElement).toHaveText("cached locally, well formed"); | ||
return { backupInfo, backupKeyStored, backupKeyCached, backupKeyWellFormed, activeBackupVersion }; | ||
}); | ||
|
||
if (!backupData) { | ||
throw new Error("Crypo module is not available"); | ||
florianduros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
await expect(page.locator(".mx_SecureBackupPanel_statusList tr:nth-child(5) td")).toHaveText( | ||
expectedBackupVersion + " (Algorithm: m.megolm_backup.v1.curve25519-aes-sha2)", | ||
); | ||
const { backupInfo, backupKeyStored, backupKeyCached, backupKeyWellFormed, activeBackupVersion } = backupData; | ||
|
||
// We have a key backup | ||
expect(backupInfo).toBeDefined(); | ||
// The key backup version is as expected | ||
expect(backupInfo.version).toBe(expectedBackupVersion); | ||
// The active backup version is as expected | ||
expect(activeBackupVersion).toBe(expectedBackupVersion); | ||
// The backup key is stored in 4S | ||
expect(backupKeyStored).toBe(true); | ||
|
||
await expect(page.locator(".mx_SecureBackupPanel_statusList tr:nth-child(6) td")).toHaveText(expectedBackupVersion); | ||
if (checkBackupKeyInCache) { | ||
// The backup key is available locally | ||
expect(backupKeyCached).toBe(true); | ||
// The backup key is well-formed | ||
expect(backupKeyWellFormed).toBe(true); | ||
} | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still not working
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just this test isn't working?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The others are working if we check that the key backup is in cache but this one is failing (so I kept the
false
attribute)