mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
## Summary S3 `PutObject` was echoing the object's `Content-Encoding` (and `Content-Disposition`, `Cache-Control`, `x-amz-meta-*`) onto a response whose body is always empty. Real AWS S3 omits all of those on PutObject — they only belong on `GetObject` / `HeadObject`, where there is a body to describe. The user-visible symptom is `Content-Encoding: gzip` on the PutObject response: AWS SDK for Java v2's `Crc32Validation.decompressing` interceptor sees the header, wraps the empty stream in `GZIPInputStream`, and throws `EOFException` from `readHeader`. The object is stored correctly server-side, but every gzip-encoded `PutObject` through the SDK fails before returning — breaking, for example, Spring Cloud AWS's `S3Template.upload(...)` with gzip metadata. `S3Controller#putObject` now calls a new `appendPutObjectResponseHeaders(resp, obj)` that emits only the headers AWS returns on PutObject (storage-class when set, SSE when set, checksum, object-lock) and intentionally omits `Content-Encoding`, `Content-Disposition`, `Cache-Control`, `Content-Language`, `Expires`, and `x-amz-meta-*`. The shared `appendObjectHeaders` is untouched, so GET / HEAD / CopyObject — including the persistence behavior added by #56 / PR #57 — are unchanged. Closes #944 ## Type of change - [x] Bug fix (`fix:`) - [ ] New feature (`feat:`) - [ ] Breaking change (`feat!:` or `fix!:`) - [ ] Docs / chore ## AWS Compatibility Incorrect behavior: PutObject's response copied the object's persisted `Content-Encoding` / `Content-Disposition` / `Cache-Control` / `x-amz-meta-*` headers onto a response that has no body. Verified against real AWS S3 (`us-west-2`) with AWS CLI v2 (`aws-cli/2.27.58`) and AWS SDK for Java v2 (`software.amazon.awssdk:s3:2.42.24`). Eight `PutObject` scenarios were captured from botocore's `--debug` response-headers log, each with one additional request header. For every header this PR changes Floci's behavior on, the post-PR response matches AWS: | Request includes | Pre-PR Floci response | Real AWS response | Post-PR Floci response | |---|---|---|---| | `Content-Encoding: gzip` | emits `Content-Encoding: gzip` | omits | omits | | `Cache-Control: max-age=…` | emits `Cache-Control` | omits | omits | | `Content-Disposition: …` | emits `Content-Disposition` | omits | omits | | `x-amz-meta-owner: team-a` | emits `x-amz-meta-owner` | omits | omits | (`Content-Language` and `Expires` exist in the old `appendObjectHeaders` only via `ResponseHeaderOverrides`, and the PutObject path passes `ResponseHeaderOverrides.NONE`, so they were never actually emitted on PutObject responses.) Regression coverage, both layers: - New SDK-level test `compatibility-tests/sdk-test-java/S3Test#putObjectWithContentEncodingDoesNotBreakSdkDecompression` uses a real `S3Client` to `PutObject` a gzip-encoded object. Before the fix it throws the exact `EOFException → Crc32Validation.decompressing → DefaultS3Client.putObject` stack from #944; with the fix it passes. - Existing in-process `S3IntegrationTest#putObjectWithContentEncoding` gains assertions that `Content-Encoding`, `Content-Disposition`, and `Cache-Control` are absent from the PutObject response. Adjacent tests (`getObjectReturnsContentEncoding`, `headObjectReturnsContentEncoding`, `copyObjectPreservesContentEncoding`, and the Cache-Control / Content-Disposition equivalents) continue to assert those headers ARE returned on GET / HEAD / CopyObject — protecting the behavior fixed by #56 / PR #57. ## Checklist - [x] `./mvnw test` passes locally (4700 tests, 0 failures, 0 errors, 8 skipped) - [x] New or updated integration test added (RestAssured regression assertions in `S3IntegrationTest#putObjectWithContentEncoding`, plus new SDK test `S3Test#putObjectWithContentEncodingDoesNotBreakSdkDecompression` in `compatibility-tests/sdk-test-java`) - [x] Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/)
floci-compatibility-tests
Compatibility test suite for Floci — a local AWS emulator.
Verifies that standard AWS tooling (SDKs, CDK, OpenTofu/Terraform) works correctly against the emulator without modification. Tests run against a live Floci instance and use real AWS SDK clients — no mocks.
Quick Start
# Install just (task runner)
# macOS: brew install just
# Linux: cargo install just
# Copy and configure environment
cp env.example .env
# Install dependencies
just setup
# Run all tests
just test-all
# Run specific SDK tests
just test-python
just test-typescript
just test-awscli
Test Runners
| Module | Language | Test Framework | Command |
|---|---|---|---|
sdk-test-python |
Python 3 | pytest | just test-python |
sdk-test-node |
TypeScript | vitest | just test-typescript |
sdk-test-awscli |
Bash / AWS CLI | bats-core | just test-awscli |
sdk-test-java |
Java 17 | JUnit 5 | just test-java |
sdk-test-go |
Go 1.24 | go test | just test-go |
sdk-test-rust |
Rust | cargo-nextest | just test-rust |
IaC Compatibility
| Module | Tool | Command |
|---|---|---|
compat-cdk |
AWS CDK v2 | ./run.sh |
compat-opentofu |
OpenTofu | ./run.sh |
compat-terraform |
Terraform | ./run.sh |
Prerequisites
- Floci running on
http://localhost:4566(or setFLOCI_ENDPOINT) - Docker — required for Lambda invocation tests
- just — task runner for orchestration
Per-module requirements:
| Module | Requirements |
|---|---|
sdk-test-python |
Python 3.9+, pip |
sdk-test-node |
Node.js 20+, npm, vitest |
sdk-test-awscli |
AWS CLI v2, bash, jq |
sdk-test-java |
Java 17+, Maven |
sdk-test-go |
Go 1.24+ |
sdk-test-rust |
Rust (stable), Cargo, cargo-nextest |
Setup
# Setup all SDKs
just setup
# Setup individual SDKs
just setup-python # pip install -r requirements.txt
just setup-typescript # npm install
just setup-awscli # Clone bats-core, bats-support, bats-assert
Running Tests
All SDKs
just test-all
Individual SDKs
# Python (pytest)
just test-python
# TypeScript (vitest)
just test-typescript
# AWS CLI (bats-core)
just test-awscli
Bats-based suites keep their normal console output and also write JUnit XML reports:
sdk-test-awscli/test-results/junit.xmlcompat-cdk/test-results/junit.xmlcompat-terraform/test-results/junit.xmlcompat-opentofu/test-results/junit.xml
Configuration
All modules read from environment variables (see .env.example):
FLOCI_ENDPOINT=http://localhost:4566
AWS_ACCESS_KEY_ID=test
AWS_SECRET_ACCESS_KEY=test
AWS_DEFAULT_REGION=us-east-1
Running with Docker
Each module includes a Dockerfile for isolated execution:
# Python
docker build -t floci-sdk-python sdk-test-python/
docker run --rm --network host floci-sdk-python pytest
# TypeScript
docker build -t floci-sdk-node sdk-test-node/
docker run --rm --network host floci-sdk-node npm test
On macOS/Windows, use host.docker.internal instead of localhost:
docker run --rm -e FLOCI_ENDPOINT=http://host.docker.internal:4566 floci-sdk-python pytest
Exit Codes
All test runners exit 0 on full pass and non-zero if any test fails — suitable for CI pipelines.