Skip to content

Commit 8dcf73c

Browse files
committed
Remove tests using MatrixClient.initLegacyCrypto
1 parent 6eda286 commit 8dcf73c

16 files changed

+7
-10357
lines changed

spec/integ/crypto/crypto.spec.ts

-3,573
This file was deleted.

spec/integ/crypto/olm-encryption-spec.ts

-693
This file was deleted.

spec/integ/devicelist-integ.spec.ts

-406
This file was deleted.

spec/integ/matrix-client-methods.spec.ts

+1-129
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import HttpBackend from "matrix-mock-request";
1717
import { Mocked } from "jest-mock";
1818

1919
import * as utils from "../test-utils/test-utils";
20-
import { CRYPTO_ENABLED, IStoredClientOpts, MatrixClient } from "../../src/client";
20+
import { IStoredClientOpts, MatrixClient } from "../../src/client";
2121
import { MatrixEvent } from "../../src/models/event";
2222
import {
2323
Filter,
@@ -644,126 +644,6 @@ describe("MatrixClient", function () {
644644
});
645645
});
646646

647-
describe("downloadKeys", function () {
648-
if (!CRYPTO_ENABLED) {
649-
return;
650-
}
651-
652-
beforeEach(function () {
653-
// running initLegacyCrypto should trigger a key upload
654-
httpBackend.when("POST", "/keys/upload").respond(200, {});
655-
return Promise.all([client.initLegacyCrypto(), httpBackend.flush("/keys/upload", 1)]);
656-
});
657-
658-
afterEach(() => {
659-
client.stopClient();
660-
});
661-
662-
it("should do an HTTP request and then store the keys", function () {
663-
const ed25519key = "7wG2lzAqbjcyEkOP7O4gU7ItYcn+chKzh5sT/5r2l78";
664-
// ed25519key = client.getDeviceEd25519Key();
665-
const borisKeys = {
666-
dev1: {
667-
algorithms: ["1"],
668-
device_id: "dev1",
669-
keys: { "ed25519:dev1": ed25519key },
670-
signatures: {
671-
boris: {
672-
"ed25519:dev1":
673-
"RAhmbNDq1efK3hCpBzZDsKoGSsrHUxb25NW5/WbEV9R" +
674-
"JVwLdP032mg5QsKt/pBDUGtggBcnk43n3nBWlA88WAw",
675-
},
676-
},
677-
unsigned: { abc: "def" },
678-
user_id: "boris",
679-
},
680-
};
681-
const chazKeys = {
682-
dev2: {
683-
algorithms: ["2"],
684-
device_id: "dev2",
685-
keys: { "ed25519:dev2": ed25519key },
686-
signatures: {
687-
chaz: {
688-
"ed25519:dev2":
689-
"FwslH/Q7EYSb7swDJbNB5PSzcbEO1xRRBF1riuijqvL" +
690-
"EkrK9/XVN8jl4h7thGuRITQ01siBQnNmMK9t45QfcCQ",
691-
},
692-
},
693-
unsigned: { ghi: "def" },
694-
user_id: "chaz",
695-
},
696-
};
697-
698-
/*
699-
function sign(o) {
700-
var anotherjson = require('another-json');
701-
var b = JSON.parse(JSON.stringify(o));
702-
delete(b.signatures);
703-
delete(b.unsigned);
704-
return client.crypto.olmDevice.sign(anotherjson.stringify(b));
705-
};
706-
707-
logger.log("Ed25519: " + ed25519key);
708-
logger.log("boris:", sign(borisKeys.dev1));
709-
logger.log("chaz:", sign(chazKeys.dev2));
710-
*/
711-
712-
httpBackend
713-
.when("POST", "/keys/query")
714-
.check(function (req) {
715-
expect(req.data).toEqual({
716-
device_keys: {
717-
boris: [],
718-
chaz: [],
719-
},
720-
});
721-
})
722-
.respond(200, {
723-
device_keys: {
724-
boris: borisKeys,
725-
chaz: chazKeys,
726-
},
727-
});
728-
729-
const prom = client.downloadKeys(["boris", "chaz"]).then(function (res) {
730-
assertObjectContains(res.get("boris")!.get("dev1")!, {
731-
verified: 0, // DeviceVerification.UNVERIFIED
732-
keys: { "ed25519:dev1": ed25519key },
733-
algorithms: ["1"],
734-
unsigned: { abc: "def" },
735-
});
736-
737-
assertObjectContains(res.get("chaz")!.get("dev2")!, {
738-
verified: 0, // DeviceVerification.UNVERIFIED
739-
keys: { "ed25519:dev2": ed25519key },
740-
algorithms: ["2"],
741-
unsigned: { ghi: "def" },
742-
});
743-
});
744-
745-
httpBackend.flush("");
746-
return prom;
747-
});
748-
});
749-
750-
describe("deleteDevice", function () {
751-
const auth = { identifier: 1 };
752-
it("should pass through an auth dict", function () {
753-
httpBackend
754-
.when("DELETE", "/_matrix/client/v3/devices/my_device")
755-
.check(function (req) {
756-
expect(req.data).toEqual({ auth: auth });
757-
})
758-
.respond(200);
759-
760-
const prom = client.deleteDevice("my_device", auth);
761-
762-
httpBackend.flush("");
763-
return prom;
764-
});
765-
});
766-
767647
describe("partitionThreadedEvents", function () {
768648
let room: Room;
769649
beforeEach(() => {
@@ -2197,11 +2077,3 @@ const buildEventCreate = () =>
21972077
type: "m.room.create",
21982078
unsigned: { age: 80126105 },
21992079
});
2200-
2201-
function assertObjectContains(obj: Record<string, any>, expected: any): void {
2202-
for (const k in expected) {
2203-
if (expected.hasOwnProperty(k)) {
2204-
expect(obj[k]).toEqual(expected[k]);
2205-
}
2206-
}
2207-
}

0 commit comments

Comments
 (0)