Seven writes take an IAM policy document and every one of them models MalformedPolicyDocument, "the request was rejected because the policy document was malformed". None of them answered it, so a document that was no policy at all was stored and told apart only later, when something tried to decide with it. A role's trust policy was the sharpest case: the trust evaluator reads a document it cannot parse as matching nothing, so a role written that way could no longer be assumed. The reading goes in IamService rather than at the Query front door, for two reasons. Three CloudFormation provisioners write these documents straight through the service and would otherwise be held to nothing. And the order AWS answers in differs per operation, which only the service can express: CreateRole, CreatePolicy, CreatePolicyVersion and UpdateAssumeRolePolicy read the document before the name clash or the entity lookup, where PutUserPolicy, PutGroupPolicy and PutRolePolicy answer NoSuchEntity for a holder that is not there whatever document the request carried. Which reading an operation asks for follows what the document is. A trust policy is held to the grammar alone and under its own validator's wording, "This policy contains invalid Json" for a text that does not parse as a JSON object and "Policy has no statements" for an object carrying no Statement, the element the grammar requires; its statements name a principal rather than resources, so an identity statement's elements are not asked of it. An inline policy is held to that grammar under the identity validator's one sentence for both, "Syntax errors in policy.", and to the values the language defines: a Version outside 2012-10-17 and 2008-10-17, an Effect that is not literally Allow or Deny, and a resource named neither by ARN nor by the wildcard. A managed policy is held to those and to each statement's own elements, "Policy statement must contain actions." and "Policy statement must contain resources.". None of those sentences is published and none is captured. They are the ones AWS's own emulator answers, a first-party implementation rather than a recording, and the split between the two validators' wordings is its reading too, which docs/services/iam.md records. The grammar is read in one place, not two. #8164 landed IamPolicyEvaluator.readsAsPolicyDocument for a document a request supplies to the two simulators or the two context-key readers, which asks exactly what the writes ask of the top level: parses as a JSON object, and carries Statement. The writes need to know which of the two failed in order to word their refusal, so the reading lives here and that method is now its boolean face rather than a second copy of it. Putting a document back is not a new write. A failed CloudFormation update restores the trust policy, the inline policy or the policy version it captured before the attempt, and a document an earlier release accepted must not be refused on the way back: that would leave the role or the policy without what the rollback had just removed, and the stack unable to roll back at all. So those three writes keep the reading on their public entry point and the provisioners restore through restoreAssumeRolePolicy, restoreRolePolicy and restorePolicyVersion, which apply the same write without it. The inline-policy provisioner already restored by writing the captured document straight back, so it needed nothing. This is the same rule as reading a stored document exactly as it was, applied to the one path that writes one. The whole text has to be the document. A member taking one takes "the complete, valid JSON text of an IAM policy", and Jackson reads the first value and stops unless it is told otherwise, so an object with anything after it parsed as a policy. The reader enables FAIL_ON_TRAILING_TOKENS, which is what the reference implementation's parser does by construction. A null document is nothing to judge: a required member the request leaves out is answered as absent by the constraints ahead of the operation. What is already stored is read exactly as it was, so a document an earlier version accepted still decides what it decided. Holding every caller means holding the fixtures too, the compatibility suites included: a Python and a Java SDK test each wrote an inline policy carrying only Version, and two roles in the EKS access-entry test were created with a trust policy of {}. All three are documents IAM refuses, the first two being the case recorded for a document that is valid JSON carrying only Version. Holding every caller means holding the fixtures too. Filler documents across the test tree, "{}" as a trust policy chief among them, were documents real AWS refuses; they now come from one place, io.floci.aws.testing.IamTestPolicies, which also answers a distinct document per marker for a test that needs several. Two fixtures changed in substance rather than in spelling: a Step Functions policy meant to name another event bus named it by bare name, which an identity policy may not, and a managed policy version's statements named no action.
sdk-test-python
Compatibility tests for Floci using boto3 (1.37.1).
Services Covered
| Group | Description |
|---|---|
ssm |
Parameter Store — put, get, label, history, path, tags |
sqs |
Queues, send/receive/delete, DLQ, visibility |
sns |
Topics, subscriptions, publish, SQS delivery |
s3 |
Buckets, objects, tagging, copy, batch delete |
s3-cors |
CORS configuration |
s3-notifications |
S3 → SQS event notifications |
dynamodb |
Tables, CRUD, batch, TTL, tags |
lambda |
Create/invoke/update/delete functions |
lambda-web |
Web functions, revisions, endpoints, waiters, tags, resource policy |
iam |
Users, roles, policies, access keys |
sts |
GetCallerIdentity, AssumeRole, GetSessionToken |
secretsmanager |
Create/get/put/list/delete secrets, versioning, tags |
kms |
Keys, aliases, encrypt/decrypt, data keys, sign/verify |
kinesis |
Streams, shards, PutRecord/GetRecords |
cloudwatch-metrics |
PutMetricData, ListMetrics, GetMetricStatistics, alarms |
cloudformation-naming |
Auto physical name generation, explicit name precedence, cross-reference |
cognito |
User pools, clients, AdminCreateUser, InitiateAuth, GetUser |
elbv2 |
Listener certificates resolved against IAM and ACM |
Requirements
- Python 3.9+
- pip
Running
pip install -r requirements.txt
# All groups
pytest tests/ --junit-xml=test-results/junit.xml
# Specific tests
pytest tests/test_s3.py
# Via just (from compatibility-tests/)
just test-python
Legacy DynamoDB client
legacy/test_dynamodb_20111205.py exercises the 2011-12-05 API with Boto 2,
including paginated queries and batch cleanup of tables created by Boto 3.
Public Boto 2.49.0 needs Python 3.9: it uses retired collections and import
interfaces. Run this suite in a separate environment; the ordinary Python
3.12 suite retains its existing dependencies.
python3.9 -m venv .venv-legacy
.venv-legacy/bin/pip install -r requirements-legacy.txt
FLOCI_ENDPOINT=http://localhost:4566 .venv-legacy/bin/python -m pytest legacy/
tests/test_ec2_subnet_ipv6.py checks that expanded IPv6 subnet CIDRs are
stored and returned in canonical form through Boto 3.
Legacy Query GET
legacy/test_elb_query_get.py checks that public Boto 2 Query GET reads and
deletes Classic load balancers created through Boto 3 POST, including the
missing-resource error. Boto 2.49.0 requires a separate Python 3.9 environment:
python3.9 -m venv .venv-legacy
.venv-legacy/bin/pip install boto==2.49.0 boto3 pytest cryptography
FLOCI_ENDPOINT=http://localhost:4566 .venv-legacy/bin/python -m pytest legacy/test_elb_query_get.py
Configuration
| Variable | Default | Description |
|---|---|---|
FLOCI_ENDPOINT |
http://localhost:4566 |
Floci emulator endpoint |
AWS credentials are always test / test / us-east-1.
Opt-in metric filter replay against AWS
tests/metric_filter_replay.py is a standalone script, not a test: pytest does
not collect it, and tests/test_metric_filter_replay.py checks its logic offline
with the network blocked. It does not change conftest.py, and FLOCI_TARGET=aws
does not select real AWS.
From the repository root, with the declared requirements installed:
python -m pytest compatibility-tests/sdk-test-python/tests/test_metric_filter_replay.py
# Against a local Floci
python compatibility-tests/sdk-test-python/tests/metric_filter_replay.py \
--endpoint http://127.0.0.1:4566 --region eu-west-1 \
--timeout 30 --stable-seconds 2 --poll-interval 1
Real AWS mode requires all three safety arguments. It creates billable CloudWatch metrics and a tagged log group, and metric series cannot be deleted; they remain until AWS ages them out.
python compatibility-tests/sdk-test-python/tests/metric_filter_replay.py \
--aws --profile YOUR_DISPOSABLE_TEST_PROFILE --region eu-west-1 \
--ack-live-writes I_ACCEPT_AWS_WRITES
Only commercial AWS regions are accepted, the clients pin the official regional
endpoints, and the group is deleted in finally only after its ownership tag is
verified. A cleanup failure exits nonzero and prints the group name. Credentials,
account ids, profile names and raw service errors are never printed.
The expected values come from tests/fixtures/metric-filter-publishing-aws.json,
a byte-identical copy of the root fixture
src/test/resources/cloudwatchlogs/metric-filter-publishing-aws.json; the root
CloudWatchLogsMetricFilterFixturePackagingTest fails when either SDK module copy
drifts. The replay ingests each scenario into its own backdated minute, runs the
quiet-default scenario last with no later ingestion, and accepts a result only
after every expected series, absent series and the idle minute after the quiet one
have stayed stable for a full window (AWS defaults: 240 second deadline, 30 second
window). Output is JSON lines of observations, not a regenerated fixture.
Docker
docker build -t floci-sdk-python .
docker run --rm --network host floci-sdk-python
# Custom endpoint (macOS/Windows)
docker run --rm -e FLOCI_ENDPOINT=http://host.docker.internal:4566 floci-sdk-python