mirror of
https://github.com/floci-io/floci.git
synced 2026-11-22 21:50:46 -05:00
* feat(secretsmanager): add the five missing actions and correct response fidelity Secrets Manager implemented 18 of the 23 actions in the API reference. This adds the remaining five and corrects a number of response and validation divergences found by working through each operation's reference page. New actions: - CancelRotateSecret turns rotation off and reports the half-built AWSPENDING version an interrupted rotation left behind. The staging labels are left alone, as AWS leaves them, because that version id is the only handle on a stale AWSPENDING - and a stale AWSPENDING that is not also AWSCURRENT makes every later RotateSecret fail with "a previous rotation isn't complete". - ValidateResourcePolicy reports wildcard principals under the same REFLEXIVE_PRINCIPAL_CHECK name AWS uses. BlockPublicPolicy on PutResourcePolicy now enforces the same check. - ReplicateSecretToRegions, RemoveRegionsFromReplication and StopReplicationToReplica, backed by a replication model on Secret. Replicas carry the primary's ARN with the Region swapped, track later writes to the primary, and are read-only; a primary that still has replicas cannot be deleted. Scheduled rotation now fires. RotationRules were stored and echoed back but never acted on, so AutomaticallyAfterDays and ScheduleExpression described a schedule that could not happen. A background sweep rotates secrets whose NextRotationDate has passed, reusing the EventBridge Scheduler expression parser for rate() and cron(). The schedule advances when a rotation is dispatched rather than when it succeeds, so a failing rotation cannot pin the sweep on one secret forever. Response fidelity: - ListSecrets honours SortBy, SortOrder and IncludePlannedDeletion, and its entries carry SecretVersionsToStages, the rotation fields, DeletedDate and PrimaryRegion. - PrimaryRegion and ReplicationStatus appear only on multi-Region secrets, matching AWS's "only returns fields that have a value" rule. - Versions with no staging labels are deprecated: DescribeSecret and ListSecretVersionIds omit them unless IncludeDeprecated is set, and an empty VersionStages array is omitted rather than sent. - ListSecretVersionIds gained IncludeDeprecated, LastAccessedDate and paging. Validation, all previously accepted silently: - DeleteSecret rejects a recovery window outside 7-30 and the ForceDeleteWithoutRecovery/RecoveryWindowInDays combination. A window of 0 used to fall through to force-delete, turning a request for no recovery window into an unrecoverable delete. - CreateSecret uses ClientRequestToken as the version id and is idempotent on retry; UpdateSecret, which AWS documents as not idempotent, rejects a token that already names a version. - RotationRules bounds, secret name charset, SecretString/SecretBinary exclusivity, KMS key existence and state, and the documented caps on BatchGetSecretValue, Filters, ExcludeCharacters and ResourcePolicy. Secret values remain stored in the clear; encrypting them with the emulator's own KMS would protect nothing while making the store unreadable. KmsKeyId is validated instead, which is the part a caller can observe. Two deviations are deliberate and recorded in docs/services/secrets-manager.md: LastRotatedDate is retained after CancelRotateSecret, and RotateSecret with RotateImmediately=false does not create the throwaway AWSPENDING version. * test(secretsmanager): create a real KMS key in the sdk-test-java compat test kmsKeyIdPreservation asserted that floci round-trips whatever KmsKeyId it is handed, using an ARN that was never created. That passed only because floci did not check the key; real AWS rejects a key it cannot access, and so does the new validation. The test now creates a key through the emulated KMS and round-trips that ARN, so it still covers KmsKeyId preservation without depending on the missing check. A second case pins the rejection itself. * refactor(secretsmanager): import types instead of qualifying them inline AGENTS.md asks for imports unless a name collision forces qualification. AwsException and UUID had neither. * fix(secretsmanager): hold the rotation lock while promoting a replica StopReplicationToReplica wrote the promoted replica outside the per-secret lock every other mutation in this file takes. The promotion races the primary's replica sync, and losing that race writes the replica back over the copy the call just promoted. Also imports KmsKey, ConcurrentHashMap and HashMap rather than qualifying them inline, per the same AGENTS.md rule. * test(secretsmanager): assert the KMS rejection by exception type, not message text createSecretWithAnUnknownKmsKeyIsRejected matched "InvalidParameterException" against the message, but that is the exception type; the message itself reads "You can't access the KMS key ... in this Region". The assertion now checks the typed InvalidParameterException and the text it actually carries. * test(secretsmanager): give the new KMS compat test its own order createSecretWithAnUnknownKmsKeyIsRejected inherited @Order(13) from the test it was added next to, so two cases shared a position. JUnit breaks the tie deterministically, but the duplicate made the sequence misleading; the tail is renumbered so each case keeps a distinct order. Also sorts the new KMS imports, which landed between the lambda ones. * fix(secretsmanager): guard every write to a secret with its owning monitor UpdateSecret read, mutated and persisted without taking the secret's lock, unlike every other mutator in the class, so two concurrent calls could drop one another's field. StopReplicationToReplica locked the replica's own ARN, but persist() writes a primary's replica slots while holding only the primary's lock: two monitors guarding one store slot, so a sync landing after the promotion could overwrite the promoted copy. The promotion now runs under the primary's monitor, and its two halves run in one critical section so nothing lands between them. SecretsManagerWriteLockTest parks a write mid-flight and asserts the second caller waits; both cases fail without the fixes.
sdk-test-java
Compatibility tests for Floci using the AWS SDK for Java v2 (2.31.8).
Runs 352 tests across 17 test classes against a live Floci instance — no mocks.
Services Covered
| Test class | Description |
|---|---|
SsmTest |
Parameter Store — put, get, path, tags |
SqsTest |
Queues, send/receive/delete, DLQ, visibility |
SnsTest |
Topics, subscriptions, publish, SQS delivery |
S3Test |
Buckets, objects, tagging, copy, multipart, batch delete |
DynamoDbTest |
Tables, CRUD, batch, TTL, tags, streams |
DynamoDbScanConditionTests |
Scan filter and condition expressions |
LambdaTest |
Create/invoke/update/delete functions |
IamTest |
Users, roles, policies, access keys |
StsTest |
GetCallerIdentity, AssumeRole, GetSessionToken |
SecretsManagerTest |
Create/get/put/list/delete secrets, versioning, tags |
KmsTest |
Keys, aliases, encrypt/decrypt, data keys, sign/verify |
CloudWatchTest |
PutMetricData, ListMetrics, GetMetricStatistics, alarms |
CloudFormationVirtualHostTests |
Virtual host style S3 access via CloudFormation |
ApigwSfnJsonataCrudlTests |
API Gateway + Step Functions JSONata CRUDL integration |
ApiGatewayV2WebSocketAndExtendedOpsTest |
API GW v2 WebSocket APIs, Update ops, Route/Integration Responses, Models, Tagging |
Ec2Tests |
EC2 instances, VPCs, security groups, subnets |
AppSyncTest |
GraphQL API CRUDL, data sources, resolvers, functions, types, API keys, tags, schema validation |
EcsTests |
ECS clusters, task definitions, services |
Adding a New Test
Create a standard JUnit 5 test class in src/test/java/com/floci/test/. Tests run against a live Floci instance using real AWS SDK clients.
Requirements
- Java 17+
- Maven
Running
# All tests
mvn test -q
# Specific test class
mvn test -Dtest=S3Test
# Via just (from compatibility-tests/)
just test-java
Configuration
| Variable | Default | Description |
|---|---|---|
FLOCI_ENDPOINT |
http://localhost:4566 |
Floci emulator endpoint |
AWS credentials are always test / test / us-east-1.
Docker
docker build -t floci-sdk-java .
docker run --rm --network host floci-sdk-java
# Custom endpoint (macOS/Windows)
docker run --rm -e FLOCI_ENDPOINT=http://host.docker.internal:4566 floci-sdk-java