test(router): freeze the differential, application, WS and boot-error corpus

The parity corpus from ROUTER-CORPUS §2, with every expected output captured
from ed47836 rather than written by hand.

Matcher: 24 hand-picked scenarios (precedence, constraint ties, exact versus
catch-all, equal-rank and same-pattern ties with reversed twins, implicit and
explicit HEAD, streaming GETs, canonical Allow, encoding, case, Unicode and
normalization) plus 40 scenarios from a fixed-seed generator
(router-parity-gen-v1, seed 10908). The generated file stores the seed, the
rules and every generated input; the test regenerates and requires a match,
so changing the generator cannot move the baseline. Each scenario runs through
the oracle and the live router and both must equal the capture, compared by
declaration ID, decoded params, implicitHead, ordered Allow, or the
normalization error.

Application level: status, Allow, headers and body through app.fetch and a
Node socket, including HEAD body suppression, 400/404/405 and OPTIONS.

WebSocket, separate from HTTP: first-registered selection, an HTTP route at the
same path not taking the upgrade, and the reserved mesh control path, through
app.upgrade and the Node listener. This freezes one adapter disagreement as
observed: a user @Ws('/__mesh__/control') on an app without mesh is refused by
app.upgrade (1008) and served by the Node listener.

Boot-time rejections: pattern compilation, local ambiguity and mesh splicing
(duplicate exports, same-shape exports, local-over-remote precedence with its
warning, and a remote static outranking a local parameter route).

Refs #109

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-10-10 16:59:45 -05:00
1 parent adce82beaa
commit c30cf7e457
18 files changed
+16595

No files matched your search

