Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0704741
renamed: spec/integ/devicelist-integ.spec.js -> spec/integ/devicel…
Sep 16, 2022
8a6087a
fix ts issue in devicelist-integ.spec
Sep 16, 2022
5c87d94
renamed: spec/integ/matrix-client-event-emitter.spec.js -> spec/in…
Sep 16, 2022
da227d8
ts issues in matrix-client-event-emitter integ
Sep 16, 2022
27ff2a0
strict fixes
Sep 16, 2022
88c37c8
renamed: spec/integ/matrix-client-methods.spec.js -> spec/integ/ma…
Sep 16, 2022
e49193b
fix ts issues
Sep 16, 2022
8de9de2
renamed: spec/integ/matrix-client-opts.spec.js -> spec/integ/matri…
Sep 16, 2022
09a6714
Merge branch 'develop' into kerry/ts-jest-integ
Sep 29, 2022
08f1275
ts fixes in matrix-client-methods / matrix-client-opts
Sep 29, 2022
3c30cc5
renamed: spec/integ/matrix-client-room-timeline.spec.js -> spec/in…
Sep 29, 2022
41d403b
most ts fixes in matrix-client-room-timeline
Sep 29, 2022
ee0584c
remove obsoleted prev_events from mockenvents
Sep 29, 2022
669a7e3
make xmlhttprequest ts
Sep 29, 2022
3071582
strict errors in matrix-client-event-timeline spec
Sep 29, 2022
5f1b5c1
strict in devicelist
Sep 29, 2022
4505fa9
strict fixes in matrix-client-crypto.spec
Sep 30, 2022
1be7660
strict fixes in spec/integ/matrix-client-room-timeline
Sep 30, 2022
28c15a8
strict issues in matrix-client-opts.specc
Sep 30, 2022
403c7fb
strict issues in matrix-client-syncing
Sep 30, 2022
7ec3ed2
strict issues in spec/integ/megolm
Sep 30, 2022
b552258
strict fixes in spec/integ/matrix-client-retrying.spec
Sep 30, 2022
317a6a8
strict fixes for spec/integ/sliding-sync
Sep 30, 2022
0ff39d0
eslint fixes
Sep 30, 2022
978cdc7
Merge branch 'develop' into kerry/ts-jest-integ
Sep 30, 2022
b200296
more strict errors sneaking in from develop
Sep 30, 2022
9f1d830
kill al httpbackends
Oct 4, 2022
51925f0
kill matrix-client-methods.spec httpbackend properly
Oct 4, 2022
fcdb04c
Merge branch 'develop' into kerry/ts-jest-integ
Oct 4, 2022
85c5c9b
Merge branch 'develop' into kerry/ts-jest-integ
Oct 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ limitations under the License.
*/

// stub for browser-matrix browserify tests
// @ts-ignore
global.XMLHttpRequest = jest.fn();

