refactor: give Inspector its own capability directory (#869)

This commit is contained in:
ysopwnable
2026-10-07 13:53:25 +08:00
committed by GitHub
parent e0fd8207a1
commit 021ba690b0
29 changed files with 73 additions and 41 deletions
@@ -0,0 +1,34 @@
import { describe, expect, it } from "vitest";
import {
authorizeRuntimeLocation,
inspectorExclusionKey,
} from "./JavaScriptRuntimeScope.js";
describe("runtime location authorization", () => {
it("reports canonical exclusion reasons per denial case", async () => {
expect(await authorizeRuntimeLocation("not a url")).toEqual({
allowed: false,
reason: "unsupported_url",
});
expect(await authorizeRuntimeLocation("ftp://example.test/app.js")).toEqual(
{
allowed: false,
reason: "unsupported_url",
},
);
expect(
await authorizeRuntimeLocation("file:///outside-approved-scope.js"),
).toEqual({ allowed: false, reason: "not_approved" });
});
it("collapses every canonical denial onto the fixed wire bucket", () => {
expect(inspectorExclusionKey("unsupported_url")).toBe(
"unsupported_location",
);
expect(inspectorExclusionKey("not_approved")).toBe("unsupported_location");
expect(inspectorExclusionKey("disallowed_origin")).toBe(
"unsupported_location",
);
});
});