mirror of
https://github.com/fosrl/pangolin.git
synced 2026-12-03 03:37:19 +00:00
30 lines
923 B
TypeScript
30 lines
923 B
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import {
|
|
BROWSER_GATEWAY_TRUST_HEADER,
|
|
buildPHostHeaders,
|
|
deriveBrowserGatewayTrustToken
|
|
} from "./browserGatewayTrust";
|
|
|
|
test("p-host trust header", () => {
|
|
const withSecret = buildPHostHeaders("s3cret", "app.example.com");
|
|
assert.equal(withSecret["p-host"], "app.example.com", "p-host is set");
|
|
assert.equal(
|
|
withSecret[BROWSER_GATEWAY_TRUST_HEADER],
|
|
deriveBrowserGatewayTrustToken("s3cret"),
|
|
"trust token is stamped"
|
|
);
|
|
assert.equal(
|
|
deriveBrowserGatewayTrustToken("a") ===
|
|
deriveBrowserGatewayTrustToken("b"),
|
|
false,
|
|
"tokens differ per secret"
|
|
);
|
|
|
|
const noSecret = buildPHostHeaders(undefined, "app.example.com");
|
|
assert.equal(
|
|
BROWSER_GATEWAY_TRUST_HEADER in noSecret,
|
|
false,
|
|
"no token without a secret"
|
|
);
|
|
});
|