Repository navigation
fix(routing): reach API Gateway v2 and SSO Admin from an SDK (#561) - #563
Merged
Merged
Conversation
Both plugins were registered, had test files, and were unreachable from any client. Both test files call HandleRequest directly, so every unit test was green while the feature did not exist from a caller's point of view. API Gateway v2: no signal distinguishes v1 from v2 — the v2 client's SigV4 signing name is "apigateway", its hostname is the same, and neither client sends X-Amz-Target. extractService now refines a resolved "apigateway" to "apigatewayv2" for a "/v2/" path. All 103 requestUris in the apigatewayv2 model are under /v2/ and none of v1's are, so the split is exact; the refinement is confined to requests that already resolved to apigateway, so another service's /v2/ endpoint cannot be captured. SSO Admin: targetServiceAliases mapped a guessed "AWSSSOAdminService" that no client sends. The real sso-admin targetPrefix is "SWBExternalService", now mapped alongside the guessed one rather than replacing it. Closes #561. Prerequisite of #529's API Gateway v2 criterion.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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 plugins were registered, had test files, and could not be reached by any SDK.
Both test files call
HandleRequestdirectly, so every unit test was green whilethe feature did not exist from a caller's point of view — the same shape twice, so
they are fixed together.
Closes #561.
Part of #529: its third acceptance criterion ("same check applied to API Gateway
v2") is unverifiable end to end while
aws apigatewayv2 create-api404s, so thisis a prerequisite of the response-shape work rather than drive-by cleanup. #529
itself stays open for that work.
API Gateway v2 was unreachable
No routing signal distinguishes v1 from v2. The apigatewayv2 client's SigV4
signing name is
apigateway, its hostname is the sameapigateway.{region}.amazonaws.com, and neither client sendsX-Amz-Target. Soevery v2 request resolved to
apigateway, landed onAPIGatewayPlugin, and cameback:
extractServicenow refines a resolvedapigatewaytoapigatewayv2when thepath begins with
/v2/. That is exact rather than heuristic: all 103 requestUrisin the apigatewayv2 model are under
/v2/, and none of the v1 model's URI spaceis — v1's roots are
/account,/apikeys,/clientcertificates,/domainnames,/domainnameaccessassociations,/rejectdomainnameaccessassociations,/restapis,/sdktypes,/tags,/usageplans,/vpclinks. So a/v2/pathcannot be a v1 call.
The refinement is confined to requests that already resolved to
apigateway.A bare
/v2/…path is not evidence of API Gateway by itself, and another service'sendpoint is free to use one — MSK's
/v2/clustersis exactly that case, and it isin the test table.
SSO Admin was unreachable
targetServiceAliasesmappedAWSSSOAdminService, a prefix derived by guessworkthat no client sends. The real
sso-admintargetPrefixisSWBExternalService:The real prefix is now mapped alongside the guessed one rather than replacing
it — retaining it costs nothing and keeps working for a caller that builds the
target header by hand from the service name. The comment records the correction,
since the existing one stated the wrong derivation with some confidence.
Verified
End to end against
substrate server --address :4620, both previously impossible:create-apireturns 201 and the response body is populated, but the CLI stillprints nothing for it — its members are PascalCase, which is #529's separate defect
and is fixed later in this milestone. Reachability is what this PR delivers; it is
also what makes that defect observable at all.
v1 regressions checked in the same session:
create-rest-api,/restapis,/usageplansand/accountall still reachAPIGatewayPlugin, and MSK's/v1/clustersis unaffected.Tests
Two table-driven cases in
parser_test.go, both red before the fix:TestParseAWSRequest_APIGatewayVersionRouting(v2 by auth scope and by host; fourv1 paths staying v1; MSK's
/v2/clustersstaying MSK) andTestParseAWSRequest_SSOAdminTargetPrefix(both target prefixes resolving tosso).Mutation testing found a real gap rather than confirming what was already
there. Six mutants: the
apigateway-only guard dropped, the refinement removed,the refinement inverted, the real SSO prefix reverted, the legacy SSO prefix
dropped — five caught — and
HasPrefixloosened toContains, which survived.A v1 rest-api id is ten lowercase alphanumerics and a stage name is caller-chosen,
so either can contain
v2;/restapis/abcv2ghijkwould have been routed to the v2plugin by that mutant with nothing to catch it. Two cases were added for it and the
mutant is now caught, 6/6.
Docs
docs/services.md: the API Gateway v2 section states how v1 and v2 arediscriminated and that a consumer needs no special client configuration, and SSO /
Identity Store gains a section — it was in the coverage matrix with no detail,
which is consistent with having been unreachable.
make docs-referencereports nochange to the generated matrix; no plugin is added or removed.