mirror of
https://github.com/jparkerweb/plan2code.git
synced 2026-12-05 08:15:41 -08:00
Make every URL the console page uses page-relative, guarded by a source test
AI Assisted
This commit is contained in:
1 parent
4ced32be5c
commit
1d007737b1
47 files changed
+401
-202
No files matched your search
@@ -685,8 +685,8 @@ test("the favicon is served as an SVG with a PNG fallback and the page points at
|
||||
assert.deepEqual([...bytes.slice(0, 4)], [0x89, 0x50, 0x4e, 0x47]);
|
||||
|
||||
const html = await (await fetch(baseUrl + "/", { headers: { cookie: cookieFor(baseUrl, token) } })).text();
|
||||
assert.ok(html.includes('href="/favicon.svg"'));
|
||||
assert.ok(html.includes('href="/favicon.png"'));
|
||||
assert.ok(html.includes('href="favicon.svg"'));
|
||||
assert.ok(html.includes('href="favicon.png"'));
|
||||
assert.doesNotMatch(html, /rel="icon"[^>]*href="data:/);
|
||||
});
|
||||
|
||||
@@ -1006,7 +1006,7 @@ test("an upload is stored under a server-chosen name inside the session's upload
|
||||
const uploads = path.join(fs.realpathSync.native(session), "uploads");
|
||||
assert.equal(path.dirname(file).toLowerCase(), uploads.toLowerCase());
|
||||
assert.equal(path.basename(file), id + ".jpg");
|
||||
assert.equal(url, `/uploads/${id}.jpg`);
|
||||
assert.equal(url, `uploads/${id}.jpg`);
|
||||
assert.equal(name, "../../evil name.png", "the name comes back as a label");
|
||||
assert.equal(res.json.kind, "image");
|
||||
assert.equal(res.json.size, JPEG.length);
|
||||
@@ -1035,7 +1035,8 @@ test("an upload that is not a JPEG, or is too large, is refused", async () => {
|
||||
});
|
||||
|
||||
test("an upload is served back by its own url, and nothing else under /uploads/ is", async () => {
|
||||
const { url } = (await uploadJpeg()).json;
|
||||
// Page-relative: the page at / asks for it here.
|
||||
const url = `/${(await uploadJpeg()).json.url}`;
|
||||
const res = await raw("GET", url);
|
||||
assert.equal(res.status, 200);
|
||||
assert.equal(res.headers["content-type"], "image/jpeg");
|
||||
@@ -1048,7 +1049,8 @@ test("an upload is served back by its own url, and nothing else under /uploads/
|
||||
});
|
||||
|
||||
test("deleting an upload removes its file, once, and only from this origin", async () => {
|
||||
const { url, path: file } = (await uploadJpeg()).json;
|
||||
const { url: link, path: file } = (await uploadJpeg()).json;
|
||||
const url = `/${link}`;
|
||||
assert.equal((await raw("DELETE", url, undefined, { origin: "http://evil.example.com" })).status, 403);
|
||||
assert.ok(fs.existsSync(file));
|
||||
assert.equal((await raw("DELETE", url)).status, 204);
|
||||
|
||||
Reference in new issue
Block a user