-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Remove manual device verification which is not supported by the new cryptography stack #28588
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
Merged
florianduros
merged 7 commits into
develop
from
florianduros/rip-out-legacy-crypto/fix-usage-deprecated
Dec 3, 2024
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ccc04de
Remove call of `MatrixClient.setDeviceVerified`
florianduros 1b35526
Replace usage of deprecated crypto events
florianduros da5e253
Replace deprecated imports
florianduros a225628
Remove legacy button in `UntrustedDeviceDialog`
florianduros 6269dbd
Review fixes
florianduros 3fbe2a5
Add tests
florianduros 76e4215
Fix doc
florianduros 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
59 changes: 59 additions & 0 deletions
59
test/unit-tests/components/views/dialogs/UntrustedDeviceDialog-test.tsx
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2024 New Vector Ltd. | ||
* | ||
* SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only | ||
* Please see LICENSE files in the repository root for full details. | ||
*/ | ||
|
||
import React from "react"; | ||
import { Device, MatrixClient, User } from "matrix-js-sdk/src/matrix"; | ||
import { render, screen } from "jest-matrix-react"; | ||
|
||
import { stubClient } from "../../../../test-utils"; | ||
import UntrustedDeviceDialog from "../../../../../src/components/views/dialogs/UntrustedDeviceDialog.tsx"; | ||
|
||
describe("<UntrustedDeviceDialog />", () => { | ||
let client: MatrixClient; | ||
let user: User; | ||
let device: Device; | ||
const onFinished = jest.fn(); | ||
|
||
beforeEach(() => { | ||
client = stubClient(); | ||
user = User.createUser("@alice:example.org", client); | ||
user.setDisplayName("Alice"); | ||
device = new Device({ deviceId: "device_id", userId: user.userId, algorithms: [], keys: new Map() }); | ||
}); | ||
|
||
afterEach(() => { | ||
onFinished.mockReset(); | ||
}); | ||
|
||
function renderComponent() { | ||
return render(<UntrustedDeviceDialog user={user} device={device} onFinished={onFinished} />); | ||
} | ||
|
||
it("should display the dialog for the device of another user", () => { | ||
const { asFragment } = renderComponent(); | ||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
|
||
it("should display the dialog for the device of the current user", () => { | ||
jest.spyOn(client, "getUserId").mockReturnValue(user.userId); | ||
|
||
const { asFragment } = renderComponent(); | ||
expect(asFragment()).toMatchSnapshot(); | ||
}); | ||
|
||
it("should call onFinished without parameter when Done is clicked", () => { | ||
renderComponent(); | ||
screen.getByRole("button", { name: "Done" }).click(); | ||
expect(onFinished).toHaveBeenCalledWith(); | ||
}); | ||
|
||
it("should call onFinished with sas when Interactively verify by emoji is clicked", () => { | ||
renderComponent(); | ||
screen.getByRole("button", { name: "Interactively verify by emoji" }).click(); | ||
expect(onFinished).toHaveBeenCalledWith("sas"); | ||
}); | ||
}); |
149 changes: 149 additions & 0 deletions
149
test/unit-tests/components/views/dialogs/__snapshots__/UntrustedDeviceDialog-test.tsx.snap
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 |
---|---|---|
@@ -0,0 +1,149 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<UntrustedDeviceDialog /> should display the dialog for the device of another user 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
data-focus-guard="true" | ||
style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;" | ||
tabindex="0" | ||
/> | ||
<div | ||
aria-labelledby="mx_BaseDialog_title" | ||
class="mx_UntrustedDeviceDialog mx_Dialog_fixedWidth" | ||
data-focus-lock-disabled="false" | ||
role="dialog" | ||
> | ||
<div | ||
class="mx_Dialog_header" | ||
> | ||
<h1 | ||
class="mx_Heading_h3 mx_Dialog_title" | ||
id="mx_BaseDialog_title" | ||
> | ||
<div | ||
class="mx_E2EIcon mx_E2EIcon_warning" | ||
style="width: 24px; height: 24px;" | ||
/> | ||
Not Trusted | ||
</h1> | ||
</div> | ||
<div | ||
class="mx_Dialog_content" | ||
id="mx_Dialog_content" | ||
> | ||
<p> | ||
Alice (@alice:example.org) signed in to a new session without verifying it: | ||
</p> | ||
<p> | ||
(device_id) | ||
</p> | ||
<p> | ||
Ask this user to verify their session, or manually verify it below. | ||
</p> | ||
</div> | ||
<div | ||
class="mx_Dialog_buttons" | ||
> | ||
<div | ||
class="mx_AccessibleButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_primary_outline" | ||
role="button" | ||
tabindex="0" | ||
> | ||
Interactively verify by emoji | ||
</div> | ||
<div | ||
class="mx_AccessibleButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_primary" | ||
role="button" | ||
tabindex="0" | ||
> | ||
Done | ||
</div> | ||
</div> | ||
<div | ||
aria-label="Close dialog" | ||
class="mx_AccessibleButton mx_Dialog_cancelButton" | ||
role="button" | ||
tabindex="0" | ||
/> | ||
</div> | ||
<div | ||
data-focus-guard="true" | ||
style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;" | ||
tabindex="0" | ||
/> | ||
</DocumentFragment> | ||
`; | ||
|
||
exports[`<UntrustedDeviceDialog /> should display the dialog for the device of the current user 1`] = ` | ||
<DocumentFragment> | ||
<div | ||
data-focus-guard="true" | ||
style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;" | ||
tabindex="0" | ||
/> | ||
<div | ||
aria-labelledby="mx_BaseDialog_title" | ||
class="mx_UntrustedDeviceDialog mx_Dialog_fixedWidth" | ||
data-focus-lock-disabled="false" | ||
role="dialog" | ||
> | ||
<div | ||
class="mx_Dialog_header" | ||
> | ||
<h1 | ||
class="mx_Heading_h3 mx_Dialog_title" | ||
id="mx_BaseDialog_title" | ||
> | ||
<div | ||
class="mx_E2EIcon mx_E2EIcon_warning" | ||
style="width: 24px; height: 24px;" | ||
/> | ||
Not Trusted | ||
</h1> | ||
</div> | ||
<div | ||
class="mx_Dialog_content" | ||
id="mx_Dialog_content" | ||
> | ||
<p> | ||
You signed in to a new session without verifying it: | ||
</p> | ||
<p> | ||
(device_id) | ||
</p> | ||
<p> | ||
Verify your other session using one of the options below. | ||
</p> | ||
</div> | ||
<div | ||
class="mx_Dialog_buttons" | ||
> | ||
<div | ||
class="mx_AccessibleButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_primary_outline" | ||
role="button" | ||
tabindex="0" | ||
> | ||
Interactively verify by emoji | ||
</div> | ||
<div | ||
class="mx_AccessibleButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_primary" | ||
role="button" | ||
tabindex="0" | ||
> | ||
Done | ||
</div> | ||
</div> | ||
<div | ||
aria-label="Close dialog" | ||
class="mx_AccessibleButton mx_Dialog_cancelButton" | ||
role="button" | ||
tabindex="0" | ||
/> | ||
</div> | ||
<div | ||
data-focus-guard="true" | ||
style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;" | ||
tabindex="0" | ||
/> | ||
</DocumentFragment> | ||
`; |
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.