33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
/**
|
|
* §16 conformance proof at the package level — the static-principal
|
|
* resolver MUST pass `runAuthSessionConformance` from
|
|
* `@suaveplan/api-auth/testing` with both seed paths populated. Seeded
|
|
* with a known Principal so the harness exercises the "recognised request"
|
|
* scenario; `nullForPaths` lets the harness assert the "unrecognised"
|
|
* scenario without rewiring the factory.
|
|
*/
|
|
import { runAuthSessionConformance } from "@suaveplan/api-auth/testing";
|
|
import type { Principal } from "@suaveplan/api-types/principal";
|
|
import { createStaticPrincipalResolver } from "../../src/factory/create-static-principal-resolver.js";
|
|
|
|
const P: Principal = {
|
|
id: "u_pkg_conf" as Principal["id"],
|
|
scopes: ["billing:write" as Principal["scopes"][number]],
|
|
tenantId: "acme" as Principal["tenantId"],
|
|
claims: { sub: "u_pkg_conf" },
|
|
};
|
|
|
|
runAuthSessionConformance({
|
|
label: "api-auth-static-principal",
|
|
factory: () =>
|
|
createStaticPrincipalResolver({
|
|
principal: P,
|
|
nullForPaths: ["/__public/*"],
|
|
}),
|
|
seedNull: () => new Request("https://example.test/__public/health"),
|
|
seedPrincipal: () => ({
|
|
request: new Request("https://example.test/api/billing/invoices"),
|
|
expected: P,
|
|
}),
|
|
});
|