Skip to content

Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.

release v1.5.12 (#1732)

Nahuel Nucera7636b91c8b53
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 20576301..60fdd94b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,23 +5,28 @@ All notable changes to MiniStack will be documented here.
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
Versioning follows [Semantic Versioning](https://semver.org/).
-## [Unreleased]
+## [1.5.12] — 2026-09-15
### Added
-- **EKS — Pod Identity associations** — the five operations did not exist, so a controller that reads pod identity to find its role (the AWS Load Balancer Controller among them) could not run against MiniStack at all. `CreatePodIdentityAssociation`, `DescribePodIdentityAssociation`, `ListPodIdentityAssociations` (filtered by `namespace` and `serviceAccount`), `UpdatePodIdentityAssociation` and `DeletePodIdentityAssociation` serve the association records, with one association per namespace and service account, an `externalId` minted for a `targetRoleArn` chain, and the summary shape on the list. Nothing runs inside the cluster: the association is a control-plane record, which is what the API serves. Reported by @josephaw1022
-- **EKS — managed Access Policy authorization in k3s** — `AmazonEKSClusterAdminPolicy`, `AmazonEKSAdminPolicy`, `AmazonEKSEditPolicy`, `AmazonEKSViewPolicy`, and `AmazonEKSAdminViewPolicy` now grant their published Kubernetes permissions under `AUTH=true`. Cluster and namespace scopes, including namespace wildcard patterns, are reconciled to managed k3s RBAC bindings after policy changes and when matching namespaces appear; disassociating a policy or deleting its Access Entry revokes the bindings.
+- **EKS — Pod Identity associations** — the five operations did not exist, so a controller that reads pod identity to find its role, the AWS Load Balancer Controller among them, could not run against MiniStack. `CreatePodIdentityAssociation`, `DescribePodIdentityAssociation`, `ListPodIdentityAssociations` (filtered by `namespace` and `serviceAccount`), `UpdatePodIdentityAssociation` and `DeletePodIdentityAssociation` serve the records, one per namespace and service account, with an `externalId` minted for a `targetRoleArn` chain. Reported by @josephaw1022.
+- **EKS — `aws eks update-kubeconfig` works against MiniStack** — k3s could not authenticate the IAM exec token `aws eks get-token` produces, so the only way in was to copy the admin kubeconfig out of the container. MiniStack now answers a TokenReview webhook for the cluster: `AUTH=false` accepts local bearer tokens, `AUTH=true` verifies the presigned token's signature, cluster binding and lifetime and then requires a creator or Access Entry grant, including account-scoped STS sessions. The five general-purpose access policies (`AmazonEKSClusterAdminPolicy`, `AmazonEKSAdminPolicy`, `AmazonEKSEditPolicy`, `AmazonEKSViewPolicy`, `AmazonEKSAdminViewPolicy`) grant their published Kubernetes permissions, at cluster or namespace scope including wildcard patterns, and disassociating a policy or deleting its Access Entry revokes them. Contributed by @jgrumboe. Reported by @StraggleCraft.
### Fixed
- **S3 — a notification configuration whose destination does not exist is refused** — `PutBucketNotificationConfiguration` stored the configuration and swallowed the failed test delivery, so a queue or topic that was not there looked like a successful setup and no event ever arrived. AWS verifies an SNS or SQS destination by sending it a test notification, and "if the message fails, the entire PUT action will fail, and Amazon S3 will not add the configuration to your bucket": a missing queue or topic is now `InvalidArgument` (400) with nothing stored. A Lambda destination is still not checked, since AWS verifies that one through the function's permissions. Reported by @ortizgui.
-- **EKS — AWS CLI kubeconfig authentication** — k3s accepts `aws eks get-token` credentials through a MiniStack TokenReview webhook, so `aws eks update-kubeconfig` works without copying a container's admin kubeconfig. `AUTH=false` permits local bearer tokens; `AUTH=true` validates IAM credentials and requires creator or Access Entry grants, including account-scoped STS sessions. Fixes #1140.
-- **IAM — a resource-scoped policy matches, instead of denying** — `extract_resource_arn` returned `*` for three whole families of request, and a resource-scoped policy can never match `*`, so under `AUTH=true` the only grant that worked was one written as `Resource: "*"`. First, IoT mapped six path prefixes to ARNs but not `/jobs` or `/provisioning-templates`, and neither data plane had a branch at all: a client signs those with the `iotdata` and `iotjobsdata` scopes, so they arrive as their own service keys and fell through. That rules out what the CDK emits: its `AwsCustomResource` for an IoT job grants `iot:CreateJob` on exactly `job/<jobId>` plus the target `thinggroup/<name>`, the scoping AWS documents, and a CloudFormation stack carrying one failed to deploy here with `is not authorized to perform: iot:CreateJob` while deploying on AWS. A publish and a retained message now resolve to their topic, which carries every level (`topic/sensors/rack-1/temperature`), and a shadow or job execution to its thing. `Publish` also resolves an action again: its URI label is non-greedy, so the SDK percent-encodes the separators and the ASGI server hands them back decoded, and a route compiled as one segment then matched no topic below the first level. Second, the query-protocol services (EC2, CloudFormation, CloudWatch, Auto Scaling, ElastiCache) carry their parameters in a form-encoded body when the SDK POSTs, which botocore does, so nothing reached the query string and every branch reading it resolved nothing: `ec2:AuthorizeSecurityGroupIngress` scoped to one security group was denied for that group. The router already parsed that body to find `Action` and now keeps the rest of it, merged underneath the query string, which still wins. Third, an `execute-api` invoke was authorized against `*` as well, so a policy naming one API and stage, which is what `grantExecute` and every service-to-service grant emit, never matched; it now resolves to `arn:aws:execute-api:<region>:<account>:<api-id>/<stage>/<METHOD>/<path>`, built by the same helper the Lambda authorizer's method ARN uses, and authorized once the stage is known so a v2 API on `$default` is not charged for a stage segment it does not have. Contributed by @iot-rocket.
-- **CloudFormation — `AWS::IAM::Policy` is provisioned inline, not as a managed policy** — the document was stored as an account-global customer-managed policy and attached to the Roles, Users and Groups the resource named, where CloudFormation embeds it on each of them the way `PutRolePolicy`, `PutUserPolicy` and `PutGroupPolicy` do. The difference is that an inline policy is scoped to its entity, so the same `PolicyName` can exist on many entities at once, and CDK relies on it: it derives `PolicyName` from the construct path, so every stack granting something to a role reached by the same path emits the same name. Twenty of one deployment's twenty-seven policies collapsed onto two records, and each deploy took the grants away from the stacks before it; under `AUTH=true` those roles were then denied the actions their own templates granted. The document now goes onto each entity through the existing inline handlers, so `ListRolePolicies`, `GetRolePolicy` and the `RolePolicyList` of `GetAccountAuthorizationDetails` report it and the IAM evaluator finds it. The physical id is generated rather than being the `PolicyName`, which is what AWS returns: measured against the account, a stack with an explicit `PolicyName` of `ms0049-refprobe-explicit-name` answers `Ref` with `ms0049--Pol-AW24HieEB0iX`, and `list-policies --scope Local` over an estate of forty deployed stacks counts zero. `AWS::IAM::ManagedPolicy` is unchanged. Contributed by @iot-rocket.
-- **Lambda — dispatch SQS event source batches concurrently** — one thread polled every mapping and waited for each invoke, so a handler that took 10 seconds held a message on an unrelated queue for about 8.6 seconds, and `ScalingConfig.MaximumConcurrency` was stored but ignored. SQS batches are now invoked off the poll thread, up to `MaximumConcurrency` batches per mapping (default 5), lowered to the function's `ReservedConcurrentExecutions` so a mapping does not throttle its own function. Kinesis and DynamoDB Streams mappings still process one batch at a time. Contributed by @ThailerL.
-- **ECS — a task's `version` counts its state changes** — the counter was minted at `1` and never moved again, so a consumer holding an older `DescribeTasks` copy could not tell it from the current one, which is the comparison the field exists for. It now increments on each transition the record reports: the move to `ACTIVATING`, the move to `RUNNING`, the move to `STOPPED` whether it came from `StopTask`, an essential container exiting or a failed start, and the restore after a restart that stops a task that was running. A real task counts the same way, measured on a Fargate task polled through `DescribeTasks`: `1` at `PROVISIONING`, `2` at `PENDING`, `3` at `RUNNING`, `4` when `StopTask` set `desiredStatus`, `5` at `DEPROVISIONING`, `6` at `STOPPED`. There are no task state change events here, so the counter is what `DescribeTasks`, `RunTask` and `StopTask` report and nothing else. Contributed by @iot-rocket.
+- **ECS — a task walks the whole lifecycle** — a Docker-backed task went straight from `PENDING` to `RUNNING` to `STOPPED`, so a consumer waiting on any other state waited forever. It now reports the states AWS documents, in order: `PROVISIONING` at `RunTask` whatever the network mode, `PENDING` while it waits on the agent, `ACTIVATING` for the image pull, then `DEACTIVATING`, `STOPPING`, `DEPROVISIONING` and `STOPPED`. Every starting state counts against a service's desired capacity, while `pendingCount` and `pendingTasksCount` still count `PENDING` alone as the API model defines them. `executionStoppedAt` is now set. Reported by @iot-rocket.
+- **Cognito — a hosted-UI request that invokes a Lambda trigger no longer deadlocks** — `/saml2/idpresponse`, `/oauth2/idpresponse` and `/oauth2/token` ran on the event loop, so a PreSignUp or PreTokenGeneration trigger calling back into MiniStack queued behind its own request, timed out and surfaced as a `400`. All three now run off the loop. Two races the change exposed close with it: a replayed authorization code gets `invalid_grant`, the error AWS returns for a code "consumed already or does not exist", instead of a `500`. Contributed by @kjdev.
+- **SQS — every batch action validates the request before its entries** — the ten-entry limit reached `SendMessageBatch` only, and three more request-level errors the SQS model declares on all three batch actions were never raised. `DeleteMessageBatch` and `ChangeMessageVisibilityBatch` now refuse an empty `Entries` list, more than ten entries, repeated ids and a malformed id, with `EmptyBatchRequest`, `TooManyEntriesInBatchRequest`, `BatchEntryIdsNotDistinct` and `InvalidBatchEntryId`. These fail the whole request rather than landing in `Failed`, as on AWS. Contributed by @CaptainAni187. Reported by @jespinoza-shippo.
+- **SES — one v2 implementation, returning the v1 `MessageId` shape** — `ses.py` carried an inline copy of the v2 endpoints that duplicated `ses_v2.py`, and the path router had already been sending `/v2/email/*` to `ses_v2`, so the copy was unreachable and the two had drifted. The duplicate is gone and every v2 request, by path or by `SESv2.*` target header, is served by one implementation. That surfaced a divergence the dead copy had hidden: `SendEmail` and `SendBulkEmail` answered an id prefixed `ministack-`, where the six v1 send paths return `<uuid>@email.amazonses.com`. Both now return the shared shape. Contributed by @jgrumboe.
+- **EKS — a deleted cluster takes its access entries and pod identity associations with it** — both stores are keyed by cluster name and neither was swept on `DeleteCluster`, so they outlived the cluster and a new one created under the same name inherited the previous cluster's grants and role ARNs. They are now removed with the cluster, along with their tags.
+- **Persistence — four services keep their state across a restart** — the save map was maintained by hand next to `SERVICE_REGISTRY`, and `cloudcontrol`, `config`, `cur` and `organizations` were never added to it, so everything they held was dropped on every warm boot. The map is now derived from the registry, which also covers the modules a service reaches through its own dispatcher, and a test refuses any service that would be saved without a way to restore it. Every service module now declares the same `get_state` / `load_persisted_state` / `reset` contract, which is what the derivation reads. Contributed by @jgrumboe.
+- **IAM — a resource-scoped policy matches, instead of denying** — under `AUTH=true` the resource ARN resolved to `*` for whole families of request, so only a grant written `Resource: "*"` matched and everything narrower was denied. IoT jobs and provisioning templates now resolve to `job/<id>` and `provisioningtemplate/<name>`, both IoT data planes reach the same branch, an MQTT topic resolves to its full multi-level path, and an API Gateway invoke resolves to `<api-id>/<stage>/<METHOD>/<path>`. A query-protocol POST carries its whole form body into resolution, not just `Action`. Contributed by @iot-rocket.
+- **CloudFormation — `AWS::IAM::Policy` is provisioned inline, not as a managed policy** — the document was stored as an account-global managed policy and attached, where CloudFormation embeds it on each Role, User and Group it names, as `PutRolePolicy` does. An inline policy is scoped to its entity, so the same `PolicyName` can exist on many at once; CDK derives that name from the construct path, so stacks sharing a path collapsed onto one record and each deploy took the grants from the ones before it. `ListRolePolicies`, `GetRolePolicy` and `GetAccountAuthorizationDetails` now report it and the IAM evaluator finds it. `AWS::IAM::ManagedPolicy` is unchanged. Contributed by @iot-rocket.
+- **Lambda — SQS event source batches are dispatched concurrently** — one thread polled every mapping and waited for each invoke, so a handler that took 10 seconds held a message on an unrelated queue for about 8.6 seconds, and `ScalingConfig.MaximumConcurrency` was stored but ignored. Batches now run off the poll thread, up to `MaximumConcurrency` per mapping (default 5), lowered to the function's `ReservedConcurrentExecutions`. A FIFO event source is held to one batch at a time whatever that setting says, since a batch is built across message groups and Amazon SQS "ensures that messages in the same group are delivered to Lambda in order". Kinesis and DynamoDB Streams still process one batch at a time. Contributed by @ThailerL.
+- **ECS — a task's `version` counts its state changes** — the counter was minted at `1` and never moved, so a consumer holding an older `DescribeTasks` copy could not tell it from the current one, which is the comparison the field exists for. It now moves on each change the record reports, measured against a real Fargate task: `1` at `PROVISIONING`, `2` at `PENDING`, `3` at `RUNNING`, `4` when `StopTask` set `desiredStatus`, `5` at `DEPROVISIONING`, `6` at `STOPPED`. Contributed by @iot-rocket.
- **ECS — only an `awsvpc` task reports an elastic network interface** — every task got an `ElasticNetworkInterface` attachment once its container was up, whatever its network mode, while the Task reference describes `attachments` as the adapter a task has "if the task uses the `awsvpc` network mode": a `bridge` or `host` task on AWS reports none and is reached through its container instance. A task in those modes now reports an empty list, an `awsvpc` task's attachment additionally names the subnet the request placed it in, and the address stays available to the target-group sync in every mode. Contributed by @iot-rocket.
- **ECS — a task no longer reports `attachmentsStatus`** — the task record carried an `attachmentsStatus` member next to its attachment, and there is no such member on the `Task` shape: the API model has it on `Cluster` only, and a live task on AWS, awsvpc and bridge alike, sends no such field. A client reading the raw wire saw an invented member, and the emulator was the only place it existed. The cluster's own `attachmentsStatus` is untouched. Contributed by @iot-rocket.
-- **ECS — the task metadata endpoint reports the status the task is in** — `${ECS_CONTAINER_METADATA_URI_V4}` served `DesiredStatus` and `KnownStatus` as the literal `RUNNING`, captured when the container was registered, so a container that read its own metadata was told the task was running while `DescribeTasks` reported `PENDING` or `ACTIVATING`. The two could not disagree before `RunTask` returned asynchronously; now that the image pull sits inside that window, they disagree for the length of it. Both members are read off the task record on every request, on the container route and the task route, and a task that no longer has a record keeps what was registered. `DesiredStatus` is the task's everywhere, which is how a container learns it is being shut down; `KnownStatus` is the task's on the task payload and the container's own on a container payload, because that is what AWS reports: a live Fargate task served `"KnownStatus": "NONE"` for itself and `"RUNNING"` for the container reading the endpoint, in one payload. The task is looked up by the account and region in its ARN, since a container reaches the endpoint with a path token and no SigV4. Contributed by @iot-rocket.
-- **IAM — one `_account_from_arn`, with the contract the condition evaluator documents** — the module carried two top-level definitions of the helper under the same name, so the later one silently won and the guards the documented one describes (a bare `*`, a value that is not an ARN at all, an AWS-owned `arn:aws:iam::aws:policy/...`) were not the ones in force when `aws:ResourceAccount` resolved a resource's account. They are folded into one definition that keeps both contracts: the field is returned only when it holds an account id, twelve digits, and only from a value that is an ARN. No request the emulator serves changes behaviour, because both callers pass an ARN whose account is twelve digits; the parametrized test gained the two cases that tell the former definitions apart. Contributed by @iot-rocket.
+- **ECS — the task metadata endpoint reports the status the task is in** — `${ECS_CONTAINER_METADATA_URI_V4}` served `DesiredStatus` and `KnownStatus` as the literal `RUNNING`, captured at registration, so a container reading its own metadata was told the task was running while `DescribeTasks` reported otherwise, for the length of the image pull. Both are now seeded from the task record and pushed at each transition. `KnownStatus` is the task's on the task payload and the container's own on a container payload, because AWS reports them separately. Contributed by @iot-rocket.
+- **IAM — one `_account_from_arn`, with the contract the condition evaluator documents** — the module carried two top-level definitions under the same name, so the later silently won and the guards the documented one describes were not the ones in force when `aws:ResourceAccount` resolved a resource's account. They are folded into one: the field is returned only when it holds a twelve-digit account id, and only from a value that is an ARN. No request changes behaviour. Contributed by @iot-rocket.
- **Test harness — the suite runs on a non-default `GATEWAY_PORT`** — eight tests compared a value a service had built from `GATEWAY_PORT` against a hard-coded `4566`, so the suite passed only on the default port. That is the port a contributor moves off to run a private server rather than resetting a shared one, which is exactly when the failures appear and look like real regressions. The ESM tests now key their queues through `sqs._queue_url()`, the AppSync and Glue assertions read the port from one place in `tests/conftest.py`, and the three files pass on any port. No user-visible behavior changes. Contributed by @iot-rocket.
## [1.5.11] — 2026-09-13
diff --git a/pyproject.toml b/pyproject.toml
index 8085a42b..d0039475 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "ministack"
-version = "1.5.11"
+version = "1.5.12"
description = "Free, open-source local AWS emulator — drop-in LocalStack replacement"
readme = "README.md"
license = { file = "LICENSE" }
diff --git a/tests/test_iot_data.py b/tests/test_iot_data.py
index e9935005..a69933a1 100644
--- a/tests/test_iot_data.py
+++ b/tests/test_iot_data.py
@@ -195,18 +195,24 @@ def _record_publish(msg, received: list) -> int | None:
return ptype
+# The handshake budget for a WS subscriber. Generous on purpose: a single
+# timeout here kills the thread before it can set `ready`, and every caller
+# then reports the same unhelpful "did not become ready" instead of why.
+_WS_HANDSHAKE_TIMEOUT = 15.0
+
+
async def _ws_subscribe_and_collect(
ws_url: str, topic: str, ready_event: threading.Event, received: list, stop: threading.Event
):
async with websockets.connect(ws_url, subprotocols=["mqtt"]) as ws:
await ws.send(_make_connect("test-client"))
# Wait for CONNACK
- await asyncio.wait_for(ws.recv(), timeout=2.0)
+ await asyncio.wait_for(ws.recv(), timeout=_WS_HANDSHAKE_TIMEOUT)
# Subscribe
await ws.send(_make_subscribe(packet_id=1, topic=topic, qos=0))
# Retained PUBLISH frames may precede SUBACK in the in-process broker.
while True:
- msg = await asyncio.wait_for(ws.recv(), timeout=2.0)
+ msg = await asyncio.wait_for(ws.recv(), timeout=_WS_HANDSHAKE_TIMEOUT)
if _record_publish(msg, received) == 9: # SUBACK
break
ready_event.set()
@@ -232,17 +238,17 @@ async def _ws_unsubscribe_one_and_collect(
"""Subscribe to every topic in ``topics``, then UNSUBSCRIBE from ``drop``."""
async with websockets.connect(ws_url, subprotocols=["mqtt"]) as ws:
await ws.send(_make_connect("unsub-client"))
- await asyncio.wait_for(ws.recv(), timeout=2.0)
+ await asyncio.wait_for(ws.recv(), timeout=_WS_HANDSHAKE_TIMEOUT)
for packet_id, topic in enumerate(topics, start=1):
await ws.send(_make_subscribe(packet_id=packet_id, topic=topic, qos=0))
while True:
- msg = await asyncio.wait_for(ws.recv(), timeout=2.0)
+ msg = await asyncio.wait_for(ws.recv(), timeout=_WS_HANDSHAKE_TIMEOUT)
if _record_publish(msg, received) == 9: # SUBACK
break
await ws.send(_make_unsubscribe(packet_id=len(topics) + 1, topics=[drop]))
while True:
- msg = await asyncio.wait_for(ws.recv(), timeout=2.0)
+ msg = await asyncio.wait_for(ws.recv(), timeout=_WS_HANDSHAKE_TIMEOUT)
if _record_publish(msg, received) == 11: # UNSUBACK
break
ready_event.set()
@@ -276,7 +282,7 @@ def test_iot_ws_unsubscribe_keeps_the_other_subscriptions(iot_data_client):
daemon=True,
)
t.start()
- assert ready.wait(timeout=5), "WebSocket subscriber did not become ready"
+ assert ready.wait(timeout=_WS_HANDSHAKE_TIMEOUT), "WebSocket subscriber did not become ready"
iot_data_client.publish(topic=dropped, payload=b"should-not-arrive")
iot_data_client.publish(topic=kept, payload=b"should-arrive")
@@ -314,7 +320,7 @@ def test_iot_lambda_publishes_browser_subscribes_e2e(iot_data_client):
t = threading.Thread(target=_runner, daemon=True)
t.start()
- assert ready.wait(timeout=5), "WebSocket subscriber did not become ready"
+ assert ready.wait(timeout=_WS_HANDSHAKE_TIMEOUT), "WebSocket subscriber did not become ready"
payload = b"telemetry-from-lambda"
iot_data_client.publish(topic=topic, payload=payload)
@@ -379,8 +385,8 @@ def test_iot_ws_publish_isolated_between_regions():
)
east_thread.start()
west_thread.start()
- assert east_ready.wait(timeout=5)
- assert west_ready.wait(timeout=5)
+ assert east_ready.wait(timeout=_WS_HANDSHAKE_TIMEOUT)
+ assert west_ready.wait(timeout=_WS_HANDSHAKE_TIMEOUT)
east_client = boto3.client(
"iot-data",
@@ -442,7 +448,7 @@ def test_iot_ws_credential_region_wildcards_cannot_bypass_isolation(
daemon=True,
)
live_thread.start()
- assert live_ready.wait(timeout=5)
+ assert live_ready.wait(timeout=_WS_HANDSHAKE_TIMEOUT)
east_client = boto3.client(
"iot-data",
@@ -473,7 +479,7 @@ def test_iot_ws_credential_region_wildcards_cannot_bypass_isolation(
daemon=True,
)
retained_thread.start()
- assert retained_ready.wait(timeout=5)
+ assert retained_ready.wait(timeout=_WS_HANDSHAKE_TIMEOUT)
time.sleep(0.6)
retained_stop.set()
retained_thread.join(timeout=2)
@@ -509,7 +515,7 @@ def test_iot_ws_topic_isolation_between_accounts(iot_data_client):
t = threading.Thread(target=_runner, daemon=True)
t.start()
- assert ready.wait(timeout=5)
+ assert ready.wait(timeout=_WS_HANDSHAKE_TIMEOUT)
# Publish from account B using a 12-digit access key.
client_b = boto3.client(
@@ -562,7 +568,7 @@ def test_iot_ws_same_account_publish_delivers(iot_data_client):
t = threading.Thread(target=_runner, daemon=True)
t.start()
- assert ready.wait(timeout=5)
+ assert ready.wait(timeout=_WS_HANDSHAKE_TIMEOUT)
# Publish from the SAME account.
client_a = boto3.client(
@@ -1006,7 +1012,7 @@ def test_iot_rule_republish_where_gated_ws_subscriber(iot_client, iot_data_clien
daemon=True,
)
t.start()
- assert ready.wait(timeout=5), "WebSocket subscriber did not become ready"
+ assert ready.wait(timeout=_WS_HANDSHAKE_TIMEOUT), "WebSocket subscriber did not become ready"
iot_data_client.publish(
topic=source, payload=json.dumps({"severity": "low", "n": 1}).encode()
@@ -1133,7 +1139,7 @@ async def _mqtt_connect(client_id: str, url: str | None = None):
"""Open an MQTT session and hold it. The caller closes the socket."""
ws = await websockets.connect(url or _broker_ws_url(), subprotocols=["mqtt"])
await ws.send(_make_connect(client_id))
- await asyncio.wait_for(ws.recv(), timeout=2.0) # CONNACK
+ await asyncio.wait_for(ws.recv(), timeout=_WS_HANDSHAKE_TIMEOUT) # CONNACK
return ws
@@ -1638,7 +1644,7 @@ def _collect_shadow_frames(sub_filter, publish_fn, want, timeout=5.0):
daemon=True,
)
t.start()
- assert ready.wait(timeout=5), "WebSocket subscriber did not become ready"
+ assert ready.wait(timeout=_WS_HANDSHAKE_TIMEOUT), "WebSocket subscriber did not become ready"
publish_fn()
@@ -1740,7 +1746,7 @@ def test_shadow_delete_over_http_emits_delete_accepted_but_get_nothing(iot_data_
f"{base}/get/+",
lambda: iot_data_client.get_thing_shadow(thingName=thing),
want=1,
- timeout=2.0,
+ timeout=_WS_HANDSHAKE_TIMEOUT,
)
assert received == []
@@ -1800,7 +1806,7 @@ def test_shadow_update_over_http_rejected_emits_no_frames(iot_data_client):
assert ei.value.response["Error"]["Code"] == "ConflictException"
received = _collect_shadow_frames(
- f"{base}/update/+", _stale_update, want=1, timeout=2.0
+ f"{base}/update/+", _stale_update, want=1, timeout=_WS_HANDSHAKE_TIMEOUT
)
assert received == []
@@ -1817,7 +1823,7 @@ def test_shadow_delete_over_http_missing_emits_no_frames(iot_data_client):
assert ei.value.response["Error"]["Code"] == "ResourceNotFoundException"
received = _collect_shadow_frames(
- f"{base}/delete/+", _delete_missing, want=1, timeout=2.0
+ f"{base}/delete/+", _delete_missing, want=1, timeout=_WS_HANDSHAKE_TIMEOUT
)
assert received == []
@@ -1888,10 +1894,10 @@ async def _ws_publish_shadow_and_collect(
async with websockets.connect(ws_url, subprotocols=["mqtt"]) as ws:
await ws.send(_make_connect(_unique("shadow-dev")))
- await asyncio.wait_for(ws.recv(), timeout=2.0) # CONNACK
+ await asyncio.wait_for(ws.recv(), timeout=_WS_HANDSHAKE_TIMEOUT) # CONNACK
await ws.send(_make_subscribe(packet_id=1, topic=sub_filter, qos=0))
while True:
- msg = await asyncio.wait_for(ws.recv(), timeout=2.0)
+ msg = await asyncio.wait_for(ws.recv(), timeout=_WS_HANDSHAKE_TIMEOUT)
if _record(msg) == 9: # SUBACK
break
await ws.send(_make_publish_frame(pub_topic, pub_payload))
@@ -3370,7 +3376,7 @@ def test_mtls_no_client_cert_uses_default_account(broker, tmp_path):
broker.client("iot-data", access_key="111111111111").publish(
topic=topic, payload=b"someone-else"
)
- assert peer.next_publish(timeout=2.0) is None, "leaked across accounts"
+ assert peer.next_publish(timeout=_WS_HANDSHAKE_TIMEOUT) is None, "leaked across accounts"
broker.client("iot-data", access_key="000000000000").publish(
topic=topic, payload=b"default-account"
@@ -3559,7 +3565,7 @@ def test_mtls_account_scoped_delivery(broker, tmp_path):
broker.client("iot-data", access_key="000000000000").publish(
topic=topic, payload=b"other-tenant"
)
- assert peer.next_publish(timeout=2.0) is None, "leaked across accounts"
+ assert peer.next_publish(timeout=_WS_HANDSHAKE_TIMEOUT) is None, "leaked across accounts"
broker.client("iot-data", access_key="111111111111").publish(
topic=topic, payload=b"own-tenant"
@@ -3576,7 +3582,7 @@ def test_mtls_garbage_bytes_dropped(broker, tmp_path):
try:
junk.send(bytes([0xFF]) * 64)
junk.send(os.urandom(256))
- junk.next_packet(timeout=2.0)
+ junk.next_packet(timeout=_WS_HANDSHAKE_TIMEOUT)
finally:
junk.close()