+234
View File
@@ -0,0 +1,234 @@
/**
* Application-level router parity: what a client sees through `app.fetch` and through a real Node
* socket — status, `Allow`, response headers, and HEAD body suppression. Matcher equality alone
* cannot prove these: the 404/405/OPTIONS decisions, the 400 for a bad path and the HEAD body rule
* live in `src/http/core.ts`, around the matcher.
*/
import 'reflect-metadata';
import http from 'http';
import type { AddressInfo } from 'net';
import { describe, it, beforeAll, afterAll } from 'vitest';
import { createApp, Route, Get, Head, Post, Put, Patch, Delete, Options, Sse, Module, param } from '../../src/index';
import type { App } from '../../src/app/types';
import { frozen, expectFrozenEqual } from './frozen';
const reply = (id: string, params: Record<string, string>) => ({ id, params });
// Ordered on purpose: the overlapping declarations are registered least-specific first, so a
// lookup that fell back to registration order would answer differently from one that ranks.
@Route('/')
class ParityHttp {
@Get('/a/:rest*') aRest(@param() p: Record<string, string>) {
return reply('aRest', p);
}
@Get('/a/:id') aId(@param() p: Record<string, string>) {
return reply('aId', p);
}
@Get('/a/b') aB(@param() p: Record<string, string>) {
return reply('aB', p);
}
@Get('/users/:value') usersValue(@param() p: Record<string, string>) {
return reply('usersValue', p);
}
@Get('/users/:id(\\d+)') usersId(@param() p: Record<string, string>) {
return reply('usersId', p);
}
@Get('/n/:num(\\d+)') nNum(@param() p: Record<string, string>) {
return reply('nNum', p);
}
@Get('/n/:code([0-9a-f]+)') nCode(@param() p: Record<string, string>) {
return reply('nCode', p);
}
@Get('/files') files(@param() p: Record<string, string>) {
return reply('files', p);
}
@Get('/files/:rest*') filesRest(@param() p: Record<string, string>) {
return reply('filesRest', p);
}
@Get('/m') mGet(@param() p: Record<string, string>) {
return reply('mGet', p);
}
@Post('/m') mPost(@param() p: Record<string, string>) {
return reply('mPost', p);
}
@Get('/h') hGet(@param() p: Record<string, string>) {
return reply('hGet', p);
}
@Head('/h') hHead(@param() p: Record<string, string>) {
return reply('hHead', p);
}
@Sse('/stream') stream() {
return (async function* () {
yield { id: 'stream' };
})();
}
@Sse('/s/live') sLive() {
return (async function* () {
yield { id: 'sLive' };
})();
}
@Get('/s/:id') sId(@param() p: Record<string, string>) {
return reply('sId', p);
}
@Get('/Case') caseUpper(@param() p: Record<string, string>) {
return reply('caseUpper', p);
}
@Get('/u/:name') uName(@param() p: Record<string, string>) {
return reply('uName', p);
}
@Get('/admin') admin(@param() p: Record<string, string>) {
return reply('admin', p);
}
@Get('/public/:file') publicFile(@param() p: Record<string, string>) {
return reply('publicFile', p);
}
@Delete('/r') rDelete(@param() p: Record<string, string>) {
return reply('rDelete', p);
}
@Patch('/r') rPatch(@param() p: Record<string, string>) {
return reply('rPatch', p);
}
@Options('/r') rOptions(@param() p: Record<string, string>) {
return reply('rOptions', p);
}
@Put('/r') rPut(@param() p: Record<string, string>) {
return reply('rPut', p);
}
@Get('/') root(@param() p: Record<string, string>) {
return reply('root', p);
}
}
@Module({ mountpoint: '/', controllers: [ParityHttp] })
class ParityHttpModule {}
type Req = [method: string, raw: string];
const REQUESTS: Req[] = [
['GET', '/a/b'],
['GET', '/a/x'],
['GET', '/a/x/y'],
['GET', '/a'],
['GET', '/users/42'],
['GET', '/users/alice'],
['GET', '/users/a%20b'],
['GET', '/n/42'],
['GET', '/n/ff'],
['GET', '/files'],
['GET', '/files/'],
['GET', '/files/a%2Fb'],
['GET', '/m'],
['HEAD', '/m'],
['OPTIONS', '/m'],
['PUT', '/m'],
['DELETE', '/m'],
['POST', '/m'],
['GET', '/h'],
['HEAD', '/h'],
['GET', '/stream'],
['HEAD', '/stream'],
['OPTIONS', '/stream'],
['HEAD', '/s/live'],
['HEAD', '/s/x'],
['GET', '/absent'],
['HEAD', '/absent'],
['OPTIONS', '/absent'],
['GET', '/users/%E0%A4%A'],
['HEAD', '/users/%E0%A4%A'],
['GET', '/a//b'],
['GET', '/Case'],
['GET', '/case'],
['GET', '/caf%C3%A9'],
['GET', '/u/caf%C3%A9'],
['GET', '/public/../admin'],
['GET', '/public/%2e%2e/admin'],
['GET', '/public/..%2fadmin'],
['GET', '/admin/'],
['OPTIONS', '/r'],
['HEAD', '/r'],
['GET', '/r'],
['PURGE', '/r'], // TRACE is a forbidden method for `new Request`
['GET', '/'],
['GET', '/?q=1'],
];
/** Headers that vary per run or per connection rather than per route decision. */
const VOLATILE = new Set(['date', 'connection', 'keep-alive', 'x-request-id']);
function stableHeaders(entries: Iterable<[string, string]>): Record<string, string> {
const out: Record<string, string> = {};
for (const [name, value] of [...entries].sort(([a], [b]) => a.localeCompare(b)))
if (!VOLATILE.has(name)) out[name] = value;
return out;
}
interface Observed {
method: string;
raw: string;
status: number;
headers: Record<string, string>;
body: string;
}
async function viaFetch(app: App, [method, raw]: Req): Promise<Observed> {
// `new Request` applies the URL parser first — exactly what Deno, Bun and workerd do.
const res = await app.fetch(new Request(`http://parity.test${raw}`, { method }));
return { method, raw, status: res.status, headers: stableHeaders(res.headers), body: await res.text() };
}
function viaNode(port: number, [method, raw]: Req): Promise<Observed> {
// `http.request` sends the path bytes as given, so the server sees the raw target.
return new Promise((resolve, reject) => {
const req = http.request({ host: '127.0.0.1', port, method, path: raw, agent: false }, (res) => {
let body = '';
res.setEncoding('utf8');
res.on('data', (chunk) => (body += chunk));
res.on('end', () => {
const headers = Object.entries(res.headers).map(([k, v]): [string, string] => [
k,
Array.isArray(v) ? v.join(', ') : String(v),
]);
resolve({ method, raw, status: res.statusCode ?? 0, headers: stableHeaders(headers), body });
});
});
req.on('error', reject);
req.end();
});
}
describe('router parity: application-level HTTP outcomes', () => {
let fetchApp: App;
let nodeApp: App;
let port: number;
beforeAll(async () => {
fetchApp = createApp({ modules: [ParityHttpModule] });
nodeApp = createApp({ modules: [ParityHttpModule] });
const server = await nodeApp.listen(0);
port = (server.address() as AddressInfo).port;
});
afterAll(async () => {
await nodeApp.close();
});
it('app.fetch outcomes equal the frozen capture', async () => {
const run = async () => {
const out: Observed[] = [];
for (const req of REQUESTS) out.push(await viaFetch(fetchApp, req));
return out;
};
const expected = await frozen('app-fetch', run);
expectFrozenEqual(await run(), expected, 'app.fetch');
});
it('Node listener outcomes equal the frozen capture', async () => {
const run = async () => {
const out: Observed[] = [];
for (const req of REQUESTS) out.push(await viaNode(port, req));
return out;
};
const expected = await frozen('app-node', run);
expectFrozenEqual(await run(), expected, 'node listener');
});
});
+315
View File
@@ -0,0 +1,315 @@
/**
* Boot-time rejection parity: invalid patterns, local ambiguity and mesh route splicing. These are
* not inputs to the differential matcher — a pattern that fails here never reaches a lookup — so
* they are frozen as their own expected-error fixture: the rejection point (pattern compile, app
* construction, mesh `ready()`), the error class and the exact message.
*/
import 'reflect-metadata';
import type { AddressInfo } from 'net';
import { describe, it } from 'vitest';
import { createApp, Route, Get, Post, Sse, Ws, Module, param } from '../../src/index';
import type { RouteDecorator } from '../../src/metadata';
import type { Logger } from '../../src/logger';
import * as live from '../../src/http/router';
import * as oracle from './oracle';
import { errorOutcome, type ErrorOutcome } from './matcher';
import { frozen, expectFrozenEqual } from './frozen';
const PATTERNS = [
'/',
'/users/:id',
'/users/:id(\\d+)',
'/files/:rest*',
'/:rest*',
'/t/',
'/café',
'/build/:version(\\d{2}\\.\\d{1,2})',
'/x/:id/:id',
'/x/:id/:rest*/tail',
'/x/:rest*/:rest*',
'/x/:',
'/x/:1x',
'/x//y',
'x',
'',
'/x/:id((a+)+)',
'/x/:id((?=a)a)',
'/x/:id(\\1)',
'/x/:id(a|b)',
'/x/:id(\\d+\\w+)',
'/x/:id(\\d{5,2})',
'/x/:id(\\d{1,4096})',
'/x/:id(\\d+',
'/x/:id()',
`/x/:id(${'a'.repeat(129)})`,
];
type PatternOutcome = { pattern: string; shape: string } | { pattern: string; error: ErrorOutcome };
function compileAll(compile: (pattern: string) => { shape: string }): PatternOutcome[] {
return PATTERNS.map((pattern) => {
try {
return { pattern, shape: compile(pattern).shape };
} catch (error) {
return { pattern, error: errorOutcome(error) };
}
});
}
type Decl = [decorator: RouteDecorator, path: string];
/** One controller per case, its handlers declared in the given order (decorators applied by hand). */
function moduleWith(decls: Decl[]) {
class ParityBoot {}
decls.forEach(([decorator, path], index) => {
const name = `h${index}`;
Object.defineProperty(ParityBoot.prototype, name, {
value: () => (async function* () {})(),
configurable: true,
});
decorator(path)(ParityBoot.prototype, name, Object.getOwnPropertyDescriptor(ParityBoot.prototype, name)!);
});
Route('/')(ParityBoot);
class ParityBootModule {}
Module({ mountpoint: '/', controllers: [ParityBoot] })(ParityBootModule);
return ParityBootModule;
}
const APP_CASES: Array<{ id: string; decls: Decl[] }> = [
{ id: 'B01-duplicate-param', decls: [[Get, '/x/:id/:id']] },
{ id: 'B02-nonfinal-catch-all', decls: [[Get, '/x/:rest*/tail']] },
{ id: 'B03-nested-quantifier', decls: [[Get, '/x/:id((a+)+)']] },
{ id: 'B04-alternation', decls: [[Get, '/x/:id(a|b)']] },
{ id: 'B05-adjacent-unbounded', decls: [[Get, '/x/:id(\\d+\\w+)']] },
{ id: 'B06-inverted-quantifier', decls: [[Get, '/x/:id(\\d{5,2})']] },
{ id: 'B07-invalid-param-name', decls: [[Get, '/x/:1x']] },
{ id: 'B08-malformed-constraint', decls: [[Get, '/x/:id(\\d+']] },
{
id: 'B09-same-shape-plain',
decls: [
[Get, '/users/:id'],
[Get, '/users/:name'],
],
},
{
id: 'B10-same-shape-constrained',
decls: [
[Get, '/c/:a(\\d+)'],
[Get, '/c/:b(\\d+)'],
],
},
{
id: 'B11-trailing-slash-twin',
decls: [
[Get, '/t'],
[Get, '/t/'],
],
},
{
id: 'B12-get-and-ws-same-path',
decls: [
[Get, '/live'],
[Ws, '/live'],
],
},
{
id: 'B13-get-and-sse-same-path',
decls: [
[Get, '/feed'],
[Sse, '/feed'],
],
},
{
id: 'B14-ws-same-shape',
decls: [
[Ws, '/w/:a'],
[Ws, '/w/:b'],
],
},
{
id: 'B15-ok-same-shape-different-methods',
decls: [
[Get, '/users/:id'],
[Post, '/users/:name'],
],
},
{
id: 'B16-ok-different-constraints',
decls: [
[Get, '/c/:a(\\d+)'],
[Get, '/c/:b([a-z]+)'],
],
},
{
id: 'B17-ok-static-and-param',
decls: [
[Get, '/users/me'],
[Get, '/users/:id'],
],
},
{
id: 'B18-ok-exact-and-catch-all',
decls: [
[Get, '/f'],
[Get, '/f/:rest*'],
],
},
];
const LABELS = new Map<RouteDecorator, string>([
[Get, '@Get'],
[Post, '@Post'],
[Sse, '@Sse'],
[Ws, '@Ws'],
]);
function bootAll() {
return APP_CASES.map(({ id, decls }) => {
const declarations = decls.map(([decorator, path]) => `${LABELS.get(decorator)}('${path}')`);
try {
createApp({ modules: [moduleWith(decls)] });
return { id, declarations, ok: true };
} catch (error) {
return { id, declarations, error: errorOutcome(error) };
}
});
}
// ── mesh ────────────────────────────────────────────────────────────────────────────────────────
const SECRET = 'parity-secret';
@Route('/dup')
class DupCtl {
@Get('/ping', { export: true }) ping() {
return { from: 'teapot' };
}
}
@Module({ mountpoint: '/api', controllers: [DupCtl] })
class DupTeapotModule {}
@Route('/shape')
class ShapeIdCtl {
@Get('/:id', { export: true }) get(@param() p: Record<string, string>) {
return { from: 'id', p };
}
}
@Module({ mountpoint: '/api', controllers: [ShapeIdCtl] })
class ShapeIdTeapotModule {}
@Route('/shape')
class ShapeNameCtl {
@Get('/:name', { export: true }) get(@param() p: Record<string, string>) {
return { from: 'name', p };
}
}
@Module({ mountpoint: '/api', controllers: [ShapeNameCtl] })
class ShapeNameTeapotModule {}
// Same method and shape as the teapot's export: the local route wins, with a warning.
@Route('/dup')
class ShadowCtl {
@Get('/ping') local() {
return { from: 'local' };
}
}
@Module({ mountpoint: '/api', controllers: [ShadowCtl] })
class ShadowTeacupModule {}
// A different shape that overlaps the export: no warning, and lookup ranks across local and remote.
@Route('/dup')
class OverlapCtl {
@Get('/:anything') local(@param() p: Record<string, string>) {
return { from: 'local', p };
}
}
@Module({ mountpoint: '/api', controllers: [OverlapCtl] })
class OverlapTeacupModule {}
@Route('/c')
class PlainCtl {
@Get('/ok') ok() {
return { from: 'teacup' };
}
}
@Module({ mountpoint: '/', controllers: [PlainCtl] })
class PlainTeacupModule {}
type Ctor = new (...args: unknown[]) => unknown;
function recordingLogger(): { logger: Logger; warnings: string[] } {
const warnings: string[] = [];
const noop = () => {};
return { logger: { debug: noop, info: noop, error: noop, warn: (m) => warnings.push(m) }, warnings };
}
/** Starts one teapot per module and returns their control URLs plus a function that hides the ports. */
async function teapots(modules: Ctor[]) {
const apps = modules.map((module) => createApp({ modules: [module], experimental: true, mesh: { secret: SECRET } }));
const servers = await Promise.all(apps.map((app) => app.listen(0)));
const urls = servers.map((s) => `ws://127.0.0.1:${(s.address() as AddressInfo).port}/__mesh__/control`);
const anonymize = (text: string) => urls.reduce((out, url, i) => out.split(url).join(`<teapot${i + 1}>`), text);
const close = () => Promise.all(apps.map((app) => app.close()));
return { urls, anonymize, close };
}
async function meshCase(id: string, teacupModule: Ctor, teapotModules: Ctor[], requests: string[]) {
const pots = await teapots(teapotModules);
const { logger, warnings } = recordingLogger();
const teacup = createApp({
modules: [teacupModule],
experimental: true,
logger,
mesh: { teapots: pots.urls.map((url) => ({ url, secret: SECRET })) },
});
try {
await teacup.ready();
const responses = [];
for (const path of requests) {
const res = await teacup.fetch(new Request(`http://parity.test${path}`));
responses.push({ path, status: res.status, body: await res.text() });
}
const routing = warnings.filter((w) => w.includes('precedence')).map(pots.anonymize);
return { id, ok: true, warnings: routing, responses };
} catch (error) {
const { name, message } = errorOutcome(error);
return { id, error: { name, message: pots.anonymize(message) } };
} finally {
await teacup.close();
await pots.close();
}
}
async function meshAll() {
return [
await meshCase('M01-two-teapots-same-route', PlainTeacupModule, [DupTeapotModule, DupTeapotModule], []),
await meshCase('M02-two-teapots-same-shape', PlainTeacupModule, [ShapeIdTeapotModule, ShapeNameTeapotModule], []),
await meshCase('M03-local-same-shape-wins', ShadowTeacupModule, [DupTeapotModule], ['/api/dup/ping']),
await meshCase('M04-unique-remote', PlainTeacupModule, [DupTeapotModule], ['/api/dup/ping', '/c/ok', '/api/nope']),
await meshCase(
'M05-remote-static-outranks-local-param',
OverlapTeacupModule,
[DupTeapotModule],
['/api/dup/ping', '/api/dup/x'],
),
];
}
describe('router parity: boot-time rejection', () => {
it('pattern compilation (oracle and live compilePattern) equals the frozen capture', async () => {
const expected = await frozen('boot-patterns', () => compileAll(live.compilePattern));
expectFrozenEqual(compileAll(oracle.compilePattern), expected, 'oracle compilePattern');
expectFrozenEqual(compileAll(live.compilePattern), expected, 'live compilePattern');
});
it('createApp route-table validation equals the frozen capture', async () => {
const expected = await frozen('boot-app', bootAll);
expectFrozenEqual(bootAll(), expected, 'createApp');
});
it('mesh route splicing equals the frozen capture', async () => {
const expected = await frozen('boot-mesh', meshAll);
expectFrozenEqual(await meshAll(), expected, 'mesh splice');
}, 30_000);
});
+252
View File
@@ -0,0 +1,252 @@
/**
* Hand-picked matcher scenarios (ROUTER-CORPUS §2). Declaration IDs are stable across a scenario
* and its reversed twin, so a reversed run is compared by which declaration answered, not by which
* pattern text happens to sit first.
*
* Inputs only. The expected outputs live in `frozen/matcher-hand.json`, captured from the pinned
* revision; nothing in this file states what the answer should be.
*/
import type { Declaration, Request, Scenario, Transport } from './matcher';
type Decl = [id: string, method: string, pattern: string, transport?: Transport];
type Req = [method: string, raw: string];
function scenario(id: string, note: string, decls: Decl[], reqs: Req[]): Scenario {
const declarations = decls.map(([declId, method, pattern, transport = 'buffer']): Declaration => ({
id: declId,
method,
pattern,
transport,
}));
const requests = reqs.map(([method, raw]): Request => ({ method, raw }));
return { id, note, declarations, requests };
}
/** The same scenario with its declarations in reverse registration order. */
function reversed(base: Scenario, id: string): Scenario {
return { ...base, id, note: `${base.note} (declarations reversed)`, declarations: [...base.declarations].reverse() };
}
const get = (...paths: string[]): Req[] => paths.map((path): Req => ['GET', path]);
const methods = (path: string, ...verbs: string[]): Req[] => verbs.map((verb): Req => [verb, path]);
const rank = scenario(
'H01-rank',
'static beats plain param beats catch-all',
[
['catchAll', 'GET', '/a/:rest*'],
['param', 'GET', '/a/:id'],
['static', 'GET', '/a/b'],
],
[...get('/a/b', '/a/x', '/a/x/y', '/a', '/a/'), ['HEAD', '/a/x'], ['OPTIONS', '/a/b'], ['POST', '/a/b']],
);
const constraint = scenario(
'H03-constraint',
'constrained param beats plain param; constraint tested against the decoded segment',
[
['plain', 'GET', '/users/:value'],
['digits', 'GET', '/users/:id(\\d+)'],
],
get('/users/42', '/users/alice', '/users/42x', '/users/%34%32', '/users/'),
);
const constraintTie = scenario(
'H05-constraint-tie',
'two overlapping constraints of equal rank: registration order decides',
[
['digits', 'GET', '/n/:num(\\d+)'],
['hex', 'GET', '/n/:code([0-9a-f]+)'],
],
get('/n/42', '/n/ff', '/n/4f', '/n/zz'),
);
const equalRank = scenario(
'H08-equal-rank',
'equal-specificity plain params: first registered wins',
[
['first', 'GET', '/t/:first'],
['second', 'GET', '/t/:second'],
],
[...get('/t/x', '/t/x/y'), ['HEAD', '/t/x']],
);
const samePattern = scenario(
'H10-same-pattern',
'identical pattern text under two declaration IDs (mesh local/remote twins reach the matcher this way)',
[
['one', 'GET', '/same'],
['two', 'GET', '/same'],
],
[...get('/same'), ['HEAD', '/same'], ['OPTIONS', '/same']],
);
export const HAND_SCENARIOS: Scenario[] = [
rank,
reversed(rank, 'H02-rank-reversed'),
constraint,
reversed(constraint, 'H04-constraint-reversed'),
constraintTie,
reversed(constraintTie, 'H06-constraint-tie-reversed'),
scenario(
'H07-exact-vs-catch-all',
'exact route at /files, catch-all below it, decoded captures',
[
['exact', 'GET', '/files'],
['rest', 'GET', '/files/:rest*'],
],
[...get('/files', '/files/', '/files/a%2Fb', '/files/a/b/c', '/files/a%20b/c%2Fd'), ['HEAD', '/files/x']],
),
equalRank,
reversed(equalRank, 'H09-equal-rank-reversed'),
samePattern,
reversed(samePattern, 'H11-same-pattern-reversed'),
scenario(
'H12-method-implicit-head',
'buffered GET supplies HEAD; OPTIONS and 405 share one canonical Allow',
[
['get', 'GET', '/m'],
['post', 'POST', '/m'],
],
methods('/m', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT', 'DELETE', 'PATCH'),
),
scenario(
'H13-method-explicit-head',
'an explicit HEAD wins over the buffered-GET fallback',
[
['get', 'GET', '/m'],
['post', 'POST', '/m'],
['head', 'HEAD', '/m'],
],
methods('/m', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT', 'DELETE'),
),
scenario(
'H14-streaming-head',
'a streaming GET does not supply HEAD',
[['stream', 'GET', '/stream', 'sse']],
methods('/stream', 'GET', 'HEAD', 'OPTIONS', 'POST'),
),
scenario(
'H15-streaming-outranks-buffered',
'HEAD skips a higher-ranked streaming GET and falls back to a lower-ranked buffered GET',
[
['live', 'GET', '/s/live', 'sse'],
['byId', 'GET', '/s/:id'],
],
[...methods('/s/live', 'GET', 'HEAD', 'OPTIONS'), ['HEAD', '/s/x']],
),
scenario(
'H16-negotiate-and-ndjson-head',
'negotiate and ndjson GETs are streaming transports for the HEAD rule',
[
['negotiate', 'GET', '/neg', 'negotiate'],
['ndjson', 'GET', '/nd', 'ndjson'],
],
[...methods('/neg', 'GET', 'HEAD', 'OPTIONS'), ...methods('/nd', 'HEAD', 'OPTIONS')],
),
scenario(
'H17-allow-order',
'Allow is canonical regardless of declaration order; explicit OPTIONS is a normal route',
[
['delete', 'DELETE', '/r'],
['patch', 'PATCH', '/r'],
['options', 'OPTIONS', '/r'],
['put', 'PUT', '/r'],
['get', 'GET', '/r', 'sse'],
['post', 'POST', '/r'],
],
methods('/r', 'OPTIONS', 'HEAD', 'GET', 'TRACE', 'POST'),
),
scenario(
'H18-path-miss',
'a path no pattern matches: no route and an empty Allow',
[['a', 'GET', '/a']],
[...get('/absent', '/a/extra', '/'), ['OPTIONS', '/absent'], ['HEAD', '/absent']],
),
scenario(
'H19-encoding-case-unicode',
'decoded params, malformed escapes, repeated slashes, exact case and Unicode literals',
[
['userId', 'GET', '/users/:id'],
['upper', 'GET', '/Case'],
['unicode', 'GET', '/café'],
['unicodeParam', 'GET', '/u/:name'],
],
get(
'/users/a%20b',
'/users/a+b',
'/users/%F0%9F%8D%B5',
'/users/%E0%A4%A',
'/users/%zz',
'/a//b',
'/users//x',
'/Case',
'/case',
'/CASE',
'/café',
'/caf%C3%A9',
'/u/caf%C3%A9',
'/u/café',
),
),
scenario(
'H20-normalization',
'one trailing slash removed; plain and encoded dot segments resolved before lookup',
[
['a', 'GET', '/a'],
['admin', 'GET', '/admin'],
['file', 'GET', '/public/:file'],
],
get(
'/a/',
'/a//',
'/public/../admin',
'/public/%2e%2e/admin',
'/public/%2E%2E/admin',
'/public/./x',
'/a/.',
'/public/..%2fadmin',
'/..',
'/a/b/../../admin',
'',
'a',
),
),
scenario(
'H21-root',
'the root pattern and a root catch-all',
[
['any', 'GET', '/:rest*'],
['root', 'GET', '/'],
],
get('/', '/x', '/x/y', '/x/'),
),
scenario(
'H22-first-differing-segment',
'ranking is decided at the first segment whose kind differs',
[
['paramStatic', 'GET', '/a/:x/c'],
['staticParam', 'GET', '/a/b/:y'],
['paramConstrained', 'GET', '/a/:x/:y(\\d+)'],
],
get('/a/b/c', '/a/z/c', '/a/z/5', '/a/b/5', '/a/z/q'),
),
scenario(
'H23-per-position-decode',
'a decoded value is the same for every candidate the scan reaches',
[
['zzz', 'GET', '/a/:x/zzz'],
['b', 'GET', '/a/:y/b'],
],
get('/a/a%20b/b', '/a/a%20b/zzz'),
),
scenario(
'H24-constrained-catch-all',
'two catch-alls ranked by the segments before them',
[
['named', 'GET', '/v/:name/:rest*'],
['versioned', 'GET', '/v/:ver(\\d+)/:rest*'],
],
get('/v/1/x', '/v/a/x', '/v/1', '/v'),
),
];
+597
View File
@@ -0,0 +1,597 @@
{
"revision": "ed47836c9820c47bf4ed5e902d91e019abdb110a",
"data": [
{
"method": "GET",
"raw": "/a/b",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"aB\",\"params\":{}}"
},
{
"method": "GET",
"raw": "/a/x",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"aId\",\"params\":{\"id\":\"x\"}}"
},
{
"method": "GET",
"raw": "/a/x/y",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"aRest\",\"params\":{\"rest\":\"x/y\"}}"
},
{
"method": "GET",
"raw": "/a",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"aRest\",\"params\":{\"rest\":\"\"}}"
},
{
"method": "GET",
"raw": "/users/42",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"usersId\",\"params\":{\"id\":\"42\"}}"
},
{
"method": "GET",
"raw": "/users/alice",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"usersValue\",\"params\":{\"value\":\"alice\"}}"
},
{
"method": "GET",
"raw": "/users/a%20b",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"usersValue\",\"params\":{\"value\":\"a b\"}}"
},
{
"method": "GET",
"raw": "/n/42",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"nNum\",\"params\":{\"num\":\"42\"}}"
},
{
"method": "GET",
"raw": "/n/ff",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"nCode\",\"params\":{\"code\":\"ff\"}}"
},
{
"method": "GET",
"raw": "/files",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"files\",\"params\":{}}"
},
{
"method": "GET",
"raw": "/files/",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"files\",\"params\":{}}"
},
{
"method": "GET",
"raw": "/files/a%2Fb",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"filesRest\",\"params\":{\"rest\":\"a/b\"}}"
},
{
"method": "GET",
"raw": "/m",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"mGet\",\"params\":{}}"
},
{
"method": "HEAD",
"raw": "/m",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "OPTIONS",
"raw": "/m",
"status": 204,
"headers": {
"allow": "GET, HEAD, POST, OPTIONS",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "PUT",
"raw": "/m",
"status": 405,
"headers": {
"allow": "GET, HEAD, POST, OPTIONS",
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Method Not Allowed\"}"
},
{
"method": "DELETE",
"raw": "/m",
"status": 405,
"headers": {
"allow": "GET, HEAD, POST, OPTIONS",
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Method Not Allowed\"}"
},
{
"method": "POST",
"raw": "/m",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"mPost\",\"params\":{}}"
},
{
"method": "GET",
"raw": "/h",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"hGet\",\"params\":{}}"
},
{
"method": "HEAD",
"raw": "/h",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "GET",
"raw": "/stream",
"status": 200,
"headers": {
"cache-control": "no-cache",
"content-type": "text/event-stream",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "data: {\"id\":\"stream\"}\n\n"
},
{
"method": "HEAD",
"raw": "/stream",
"status": 405,
"headers": {
"allow": "GET, OPTIONS",
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "OPTIONS",
"raw": "/stream",
"status": 204,
"headers": {
"allow": "GET, OPTIONS",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "HEAD",
"raw": "/s/live",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "HEAD",
"raw": "/s/x",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "GET",
"raw": "/absent",
"status": 404,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Not Found\"}"
},
{
"method": "HEAD",
"raw": "/absent",
"status": 404,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "OPTIONS",
"raw": "/absent",
"status": 404,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Not Found\"}"
},
{
"method": "GET",
"raw": "/users/%E0%A4%A",
"status": 400,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Bad Request\"}"
},
{
"method": "HEAD",
"raw": "/users/%E0%A4%A",
"status": 400,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "GET",
"raw": "/a//b",
"status": 400,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Bad Request\"}"
},
{
"method": "GET",
"raw": "/Case",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"caseUpper\",\"params\":{}}"
},
{
"method": "GET",
"raw": "/case",
"status": 404,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Not Found\"}"
},
{
"method": "GET",
"raw": "/caf%C3%A9",
"status": 404,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Not Found\"}"
},
{
"method": "GET",
"raw": "/u/caf%C3%A9",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"uName\",\"params\":{\"name\":\"café\"}}"
},
{
"method": "GET",
"raw": "/public/../admin",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"admin\",\"params\":{}}"
},
{
"method": "GET",
"raw": "/public/%2e%2e/admin",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"admin\",\"params\":{}}"
},
{
"method": "GET",
"raw": "/public/..%2fadmin",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"publicFile\",\"params\":{\"file\":\"../admin\"}}"
},
{
"method": "GET",
"raw": "/admin/",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"admin\",\"params\":{}}"
},
{
"method": "OPTIONS",
"raw": "/r",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"rOptions\",\"params\":{}}"
},
{
"method": "HEAD",
"raw": "/r",
"status": 405,
"headers": {
"allow": "PUT, PATCH, DELETE, OPTIONS",
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "GET",
"raw": "/r",
"status": 405,
"headers": {
"allow": "PUT, PATCH, DELETE, OPTIONS",
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Method Not Allowed\"}"
},
{
"method": "PURGE",
"raw": "/r",
"status": 405,
"headers": {
"allow": "PUT, PATCH, DELETE, OPTIONS",
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Method Not Allowed\"}"
},
{
"method": "GET",
"raw": "/",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"root\",\"params\":{}}"
},
{
"method": "GET",
"raw": "/?q=1",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"root\",\"params\":{}}"
}
]
}
+632
View File
@@ -0,0 +1,632 @@
{
"revision": "ed47836c9820c47bf4ed5e902d91e019abdb110a",
"data": [
{
"method": "GET",
"raw": "/a/b",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"aB\",\"params\":{}}"
},
{
"method": "GET",
"raw": "/a/x",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"aId\",\"params\":{\"id\":\"x\"}}"
},
{
"method": "GET",
"raw": "/a/x/y",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"aRest\",\"params\":{\"rest\":\"x/y\"}}"
},
{
"method": "GET",
"raw": "/a",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"aRest\",\"params\":{\"rest\":\"\"}}"
},
{
"method": "GET",
"raw": "/users/42",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"usersId\",\"params\":{\"id\":\"42\"}}"
},
{
"method": "GET",
"raw": "/users/alice",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"usersValue\",\"params\":{\"value\":\"alice\"}}"
},
{
"method": "GET",
"raw": "/users/a%20b",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"usersValue\",\"params\":{\"value\":\"a b\"}}"
},
{
"method": "GET",
"raw": "/n/42",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"nNum\",\"params\":{\"num\":\"42\"}}"
},
{
"method": "GET",
"raw": "/n/ff",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"nCode\",\"params\":{\"code\":\"ff\"}}"
},
{
"method": "GET",
"raw": "/files",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"files\",\"params\":{}}"
},
{
"method": "GET",
"raw": "/files/",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"files\",\"params\":{}}"
},
{
"method": "GET",
"raw": "/files/a%2Fb",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"filesRest\",\"params\":{\"rest\":\"a/b\"}}"
},
{
"method": "GET",
"raw": "/m",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"mGet\",\"params\":{}}"
},
{
"method": "HEAD",
"raw": "/m",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "OPTIONS",
"raw": "/m",
"status": 204,
"headers": {
"allow": "GET, HEAD, POST, OPTIONS",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "PUT",
"raw": "/m",
"status": 405,
"headers": {
"allow": "GET, HEAD, POST, OPTIONS",
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Method Not Allowed\"}"
},
{
"method": "DELETE",
"raw": "/m",
"status": 405,
"headers": {
"allow": "GET, HEAD, POST, OPTIONS",
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Method Not Allowed\"}"
},
{
"method": "POST",
"raw": "/m",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"mPost\",\"params\":{}}"
},
{
"method": "GET",
"raw": "/h",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"hGet\",\"params\":{}}"
},
{
"method": "HEAD",
"raw": "/h",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "GET",
"raw": "/stream",
"status": 200,
"headers": {
"cache-control": "no-cache",
"content-type": "text/event-stream",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "data: {\"id\":\"stream\"}\n\n"
},
{
"method": "HEAD",
"raw": "/stream",
"status": 405,
"headers": {
"allow": "GET, OPTIONS",
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "OPTIONS",
"raw": "/stream",
"status": 204,
"headers": {
"allow": "GET, OPTIONS",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "HEAD",
"raw": "/s/live",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "HEAD",
"raw": "/s/x",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "GET",
"raw": "/absent",
"status": 404,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Not Found\"}"
},
{
"method": "HEAD",
"raw": "/absent",
"status": 404,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "OPTIONS",
"raw": "/absent",
"status": 404,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Not Found\"}"
},
{
"method": "GET",
"raw": "/users/%E0%A4%A",
"status": 400,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Bad Request\"}"
},
{
"method": "HEAD",
"raw": "/users/%E0%A4%A",
"status": 400,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "GET",
"raw": "/a//b",
"status": 400,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Bad Request\"}"
},
{
"method": "GET",
"raw": "/Case",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"caseUpper\",\"params\":{}}"
},
{
"method": "GET",
"raw": "/case",
"status": 404,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Not Found\"}"
},
{
"method": "GET",
"raw": "/caf%C3%A9",
"status": 404,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Not Found\"}"
},
{
"method": "GET",
"raw": "/u/caf%C3%A9",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"uName\",\"params\":{\"name\":\"café\"}}"
},
{
"method": "GET",
"raw": "/public/../admin",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"admin\",\"params\":{}}"
},
{
"method": "GET",
"raw": "/public/%2e%2e/admin",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"admin\",\"params\":{}}"
},
{
"method": "GET",
"raw": "/public/..%2fadmin",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"publicFile\",\"params\":{\"file\":\"../admin\"}}"
},
{
"method": "GET",
"raw": "/admin/",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"admin\",\"params\":{}}"
},
{
"method": "OPTIONS",
"raw": "/r",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"rOptions\",\"params\":{}}"
},
{
"method": "HEAD",
"raw": "/r",
"status": 405,
"headers": {
"allow": "PUT, PATCH, DELETE, OPTIONS",
"content-type": "application/json",
"referrer-policy": "no-referrer",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": ""
},
{
"method": "GET",
"raw": "/r",
"status": 405,
"headers": {
"allow": "PUT, PATCH, DELETE, OPTIONS",
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Method Not Allowed\"}"
},
{
"method": "PURGE",
"raw": "/r",
"status": 405,
"headers": {
"allow": "PUT, PATCH, DELETE, OPTIONS",
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"error\":\"Method Not Allowed\"}"
},
{
"method": "GET",
"raw": "/",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"root\",\"params\":{}}"
},
{
"method": "GET",
"raw": "/?q=1",
"status": 200,
"headers": {
"content-type": "application/json",
"referrer-policy": "no-referrer",
"transfer-encoding": "chunked",
"x-content-type-options": "nosniff",
"x-dns-prefetch-control": "off",
"x-frame-options": "SAMEORIGIN"
},
"body": "{\"id\":\"root\",\"params\":{}}"
}
]
}
+183
View File
@@ -0,0 +1,183 @@
{
"revision": "ed47836c9820c47bf4ed5e902d91e019abdb110a",
"data": [
{
"id": "B01-duplicate-param",
"declarations": [
"@Get('/x/:id/:id')"
],
"error": {
"name": "Error",
"message": "invalid route pattern '/x/:id/:id': duplicate parameter 'id'"
}
},
{
"id": "B02-nonfinal-catch-all",
"declarations": [
"@Get('/x/:rest*/tail')"
],
"error": {
"name": "Error",
"message": "invalid route pattern '/x/:rest*/tail': catch-all must be the final segment"
}
},
{
"id": "B03-nested-quantifier",
"declarations": [
"@Get('/x/:id((a+)+)')"
],
"error": {
"name": "Error",
"message": "unsafe route constraint: unsupported expression '(a+)+'"
}
},
{
"id": "B04-alternation",
"declarations": [
"@Get('/x/:id(a|b)')"
],
"error": {
"name": "Error",
"message": "unsafe route constraint: unsupported expression 'a|b'"
}
},
{
"id": "B05-adjacent-unbounded",
"declarations": [
"@Get('/x/:id(\\d+\\w+)')"
],
"error": {
"name": "Error",
"message": "unsafe route constraint: adjacent unbounded quantifiers in '\\d+\\w+'"
}
},
{
"id": "B06-inverted-quantifier",
"declarations": [
"@Get('/x/:id(\\d{5,2})')"
],
"error": {
"name": "Error",
"message": "unsafe route constraint: invalid quantifier '{5,2}'"
}
},
{
"id": "B07-invalid-param-name",
"declarations": [
"@Get('/x/:1x')"
],
"error": {
"name": "Error",
"message": "invalid route pattern '/x/:1x': invalid parameter name '1x'"
}
},
{
"id": "B08-malformed-constraint",
"declarations": [
"@Get('/x/:id(\\d+')"
],
"error": {
"name": "Error",
"message": "invalid route pattern '/x/:id(\\d+': malformed constraint"
}
},
{
"id": "B09-same-shape-plain",
"declarations": [
"@Get('/users/:id')",
"@Get('/users/:name')"
],
"error": {
"name": "Error",
"message": "ambiguous route GET /users/:name at ParityBoot.h1 conflicts with GET /users/:id at ParityBoot.h0"
}
},
{
"id": "B10-same-shape-constrained",
"declarations": [
"@Get('/c/:a(\\d+)')",
"@Get('/c/:b(\\d+)')"
],
"error": {
"name": "Error",
"message": "ambiguous route GET /c/:b(\\d+) at ParityBoot.h1 conflicts with GET /c/:a(\\d+) at ParityBoot.h0"
}
},
{
"id": "B11-trailing-slash-twin",
"declarations": [
"@Get('/t')",
"@Get('/t/')"
],
"error": {
"name": "Error",
"message": "ambiguous route GET /t/ at ParityBoot.h1 conflicts with GET /t at ParityBoot.h0"
}
},
{
"id": "B12-get-and-ws-same-path",
"declarations": [
"@Get('/live')",
"@Ws('/live')"
],
"error": {
"name": "Error",
"message": "ambiguous route GET /live at ParityBoot.h1 conflicts with GET /live at ParityBoot.h0"
}
},
{
"id": "B13-get-and-sse-same-path",
"declarations": [
"@Get('/feed')",
"@Sse('/feed')"
],
"error": {
"name": "Error",
"message": "ambiguous route GET /feed at ParityBoot.h1 conflicts with GET /feed at ParityBoot.h0"
}
},
{
"id": "B14-ws-same-shape",
"declarations": [
"@Ws('/w/:a')",
"@Ws('/w/:b')"
],
"error": {
"name": "Error",
"message": "ambiguous route GET /w/:b at ParityBoot.h1 conflicts with GET /w/:a at ParityBoot.h0"
}
},
{
"id": "B15-ok-same-shape-different-methods",
"declarations": [
"@Get('/users/:id')",
"@Post('/users/:name')"
],
"ok": true
},
{
"id": "B16-ok-different-constraints",
"declarations": [
"@Get('/c/:a(\\d+)')",
"@Get('/c/:b([a-z]+)')"
],
"ok": true
},
{
"id": "B17-ok-static-and-param",
"declarations": [
"@Get('/users/me')",
"@Get('/users/:id')"
],
"ok": true
},
{
"id": "B18-ok-exact-and-catch-all",
"declarations": [
"@Get('/f')",
"@Get('/f/:rest*')"
],
"ok": true
}
]
}
+72
View File
@@ -0,0 +1,72 @@
{
"revision": "ed47836c9820c47bf4ed5e902d91e019abdb110a",
"data": [
{
"id": "M01-two-teapots-same-route",
"error": {
"name": "Error",
"message": "mesh: ambiguous remote route 'GET /api/dup/ping' from <teapot2> conflicts with 'GET /api/dup/ping' from <teapot1> — load balancing across teapots is not implemented yet, so green-tea will not choose one for you. Export it from a single teapot."
}
},
{
"id": "M02-two-teapots-same-shape",
"error": {
"name": "Error",
"message": "mesh: ambiguous remote route 'GET /api/shape/:name' from <teapot2> conflicts with 'GET /api/shape/:id' from <teapot1> — load balancing across teapots is not implemented yet, so green-tea will not choose one for you. Export it from a single teapot."
}
},
{
"id": "M03-local-same-shape-wins",
"ok": true,
"warnings": [
"mesh: route 'GET /api/dup/ping' is exported by teapot <teapot1> but also declared locally — the local route takes precedence and the remote one will not be reached. Remove one if that is not what you meant."
],
"responses": [
{
"path": "/api/dup/ping",
"status": 200,
"body": "{\"from\":\"local\"}"
}
]
},
{
"id": "M04-unique-remote",
"ok": true,
"warnings": [],
"responses": [
{
"path": "/api/dup/ping",
"status": 200,
"body": "{\"from\":\"teapot\"}"
},
{
"path": "/c/ok",
"status": 200,
"body": "{\"from\":\"teacup\"}"
},
{
"path": "/api/nope",
"status": 404,
"body": "{\"error\":\"Not Found\"}"
}
]
},
{
"id": "M05-remote-static-outranks-local-param",
"ok": true,
"warnings": [],
"responses": [
{
"path": "/api/dup/ping",
"status": 200,
"body": "{\"from\":\"teapot\"}"
},
{
"path": "/api/dup/x",
"status": 200,
"body": "{\"from\":\"local\",\"p\":{\"anything\":\"x\"}}"
}
]
}
]
}
@@ -0,0 +1,163 @@
{
"revision": "ed47836c9820c47bf4ed5e902d91e019abdb110a",
"data": [
{
"pattern": "/",
"shape": ""
},
{
"pattern": "/users/:id",
"shape": "s:users/p"
},
{
"pattern": "/users/:id(\\d+)",
"shape": "s:users/r:\\d+"
},
{
"pattern": "/files/:rest*",
"shape": "s:files/c"
},
{
"pattern": "/:rest*",
"shape": "c"
},
{
"pattern": "/t/",
"shape": "s:t"
},
{
"pattern": "/café",
"shape": "s:café"
},
{
"pattern": "/build/:version(\\d{2}\\.\\d{1,2})",
"shape": "s:build/r:\\d{2}\\.\\d{1,2}"
},
{
"pattern": "/x/:id/:id",
"error": {
"name": "Error",
"message": "invalid route pattern '/x/:id/:id': duplicate parameter 'id'"
}
},
{
"pattern": "/x/:id/:rest*/tail",
"error": {
"name": "Error",
"message": "invalid route pattern '/x/:id/:rest*/tail': catch-all must be the final segment"
}
},
{
"pattern": "/x/:rest*/:rest*",
"error": {
"name": "Error",
"message": "invalid route pattern '/x/:rest*/:rest*': catch-all must be the final segment"
}
},
{
"pattern": "/x/:",
"error": {
"name": "Error",
"message": "invalid route pattern '/x/:': invalid parameter name ''"
}
},
{
"pattern": "/x/:1x",
"error": {
"name": "Error",
"message": "invalid route pattern '/x/:1x': invalid parameter name '1x'"
}
},
{
"pattern": "/x//y",
"error": {
"name": "Error",
"message": "invalid route pattern '/x//y': repeated slash"
}
},
{
"pattern": "x",
"error": {
"name": "Error",
"message": "invalid route pattern 'x': pattern must start with '/'"
}
},
{
"pattern": "",
"error": {
"name": "Error",
"message": "invalid route pattern '': pattern must start with '/'"
}
},
{
"pattern": "/x/:id((a+)+)",
"error": {
"name": "Error",
"message": "unsafe route constraint: unsupported expression '(a+)+'"
}
},
{
"pattern": "/x/:id((?=a)a)",
"error": {
"name": "Error",
"message": "unsafe route constraint: unsupported expression '(?=a)a'"
}
},
{
"pattern": "/x/:id(\\1)",
"error": {
"name": "Error",
"message": "unsafe route constraint: unsupported expression '\\1'"
}
},
{
"pattern": "/x/:id(a|b)",
"error": {
"name": "Error",
"message": "unsafe route constraint: unsupported expression 'a|b'"
}
},
{
"pattern": "/x/:id(\\d+\\w+)",
"error": {
"name": "Error",
"message": "unsafe route constraint: adjacent unbounded quantifiers in '\\d+\\w+'"
}
},
{
"pattern": "/x/:id(\\d{5,2})",
"error": {
"name": "Error",
"message": "unsafe route constraint: invalid quantifier '{5,2}'"
}
},
{
"pattern": "/x/:id(\\d{1,4096})",
"error": {
"name": "Error",
"message": "unsafe route constraint: invalid quantifier '{1,4096}'"
}
},
{
"pattern": "/x/:id(\\d+",
"error": {
"name": "Error",
"message": "invalid route pattern '/x/:id(\\d+': malformed constraint"
}
},
{
"pattern": "/x/:id()",
"error": {
"name": "Error",
"message": "unsafe route constraint: expression must contain 1-128 characters"
}
},
{
"pattern": "/x/:id(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)",
"error": {
"name": "Error",
"message": "unsafe route constraint: expression must contain 1-128 characters"
}
}
]
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+214
View File
@@ -0,0 +1,214 @@
{
"revision": "ed47836c9820c47bf4ed5e902d91e019abdb110a",
"data": [
{
"id": "W01-overlap",
"declarations": [
{
"id": "param",
"pattern": "/ws/:id"
},
{
"id": "static",
"pattern": "/ws/static"
},
{
"id": "rest",
"pattern": "/ws/:rest*"
}
],
"outcomes": [
{
"path": "/ws/static",
"route": {
"id": "param",
"params": {
"id": "static"
}
}
},
{
"path": "/ws/x",
"route": {
"id": "param",
"params": {
"id": "x"
}
}
},
{
"path": "/ws/a%20b",
"route": {
"id": "param",
"params": {
"id": "a b"
}
}
},
{
"path": "/ws",
"route": {
"id": "rest",
"params": {
"rest": ""
}
}
},
{
"path": "/ws/x/y",
"route": {
"id": "rest",
"params": {
"rest": "x/y"
}
}
},
{
"path": "/w",
"route": null
},
{
"path": "/w/a%2Fb/c",
"route": null
},
{
"path": "/nope",
"route": null
}
]
},
{
"id": "W02-overlap-reversed",
"declarations": [
{
"id": "rest",
"pattern": "/ws/:rest*"
},
{
"id": "static",
"pattern": "/ws/static"
},
{
"id": "param",
"pattern": "/ws/:id"
}
],
"outcomes": [
{
"path": "/ws/static",
"route": {
"id": "rest",
"params": {
"rest": "static"
}
}
},
{
"path": "/ws/x",
"route": {
"id": "rest",
"params": {
"rest": "x"
}
}
},
{
"path": "/ws/a%20b",
"route": {
"id": "rest",
"params": {
"rest": "a b"
}
}
},
{
"path": "/ws",
"route": {
"id": "rest",
"params": {
"rest": ""
}
}
},
{
"path": "/ws/x/y",
"route": {
"id": "rest",
"params": {
"rest": "x/y"
}
}
},
{
"path": "/w",
"route": null
},
{
"path": "/w/a%2Fb/c",
"route": null
},
{
"path": "/nope",
"route": null
}
]
},
{
"id": "W03-catch-all-first",
"declarations": [
{
"id": "rest",
"pattern": "/w/:rest*"
},
{
"id": "exact",
"pattern": "/w"
}
],
"outcomes": [
{
"path": "/ws/static",
"route": null
},
{
"path": "/ws/x",
"route": null
},
{
"path": "/ws/a%20b",
"route": null
},
{
"path": "/ws",
"route": null
},
{
"path": "/ws/x/y",
"route": null
},
{
"path": "/w",
"route": {
"id": "rest",
"params": {
"rest": ""
}
}
},
{
"path": "/w/a%2Fb/c",
"route": {
"id": "rest",
"params": {
"rest": "a/b/c"
}
}
},
{
"path": "/nope",
"route": null
}
]
}
]
}
@@ -0,0 +1,151 @@
{
"revision": "ed47836c9820c47bf4ed5e902d91e019abdb110a",
"data": [
{
"path": "/live/lobby",
"sent": [
{
"id": "liveRoom",
"params": {
"room": "lobby"
}
}
],
"closes": [
{}
]
},
{
"path": "/live/kitchen",
"sent": [
{
"id": "liveRoom",
"params": {
"room": "kitchen"
}
}
],
"closes": [
{}
]
},
{
"path": "/live/lobby/",
"sent": [
{
"id": "liveRoom",
"params": {
"room": "lobby"
}
}
],
"closes": [
{}
]
},
{
"path": "/live/x/../lobby",
"sent": [
{
"id": "liveRoom",
"params": {
"room": "lobby"
}
}
],
"closes": [
{}
]
},
{
"path": "/live/a%20b",
"sent": [
{
"id": "liveRoom",
"params": {
"room": "a b"
}
}
],
"closes": [
{}
]
},
{
"path": "/live/lobby?x=1",
"sent": [
{
"id": "liveRoom",
"params": {
"room": "lobby"
}
}
],
"closes": [
{}
]
},
{
"path": "/live/%E0%A4%A",
"sent": [],
"closes": [
{
"code": 1008,
"reason": "invalid request path"
}
]
},
{
"path": "/live//lobby",
"sent": [],
"closes": [
{
"code": 1008,
"reason": "invalid request path"
}
]
},
{
"path": "/plain",
"sent": [],
"closes": [
{
"code": 1008,
"reason": "no matching ws route"
}
]
},
{
"path": "/nope",
"sent": [],
"closes": [
{
"code": 1008,
"reason": "no matching ws route"
}
]
},
{
"path": "/feed",
"sent": [
{
"id": "feed",
"params": {}
}
],
"closes": [
{}
]
},
{
"path": "/__mesh__/control",
"sent": [],
"closes": [
{
"code": 1008,
"reason": "mesh control channel not enabled: this app exports nothing, or has no mesh.secret"
}
]
}
]
}
@@ -0,0 +1,40 @@
{
"revision": "ed47836c9820c47bf4ed5e902d91e019abdb110a",
"data": [
{
"method": "GET",
"path": "/live/lobby",
"status": 405,
"allow": "POST, OPTIONS",
"body": "{\"error\":\"Method Not Allowed\"}"
},
{
"method": "POST",
"path": "/live/lobby",
"status": 200,
"allow": null,
"body": "{\"id\":\"httpLobby\"}"
},
{
"method": "OPTIONS",
"path": "/live/lobby",
"status": 204,
"allow": "POST, OPTIONS",
"body": ""
},
{
"method": "GET",
"path": "/live/kitchen",
"status": 404,
"allow": null,
"body": "{\"error\":\"Not Found\"}"
},
{
"method": "GET",
"path": "/feed",
"status": 200,
"allow": null,
"body": "{\"id\":\"feed\",\"params\":{}}\n"
}
]
}
@@ -0,0 +1,149 @@
{
"revision": "ed47836c9820c47bf4ed5e902d91e019abdb110a",
"data": [
{
"path": "/live/lobby",
"status": 101,
"sent": [
{
"id": "liveRoom",
"params": {
"room": "lobby"
}
}
],
"close": {
"code": 1005,
"reason": ""
}
},
{
"path": "/live/kitchen",
"status": 101,
"sent": [
{
"id": "liveRoom",
"params": {
"room": "kitchen"
}
}
],
"close": {
"code": 1005,
"reason": ""
}
},
{
"path": "/live/lobby/",
"status": 101,
"sent": [
{
"id": "liveRoom",
"params": {
"room": "lobby"
}
}
],
"close": {
"code": 1005,
"reason": ""
}
},
{
"path": "/live/x/../lobby",
"status": 101,
"sent": [
{
"id": "liveRoom",
"params": {
"room": "lobby"
}
}
],
"close": {
"code": 1005,
"reason": ""
}
},
{
"path": "/live/a%20b",
"status": 101,
"sent": [
{
"id": "liveRoom",
"params": {
"room": "a b"
}
}
],
"close": {
"code": 1005,
"reason": ""
}
},
{
"path": "/live/lobby?x=1",
"status": 101,
"sent": [
{
"id": "liveRoom",
"params": {
"room": "lobby"
}
}
],
"close": {
"code": 1005,
"reason": ""
}
},
{
"path": "/live/%E0%A4%A",
"status": 400,
"sent": []
},
{
"path": "/live//lobby",
"status": 400,
"sent": []
},
{
"path": "/plain",
"status": 404,
"sent": []
},
{
"path": "/nope",
"status": 404,
"sent": []
},
{
"path": "/feed",
"status": 101,
"sent": [
{
"id": "feed",
"params": {}
}
],
"close": {
"code": 1005,
"reason": ""
}
},
{
"path": "/__mesh__/control",
"status": 101,
"sent": [
{
"id": "reserved",
"params": {}
}
],
"close": {
"code": 1005,
"reason": ""
}
}
]
}
+121
View File
@@ -0,0 +1,121 @@
/**
* Fixed-seed route/path generator for the differential corpus.
*
* Its output is versioned with the fixture: `frozen/matcher-generated.json` stores the seed, the
* rules below and every generated declaration and request. The test regenerates from the seed and
* requires the result to equal the stored inputs, so a change to this file cannot quietly move the
* baseline — it fails until someone deliberately starts a new generator version.
*
* Do not edit GENERATOR_V1. A new generator is a new version with its own frozen file.
*/
import { compilePattern } from './oracle';
import type { Declaration, Request, Scenario, Transport } from './matcher';
export const GENERATOR_SEED = 10908;
export const GENERATOR_VERSION = 'router-parity-gen-v1';
export const GENERATOR_RULES = [
'PRNG: mulberry32(seed); every choice below draws from it in program order.',
'40 scenarios; each has 2-10 declarations and 12 requests.',
'Declaration: 0-3 segments, each static (a|b|c|x, p=0.5), plain param (p=0.25) or constrained param (p=0.25) ' +
'using one of \\d+ | [a-c]+ | [0-9a-f]{2}; then a final catch-all with p=0.2. Param names are p<index>.',
'Declaration method from GET x3, POST, PUT, DELETE, PATCH, HEAD, OPTIONS. A GET is buffer with p=0.7, else ' +
'sse | ndjson | negotiate; every other method is buffer.',
'Request path: p=0.6 instantiate a random declaration (static -> its literal, param -> value pool, catch-all -> ' +
'0-2 pool values), else 0-4 random pool segments. Value pool: a b c x 7 42 ff 0a a%20b caf%C3%A9 %34%32.',
'Request decoration: trailing slash p=0.15, a dot segment (/./ or /q/../) inserted p=0.1, a repeated slash p=0.05.',
'Request method from GET x2, HEAD, POST, PUT, DELETE, PATCH, OPTIONS.',
'Unsupported patterns are never produced: every generated pattern must pass compilePattern.',
];
const STATICS = ['a', 'b', 'c', 'x'];
const CONSTRAINTS = ['\\d+', '[a-c]+', '[0-9a-f]{2}'];
const VALUES = ['a', 'b', 'c', 'x', '7', '42', 'ff', '0a', 'a%20b', 'caf%C3%A9', '%34%32'];
const DECL_METHODS = ['GET', 'GET', 'GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS'];
const STREAMING: Transport[] = ['sse', 'ndjson', 'negotiate'];
const REQUEST_METHODS = ['GET', 'GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS'];
type Rng = () => number;
function mulberry32(seed: number): Rng {
let state = seed >>> 0;
return () => {
state = (state + 0x6d2b79f5) >>> 0;
let t = state;
t = Math.imul(t ^ (t >>> 15), t | 1);
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
};
}
const pick = <T>(rng: Rng, items: readonly T[]): T => items[Math.floor(rng() * items.length)];
const int = (rng: Rng, min: number, max: number): number => min + Math.floor(rng() * (max - min + 1));
function patternSegment(rng: Rng, index: number): string {
const roll = rng();
if (roll < 0.5) return pick(rng, STATICS);
if (roll < 0.75) return `:p${index}`;
return `:p${index}(${pick(rng, CONSTRAINTS)})`;
}
function declaration(rng: Rng, id: string): Declaration {
const depth = int(rng, 0, 3);
const segments = Array.from({ length: depth }, (_, index) => patternSegment(rng, index));
if (rng() < 0.2) segments.push(`:p${depth}*`);
const method = pick(rng, DECL_METHODS);
const transport: Transport = method === 'GET' && rng() >= 0.7 ? pick(rng, STREAMING) : 'buffer';
const pattern = `/${segments.join('/')}`;
compilePattern(pattern); // throws if a rule above ever produced an unsupported pattern
return { id, method, pattern, transport };
}
function instantiate(rng: Rng, decl: Declaration): string[] {
const segments: string[] = [];
for (const segment of decl.pattern.split('/').slice(1)) {
if (!segment) continue;
if (segment.endsWith('*')) {
const count = int(rng, 0, 2);
for (let index = 0; index < count; index++) segments.push(pick(rng, VALUES));
} else {
segments.push(segment.startsWith(':') ? pick(rng, VALUES) : segment);
}
}
return segments;
}
function decorate(rng: Rng, segments: string[]): string {
let path = `/${segments.join('/')}`;
if (rng() < 0.15 && path !== '/') path += '/';
if (rng() < 0.1) {
const at = int(rng, 0, segments.length);
const dots = rng() < 0.5 ? ['.'] : ['q', '..'];
const withDots = [...segments.slice(0, at), ...dots, ...segments.slice(at)];
path = `/${withDots.join('/')}`;
}
if (rng() < 0.05) path = path.replace('/', '//');
return path;
}
function request(rng: Rng, declarations: Declaration[]): Request {
const segments =
rng() < 0.6
? instantiate(rng, pick(rng, declarations))
: Array.from({ length: int(rng, 0, 4) }, () => pick(rng, VALUES));
return { method: pick(rng, REQUEST_METHODS), raw: decorate(rng, segments) };
}
export function generateScenarios(seed: number = GENERATOR_SEED): Scenario[] {
const rng = mulberry32(seed);
return Array.from({ length: 40 }, (_, index): Scenario => {
const id = `G${String(index + 1).padStart(2, '0')}`;
const declarations = Array.from({ length: int(rng, 2, 10) }, (_, d) => declaration(rng, `${id}.d${d + 1}`));
const requests = Array.from({ length: 12 }, () => request(rng, declarations));
return { id, note: `generated by ${GENERATOR_VERSION}, seed ${seed}`, declarations, requests };
});
}
+116
View File
@@ -0,0 +1,116 @@
/**
* Differential matcher parity (CARD-08 → CARD-07, #109).
*
* Every scenario runs through the frozen oracle and through the live `src/http/router` exports, and
* both must equal the outputs captured at the pinned revision. Today the live router *is* the
* linear matcher, so this proves the oracle is a faithful copy; once CARD-07 swaps the internals
* for a radix index behind the same exports, the same test compares oracle against radix with no
* edit here.
*/
import { describe, it, expect, beforeAll } from 'vitest';
import * as live from '../../src/http/router';
import { matchWsRoute as liveMatchWsRoute } from '../../src/http/ws-core';
import type { WsRouteDef } from '../../src/http/types';
import * as oracle from './oracle';
import { runScenario, type MatcherImpl, type Outcome, type Scenario } from './matcher';
import { HAND_SCENARIOS } from './cases';
import { generateScenarios, GENERATOR_RULES, GENERATOR_SEED, GENERATOR_VERSION } from './generator';
import { frozen, expectFrozenEqual } from './frozen';
const LIVE: MatcherImpl = live;
const ORACLE: MatcherImpl = oracle;
interface CapturedScenario extends Scenario {
outcomes: Outcome[];
}
interface GeneratedFile {
generator: string;
seed: number;
rules: string[];
scenarios: CapturedScenario[];
}
const capture = (scenarios: Scenario[]): CapturedScenario[] =>
scenarios.map((scenario) => ({ ...scenario, outcomes: runScenario(LIVE, scenario) }));
function checkScenario(scenario: Scenario, expected: CapturedScenario | undefined): void {
expect(expected, `${scenario.id} is missing from the frozen fixture`).toBeDefined();
const { outcomes, ...inputs } = expected!;
expectFrozenEqual(scenario, inputs, `${scenario.id} inputs`);
expectFrozenEqual(runScenario(ORACLE, scenario), outcomes, `${scenario.id} oracle`);
expectFrozenEqual(runScenario(LIVE, scenario), outcomes, `${scenario.id} live router`);
}
describe('router parity: hand-picked matcher cases', () => {
let expected: Map<string, CapturedScenario>;
beforeAll(async () => {
const data = await frozen('matcher-hand', () => capture(HAND_SCENARIOS));
expect(data.map((scenario) => scenario.id)).toEqual(HAND_SCENARIOS.map((scenario) => scenario.id));
expected = new Map(data.map((scenario) => [scenario.id, scenario]));
});
for (const scenario of HAND_SCENARIOS) {
it(`${scenario.id}: ${scenario.note}`, () => checkScenario(scenario, expected.get(scenario.id)));
}
});
describe(`router parity: generated matcher cases (${GENERATOR_VERSION}, seed ${GENERATOR_SEED})`, () => {
const generated = generateScenarios(GENERATOR_SEED);
let expected: Map<string, CapturedScenario>;
beforeAll(async () => {
const data = await frozen<GeneratedFile>('matcher-generated', () => ({
generator: GENERATOR_VERSION,
seed: GENERATOR_SEED,
rules: GENERATOR_RULES,
scenarios: capture(generated),
}));
expect({ generator: data.generator, seed: data.seed, rules: data.rules }).toEqual({
generator: GENERATOR_VERSION,
seed: GENERATOR_SEED,
rules: GENERATOR_RULES,
});
expect(data.scenarios.map((scenario) => scenario.id)).toEqual(generated.map((scenario) => scenario.id));
expected = new Map(data.scenarios.map((scenario) => [scenario.id, scenario]));
});
for (const scenario of generated) {
it(`${scenario.id}`, () => checkScenario(scenario, expected.get(scenario.id)));
}
});
describe('router parity: WebSocket matcher (first registered wins)', () => {
// WS selection is a separate contract from HTTP: no specificity ranking, registration order only.
// Paths are fed already normalized, as both upgrade adapters do since #117.
type WsDecl = WsRouteDef & { id: string };
type WsMatcher = (
routes: WsRouteDef[],
path: string,
) => { def: WsRouteDef; params: Record<string, string> | undefined } | undefined;
const ws = (id: string, pattern: string): WsDecl => ({ id, pattern, open: async () => (async function* () {})() });
const overlap = [ws('param', '/ws/:id'), ws('static', '/ws/static'), ws('rest', '/ws/:rest*')];
const scenarios = [
{ id: 'W01-overlap', routes: overlap },
{ id: 'W02-overlap-reversed', routes: [...overlap].reverse() },
{ id: 'W03-catch-all-first', routes: [ws('rest', '/w/:rest*'), ws('exact', '/w')] },
];
const paths = ['/ws/static', '/ws/x', '/ws/a%20b', '/ws', '/ws/x/y', '/w', '/w/a%2Fb/c', '/nope'];
const run = (matchWs: WsMatcher) =>
scenarios.map(({ id, routes }) => ({
id,
declarations: routes.map((route) => ({ id: route.id, pattern: route.pattern })),
outcomes: paths.map((path) => {
const hit = matchWs(routes, path);
return { path, route: hit ? { id: (hit.def as WsDecl).id, params: hit.params } : null };
}),
}));
it('oracle and live matchWsRoute equal the frozen capture', async () => {
const expected = await frozen('matcher-ws', () => run(liveMatchWsRoute));
expectFrozenEqual(run(oracle.matchWsRoute), expected, 'ws oracle');
expectFrozenEqual(run(liveMatchWsRoute), expected, 'ws live');
});
});
+107
View File
@@ -0,0 +1,107 @@
/**
* The differential matcher harness: one ordered declaration array and one request list, run through
* any implementation of the router's lookup functions, reduced to what a caller can observe —
* which declaration answered (by stable ID, never by pattern text), its decoded params, whether HEAD
* was implicit, the ordered `Allow` list, and the normalization error if the path never got that far.
*/
import type { RouteDef } from '../../src/http/types';
export type Transport = 'buffer' | 'sse' | 'ndjson' | 'negotiate';
export interface Declaration {
id: string;
method: string;
pattern: string;
transport: Transport;
}
export interface Request {
method: string;
raw: string;
}
export interface Scenario {
id: string;
note: string;
declarations: Declaration[];
requests: Request[];
}
/** The lookup surface CARD-07 replaces. The live router and the frozen oracle both satisfy it. */
export interface MatcherImpl {
normalizeRequestPath(path: string): string;
matchRoute(
routes: RouteDef[],
method: string,
path: string,
): { def: unknown; params: Record<string, string> } | undefined;
resolveRoute(
routes: RouteDef[],
method: string,
path: string,
): { def: unknown; params: Record<string, string>; implicitHead: boolean } | undefined;
allowedMethods(routes: RouteDef[], path: string): string[];
}
export interface ErrorOutcome {
name: string;
message: string;
}
export interface Outcome {
method: string;
raw: string;
normalized?: string;
error?: ErrorOutcome;
match?: { id: string; params: Record<string, string> } | null;
resolve?: { id: string; params: Record<string, string>; implicitHead: boolean } | null;
allow?: string[];
}
export function errorOutcome(error: unknown): ErrorOutcome {
const err = error as Error;
return { name: err.name, message: err.message };
}
/** Builds fresh `RouteDef` objects for one run, so no implementation can see another's cached table. */
function buildRoutes(declarations: Declaration[]): { routes: RouteDef[]; idOf: Map<unknown, string> } {
const idOf = new Map<unknown, string>();
const routes = declarations.map((decl): RouteDef => {
const def: RouteDef = {
method: decl.method,
pattern: decl.pattern,
transport: decl.transport,
handler: async () => ({ status: 200, headers: {}, body: decl.id }),
};
idOf.set(def, decl.id);
return def;
});
return { routes, idOf };
}
export function runScenario(impl: MatcherImpl, scenario: Scenario): Outcome[] {
const { routes, idOf } = buildRoutes(scenario.declarations);
const id = (def: unknown): string => idOf.get(def) ?? '<unknown declaration>';
return scenario.requests.map(({ method, raw }): Outcome => {
let normalized: string;
try {
normalized = impl.normalizeRequestPath(raw);
} catch (error) {
return { method, raw, error: errorOutcome(error) };
}
const match = impl.matchRoute(routes, method, normalized);
const resolved = impl.resolveRoute(routes, method, normalized);
return {
method,
raw,
normalized,
match: match ? { id: id(match.def), params: match.params } : null,
resolve: resolved ? { id: id(resolved.def), params: resolved.params, implicitHead: resolved.implicitHead } : null,
allow: impl.allowedMethods(routes, normalized),
};
});
}
+183
View File
@@ -0,0 +1,183 @@
/**
* WebSocket upgrade parity, kept apart from HTTP on purpose: WS selection is first-registered-wins
* with no specificity ranking, an HTTP route at the same path never takes the upgrade, and the mesh
* control path is checked before WS route matching. Captured through both upgrade entry points —
* `app.upgrade` (Deno/Bun/edge) and the Node `server.on('upgrade')` listener — because they are
* separate code paths and do not agree on everything (see the reserved-path rows in the fixture).
*/
import 'reflect-metadata';
import type { AddressInfo } from 'net';
import WebSocket from 'ws';
import { describe, it, beforeAll, afterAll } from 'vitest';
import { createApp, Route, Get, Post, Ws, Stream, Module, param } from '../../src/index';
import { channel } from '../../src/channel';
import type { App } from '../../src/app/types';
import type { WsRequest, WsSocket } from '../../src/http/ws-core';
import { frozen, expectFrozenEqual } from './frozen';
const announce = (id: string, params: Record<string, string>) =>
(async function* () {
yield { id, params };
})();
@Route('/')
class ParityWs {
// Registered before the static twin: WS does not rank, so this one answers /live/lobby.
@Ws('/live/:room') liveRoom(@param() p: Record<string, string>) {
return announce('liveRoom', p);
}
@Ws('/live/lobby') liveLobby(@param() p: Record<string, string>) {
return announce('liveLobby', p);
}
// Same path as the WS routes, different method, so the boot accepts it; it must not take upgrades.
@Post('/live/lobby') httpLobby() {
return { id: 'httpLobby' };
}
@Get('/plain') plain() {
return { id: 'plain' };
}
// `negotiate` routes are registered for both HTTP and WS.
@Stream('/feed') feed() {
return announce('feed', {});
}
// A user route on the reserved mesh path, on an app with no mesh: the two adapters disagree here.
@Ws('/__mesh__/control') reserved(@param() p: Record<string, string>) {
return announce('reserved', p);
}
}
@Module({ mountpoint: '/', controllers: [ParityWs] })
class ParityWsModule {}
// The `ws` client runs its URL through the URL parser, so on the Node rows dot segments are already
// resolved before the server sees them; `app.upgrade` receives each path exactly as written here.
const UPGRADE_PATHS = [
'/live/lobby',
'/live/kitchen',
'/live/lobby/',
'/live/x/../lobby',
'/live/a%20b',
'/live/lobby?x=1',
'/live/%E0%A4%A',
'/live//lobby',
'/plain',
'/nope',
'/feed',
'/__mesh__/control',
];
const HTTP_REQUESTS: Array<[string, string]> = [
['GET', '/live/lobby'],
['POST', '/live/lobby'],
['OPTIONS', '/live/lobby'],
['GET', '/live/kitchen'],
['GET', '/feed'],
];
interface UpgradeOutcome {
path: string;
sent: unknown[];
closes: Array<{ code?: number; reason?: string }>;
}
async function viaAppUpgrade(app: App, path: string): Promise<UpgradeOutcome> {
const inbound = channel<unknown>();
const ac = new AbortController();
const sent: unknown[] = [];
const closes: Array<{ code?: number; reason?: string }> = [];
let open = true;
const socket: WsSocket = {
inbound,
abort: ac.signal,
get isOpen() {
return open;
},
send: (data) => sent.push(JSON.parse(data)),
close: (code, reason) => {
open = false;
closes.push({ code, reason });
ac.abort();
},
terminate: () => {
open = false;
ac.abort();
},
};
const request: WsRequest = { url: path, headers: {}, protocol: 'http', ip: '127.0.0.1' };
await app.upgrade(request, socket);
return { path, sent, closes };
}
interface NodeUpgradeOutcome {
path: string;
status?: number;
sent: unknown[];
close?: { code: number; reason: string };
}
function viaNodeUpgrade(port: number, path: string): Promise<NodeUpgradeOutcome> {
return new Promise((resolve) => {
const sent: unknown[] = [];
const client = new WebSocket(`ws://127.0.0.1:${port}${path}`);
client.on('unexpected-response', (_req, res) => {
resolve({ path, status: res.statusCode, sent });
res.resume();
client.terminate();
});
client.on('message', (data) => sent.push(JSON.parse(String(data))));
client.on('close', (code, reason) => resolve({ path, status: 101, sent, close: { code, reason: String(reason) } }));
client.on('error', () => {
/* reported through unexpected-response or close */
});
});
}
describe('router parity: WebSocket upgrade outcomes', () => {
let app: App;
let nodeApp: App;
let port: number;
beforeAll(async () => {
app = createApp({ modules: [ParityWsModule] });
nodeApp = createApp({ modules: [ParityWsModule] });
const server = await nodeApp.listen(0);
port = (server.address() as AddressInfo).port;
});
afterAll(async () => {
await nodeApp.close();
});
it('app.upgrade outcomes equal the frozen capture', async () => {
const run = async () => {
const out: UpgradeOutcome[] = [];
for (const path of UPGRADE_PATHS) out.push(await viaAppUpgrade(app, path));
return out;
};
const expected = await frozen('ws-app-upgrade', run);
expectFrozenEqual(await run(), expected, 'app.upgrade');
});
it('Node upgrade listener outcomes equal the frozen capture', async () => {
const run = async () => {
const out: NodeUpgradeOutcome[] = [];
for (const path of UPGRADE_PATHS) out.push(await viaNodeUpgrade(port, path));
return out;
};
const expected = await frozen('ws-node-upgrade', run);
expectFrozenEqual(await run(), expected, 'node upgrade');
});
it('plain HTTP requests at the WS paths equal the frozen capture', async () => {
const run = async () => {
const out: Array<{ method: string; path: string; status: number; allow: string | null; body: string }> = [];
for (const [method, path] of HTTP_REQUESTS) {
const res = await app.fetch(new Request(`http://parity.test${path}`, { method }));
out.push({ method, path, status: res.status, allow: res.headers.get('allow'), body: await res.text() });
}
return out;
};
const expected = await frozen('ws-http-same-path', run);
expectFrozenEqual(await run(), expected, 'http at ws paths');
});
});