refactor(gateway): streamline control-ui secure file serving

This commit is contained in:
Peter Steinberger
2026-02-21 23:36:47 +01:00
parent 0608587bc3
commit 4ef4aa3c10
2 changed files with 81 additions and 16 deletions

View File

@@ -180,6 +180,29 @@ describe("handleControlUiHttpRequest", () => {
});
});
it("serves HEAD for in-root assets without writing a body", async () => {
await withControlUiRoot({
fn: async (tmp) => {
const assetsDir = path.join(tmp, "assets");
await fs.mkdir(assetsDir, { recursive: true });
await fs.writeFile(path.join(assetsDir, "actual.txt"), "inside-ok\n");
const { res, end } = makeMockHttpResponse();
const handled = handleControlUiHttpRequest(
{ url: "/assets/actual.txt", method: "HEAD" } as IncomingMessage,
res,
{
root: { kind: "resolved", path: tmp },
},
);
expect(handled).toBe(true);
expect(res.statusCode).toBe(200);
expect(end.mock.calls[0]?.length ?? -1).toBe(0);
},
});
});
it("rejects symlinked SPA fallback index.html outside control-ui root", async () => {
await withControlUiRoot({
fn: async (tmp) => {