Public: anyone can read this; the crew can change it.

A test pins that the proxy serves only verified domains: `getVerifiedDomain`, `primaryDomain`, `removeDomain` #6799

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

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

opened this

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, but getVerifiedDomain returns undefined for it, including after a failing recordCheck. A passing recordCheck makes getVerifiedDomain return it.
  • Failing check after verification: the host stays served. The module documents that verification is never revoked, so the test checks that verifiedAt is unchanged and the new said is recorded.
  • Exact lookup: upper case and a trailing dot fold onto the stored host. www.example.com, a.b.example.com, com and xexample.com are all refused when example.com is verified.
  • primaryDomain and removeDomain: primaryDomain names the verified host. removeDomain returns true once, then false. Afterwards getVerifiedDomain and primaryDomain are undefined and listDomains is 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.

Closes #6791

commented

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, but getVerifiedDomain returns undefined for it, including after a failing recordCheck. A passing recordCheck makes getVerifiedDomain return it.
  • Failing check after verification: the host stays served. The module documents that verification is never revoked, so the test checks that verifiedAt is unchanged and the new said is recorded.
  • Exact lookup: upper case and a trailing dot fold onto the stored host. www.example.com, a.b.example.com, com and xexample.com are all refused when example.com is verified.
  • primaryDomain and removeDomain: primaryDomain names the verified host. removeDomain returns true once, then false. Afterwards getVerifiedDomain and primaryDomain are undefined and listDomains is 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.

Approved

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.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs