Repository navigation
Conversation
Synthesize ExclusaoClienteStack and reject any HttpApi route with no authorizer, except GET /health. Install the CDK library in the CI test job so the gate runs there. Co-authored-by: Rodrigo Patote <patote85@users.noreply.github.com>
Owner
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 91908b8. Configure here.
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.
In your own words
I need a test that synthesizes this CDK stack and fails when any HTTP API route is missing an authorizer. GET /health is the only route that may stay open. PR #21 wrote that rule into ADR-002 and left the check as a CAB follow-up. The rule still lives as prose. A new route can omit the authorizer and
make checkstill passes. The CORS test scanscdk/for a*string and stops there.Why
ADR-002 requires an authorizer on every HttpApi route except GET /health.
test_every_http_route_has_authorizer_except_get_healthsynthesizesExclusaoClienteStackand reads eachAWS::ApiGatewayV2::Route. The test fails whenAuthorizationTypeis missing orNONE, and whenJWTorCUSTOMhas noAuthorizerId.What changed
cdk/requirements.txtand Node 20 so pytest can importaws_cdk.POST /solicitar-exclusao-cliente,GET /status-exclusao/{cliente_id}, andPOST /confirmar-pagamentoare JWT with anAuthorizerId.GET /healthisAuthorizationTypeNONE. No other route is missing an authorizer, so there is no route to report or leave broken.Blast radius
Deployed resources stay the same. A later route with no authorizer fails the test job. That job also installs the CDK library and Node, so a broken install fails the job even when the routes are fine.
The safety fact is that
cdk/app.pyis unchanged.git diff main -- cdk/app.pyis empty, andmake checkrunsnpx --yes aws-cdk@2 synthto exit 0.Verification
Temporary
GET /cab-caveat-probewith no authorizer, not committed.python3 -m pytest tests/test_cdk_route_authorizer.py -v --tb=shortexited 1:After removing that route, the same test passed (
1 passed in 1.70s).make checkon the real stack exited 0. Lint, typecheck, and pytest:Route lines from that synth:
The synth stdout continues with the CloudFormation template and ends with
83 feature flags are not configured. Run 'cdk flags --unstable=flags' to learn more.Exit code 0.Principles
Encode lessons in structure. The CAB follow-up on PR #21 said the authorizer rule should become a synth test. That became
tests/test_cdk_route_authorizer.py. The ADR paragraph is unchanged.Prove it works. The test went red on a temporary route with
AuthorizationType='NONE', then green on the real stack.make checkwas run after the probe route was gone.Test behavior, not implementation. The assertion reads the synthesized route key and authorization fields that API Gateway enforces. Renaming the Python authorizer variable leaves the test green. A route that synthesizes as
NONEturns it red.Laziness protocol. The diff is the test plus the CI packages that test needs.
Note
Low Risk
Test-only and CI dependency changes; no runtime or infrastructure code modified, but future unauthenticated routes will be blocked at merge time.
Reviewed by Cursor Bugbot for commit 91908b8. Bugbot is set up for automated code reviews on this repo. Configure here.