impl/js (Node, zero deps, written from the specs): parser, v0.2 statute-aware rules, signing, outside master. Passes addresses.json, statute-aware.json and auth.json unchanged; its master passes the 11 slave-setup mode flows against the Python email side (ExternalMaster). Differential testing vs mas_core found two unstated stand-in rules, now SCP-9 in the v0.2 draft with fixtures si-011..013, dt-109; ABNF comments no longer say v0.1. Runner: external masters, step errors fail the flow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Assistant: claude-code Assistant-Model: opus Assistant-Process: 5787@bnt-lap001 Assistant-Session: 5db26b82-138b-40cc-9856-4d5eb0f752fd
31 lines
1.3 KiB
JavaScript
31 lines
1.3 KiB
JavaScript
// mas-v0.2-spec/conformance/addresses.json, consumed unchanged (CONFORMANCE.md section 2).
|
|
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import { parseLocalPart, MasSyntaxError } from "../src/parser.mjs";
|
|
|
|
const BUNDLE = new URL("../../../mas-v0.2-spec/", import.meta.url);
|
|
const fixtures = JSON.parse(readFileSync(new URL("conformance/addresses.json", BUNDLE)));
|
|
|
|
for (const f of fixtures) {
|
|
test(`${f.id} ${JSON.stringify(f.local_part)} (${f.profile})`, () => {
|
|
let got;
|
|
try {
|
|
got = parseLocalPart(f.local_part, f.profile);
|
|
} catch (e) {
|
|
assert.ok(e instanceof MasSyntaxError, e);
|
|
assert.equal(f.valid, false, `rejected (${e.code}) but fixture is valid`);
|
|
return;
|
|
}
|
|
assert.equal(f.valid, true, `accepted but fixture is invalid (${f.error})`);
|
|
const { required_profile, generator_allowed, ...parsed } = got;
|
|
assert.deepEqual(parsed, f.parsed);
|
|
if ("generator_allowed" in f) assert.equal(generator_allowed, f.generator_allowed);
|
|
});
|
|
}
|
|
|
|
test("a P2 parser also passes every P1 fixture (CONFORMANCE.md 2)", () => {
|
|
for (const f of fixtures.filter((x) => x.profile === "p1" && x.valid)) {
|
|
assert.deepEqual((({ required_profile, generator_allowed, ...p }) => p)(parseLocalPart(f.local_part, "p2")), f.parsed);
|
|
}
|
|
});
|