Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
test(media-server): extend streaming manifest materialization tests
Richie McIlroy0dfce2cb37e1
diff --git a/apps/media-server/src/__tests__/lib/media-video.integration.test.ts b/apps/media-server/src/__tests__/lib/media-video.integration.test.tsindex 0d565f37b..c5a3a82d5 100644--- a/apps/media-server/src/__tests__/lib/media-video.integration.test.ts+++ b/apps/media-server/src/__tests__/lib/media-video.integration.test.ts@@ -239,7 +239,7 @@ describe("processVideo integration tests", () => {globalThis.fetch = (async () =>new Response(- '<MPD><Period><AdaptationSet><Representation><SegmentTemplate initialization="init.mp4" media="chunk-$Number$.m4s"/></Representation></AdaptationSet></Period></MPD>',+ '<MPD><Period><AdaptationSet><Representation><SegmentTemplate initialization="init.mp4" media="chunk-$Number$.m4s"/><Initialization sourceURL="escaped.mp4?part=1&token=x"/></Representation></AdaptationSet></Period></MPD>',{ status: 200, statusText: "OK" },)) as unknown as typeof fetch;@@ -256,6 +256,8 @@ describe("processVideo integration tests", () => {expect(content).toContain("chunk-$Number$.m4s?Policy=a&Signature=b&Key-Pair-Id=c",);+ expect(content).toContain("escaped.mp4?part=1&token=x");+ expect(content).not.toContain("&amp;");} finally {globalThis.fetch = originalFetch;rmSync(manifestDir, { recursive: true, force: true });@@ -340,6 +342,7 @@ describe("processVideo integration tests", () => {<Period><AdaptationSet mimeType="video/mp4"><Representation id="v1" bandwidth="800000">+ <BaseURL>media/</BaseURL><SegmentList><Initialization sourceURL="init.mp4"/><SegmentURL media="seg-1.m4s"/>@@ -361,6 +364,9 @@ describe("processVideo integration tests", () => {expect(path.endsWith(".mpd")).toBe(true);expect(requests).toBe(2);+ expect(content).toContain(+ "https://cdn.example/video/media/?Policy=a&Signature=b",+ );expect(content).toContain("seg-1.m4s?Policy=a&Signature=b");} finally {globalThis.fetch = originalFetch;@@ -392,6 +398,40 @@ describe("processVideo integration tests", () => {}});+ test("rejects local file references in remote DASH manifests", async () => {+ const originalFetch = globalThis.fetch;+ const manifestDir = mkdtempSync(join(tmpdir(), "cap-mpd-local-file-"));++ globalThis.fetch = (async () =>+ new Response(+ `<MPD>+ <Period>+ <AdaptationSet mimeType="video/mp4">+ <Representation id="v1" bandwidth="800000">+ <BaseURL>file:///etc/</BaseURL>+ <SegmentList>+ <Initialization sourceURL="passwd"/>+ </SegmentList>+ </Representation>+ </AdaptationSet>+ </Period>+ </MPD>`,+ { status: 200, statusText: "OK" },+ )) as unknown as typeof fetch;++ try {+ await expect(+ materializeStreamingInput(+ "https://cdn.example/video/manifest.mpd",+ manifestDir,+ ),+ ).rejects.toThrow("Unsupported media resource protocol: file:");+ } finally {+ globalThis.fetch = originalFetch;+ rmSync(manifestDir, { recursive: true, force: true });+ }+ });+test("materializes signed HLS playlists with inherited query strings", async () => {const originalFetch = globalThis.fetch;const manifestDir = mkdtempSync(join(tmpdir(), "cap-hls-"));@@ -469,6 +509,28 @@ describe("processVideo integration tests", () => {}});+ test("rejects local file references in remote HLS playlists", async () => {+ const originalFetch = globalThis.fetch;+ const manifestDir = mkdtempSync(join(tmpdir(), "cap-hls-local-file-"));++ globalThis.fetch = (async () =>+ new Response(+ ["#EXTM3U", "#EXTINF:1.0,", "file:///etc/passwd"].join("\n"),+ )) as unknown as typeof fetch;++ try {+ await expect(+ materializeStreamingInput(+ "https://cdn.example/video/manifest.m3u8",+ manifestDir,+ ),+ ).rejects.toThrow("Unsupported media resource protocol: file:");+ } finally {+ globalThis.fetch = originalFetch;+ rmSync(manifestDir, { recursive: true, force: true });+ }+ });+test("waits for async cleanup before rejecting timed out work", async () => {let resolveCleanup: (() => void) | undefined;let settled = false;