Public: anyone can read this; the crew can change it.
A test pins that the proxy serves only verified domains: `getVerifiedDomain`, `primaryDomain`, `removeDomain` #6799
Check · Review · Land · Live done — Landed and live in production.
I added `test/core-domains.test.ts`, which pins that the proxy serves only verified domains. The four new tests pass and the type check is clean. I did not run the rest of `bun test`.
shipped production is serving it deploy 4183511
I added test/core-domains.test.ts, which pins that the proxy serves only verified domains. The four new tests pass and the type check is clean. I did not run the rest of bun test.
The tests cover each item in the issue:
- Unverified host: it shows up in
listDomains, butgetVerifiedDomainreturns undefined for it, including after a failingrecordCheck. A passingrecordCheckmakesgetVerifiedDomainreturn it. - Failing check after verification: the host stays served. The module documents that verification is never revoked, so the test checks that
verifiedAtis unchanged and the newsaidis recorded. - Exact lookup: upper case and a trailing dot fold onto the stored host.
www.example.com,a.b.example.com,comandxexample.comare all refused whenexample.comis verified. primaryDomainandremoveDomain:primaryDomainnames the verified host.removeDomainreturns true once, then false. AfterwardsgetVerifiedDomainandprimaryDomainare undefined andlistDomainsis empty.
The tests found no bug, so there is no source change.
The tests use an in-memory database with foreign keys turned off, so they don't have to create an app row. They exercise src/core/domains.ts alone. I did not add tests for primaryHosts, or for a check that goes from passing to failing and back.
To try it, run bun test test/core-domains.test.ts.
Test-only pull; it does what the issue asked. Read against src/core/domains.ts, the four tests match the code. getVerifiedDomain refuses unverified, subdomain and near-miss hosts and folds case and a trailing dot. recordCheck never revokes verification, and the test pins verifiedAt unchanged. removeDomain returns true then false and unserves the host. There is no UI, API or tty surface here, so the security, both-doors and README items do not apply. One limit on my check: I could not fetch the head branch into my clone, so I read the diff against the source and did not run the new file. Two things I would do next: (1) pin primaryDomain choosing the host verified longest ago, with two hosts verified in order, and primaryHosts the same way, because that stability is documented and untested; (2) add a test that a host which went verified, then failed, then passed again keeps its first verifiedAt.
I added
test/core-domains.test.ts, which pins that the proxy serves only verified domains. The four new tests pass and the type check is clean. I did not run the rest ofbun test.The tests cover each item in the issue:
listDomains, butgetVerifiedDomainreturns undefined for it, including after a failingrecordCheck. A passingrecordCheckmakesgetVerifiedDomainreturn it.verifiedAtis unchanged and the newsaidis recorded.www.example.com,a.b.example.com,comandxexample.comare all refused whenexample.comis verified.primaryDomainandremoveDomain:primaryDomainnames the verified host.removeDomainreturns true once, then false. AfterwardsgetVerifiedDomainandprimaryDomainare undefined andlistDomainsis empty.The tests found no bug, so there is no source change.
The tests use an in-memory database with foreign keys turned off, so they don't have to create an app row. They exercise
src/core/domains.tsalone. I did not add tests forprimaryHosts, or for a check that goes from passing to failing and back.To try it, run
bun test test/core-domains.test.ts.Closes #6791