With enforcement on, three kinds of request got past the filter's
credential checks, and an expired session was answered as a key that
exists nowhere.
A deactivated access key could still be used. Account routing skips an
inactive key, so its requests landed in the default account. A key of a
user there kept that user's permissions, since resolveCallerContext
reads the user's policies whatever the key's status. A key of another
account matched no user in the default account, and isKnownAccessKey,
which counts every key in every account, let the request through as a
credential the filter could not map, with no policy check at all.
Deactivating a key of a user allowed nothing let it create IAM users
and mint session tokens. The IAM User Guide ("Manage access keys for
IAM users") says that once deactivated a key "can no longer be used by
API calls" until it is activated again.
An Authorization header the filter could not read a credential from made
it return before any check. That covered a header naming no access key
at all (a Bearer token, SigV2, a Credential without the SigV4 scheme or
with the key left out) and a SigV4 scope missing a part, such as its
aws4_request terminator. Any caller could make any call that way,
including the management calls an unsigned request is refused. Such a
request is now refused as AWS refuses a header it cannot read:
IncompleteSignature for Query services and IncompleteSignatureException
for JSON and CBOR ones (the common errors, and the IAM User Guide's
SigV4 troubleshooting section), and S3's AuthorizationHeaderMalformed
with the wording S3HeaderSignatureFilter already uses, all 400. A
presigned S3 URL sends no header, and S3 answers a mal-formed
X-Amz-Credential with AuthorizationQueryParametersError, so that is
what it gets. Otherwise the request is treated as an unsigned one is: an
operation AWS serves without credentials is left alone, and a REST
request is refused only when the header claims SigV4 and its route maps
to an action, since AppSync, CodeArtifact's package endpoints, Identity
Store's SCIM endpoint and API Gateway's authorizers take Bearer and
Basic tokens of their own. An empty header with nothing else to read is
refused the same way, not as a missing one; next to a presigned URL's
X-Amz-Credential it still defers to that credential. Where the guide
gives the message, the refusal uses it: "Authorization header cannot be
empty." and, for a SigV4 header with no Credential, "Authorization
header requires 'Credential' parameter.". The other shapes get the
common errors' "The request signature does not conform to AWS
standards.".
sts:GetCallerIdentity answered a key that exists nowhere, as the
default account's root, because its exemption ran before the
unknown-key check. The exemption is about permissions only, so the key
checks now run first.
An expired session was refused with InvalidClientTokenId or
UnrecognizedClientException, because resolveCallerContext deletes it and
the known-key check then finds nothing. The common errors of the IAM,
STS, EC2, SNS, CloudFormation, Lambda and Step Functions API references
give ExpiredTokenException, 403, "The security token included in the
request has expired", and S3's error list gives ExpiredToken, 400. The
filter now asks isExpiredSession before resolving the caller, so it no
longer deletes the session, and later uses get the same answer. Both
lookups are asked about one moment: read apart, a session expiring
between them would be deleted and answered as unknown, or on the
presigned POST path below allowed with no policy check. Once Floci's own
sweep has removed the session (the first presigned URL it generates in a
process runs one), the key reads as unknown again, as
docs/services/iam.md says.
The inactive-key, expired-session and unknown-key checks run before the
action is used, on every Query, JSON and CBOR call and on every REST
request whose route maps to an action. A REST request no rule maps is
left alone, as an unsigned one already is: the filter cannot tell it
from the API Gateway execute path, Lambda function URLs and the other
paths it sees that are unsigned by design, and the execute path answers
a bad AWS_IAM signature in its own shape. Every refusal to a CBOR call,
AccessDenied included, now arrives CBOR-encoded, where only the
unsigned-call refusal did before; the others were JSON bodies the client
could not read. AccessDenied keeps its 403, the status the Kinesis and
CloudWatch common errors give it. The filter's JSON errors are now
written from AwsErrorResponse, as AwsExceptionMapper writes every other
JSON error, rather than built as strings. That gives a REST JSON
refusal, such as Lambda's, the X-Amzn-Errortype header the rest of
Floci's REST JSON errors carry.
A presigned POST carries its credential in the form body, which the
filter never sees, so authorizeAdditionalResource is the only IAM check
it gets. That evaluated an inactive key with its user's policies, and
resolved an expired session, which deleted it. Both are now refused
there as the filter refuses them, before the caller is resolved:
InvalidAccessKeyId, 403, and ExpiredToken, 400. A key that exists
nowhere, or a credential that cannot be read, is still left to S3's own
presigned-POST check, and uploads as an unsigned request would when that
check is off. docs/services/iam.md now says so.
isKnownAccessKey keeps counting inactive keys: GetSessionToken relies
on it, so a session minted with an inactive key has no issuer rather
than acting as the account root. resolveCallerContext keeps returning
an inactive key's user policies rather than null, which AppSync and RDS
read as allowed; both verify the signature first, which an inactive key
fails. isInactiveAccessKey looks in the request's account before
scanning the others, since routing sends an active key to its own
account.
Integration tests cover a same-account and another account's inactive
key (including GetCallerIdentity, GetSessionToken, S3, a JSON service,
a presigned POST, and reactivation); an expired session on Query (asked
twice), JSON (with its X-Amzn-Errortype header), S3 and presigned POST
calls; an unreadable credential on Query (eight header shapes, none of
which creates the user), JSON, CBOR and S3 calls, on a presigned S3 URL,
and with the guide's two messages; the cases left alone (a Cognito flow
AWS serves without credentials, a Bearer token on S3, a REST route no
rule maps); an unknown key on GetCallerIdentity and on a CBOR call; and
AccessDenied on a CBOR call. Every refusal fails without this change.
IamServiceTest and IamEnforcementFilterTest check that the expiry check
and the caller lookup are asked about one moment. The SDK compatibility
suite's IamEnforcementTest adds a deactivated key, refused by STS and S3
with the codes the SDK reads and accepted again once activated.
docs/services/iam.md lists the cases in both enforcement tables and
under unsigned requests.
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_REGION |
us-east-1 |
Region the TestFixtures clients sign for |
AWS credentials are always test / test. Setting AWS_REGION=cn-north-1 (with Floci started
with FLOCI_DEFAULT_REGION=cn-north-1) runs the suite in the China partition; the nightly
Partition Compatibility workflow does exactly that, and tolerates only the failures listed in
.github/ci/compat-partition-allowlist-cn-north-1.txt. Tests that build their own client with an
explicit region keep that region.
Metric filter publishing checks
CloudWatchLogsMetricFilterTest and CloudFormationLogsMetricFilterTest run
with the rest of the suite. Against a server on another port:
# From compatibility-tests/sdk-test-java
FLOCI_ENDPOINT=http://127.0.0.1:18084 ../../mvnw test \
-Dtest=CloudWatchLogsMetricFilterTest,CloudFormationLogsMetricFilterTest
The publishing tests read their expected values from
src/test/resources/cloudwatchlogs/metric-filter-publishing-aws.json, a
byte-identical copy of the root fixture recorded from AWS. MetricFilterFixturePackagingTest
checks the copy loads from the classpath, and the root
CloudWatchLogsMetricFilterFixturePackagingTest fails when either SDK module
copy drifts from the root file. The SDK selects the CloudWatch JSON protocol;
MetricFilterQueryAssertions signs the same reads as legacy form-encoded Query
requests, so GetMetricStatistics and GetMetricData on both wire formats are
asserted against every statistic the fixture records (Sum, SampleCount, Minimum,
Maximum). Reads poll for the sample, since the server publishes it shortly after
PutLogEvents returns. Passing
these tests shows Floci matches the recorded values; it is not live AWS
verification. For the opt-in replay against AWS see ../sdk-test-python/README.md.
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