1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-07 23:02:56 +03:00

Do not rotate MatrixRTC media encryption key when a new member joins a session (#4472)

* Do not rotate MatrixRTC media encryption key when a new member joins a call

This change reverts https://github.com/matrix-org/matrix-js-sdk/pull/4422.

Instead, the rotation when a new member joins will be reintroduced as part of supporting to-device based MatrixRTC encryption key distribution.

* Improve function name
This commit is contained in:
Hugh Nimmo-Smith
2024-10-25 14:32:44 +01:00
committed by GitHub
parent 3cc3bd0728
commit 0a29063bc9
2 changed files with 15 additions and 20 deletions

View File

@@ -773,7 +773,7 @@ describe("MatrixRTCSession", () => {
expect(client.cancelPendingEvent).toHaveBeenCalledWith(eventSentinel);
});
it("rotates key if a new member joins", async () => {
it("Re-sends key if a new member joins", async () => {
jest.useFakeTimers();
try {
const mockRoom = makeMockRoom([membershipTemplate]);
@@ -784,9 +784,7 @@ describe("MatrixRTCSession", () => {
});
sess.joinRoomSession([mockFocus], mockFocus, { manageMediaKeys: true });
const firstKeysPayload = await keysSentPromise1;
expect(firstKeysPayload.keys).toHaveLength(1);
expect(firstKeysPayload.keys[0].index).toEqual(0);
await keysSentPromise1;
expect(sess!.statistics.counters.roomEventEncryptionKeysSent).toEqual(1);
sendEventMock.mockClear();
@@ -808,14 +806,9 @@ describe("MatrixRTCSession", () => {
.mockReturnValue(makeMockRoomState([membershipTemplate, member2], mockRoom.roomId));
sess.onMembershipUpdate();
jest.advanceTimersByTime(10000);
const secondKeysPayload = await keysSentPromise2;
await keysSentPromise2;
expect(sendEventMock).toHaveBeenCalled();
expect(secondKeysPayload.keys).toHaveLength(1);
expect(secondKeysPayload.keys[0].index).toEqual(1);
expect(secondKeysPayload.keys[0].key).not.toEqual(firstKeysPayload.keys[0].key);
expect(sess!.statistics.counters.roomEventEncryptionKeysSent).toEqual(2);
} finally {
jest.useRealTimers();
@@ -1103,8 +1096,8 @@ describe("MatrixRTCSession", () => {
}
jest.useFakeTimers();
try {
// start with a single member
const mockRoom = makeMockRoom(members.slice(0, 1));
// start with all members
const mockRoom = makeMockRoom(members);
for (let i = 0; i < membersToTest; i++) {
const keysSentPromise = new Promise<EncryptionKeysEventContent>((resolve) => {
@@ -1116,10 +1109,12 @@ describe("MatrixRTCSession", () => {
sess = MatrixRTCSession.roomSessionForRoom(client, mockRoom);
sess.joinRoomSession([mockFocus], mockFocus, { manageMediaKeys: true });
} else {
// otherwise update the state
// otherwise update the state reducing the membership each time in order to trigger key rotation
mockRoom.getLiveTimeline().getState = jest
.fn()
.mockReturnValue(makeMockRoomState(members.slice(0, i + 1), mockRoom.roomId));
.mockReturnValue(
makeMockRoomState(members.slice(0, membersToTest - i), mockRoom.roomId),
);
}
sess!.onMembershipUpdate();