diff --git a/lib/admin/__tests__/config-keys-read.test.ts b/lib/admin/__tests__/config-keys-read.test.ts new file mode 100644 index 000000000..308bc269f --- /dev/null +++ b/lib/admin/__tests__/config-keys-read.test.ts @@ -0,0 +1,31 @@ +// @vitest-environment node +import { describe, expect, it } from 'vitest'; +import { readdirSync, readFileSync, statSync } from 'node:fs'; +import path from 'node:path'; +import { CONFIG_ENV_MAP } from '../types'; + +const ROOT = path.resolve(__dirname, '../../..'); +const SKIP = new Set(['node_modules', '.next', '.git', 'repos', 'local-data', 'integration', '__tests__', 'out', 'public']); + +function sourceFiles(dir = ROOT, out: string[] = []): string[] { + for (const name of readdirSync(dir)) { + if (SKIP.has(name)) continue; + const full = path.join(dir, name); + if (statSync(full).isDirectory()) sourceFiles(full, out); + else if (/\.(ts|tsx|mjs)$/.test(name)) out.push(full); + } + return out; +} + +describe('admin config map', () => { + // A key in the map shows up in the admin API and can be saved, so one that + // nothing reads is a setting that silently does nothing. + it('has no key that nothing outside the map reads', () => { + const typesFile = path.join(ROOT, 'lib', 'admin', 'types.ts'); + const texts = sourceFiles().filter((f) => f !== typesFile).map((f) => readFileSync(f, 'utf8')); + const unread = Object.keys(CONFIG_ENV_MAP).filter( + (key) => !texts.some((text) => new RegExp(`\\b${key}\\b`).test(text)), + ); + expect(unread).toEqual([]); + }); +}); diff --git a/lib/admin/outgoing-hosts-registry.ts b/lib/admin/outgoing-hosts-registry.ts index 3c91d7c44..d4a2901dd 100644 --- a/lib/admin/outgoing-hosts-registry.ts +++ b/lib/admin/outgoing-hosts-registry.ts @@ -77,7 +77,7 @@ export const OUTGOING_HOSTS: readonly OutgoingHost[] = [ { id: 'connector', host: 'connector.bulwarkmail.org', - files: ['lib/admin/types.ts', 'lib/connector/registry.ts'], + files: ['lib/connector/registry.ts'], side: 'server', usedBy: 'Links in the docs and the directory that open this instance; the connector asks this server what it can open.', off: 'CONNECTOR_ENABLED=false.', diff --git a/lib/admin/types.ts b/lib/admin/types.ts index fcf317f33..fb35d3954 100644 --- a/lib/admin/types.ts +++ b/lib/admin/types.ts @@ -374,13 +374,12 @@ export const CONFIG_ENV_MAP: Record. connectorEnabled: { envVar: 'CONNECTOR_ENABLED', type: 'boolean', defaultValue: true }, - connectorUrl: { envVar: 'CONNECTOR_URL', type: 'url', defaultValue: 'https://connector.bulwarkmail.org' }, // Fail-closed "no third-party traffic" mode (#903): every built-in outside // host in lib/outgoing-hosts.ts is off (telemetry, version check, the // built-in push relay, the official extension directory, the connector,