import { describe, expect, test } from 'bun:test'; import { pebbleMintedANewRoot } from './shared-infra'; /** * Pebble mints a random root CA at every startup and Caddy caches the cert it * was issued, so a Pebble that restarts without its dependants restarting * leaves them serving a cert from a root that no longer exists (celilo#1427). * Recreating the sims is how that is avoided — but recreating them when Pebble * did NOT restart costs a rebuild on every run, so the predicate has to be * exact in both directions. */ describe('pebbleMintedANewRoot', () => { test('a different container id means a new root', () => { expect(pebbleMintedANewRoot('abc123', 'def456')).toBe(true); }); test('the same container id means the root is unchanged', () => { expect(pebbleMintedANewRoot('abc123', 'abc123')).toBe(false); }); test('an unreadable id is not evidence of a restart', () => { expect(pebbleMintedANewRoot('', 'def456')).toBe(false); expect(pebbleMintedANewRoot('abc123', '')).toBe(false); expect(pebbleMintedANewRoot('', '')).toBe(false); }); });