Support multi-screenshot calibration and cached shop context
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { forwardMarketBatch } from "../vite.config.js";
|
||||
import { forwardMarketBatch, rejectNonLocalRequest } from "../vite.config.js";
|
||||
|
||||
test("keeps the import token in the local server-side forwarder", async () => {
|
||||
let forwarded;
|
||||
@@ -19,3 +19,12 @@ test("keeps the import token in the local server-side forwarder", async () => {
|
||||
assert.equal(forwarded.init.body, '{"batchId":"one"}');
|
||||
assert.equal((await forwardMarketBatch("{}", {})).status, 503);
|
||||
});
|
||||
|
||||
test("rejects cross-site and non-JSON calls before using the import token", () => {
|
||||
assert.equal(
|
||||
rejectNonLocalRequest({ headers: { host: "127.0.0.1:5173", origin: "http://127.0.0.1:5173", "content-type": "application/json" } }),
|
||||
null,
|
||||
);
|
||||
assert.equal(rejectNonLocalRequest({ headers: { host: "127.0.0.1:5173", origin: "https://evil.example", "content-type": "application/json" } }), 403);
|
||||
assert.equal(rejectNonLocalRequest({ headers: { host: "127.0.0.1:5173", origin: "http://127.0.0.1:5173", "content-type": "text/plain" } }), 415);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user