GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||
GeezerVison is showing github.com — test(aws): add S3 contract tests by mbevc1 · Pull Request #1065 · kosli-dev/cli Conversation
Contributor
The suite runs against both Related #758 Checklist
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
|
Claude finished @mbevc1's task in 2m 51s —— View job PR Review: S3 contract tests
This is a well-constructed PR. The dual-target contract suite (fake + gated real-AWS) is exactly the right shape to stop the fake from drifting, and the seam design is clean. Static analysis
Strengths
Minor / optional (nothing blocking)
VerdictLooks good to merge. The observations above are all optional polish — I found no correctness bugs, and the previously-raised hardening items are resolved. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Comments on the observations:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Introduce `S3ListAPI` (ListObjectsV2) and `S3DownloadAPI` (DownloadObject), combined into `S3API`, plus a `NewS3ClientFunc` factory that tests can replace. The real `*s3.Client` and `*transfermanager.Client` satisfy their half of the interface implicitly, so no adapter is needed. Split `GetS3Data` into a credentials-to-client entry point and `getS3DataFromClient`, mirroring the existing Lambda seam.
`runS3ContractTests` asserts the S3 behaviours this codebase depends on: object listing, continuation-token pagination, object download, and the error responses for unknown buckets and missing keys. The suite runs against both `FakeS3Client` (always) and real AWS (gated on credentials), so the fake cannot drift from the real API unnoticed.
Cover the paths real AWS cannot exercise cheaply: path and regex filters, folder-marker skipping, single-file versus directory fingerprinting and naming, multi-page listing, the newest-matched-object timestamp, and error propagation from listing and download. Filter selection is pinned by asserting that filtering the full bucket fingerprints identically to a bucket holding only the expected subset, which avoids hardcoding directory digests. This also gives `--include-regex` / `--exclude-regex` their first end-to-end coverage.
Inject `FakeS3Client` via `NewS3ClientFunc` in `SetupTest` and restore the real factory in TearDownTest, so all 11 cases run without AWS credentials. Three of these cases previously called live S3 with no credential gate at all, so they failed for anyone without AWS credentials; CI only masked it because the main test job configures them.
Reduce the live-S3 table from 10 cases to 4: the two credential and region error paths, a whole-bucket happy path, and one include-path case that keeps its fingerprint so drift in the test bucket is still detected. The nested-path, leading-slash and exclude cases now live in the fake-backed tests, where their fingerprints come from fixtures rather than live bucket content. Run the S3 contract tests against real AWS from make test_contract_aws.
The ADR claimed we always fake at the operation level, but that only described GitHub: LambdaAPI and ECSServicesAPI are SDK-level interfaces. State the rule we actually follow — prefer SDK-level when the SDK client is an ordinary Go type a fake can implement directly, fall back to operation-level when that would mean reimplementing SDK machinery — and use S3 as the worked example of a seam that mixes both.
staticcheck flags an error string whose first word is an ordinary
capitalized word, which failed the Lint job on two of the fake's
argument checks.
The sibling fakes escape the check only because their leading words
("FunctionName", "InvalidParameterException", "WriterAt") contain internal
capitals and read as identifiers. Reword all three of this file's argument
errors to start lowercase while still naming the SDK input field.
Two odd inputs made the fake misbehave in ways real S3 would not: - MaxKeys of 0 gave every page zero objects while IsTruncated stayed true and the continuation token repeated, so s3.ListObjectsV2Paginator would spin forever. - A negative continuation token parsed fine via strconv.Atoi and then indexed the key slice out of range. Reject both rather than clamping them. Nothing in this package sets MaxKeys, so values below 1 sit outside the contract verified against real S3, and silently substituting a different page size is the kind of fake/real divergence contract tests exist to catch. The two new cases go in the fake-only block: real S3 accepts these inputs without erroring, so asserting on them in runS3ContractTests would break the real-AWS run.
DownloadObject looked the object body up before checking WriterAt, so a nil WriterAt combined with a missing key reported "object not found" instead of the programming error that actually caused it. Move the check up beside the Bucket and Key checks, so all required-input validation happens together and the more specific diagnostic wins.
bbbcb20 to
a33359b
Compare
There was an error while loading. Please reload this page.
kosli-cli 2.36.4 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre>- Added `pull_request`, `merge_request` as additional command aliases for `assert pullrequest` and `attest pullrequest` (alongside existing `pr`, `mr`, `mergerequest`). - Fixed a bug where packaging multiple evidence paths (e.g. `--attachments`) would fail with "operation not permitted" when any attachment was owned by a different user (e.g. files written by a Docker container). Ownership is no longer preserved during staging. - Improved error messages when an evidence attachment path cannot be packaged: the error now names the path the user provided rather than an internal temp directory. ## What's Changed * chore: add cmd aliases by @mbevc1 in kosli-dev/cli#1066 * test(aws): add S3 contract tests by @mbevc1 in kosli-dev/cli#1065 * fix(docs): separate flag types into a column by @mbevc1 in kosli-dev/cli#1068 * chore(deps): bump the github-actions-dependencies group with 2 updates by @dependabot[bot] in kosli-dev/cli#1070 * chore(deps): bump the go-dependencies group with 10 updates by @dependabot[bot] in kosli-dev/cli#1071 * fix(attest): don't preserve file ownership when packaging attachments by @mbevc1 in kosli-dev/cli#1076 **Full Changelog**: https://github.com/kosli-dev/cli/compare/v2.36.3...v2.36.4</pre> <p>View the full release notes at <a href="https://github.com/kosli-dev/cli/releases/tag/v2.36.4">https://github.com/kosli-dev/cli/releases/tag/v2.36.4</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!15762
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.