mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-02 19:49:23 +00:00
Cleanup
This commit is contained in:
@@ -16,20 +16,7 @@ import {
|
|||||||
} from "vitest";
|
} from "vitest";
|
||||||
import fetchMock from "fetch-mock";
|
import fetchMock from "fetch-mock";
|
||||||
import { getSFUConfigWithOpenID, OpenIDClientParts } from "./openIDSFU";
|
import { getSFUConfigWithOpenID, OpenIDClientParts } from "./openIDSFU";
|
||||||
|
import { testJWTToken } from "../utils/test-fixtures";
|
||||||
const jwtToken = [
|
|
||||||
{}, // header
|
|
||||||
{
|
|
||||||
// payload
|
|
||||||
sub: "@me:example.org:ABCDEF",
|
|
||||||
video: {
|
|
||||||
room: "!example_room_id",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{}, // signature
|
|
||||||
]
|
|
||||||
.map((d) => global.btoa(JSON.stringify(d)))
|
|
||||||
.join(".");
|
|
||||||
|
|
||||||
const sfuUrl = "https://sfu.example.org";
|
const sfuUrl = "https://sfu.example.org";
|
||||||
|
|
||||||
@@ -49,7 +36,7 @@ describe("getSFUConfigWithOpenID", () => {
|
|||||||
fetchMock.post("https://sfu.example.org/sfu/get", () => {
|
fetchMock.post("https://sfu.example.org/sfu/get", () => {
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 200,
|
||||||
body: { url: sfuUrl, jwt: jwtToken },
|
body: { url: sfuUrl, jwt: testJWTToken },
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
const config = await getSFUConfigWithOpenID(
|
const config = await getSFUConfigWithOpenID(
|
||||||
@@ -58,7 +45,7 @@ describe("getSFUConfigWithOpenID", () => {
|
|||||||
"!example_room_id",
|
"!example_room_id",
|
||||||
);
|
);
|
||||||
expect(config).toEqual({
|
expect(config).toEqual({
|
||||||
jwt: jwtToken,
|
jwt: testJWTToken,
|
||||||
url: sfuUrl,
|
url: sfuUrl,
|
||||||
livekitIdentity: "@me:example.org:ABCDEF",
|
livekitIdentity: "@me:example.org:ABCDEF",
|
||||||
livekitAlias: "!example_room_id",
|
livekitAlias: "!example_room_id",
|
||||||
@@ -105,7 +92,7 @@ describe("getSFUConfigWithOpenID", () => {
|
|||||||
fetchMock.post("https://sfu.example.org/sfu/get", () => {
|
fetchMock.post("https://sfu.example.org/sfu/get", () => {
|
||||||
return {
|
return {
|
||||||
status: 200,
|
status: 200,
|
||||||
body: { url: sfuUrl, jwt: jwtToken },
|
body: { url: sfuUrl, jwt: testJWTToken },
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
const config = await getSFUConfigWithOpenID(
|
const config = await getSFUConfigWithOpenID(
|
||||||
@@ -114,7 +101,7 @@ describe("getSFUConfigWithOpenID", () => {
|
|||||||
"!example_room_id",
|
"!example_room_id",
|
||||||
);
|
);
|
||||||
expect(config).toEqual({
|
expect(config).toEqual({
|
||||||
jwt: jwtToken,
|
jwt: testJWTToken,
|
||||||
url: sfuUrl,
|
url: sfuUrl,
|
||||||
livekitIdentity: "@me:example.org:ABCDEF",
|
livekitIdentity: "@me:example.org:ABCDEF",
|
||||||
livekitAlias: "!example_room_id",
|
livekitAlias: "!example_room_id",
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import {
|
|||||||
ElementCallError,
|
ElementCallError,
|
||||||
FailToGetOpenIdToken,
|
FailToGetOpenIdToken,
|
||||||
} from "../../../utils/errors.ts";
|
} from "../../../utils/errors.ts";
|
||||||
|
import { testJWTToken } from "../../../utils/test-fixtures.ts";
|
||||||
|
|
||||||
let testScope: ObservableScope;
|
let testScope: ObservableScope;
|
||||||
|
|
||||||
@@ -121,7 +122,7 @@ function setupRemoteConnection(): Connection {
|
|||||||
status: 200,
|
status: 200,
|
||||||
body: {
|
body: {
|
||||||
url: "wss://matrix-rtc.m.localhost/livekit/sfu",
|
url: "wss://matrix-rtc.m.localhost/livekit/sfu",
|
||||||
jwt: "ATOKEN",
|
jwt: testJWTToken,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -258,7 +259,7 @@ describe("Start connection states", () => {
|
|||||||
capturedState.cause instanceof Error
|
capturedState.cause instanceof Error
|
||||||
) {
|
) {
|
||||||
expect(capturedState.cause.message).toContain(
|
expect(capturedState.cause.message).toContain(
|
||||||
"SFU Config fetch failed with exception Error",
|
"SFU Config fetch failed with exception",
|
||||||
);
|
);
|
||||||
expect(connection.transport.livekit_alias).toEqual(
|
expect(connection.transport.livekit_alias).toEqual(
|
||||||
livekitFocus.livekit_alias,
|
livekitFocus.livekit_alias,
|
||||||
@@ -294,7 +295,7 @@ describe("Start connection states", () => {
|
|||||||
status: 200,
|
status: 200,
|
||||||
body: {
|
body: {
|
||||||
url: "wss://matrix-rtc.m.localhost/livekit/sfu",
|
url: "wss://matrix-rtc.m.localhost/livekit/sfu",
|
||||||
jwt: "ATOKEN",
|
jwt: testJWTToken,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -59,3 +59,17 @@ export const daveRTLRtcMember = mockRtcMembership("@dave2:example.org", "DDDD");
|
|||||||
export const daveRTL = mockMatrixRoomMember(daveRTLRtcMember, {
|
export const daveRTL = mockMatrixRoomMember(daveRTLRtcMember, {
|
||||||
rawDisplayName: "\u202eevaD",
|
rawDisplayName: "\u202eevaD",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const testJWTToken = [
|
||||||
|
{}, // header
|
||||||
|
{
|
||||||
|
// payload
|
||||||
|
sub: "@me:example.org:ABCDEF",
|
||||||
|
video: {
|
||||||
|
room: "!example_room_id",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{}, // signature
|
||||||
|
]
|
||||||
|
.map((d) => global.btoa(JSON.stringify(d)))
|
||||||
|
.join(".");
|
||||||
|
|||||||
Reference in New Issue
Block a user