fix(sites): integrate shared download access and register synced adapters
This commit is contained in:
1 parent
6dab134617
commit
36f3ece5b5
20 files changed
+175
-38
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { expect, it, vi } from "vitest";
|
||||
import { SourcesRuntime } from "../src/modules/sources-identity/runtime.ts";
|
||||
|
||||
it("签名下载的 credentials omit 不复用账号或浏览器Cookie", async () => {
|
||||
let sent = new Headers();
|
||||
const rt = new SourcesRuntime({} as never, {
|
||||
fetch: async (_input, init) => {
|
||||
sent = new Headers(init?.headers);
|
||||
return new Response("subtitle bytes");
|
||||
},
|
||||
});
|
||||
const browser = vi.spyOn(rt.cloudflare, "handle");
|
||||
const fetch = rt.siteFetch({ id: "original-site", proxy: false }, undefined, "Site User Agent");
|
||||
const headers = { cookie: "account-cookie", authorization: "account-token" };
|
||||
const url = "https://signed-cdn.example/file?credential=ephemeral";
|
||||
const response = await fetch(url, { headers, credentials: "omit" });
|
||||
expect(await response.text()).toBe("subtitle bytes");
|
||||
expect(sent.has("cookie")).toBe(false);
|
||||
expect(sent.has("authorization")).toBe(false);
|
||||
expect(sent.get("user-agent")).toBe("Site User Agent");
|
||||
expect(browser).not.toHaveBeenCalled();
|
||||
});
|
||||
Reference in new issue
Block a user