Repository navigation
fix(#756): answer CloudTrail's trail through a projection - #1356
Merged
Merged
Conversation
createTrail and updateTrail answered the persisted CloudTrailTrail as the body, and getTrail and describeTrails answered it under Trail and in trailList, so a consumer read AccountID, Region and CreatedAt, which no CloudTrail shape publishes, and IsLogging, which only GetTrailStatus publishes. The two writes also answered HomeRegion and HasCustomEventSelectors, which Trail publishes and CreateTrailResponse/UpdateTrailResponse do not. The reads now answer emulator/cloudtrail_wire.go's cloudtrailTrailOut and the writes cloudtrailTrailWriteOut. The stored record is unchanged. Two tests pinned IsLogging on shapes that do not publish it. StartStopLogging observed StopLogging through GetTrail; because GetTrailStatus hardcodes true (#1157), it now reads the persisted flag. emulator/cloudtrail_wire_test.go drives all eight routed operations and is cited in scripts/wire-bookkeeping-projected.txt, taking it from 267 projected across 110 records to 270 across 111, and from 43 still reachable to 40. #756 and #1157 stay open.
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.
This is the ninth of ten PRs in #756's 3-line block.
The leak, at four sites, in two shapes
createTrail,updateTrailCloudTrailTrailas the bodyCreateTrailResponse/UpdateTrailResponsegetTrail{"Trail": trail}TraildescribeTrails{"trailList": []CloudTrailTrail}TrailI verified all three shapes against the reference today. A consumer read:
AccountID,RegionandCreatedAt, which no CloudTrail shape publishes.IsLogging, which onlyGetTrailStatuspublishes. It is in neitherTrailnor the writeresponses.
HomeRegionandHasCustomEventSelectors, whichTrailpublishes butCreateTrailResponse/UpdateTrailResponsedo not.The fix: two projections, because there are two shapes
In the new
emulator/cloudtrail_wire.go:cloudtrailTrailOuthas eleven ofTrail's members and serves the reads.cloudtrailTrailWriteOuthas the nine write-response members the record models and serves thewrites.
Both functions are at 100% coverage. The stored record is unchanged.
Two tests pinned
IsLoggingon shapes that do not publish itTestCloudTrailPlugin_CreateGetDeleteTrailassertedIsLogging == trueon theCreateTrailresponse. That is unpublished, and per CloudTrail GetTrailStatus hardcodes IsLogging: true, so StopLogging is unobservable and a trail is born logging #1157 a trail being born logging is itself wrong. The
assertion is removed, with a pointer to CloudTrail GetTrailStatus hardcodes IsLogging: true, so StopLogging is unobservable and a trail is born logging #1157.
TestCloudTrailPlugin_StartStopLoggingobservedStopLoggingthroughGetTrail'sIsLogging.The published place for that answer is
GetTrailStatus, which hardcodestrue(CloudTrail GetTrailStatus hardcodes IsLogging: true, so StopLogging is unobservable and a trail is born logging #1157). So thetest now reads the persisted flag, which is what
StopLoggingactually changes.Every other test there now decodes the published members instead of
emulator.CloudTrailTrail.A consequence worth stating. With the leak gone, a stopped trail is reported as stopped by no
published response at all. The only place a consumer could see it was an unpublished member. That
was already true for every published shape, and it is exactly #1157's to fix: born not-logging,
plus
GetTrailStatusreading the flag. It is in a later milestone, and it gets a comment once thismerges.
The citation
emulator/cloudtrail_wire_test.godrives all eight routed operations. After the walk it requires:IsLogging,HomeRegionorHasCustomEventSelectors;Trailcarries noIsLogging, and does carryHomeRegion.Negative controls (each run, then restored)
createTrail/CreateTrail, then "CreateTrail answered IsLogging, which its response does not publish"getTrail/GetTrail, then "API_Trail publishes no IsLogging"The ratchet
Verification
All of these pass:
make lint: 0 issues.make test: race,-count=1.docs-reference-check docs-versions version-check discarded-unmarshal-check wire-bookkeeping-check operation-catalog-check operation-docs-check.#756 and #1157 stay open.