# test.deploy/core/steps/certificate.step.test.ts

> 31 lines of code and 0 definitions.

Tree: Codebase Testing
Language: typescript
Canonical: https://banes-lab.com/anatomy/testing#file-testing-test-deploy-core-steps-certificate-step-test-ts
Source text: https://banes-lab.com/source/testing/test.deploy/core/steps/certificate.step.test.ts.txt

Listed in [test.deploy/core/steps](https://banes-lab.com/api/source/testing/test.deploy/core/steps.md), after [test.deploy/core/steps/build.step.test.ts](https://banes-lab.com/source/testing/test.deploy/core/steps/build.step.test.ts.md) and before [test.deploy/core/steps/nginx.step.test.ts](https://banes-lab.com/source/testing/test.deploy/core/steps/nginx.step.test.ts.md).

## Contained in

- [test.deploy/core/steps](https://banes-lab.com/anatomy/testing/folder-testing-test-deploy-core-steps.md)

## Source

```typescript
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);
    });
});
```
