test.deploy/core/steps/certificate.step.test.ts
test.deploy/core/steps/certificate.step.test.ts is a file in Codebase Testing. 31 lines of code and 0 definitions.
import {
DANE_REMEDY,
PROBE_DANE_PASSED,
daneMismatch,
} from "@banes-lab/deploy/configuration/strings/deployment.strings.ts";
import { describe, expect, it } from "vitest";
import type { DaneKeys } from "@banes-lab/deploy/types/deployment.types.ts";
import { fakeJournal } from "./shell.fixture.ts";
import { probeCertificate } from "@banes-lab/deploy/core/steps/certificate.step.ts";
const SITE = "https://x.test";
const NAME = "_443._tcp.x.test";
const SERVED = "ab".repeat(32);
describe("probeCertificate", () => {
it("passes when a published 3 1 1 record names the served key digest", async () => {
const journal = fakeJournal();
const sites: string[] = [];
const reader = async (site: string): Promise<DaneKeys> => {
sites.push(site);
return Promise.resolve({ name: NAME, published: ["cd".repeat(32), SERVED], served: SERVED });
};
await probeCertificate(journal, SITE, reader);
expect(sites).toStrictEqual([SITE]);
expect(journal.lines).toContain(PROBE_DANE_PASSED);
});
it("fails with the record name, the served digest and the remedy when no record names it", async () => {
const reader = async (): Promise<DaneKeys> => Promise.resolve({ name: NAME, published: [], served: SERVED });
const failure = probeCertificate(fakeJournal(), SITE, reader);
await expect(failure).rejects.toThrow(daneMismatch(NAME, SERVED, []));
await expect(probeCertificate(fakeJournal(), SITE, reader)).rejects.toThrow(DANE_REMEDY);
});
});