test(api): lock in production CORS origins, use reserved example domains - #3523
Merged
Conversation
The CORS layer was replaced in #3064 to support the questionnaire extension. These assert the four origin classes that actually reach production — the app, the portal, an arbitrary trycomp.ai subdomain, and a customer custom domain — still receive the right headers, that an untrusted origin is still rejected, and that resolution does not depend on AUTH_TRUSTED_ORIGINS, which the API is not given in production. Tests only; no production code changes.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The specs hardcoded a developer's real local unpacked-extension id and used evil.com / acmecorp.com, both of which are real registrable domains, in a public repository. Replace them with a synthetic extension id and RFC 2606 reserved names (untrusted.example, trust.example.com), and drop the attack framing. Behaviour of the tests is unchanged.
Contributor
|
🎉 This PR is included in version 3.111.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two test-only changes. No production code.
1. Lock in that production origins still pass CORS
#3064 replaced
app.enableCors()with a custom middleware so the questionnaire extension could be allowed on specific routes. Nothing asserted the existing apps still pass.Covers the four origin classes that actually reach production:
app.trycomp.aiportal.trycomp.ai*.trycomp.aisubdomainPlus two guards: an untrusted origin is still rejected, and resolution does not depend on
AUTH_TRUSTED_ORIGINS— the API is not given that variable in production, so it falls back to the built-in default list.2. Stop publishing real identifiers in a public repo
The existing auth specs contained:
evil.comandacmecorp.com— both real, registrable domainsReplaced with a synthetic extension id and RFC 2606 reserved names (
untrusted.example,trust.example.com), and dropped the attack framing. Test behaviour is unchanged.Verification
The one failure in that suite (
domainVerified) is pre-existing on main and unrelated.