You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-07-31 15:24:23 +03:00
ElementR: Process all verification events, not just requests (#3650)
* Process all verification event * Add test for `isVerificationEvent` * Review changes * Remove null comparison and add doc to remote echo * review changes
This commit is contained in:
@ -17,8 +17,9 @@ limitations under the License.
|
||||
import * as RustSdkCryptoJs from "@matrix-org/matrix-sdk-crypto-wasm";
|
||||
import { Mocked } from "jest-mock";
|
||||
|
||||
import { RustVerificationRequest } from "../../../src/rust-crypto/verification";
|
||||
import { isVerificationEvent, RustVerificationRequest } from "../../../src/rust-crypto/verification";
|
||||
import { OutgoingRequestProcessor } from "../../../src/rust-crypto/OutgoingRequestProcessor";
|
||||
import { EventType, MatrixEvent, MsgType } from "../../../src";
|
||||
|
||||
describe("VerificationRequest", () => {
|
||||
describe("pending", () => {
|
||||
@ -80,6 +81,40 @@ describe("VerificationRequest", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("isVerificationEvent", () => {
|
||||
it.each([
|
||||
[EventType.KeyVerificationCancel],
|
||||
[EventType.KeyVerificationDone],
|
||||
[EventType.KeyVerificationMac],
|
||||
[EventType.KeyVerificationStart],
|
||||
[EventType.KeyVerificationKey],
|
||||
[EventType.KeyVerificationReady],
|
||||
[EventType.KeyVerificationAccept],
|
||||
])("should return true with %s event", (eventType) => {
|
||||
const event = new MatrixEvent({
|
||||
type: eventType,
|
||||
});
|
||||
expect(isVerificationEvent(event)).toBe(true);
|
||||
});
|
||||
|
||||
it("should return true with EventType.RoomMessage and MsgType.KeyVerificationRequest", () => {
|
||||
const event = new MatrixEvent({
|
||||
type: EventType.RoomMessage,
|
||||
content: {
|
||||
msgtype: MsgType.KeyVerificationRequest,
|
||||
},
|
||||
});
|
||||
expect(isVerificationEvent(event)).toBe(true);
|
||||
});
|
||||
|
||||
it("should return false with a non verification event", () => {
|
||||
const event = new MatrixEvent({
|
||||
type: EventType.RoomName,
|
||||
});
|
||||
expect(isVerificationEvent(event)).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
/** build a RustVerificationRequest with default parameters */
|
||||
function makeTestRequest(
|
||||
inner?: RustSdkCryptoJs.VerificationRequest,
|
||||
|
Reference in New Issue
Block a user