-
-
Notifications
You must be signed in to change notification settings - Fork 831
Set up key backup using non-deprecated APIs (2nd take) #12098
Conversation
src/async-components/views/dialogs/security/CreateKeyBackupDialog.tsx
Outdated
Show resolved
Hide resolved
src/async-components/views/dialogs/security/CreateKeyBackupDialog.tsx
Outdated
Show resolved
Hide resolved
…log.tsx Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
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.
a few more suggestions for clarity, but lgtm otherwise
const secretStorageAlreadySetup = await cli.hasSecretStorageKey(); | ||
|
||
if (!secretStorageAlreadySetup) { | ||
// bootstrap secret storage, that will also create a backup version |
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.
nit
// bootstrap secret storage, that will also create a backup version | |
// bootstrap secret storage; that will also create a backup version |
if (!secretStorageAlreadySetup) { | ||
// bootstrap secret storage, that will also create a backup version | ||
await accessSecretStorage(async (): Promise<void> => { | ||
// do nothing, all is now setup correctly |
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.
nit
// do nothing, all is now setup correctly | |
// do nothing, all is now set up correctly |
// Secret storage exists, we need to ensure that we can write to it before | ||
// we create a new backup version. It ensures that we can write to it and keep it in sync. |
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.
Sorry, only just seeing this now. It rather duplicates the comment below.
// Secret storage exists, we need to ensure that we can write to it before | |
// we create a new backup version. It ensures that we can write to it and keep it in sync. |
test/test-utils/test-utils.ts
Outdated
@@ -116,6 +117,10 @@ export function createTestClient(): MatrixClient { | |||
bootstrapCrossSigning: jest.fn(), | |||
hasSecretStorageKey: jest.fn(), | |||
|
|||
secretStorage: { | |||
get: jest.fn(), | |||
} as unknown as ServerSideSecretStorage, |
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.
I'm surprised this typecast is necessary: it doesn't seem to be for any of the other properties. Can we get rid of it?
} as unknown as ServerSideSecretStorage, | |
}, |
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.
(also remove the import of ServerSideSecretStorage
)
await currentDialogLocator.getByRole("button", { name: "Copy", exact: true }).click(); | ||
|
||
// copy the recovery key to use it later | ||
securityKey = await app.getClipboard(); |
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.
securityKey = await app.getClipboard(); | |
const securityKey = await app.getClipboard(); |
|
||
let securityKey = ""; | ||
|
||
const currentDialogLocator = page.locator(".mx_Dialog"); |
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.
suggest moving this (const currentDialogLocator = page.locator(".mx_Dialog");
) down to where it is used.
// Create a backup | ||
const tab = await app.settings.openUserSettings("Security & Privacy"); | ||
|
||
await expect(tab.getByRole("heading", { name: "Secure Backup" })).toBeVisible(); | ||
|
||
let securityKey = ""; | ||
|
||
const currentDialogLocator = page.locator(".mx_Dialog"); | ||
|
||
await tab.getByRole("button", { name: "Set up", exact: true }).click(); |
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.
Lots of whitespace here, and I don't think it helps readability.
// Create a backup | |
const tab = await app.settings.openUserSettings("Security & Privacy"); | |
await expect(tab.getByRole("heading", { name: "Secure Backup" })).toBeVisible(); | |
let securityKey = ""; | |
const currentDialogLocator = page.locator(".mx_Dialog"); | |
await tab.getByRole("button", { name: "Set up", exact: true }).click(); | |
// Create a backup | |
const tab = await app.settings.openUserSettings("Security & Privacy"); | |
await expect(tab.getByRole("heading", { name: "Secure Backup" })).toBeVisible(); | |
await tab.getByRole("button", { name: "Set up", exact: true }).click(); |
|
||
await tab.getByRole("button", { name: "Set up", exact: true }).click(); | ||
|
||
// It's the first time and secure storage not setup, so it will create one |
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.
nit
// It's the first time and secure storage not setup, so it will create one | |
// It's the first time and secure storage is not set up, so it will create one |
await tab.getByRole("button", { name: "Delete Backup", exact: true }).click(); | ||
|
||
await expect(currentDialogLocator.getByRole("heading", { name: "Delete Backup" })).toBeVisible(); | ||
|
||
// Delete it | ||
await currentDialogLocator.getByTestId("dialog-primary-button").click(); // Click "Delete Backup" |
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.
Again, too much whitespace. And the comment is in the wrong place.
await tab.getByRole("button", { name: "Delete Backup", exact: true }).click(); | |
await expect(currentDialogLocator.getByRole("heading", { name: "Delete Backup" })).toBeVisible(); | |
// Delete it | |
await currentDialogLocator.getByTestId("dialog-primary-button").click(); // Click "Delete Backup" | |
// Delete it | |
await tab.getByRole("button", { name: "Delete Backup", exact: true }).click(); | |
await expect(currentDialogLocator.getByRole("heading", { name: "Delete Backup" })).toBeVisible(); | |
await currentDialogLocator.getByTestId("dialog-primary-button").click(); // Click "Delete Backup" |
await currentDialogLocator.getByTestId("dialog-cancel-button").click(); | ||
|
||
// go back to the settings to check that no backup was created (the setup button should still be there) | ||
const tab2 = await app.settings.openUserSettings("Security & Privacy"); |
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.
why do we create a new tab2
here, but not the other two times we re-open the settings? Surely either we can re-use tab
or we can't?
Checklist
Fixes element-hq/element-web#26323
Put back the changes that were on #12005 without the regression that causes unwanted backup resets
Here's what your changelog entry will look like:
🐛 Bug Fixes