afterAll(() => {
// clean up XMLHttpRequest mock
// @ts-ignore
global.XMLHttpRequest = undefined;
});
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ describe("DeviceList management:", function() {
aliceTestClient.httpBackend.when(
'PUT', '/send/',
).respond(200, {
event_id: '$event_id',
event_id: '$event_id',
});

return Promise.all([
Expand Down Expand Up @@ -290,8 +290,9 @@ describe("DeviceList management:", function() {
aliceTestClient.client.cryptoStore.getEndToEndDeviceData(null, (data) => {
const bobStat = data.trackingStatus['@bob:xyz'];

// Alice should be tracking bob's device list
expect(bobStat).toBeGreaterThan(
0, "Alice should be tracking bob's device list",
0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May as well just make this a single line

);
});
});
Expand Down Expand Up @@ -326,8 +327,9 @@ describe("DeviceList management:", function() {
aliceTestClient.client.cryptoStore.getEndToEndDeviceData(null, (data) => {
const bobStat = data.trackingStatus['@bob:xyz'];

// Alice should have marked bob's device list as untracked
expect(bobStat).toEqual(
0, "Alice should have marked bob's device list as untracked",
0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise

);
});
});
Expand Down Expand Up @@ -362,8 +364,9 @@ describe("DeviceList management:", function() {
aliceTestClient.client.cryptoStore.getEndToEndDeviceData(null, (data) => {
const bobStat = data.trackingStatus['@bob:xyz'];

// Alice should have marked bob's device list as untracked
expect(bobStat).toEqual(
0, "Alice should have marked bob's device list as untracked",
0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

);
});
});
Expand All @@ -378,13 +381,15 @@ describe("DeviceList management:", function() {
anotherTestClient.httpBackend.when('GET', '/sync').respond(
200, getSyncResponse([]));
await anotherTestClient.flushSync();
await anotherTestClient.client.crypto.deviceList.saveIfDirty();
await anotherTestClient.client?.crypto?.deviceList?.saveIfDirty();

// @ts-ignore accessing private property
anotherTestClient.client.cryptoStore.getEndToEndDeviceData(null, (data) => {
const bobStat = data.trackingStatus['@bob:xyz'];
const bobStat = data!.trackingStatus['@bob:xyz'];

// Alice should have marked bob's device list as untracked
expect(bobStat).toEqual(
0, "Alice should have marked bob's device list as untracked",
0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

);
});
} finally {
Expand Down
34 changes: 17 additions & 17 deletions spec/integ/matrix-client-crypto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ import '../olm-loader';
import { logger } from '../../src/logger';
import * as testUtils from "../test-utils/test-utils";
import { TestClient } from "../TestClient";
import { CRYPTO_ENABLED } from "../../src/client";
import { CRYPTO_ENABLED, IUploadKeysRequest } from "../../src/client";
import { ClientEvent, IContent, ISendEventResponse, MatrixClient, MatrixEvent } from "../../src/matrix";
import { DeviceInfo } from '../../src/crypto/deviceinfo';

let aliTestClient: TestClient;
const roomId = "!room:localhost";
Expand Down Expand Up @@ -71,12 +72,12 @@ function expectQueryKeys(querier: TestClient, uploader: TestClient): Promise<num
expect(uploader.deviceKeys).toBeTruthy();

const uploaderKeys = {};
uploaderKeys[uploader.deviceId] = uploader.deviceKeys;
uploaderKeys[uploader.deviceId!] = uploader.deviceKeys;
querier.httpBackend.when("POST", "/keys/query")
.respond(200, function(_path, content) {
expect(content.device_keys[uploader.userId]).toEqual([]);
.respond(200, function(_path, content: IUploadKeysRequest) {
expect(content.device_keys![uploader.userId!]).toEqual([]);
const result = {};
result[uploader.userId] = uploaderKeys;
result[uploader.userId!] = uploaderKeys;
return { device_keys: result };
});
return querier.httpBackend.flush("/keys/query", 1);
Expand All @@ -93,10 +94,10 @@ async function expectAliClaimKeys(): Promise<void> {
const keys = await bobTestClient.awaitOneTimeKeyUpload();
aliTestClient.httpBackend.when(
"POST", "/keys/claim",
).respond(200, function(_path, content) {
const claimType = content.one_time_keys[bobUserId][bobDeviceId];
).respond(200, function(_path, content: IUploadKeysRequest) {
const claimType = content.one_time_keys![bobUserId][bobDeviceId];
expect(claimType).toEqual("signed_curve25519");
let keyId = null;
let keyId = '';
for (keyId in keys) {
if (bobTestClient.oneTimeKeys.hasOwnProperty(keyId)) {
if (keyId.indexOf(claimType + ":") === 0) {
Expand Down Expand Up @@ -135,10 +136,10 @@ async function aliDownloadsKeys(): Promise<void> {
await aliTestClient.client.crypto!.deviceList.saveIfDirty();
// @ts-ignore - protected
aliTestClient.client.cryptoStore.getEndToEndDeviceData(null, (data) => {
const devices = data.devices[bobUserId];
const devices = data!.devices[bobUserId]!;
expect(devices[bobDeviceId].keys).toEqual(bobTestClient.deviceKeys.keys);
expect(devices[bobDeviceId].verified).
toBe(0); // DeviceVerification.UNVERIFIED
toBe(DeviceInfo.DeviceVerification.UNVERIFIED);
});
}

Expand Down Expand Up @@ -237,7 +238,7 @@ function sendMessage(client: MatrixClient): Promise<ISendEventResponse> {

async function expectSendMessageRequest(httpBackend: TestClient["httpBackend"]): Promise<IContent> {
const path = "/send/m.room.encrypted/";
const prom = new Promise((resolve) => {
const prom = new Promise<IContent>((resolve) => {
httpBackend.when("PUT", path).respond(200, function(_path, content) {
resolve(content);
return {
Expand All @@ -252,14 +253,14 @@ async function expectSendMessageRequest(httpBackend: TestClient["httpBackend"]):
}

function aliRecvMessage(): Promise<void> {
const message = bobMessages.shift();
const message = bobMessages.shift()!;
return recvMessage(
aliTestClient.httpBackend, aliTestClient.client, bobUserId, message,
);
}

function bobRecvMessage(): Promise<void> {
const message = aliMessages.shift();
const message = aliMessages.shift()!;
return recvMessage(
bobTestClient.httpBackend, bobTestClient.client, aliUserId, message,
);
Expand Down Expand Up @@ -509,7 +510,7 @@ describe("MatrixClient crypto", () => {
await firstSync(aliTestClient);
await aliEnablesEncryption();
await aliSendsFirstMessage();
const message = aliMessages.shift();
const message = aliMessages.shift()!;
const syncData = {
next_batch: "x",
rooms: {
Expand Down Expand Up @@ -664,11 +665,10 @@ describe("MatrixClient crypto", () => {
]);
logger.log(aliTestClient + ': started');
httpBackend.when("POST", "/keys/upload")
.respond(200, (_path, content) => {
.respond(200, (_path, content: IUploadKeysRequest) => {
expect(content.one_time_keys).toBeTruthy();
expect(content.one_time_keys).not.toEqual({});
expect(Object.keys(content.one_time_keys).length).toBeGreaterThanOrEqual(1);
logger.log('received %i one-time keys', Object.keys(content.one_time_keys).length);
expect(Object.keys(content.one_time_keys!).length).toBeGreaterThanOrEqual(1);
// cancel futher calls by telling the client
// we have more than we need
return {
Expand Down
Loading