Files
floci/compatibility-tests
Michal Schreiber 23015a7475 fix(secretsmanager,rds): rotate secrets that an AWS service manages (#2378)
* fix(secretsmanager): rotate secrets that an AWS service manages

RotateSecret required a rotation Lambda for every secret, so a secret RDS
manages through ManageMasterUserPassword could never enable rotation:

  InvalidRequestException: You tried to enable rotation on a secret that
  doesn't already have a Lambda function ARN configured and you didn't
  include such an ARN as a parameter in this call.

AWS rotates those secrets itself, so they carry no Lambda at all. It accepts
RotateSecret with rotation rules alone, and refuses a Lambda ARN outright:
"Rotation Lambda ARN is not supported for a service-managed secret."

Key the behaviour off ownership rather than the rds! name prefix, since
anyone may create an ordinary secret called rds!something and that must not
grant it managed-rotation semantics:

- Secret carries an owningService, set by floci services only and never
  settable over the wire
- RDS marks the master user secret it creates as owned by rds, with the two
  tags AWS attaches to it
- RotateSecret needs no Lambda for an owned secret, rejects one, and skips
  the Lambda rotation lifecycle that has nothing to invoke
- DescribeSecret and ListSecrets report OwningService, and the owning-service
  ListSecrets filter matches on it instead of always returning nothing

Covered by unit tests and by a CLI compatibility test that walks the whole
path: create the instance with --manage-master-user-password, describe the
secret it produced, then rotate it with rules and no Lambda ARN.

Behaviour confirmed against a live AWS account: a db.t3.micro postgres
instance created with --manage-master-user-password, then describe-secret and
rotate-secret against the secret it produced.

* fix(secretsmanager): keep managed rotation across restarts, report a real version

Two problems in the previous commit:

A secret persisted before ownership tracking deserializes without an owning
service, so after an upgrade RotateSecret went on rejecting the Lambda-free
call these secrets are rotated with. RDS backfills ownership at startup from
the instances that name those secrets: RDS state is what makes a secret
managed, so that is what the backfill reads, never the secret's name.

RotateSecret answered a service-managed rotation with the request token as
VersionId, while nothing stages a version for that token, so reading the
advertised version failed with "can't find the specified secret version".
Report the current version instead, which exists and holds the value a caller
reads back.

* fix(secretsmanager): back-fill ownership per account, stop claiming a rotation

The startup backfill ran outside any request, so the secrets store resolved the
default account while the instances it read span every account. Secrets owned by
another account were left unmarked, and a same-named default-account secret could
be written instead. The secret's ARN names its own account and region, so
markOwnedByService takes the ARN and addresses that account's store directly.

RotateSecret also recorded LastRotatedDate for a service-managed secret while
neither the master password nor the stored value changed, so the secret claimed a
rotation that GetSecretValue and the database would contradict. floci does not
re-issue the credential, so it no longer reports one: rotation is enabled and
scheduled, and NextRotationDate still follows from the rules.

* fix(rds): never fail startup on the master user secret backfill

The backfill reads persisted state at StartupEvent, so a storage error while
scanning instances would have stopped the emulator from starting over work that
is not needed to serve requests. It now logs and moves on, per instance and for
the scan as a whole.

* fix(rds): run the secret ownership backfill after storage is loaded

The backfill observed StartupEvent, as does EmulatorLifecycle.onStart, which
calls storageFactory.loadAll(). Two observers of one event have no ordering
between them, so under hybrid or WAL storage the backfill could write ownership
into memory that the reload then replaced with the older on-disk secret, leaving
rotation rejected exactly where the backfill exists to help.

It now hangs off restorePersistedRuntime(), which the lifecycle already calls
after loadAll() for the same reason, alongside the other persisted-state fixups.
2026-08-18 17:38:11 -04:00
..

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

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 set FLOCI_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+

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.xml
  • compat-cdk/test-results/junit.xml
  • compat-terraform/test-results/junit.xml
  • compat-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.