Repository navigation
fix(cdn): move a Fastly domain to the configured service before requesting its certificate - #303
Conversation
…sting its certificate A domain attached to another service was moved only once its TLS subscription reported issued. A fresh subscription is always pending, so the move almost never happened on that call, and nothing revisits it: the consumer's status sync marks the rule verified when the certificate issues but never touches the domain record. Hostnames stayed on the old service for good. The service decides routing only; the subscription belongs to the account and follows the hostname. Issuance is requested by the one rule that owns the domain, after its DNS verified, so the configured service is where the hostname belongs whatever the certificate is doing. Reassign first, then run the subscription flow. A refused PATCH throws before any TLS call, so the next attempt finds the same state and retries the move. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
| $this->assertCount(3, $client->calls); | ||
| $this->assertSame('PATCH', $client->calls[1]['method']); | ||
| $this->assertSame('https://api.fastly.com/domain-management/v1/domains/domain_1', $client->calls[1]['url']); | ||
| $this->assertSame(['service_id' => 'new_service'], $client->calls[1]['body']); | ||
| $this->assertStringStartsWith('https://api.fastly.com/tls/subscriptions?', $client->calls[2]['url']); |
There was a problem hiding this comment.
Tests mirror HTTP choreography
These tests hard-code exact call counts, array positions, methods, URLs, payloads, and ordering. This violates the repository directive to test observable behavior instead of mirroring source implementation. An equivalent client refactor would fail these tests even if domain ownership and certificate behavior stayed correct, while the canned response queue still does not prove the resulting provider state. Replace this request choreography with a stateful fake that verifies the resulting domain ownership and TLS behavior. The same problem appears in the pending, reassignment-failure, and TLS-failure cases. This repository requirement must be satisfied before merging.
Context Used: Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/cdn/tests/Cdn/Certificates/Provider/FastlyTest.php
Line: 76-80
Comment:
**Tests mirror HTTP choreography**
These tests hard-code exact call counts, array positions, methods, URLs, payloads, and ordering. This violates the repository directive to test observable behavior instead of mirroring source implementation. An equivalent client refactor would fail these tests even if domain ownership and certificate behavior stayed correct, while the canned response queue still does not prove the resulting provider state. Replace this request choreography with a stateful fake that verifies the resulting domain ownership and TLS behavior. The same problem appears in the pending, reassignment-failure, and TLS-failure cases. This repository requirement must be satisfied before merging.
**Context Used:** Call out and harshly judge implementation-coupled tests. We don't mirror source code, configuration, or version pins in assertions. We test observable behavior; use linters for syntax and schema checks. ([source](https://app.greptile.com/review/custom-context?memory=instruction-0))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
…tions' into fix/cdn-fastly-reassign-before-tls # Conflicts: # packages/cdn/src/Cdn/Certificates/Provider/Fastly.php
5a36d83
into
fix/cdn-fastly-blocked-authorizations
Stacked on #300 so the diff is only this change; the base switches to
mainonce that merges. #222 rewrites the same block for orphaned domains and will conflict with either.Problem
In
Fastly::issueCertificate, a versionless domain attached to another service was moved only after its TLS subscription reportedissuedorrenewing. A fresh subscription is alwayspending, so on the call that creates it the move is skipped, and nothing revisits it: the consumer's status sync marks the rule verified once the certificate issues but never touches the domain record, and a verified rule does not request issuance again.isRenewRequireddoes report true for the wrong service, but only maintenance asks it, and only for rows whose renew date has passed. So a hostname that arrives on the wrong service stays there until someone moves it by hand.The gate was guarding against a coupling that does not exist.
service_idon a domain-management record decides which service's origin answers the hostname, nothing more. The TLS subscription belongs to the account and a TLS configuration, keyed by hostname, so moving the domain changes nothing about its certificate, and a pending or blocked subscription is exactly as pending or blocked on either service.Change
ISSUED/RENEWINGcheck and thecatch (Certificate)that fix(cdn): report blocked Fastly domain validation instead of pending #300 added around it go away, since nothing reads the status in this method anymore.PATCHstill throws, before any TLS call, so the next attempt finds the same state and retries the move.Tests
FastlyTest.php, all scripted through the existingTestClient, asserting the call sequence and outcome:GETdomains,PATCHto the configured service,GETsubscriptionsPATCHrefused: throwsreassign Fastly domain, no TLS call madefetch Fastly TLS subscriptions, the move standsbin/monorepo check cdnpasses (Pint, PHPStan, Rector). Vale passes on the README. Tests were not run locally.🤖 Generated with Claude Code