C4 fix: parity fixtures carry a recordKey with every Uri.EscapeDataString special character
A fourth fixture (escape) has a chunk recordKey of k!'()* <e-acute>%41+~. The provider's honest mount answers that one key as the canonical key after logging the raw URL, so both consumers fetch the bytes and the log holds what each actually sent. The orchestrator asserts the C# and TS URLs are identical and equal the RFC 3986 escaping. Deleting the reader's !'() * escape now fails test:interop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
424913bfb7
commit
11218b8889
4 changed files with 29 additions and 7 deletions
|
|
@ -1,13 +1,14 @@
|
|||
// The TypeScript content provider in its own process, for content-https.test.ts. Argv: <store dir> <corrupt store dir> <key pem> <cert pem>.
|
||||
// The TypeScript content provider in its own process, for content-https.test.ts. Argv: <store dir> <corrupt store dir> <key pem> <cert pem> <escape record key>.
|
||||
// Protocol, stdout JSON lines only: ready, one line per request ({phase, mount, url}), one per server fault ({phase, mount, fault}).
|
||||
// Stdin: "phase <name>" sets the phase and is answered {ack}; stdin ending closes the server and exits, so no orchestrator crash orphans it.
|
||||
import { readFileSync } from "node:fs";
|
||||
import { createServer } from "node:https";
|
||||
import type { AddressInfo } from "node:net";
|
||||
import { createInterface } from "node:readline";
|
||||
import { chunkRecordKey } from "cultnet-ts/content";
|
||||
import { createContentChunkHandler, createDirectoryChunkStore, toNodeListener, type ContentChunkAnswer, type ContentChunkRequest } from "cultmesh-ts/content";
|
||||
|
||||
const [storeDir, corruptDir, keyPem, certPem] = process.argv.slice(2) as [string, string, string, string];
|
||||
const [storeDir, corruptDir, keyPem, certPem, escapeKey] = process.argv.slice(2) as [string, string, string, string, string];
|
||||
const say = (line: object): void => { process.stdout.write(`${JSON.stringify(line)}\n`); };
|
||||
let phase = "start";
|
||||
|
||||
|
|
@ -23,7 +24,15 @@ const tampered = async (request: ContentChunkRequest): Promise<ContentChunkAnswe
|
|||
body[0]! ^= 1;
|
||||
return { ...answer, body };
|
||||
};
|
||||
const mounts = { honest: toNodeListener(honest), tampered: toNodeListener(tampered), corrupt: toNodeListener(handlerFor("corrupt", corruptDir)) };
|
||||
// The one non-canonical record key the fixtures carry (escapeKey) is answered as its canonical key, so the real handler serves the chunk
|
||||
// and the request line above, logged before this runs, is what each consumer actually sent. Every other recordKey reaches the handler untouched.
|
||||
const honestEscape = async (request: ContentChunkRequest): Promise<ContentChunkAnswer> => {
|
||||
const url = new URL(request.url, "http://provider.invalid");
|
||||
if (url.searchParams.get("recordKey") !== escapeKey) return honest(request);
|
||||
url.searchParams.set("recordKey", chunkRecordKey(url.searchParams.get("chunkHash")));
|
||||
return honest({ ...request, url: `${url.pathname}${url.search}` });
|
||||
};
|
||||
const mounts = { honest: toNodeListener(honestEscape), tampered: toNodeListener(tampered), corrupt: toNodeListener(handlerFor("corrupt", corruptDir)) };
|
||||
|
||||
const server = createServer({ key: readFileSync(keyPem), cert: readFileSync(certPem) }, (req, res) => {
|
||||
const mount = /^\/(honest|tampered|corrupt)\//.exec(req.url ?? "")?.[1] as keyof typeof mounts | undefined;
|
||||
|
|
|
|||
Loading…
Reference in a new issue