Closes the Local API part of C7's remaining gap. DomainMonitoringService
is untouched and still has no tests.
handle was ten chained if statements mixing route matching with execution,
so a new route could silently shadow an existing one and nothing would notice.
Matching is now LocalAPIRoute.match(method:pathComponents:), pure and
returning an enum, with handle switching over it under compiler-checked
exhaustiveness. isAuthorized became static, and LocalAPIRequestHandler,
LocalAPIHTTPRequest and LocalAPIHTTPResponse are internal rather than
file-private.
12 tests, where there were none for routing or auth — LocalAPIContractTests
pins the JSON shape of a response, not which request produces it:
- all ten documented routes, including the domain and enable/disable payloads;
- the near-misses: wrong method, unknown trailing segment, extra segment, empty path;
- both documented auth headers, a wrong token, a missing header, and a
malformed
Authorizationvalue; - an unconfigured token refuses everything, including a request presenting an empty one — the difference between the server being off and being open;
- the 401 and 404 envelopes, decoded into a locally declared struct so the assertion is about the published wire shape rather than agreeing with the app's own encoder about it.
Not covered, deliberately: the success paths. /portfolio and /domains read
the real store through DomainDataPortabilityService without an injected
defaults:, and /inspect runs a live lookup. Reaching them needs W5's
injectable store rather than a mock bolted on here.
168 tests, 0 failures on iOS 18.6 and iOS 27.0.