You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Fix more tests
This commit is contained in:
@@ -27,6 +27,7 @@ import olmlib from '../../../../lib/crypto/olmlib';
|
|||||||
import sdk from '../../../..';
|
import sdk from '../../../..';
|
||||||
|
|
||||||
import {verificationMethods} from '../../../../lib/crypto';
|
import {verificationMethods} from '../../../../lib/crypto';
|
||||||
|
import DeviceInfo from '../../../../lib/crypto/deviceinfo';
|
||||||
|
|
||||||
import SAS from '../../../../lib/crypto/verification/SAS';
|
import SAS from '../../../../lib/crypto/verification/SAS';
|
||||||
|
|
||||||
@@ -393,11 +394,11 @@ describe("SAS verification", function() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
alice.setDeviceVerified = expect.createSpy();
|
alice.client.setDeviceVerified = expect.createSpy();
|
||||||
alice.getDeviceEd25519Key = () => {
|
alice.client.getDeviceEd25519Key = () => {
|
||||||
return "alice+base64+ed25519+key";
|
return "alice+base64+ed25519+key";
|
||||||
};
|
};
|
||||||
alice.getStoredDevice = () => {
|
alice.client.getStoredDevice = () => {
|
||||||
return DeviceInfo.fromStorage(
|
return DeviceInfo.fromStorage(
|
||||||
{
|
{
|
||||||
keys: {
|
keys: {
|
||||||
@@ -407,12 +408,12 @@ describe("SAS verification", function() {
|
|||||||
"Dynabook",
|
"Dynabook",
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
alice.downloadKeys = () => {
|
alice.client.downloadKeys = () => {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
bob.setDeviceVerified = expect.createSpy();
|
bob.client.setDeviceVerified = expect.createSpy();
|
||||||
bob.getStoredDevice = () => {
|
bob.client.getStoredDevice = () => {
|
||||||
return DeviceInfo.fromStorage(
|
return DeviceInfo.fromStorage(
|
||||||
{
|
{
|
||||||
keys: {
|
keys: {
|
||||||
@@ -422,10 +423,10 @@ describe("SAS verification", function() {
|
|||||||
"Osborne2",
|
"Osborne2",
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
bob.getDeviceEd25519Key = () => {
|
bob.client.getDeviceEd25519Key = () => {
|
||||||
return "bob+base64+ed25519+key";
|
return "bob+base64+ed25519+key";
|
||||||
};
|
};
|
||||||
bob.downloadKeys = () => {
|
bob.client.downloadKeys = () => {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -433,13 +434,13 @@ describe("SAS verification", function() {
|
|||||||
bobSasEvent = null;
|
bobSasEvent = null;
|
||||||
|
|
||||||
bobPromise = new Promise((resolve, reject) => {
|
bobPromise = new Promise((resolve, reject) => {
|
||||||
bob.on("event", async (event) => {
|
bob.client.on("event", async (event) => {
|
||||||
const content = event.getContent();
|
const content = event.getContent();
|
||||||
if (event.getType() === "m.room.message"
|
if (event.getType() === "m.room.message"
|
||||||
&& content.msgtype === "m.key.verification.request") {
|
&& content.msgtype === "m.key.verification.request") {
|
||||||
expect(content.methods).toInclude(SAS.NAME);
|
expect(content.methods).toInclude(SAS.NAME);
|
||||||
expect(content.to).toBe(bob.getUserId());
|
expect(content.to).toBe(bob.client.getUserId());
|
||||||
const verifier = bob.acceptVerificationDM(event, SAS.NAME);
|
const verifier = bob.client.acceptVerificationDM(event, SAS.NAME);
|
||||||
verifier.on("show_sas", (e) => {
|
verifier.on("show_sas", (e) => {
|
||||||
if (!e.sas.emoji || !e.sas.decimal) {
|
if (!e.sas.emoji || !e.sas.decimal) {
|
||||||
e.cancel();
|
e.cancel();
|
||||||
@@ -462,8 +463,8 @@ describe("SAS verification", function() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
aliceVerifier = await alice.requestVerificationDM(
|
aliceVerifier = await alice.client.requestVerificationDM(
|
||||||
bob.getUserId(), "!room_id", [verificationMethods.SAS],
|
bob.client.getUserId(), "!room_id", [verificationMethods.SAS],
|
||||||
);
|
);
|
||||||
aliceVerifier.on("show_sas", (e) => {
|
aliceVerifier.on("show_sas", (e) => {
|
||||||
if (!e.sas.emoji || !e.sas.decimal) {
|
if (!e.sas.emoji || !e.sas.decimal) {
|
||||||
@@ -490,10 +491,10 @@ describe("SAS verification", function() {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
// make sure Alice and Bob verified each other
|
// make sure Alice and Bob verified each other
|
||||||
expect(alice.setDeviceVerified)
|
expect(alice.client.setDeviceVerified)
|
||||||
.toHaveBeenCalledWith(bob.getUserId(), bob.deviceId);
|
.toHaveBeenCalledWith(bob.client.getUserId(), bob.client.deviceId);
|
||||||
expect(bob.setDeviceVerified)
|
expect(bob.client.setDeviceVerified)
|
||||||
.toHaveBeenCalledWith(alice.getUserId(), alice.deviceId);
|
.toHaveBeenCalledWith(alice.client.getUserId(), alice.client.deviceId);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -58,9 +58,9 @@ export async function makeTestClients(userInfos, options) {
|
|||||||
room_id: room,
|
room_id: room,
|
||||||
event_id: eventId,
|
event_id: eventId,
|
||||||
});
|
});
|
||||||
for (const client of clients) {
|
for (const tc of clients) {
|
||||||
setTimeout(
|
setTimeout(
|
||||||
() => client.emit("event", event),
|
() => tc.client.emit("event", event),
|
||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1719,9 +1719,11 @@ MatrixBaseApis.prototype.uploadKeysRequest = function(content, opts, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
MatrixBaseApis.prototype.uploadKeySignatures = function(content) {
|
MatrixBaseApis.prototype.uploadKeySignatures = function(content) {
|
||||||
return this._http.authedRequestWithPrefix(
|
return this._http.authedRequest(
|
||||||
undefined, "POST", '/keys/signatures/upload', undefined,
|
undefined, "POST", '/keys/signatures/upload', undefined,
|
||||||
content, httpApi.PREFIX_UNSTABLE,
|
content, {
|
||||||
|
prefix: httpApi.PREFIX_UNSTABLE,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1811,9 +1813,10 @@ MatrixBaseApis.prototype.getKeyChanges = function(oldToken, newToken) {
|
|||||||
|
|
||||||
MatrixBaseApis.prototype.uploadDeviceSigningKeys = function(auth, keys) {
|
MatrixBaseApis.prototype.uploadDeviceSigningKeys = function(auth, keys) {
|
||||||
const data = Object.assign({}, keys, {auth});
|
const data = Object.assign({}, keys, {auth});
|
||||||
return this._http.authedRequestWithPrefix(
|
return this._http.authedRequest(
|
||||||
undefined, "POST", "/keys/device_signing/upload", undefined, data,
|
undefined, "POST", "/keys/device_signing/upload", undefined, data, {
|
||||||
httpApi.PREFIX_UNSTABLE,
|
prefix: httpApi.PREFIX_UNSTABLE,
|
||||||
|
},
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user