The Capture, Map and Bind steps read the module's captures, event types, mappings and triggers. A binding is a trigger bound to an event type; the sources panel creates HMAC sources and shows each delivery's verification result. The workspace filter is removed: the binary has one workspace per organisation and the data carries none.
71 lines
2.3 KiB
TypeScript
71 lines
2.3 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { captureSignature } from "../src/captures/capture-signature.ts";
|
|
import {
|
|
signingKind,
|
|
signingLabel,
|
|
sourceURL,
|
|
} from "../src/sources/source-signing.ts";
|
|
import { describeTimelineEvent } from "../src/tasks/timeline-event.ts";
|
|
|
|
test("a capture shows how it may dispatch", () => {
|
|
const cases: Array<[{ verification?: string }, string, string]> = [
|
|
[{ verification: "signed" }, "Signed", "ok"],
|
|
[{ verification: "token" }, "Token", "ok"],
|
|
[{ verification: "unsigned" }, "Unsigned", "warn"],
|
|
[{}, "Unverified", "idle"],
|
|
[{ verification: "" }, "Unverified", "idle"],
|
|
];
|
|
for (const [capture, label, kind] of cases) {
|
|
assert.deepEqual(
|
|
captureSignature(capture),
|
|
{ label, kind },
|
|
JSON.stringify(capture),
|
|
);
|
|
}
|
|
});
|
|
|
|
test("a source's signing state names itself and its tone", () => {
|
|
const cases: Array<[string | undefined, string, string]> = [
|
|
["signed", "signed", "ok"],
|
|
["token", "bearer token", "ok"],
|
|
["unsigned_pending_approval", "unsigned pending approval", "info"],
|
|
["unsigned", "unsigned", "warn"],
|
|
["something_new", "something_new", "idle"],
|
|
[undefined, "unknown", "idle"],
|
|
];
|
|
for (const [signing, label, kind] of cases) {
|
|
assert.equal(signingLabel(signing), label, String(signing));
|
|
assert.equal(signingKind(signing), kind, String(signing));
|
|
}
|
|
});
|
|
|
|
test("a source's URL escapes nothing a valid path can hold", () => {
|
|
assert.equal(
|
|
sourceURL("https://archie.example", "0199a0b2-0000-7000-8000-000000000000"),
|
|
"https://archie.example/hooks/0199a0b2-0000-7000-8000-000000000000",
|
|
);
|
|
assert.equal(sourceURL("http://h", "a b"), "http://h/hooks/a%20b");
|
|
});
|
|
|
|
test("a task started by an unsigned event says so on its timeline", () => {
|
|
const line = describeTimelineEvent({
|
|
kind: "binding_started",
|
|
data: { source: "firewall", binding_name: "fw", capture_id: "c1", unsigned: true },
|
|
});
|
|
assert.deepEqual(line, {
|
|
title: "Started by an unsigned event",
|
|
detail: "source firewall",
|
|
tone: "warn",
|
|
links: [
|
|
{ label: "binding fw", to: "/events?tab=bindings" },
|
|
{ label: "captured event", to: "/events?tab=inspector&capture=c1" },
|
|
],
|
|
});
|
|
assert.equal(
|
|
describeTimelineEvent({ kind: "stage_start", stage: "plan" }).tone,
|
|
undefined,
|
|
);
|
|
});
|