Skip to content

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

Hotfix/v1.0.4 apigateway (#5)

Nahuel Nucera76534fe4b3da
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0e8a041a..0c142dfd 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,20 @@ Versioning follows [Semantic Versioning](https://semver.org/).
---
-## [0.2.0] — 2026-03-25
+## [1.0.3] — 2026-03-25
+
+### Fixed
+- **Test port portability**: execute-api test URLs now read port from `MINISTACK_ENDPOINT` env var instead of hardcoding 4566 — fixes all execute-api tests when running against Docker on a non-default port
+- **API Gateway Authorizers**: `CreateAuthorizer`, `GetAuthorizer`, `GetAuthorizers`, `UpdateAuthorizer`, `DeleteAuthorizer` — full CRUD for JWT and Lambda authorizers; state included in persistence snapshot
+- **API Gateway `{proxy+}` greedy path matching**: `_path_matches` now handles `{param+}` placeholders matching multiple path segments (e.g. `/files/{proxy+}` matches `/files/a/b/c`)
+- **API Gateway `routeKey` in Lambda event**: Lambda proxy event `routeKey` now reflects the matched route key (e.g. `"GET /ping"`) instead of always being `"$default"`
+- **API Gateway Authorizer `identitySource` compliance**: field now stored and returned as array of strings (`["$request.header.Authorization"]`) matching AWS spec — was incorrectly a single string
+- **Lambda `DeleteFunctionUrlConfig` response**: now returns 204 with empty body (was returning 204 with `{}` body, causing `RemoteDisconnected` in boto3)
+- 377 integration tests — all passing, including against Docker image
+
+---
+
+## [1.0.2] — 2026-03-25
### Added
@@ -75,7 +88,10 @@ Versioning follows [Semantic Versioning](https://semver.org/).
- **API Gateway `routeKey` in Lambda event**: Lambda proxy event `routeKey` now reflects the matched route key (e.g. `"GET /ping"`) instead of always being `"$default"`
- **API Gateway Authorizers**: `CreateAuthorizer`, `GetAuthorizer`, `GetAuthorizers`, `UpdateAuthorizer`, `DeleteAuthorizer` — full CRUD for JWT and Lambda authorizers; state included in persistence snapshot
- **Test idempotency**: added `POST /_ministack/reset` endpoint and session-scoped `autouse` fixture so the test suite passes on repeated runs against the same server without restarting
-- 377 integration tests — all passing (6 new tests covering the above gaps)
+- **API Gateway Authorizer `identitySource` compliance**: field now stored and returned as array of strings (`["$request.header.Authorization"]`) matching AWS spec — was incorrectly a single string
+- **Lambda `DeleteFunctionUrlConfig` response**: now returns 204 with empty body (was returning 204 with `{}` body, causing `RemoteDisconnected` in boto3)
+- **Test port portability**: execute-api test URLs now read port from `MINISTACK_ENDPOINT` env var instead of hardcoding 4566 — fixes all execute-api tests when running against Docker on a non-default port
+- 377 integration tests — all passing, including against Docker image
### Roadmap Update
The following roadmap items from v0.1.0 are now **completed**:
@@ -87,7 +103,7 @@ The following roadmap items from v0.1.0 are now **completed**:
---
-## [0.1.0] — 2024-03-24
+## [1.0.1] — 2024-03-24
Initial public release. Built as a free, open-source alternative to LocalStack.
diff --git a/services/apigateway.py b/services/apigateway.py
index 4067ef2e..fa4f95de 100644
--- a/services/apigateway.py
+++ b/services/apigateway.py
@@ -664,7 +664,7 @@ def _create_authorizer(api_id, data):
"authorizerId": auth_id,
"authorizerType": data.get("authorizerType", "JWT"),
"name": data.get("name", ""),
- "identitySource": data.get("identitySource", "$request.header.Authorization"),
+ "identitySource": data.get("identitySource", ["$request.header.Authorization"]),
"jwtConfiguration": data.get("jwtConfiguration", {}),
"authorizerUri": data.get("authorizerUri", ""),
"authorizerPayloadFormatVersion": data.get("authorizerPayloadFormatVersion", "2.0"),
diff --git a/services/ecs.py b/services/ecs.py
index d5286636..5eb7c306 100644
--- a/services/ecs.py
+++ b/services/ecs.py
@@ -782,12 +782,11 @@ def _describe_tasks(data):
for ref in task_refs:
task = _resolve_task(ref, cluster_name)
if task:
+ _maybe_mark_stopped(task)
t = _sanitize(task)
if "TAGS" in include:
t["tags"] = _tags.get(task["taskArn"], [])
result.append(t)
- _maybe_mark_stopped(task)
- result.append({k: v for k, v in task.items() if not k.startswith("_")})
else:
arn = ref if ref.startswith("arn:") else \
f"arn:aws:ecs:{REGION}:{ACCOUNT_ID}:task/{cluster_name}/{ref}"
diff --git a/services/lambda_svc.py b/services/lambda_svc.py
index 00024c73..5191c5bd 100644
--- a/services/lambda_svc.py
+++ b/services/lambda_svc.py
@@ -1864,7 +1864,7 @@ def _delete_function_url_config(func_name: str, qualifier: str | None):
return error_response_json("ResourceNotFoundException",
f"Function URL config not found for {func_name}", 404)
del _function_urls[key]
- return json_response({}, status=204)
+ return 204, {}, b""
def _list_function_url_configs(func_name: str, query_params: dict):
diff --git a/tests/test_services.py b/tests/test_services.py
index ede8ec57..134a8929 100644
--- a/tests/test_services.py
+++ b/tests/test_services.py
@@ -6,8 +6,17 @@ Requires: pip install boto3 pytest
import io
import json
+import os
import time
import zipfile
+from urllib.parse import urlparse
+
+import pytest
+from botocore.exceptions import ClientError
+
+# Derive execute-api port from MINISTACK_ENDPOINT so Docker runs work
+_endpoint = os.environ.get("MINISTACK_ENDPOINT", "http://localhost:4566")
+_EXECUTE_PORT = urlparse(_endpoint).port or 4566
import pytest
from botocore.exceptions import ClientError
@@ -105,6 +114,12 @@ def test_s3_delete_object_idempotent(s3):
resp = s3.delete_object(Bucket="intg-s3-delidempotent", Key="nonexistent.txt")
assert resp["ResponseMetadata"]["HTTPStatusCode"] == 204
+def test_s3_delete_object(s3):
+ s3.create_bucket(Bucket="intg-s3-delobj")
+ s3.put_object(Bucket="intg-s3-delobj", Key="bye.txt", Body=b"bye")
+ s3.delete_object(Bucket="intg-s3-delobj", Key="bye.txt")
+ with pytest.raises(ClientError):
+ s3.get_object(Bucket="intg-s3-delobj", Key="bye.txt")
def test_s3_copy_object(s3):
s3.create_bucket(Bucket="intg-s3-copysrc")
@@ -353,6 +368,33 @@ def test_sqs_list_queues(sqs):
assert any("intg-sqs-list-alpha" in u for u in urls)
assert any("intg-sqs-list-beta" in u for u in urls)
+def test_sqs_create_queue(sqs):
+ resp = sqs.create_queue(QueueName="intg-sqs-create")
+ assert "QueueUrl" in resp
+ assert "intg-sqs-create" in resp["QueueUrl"]
+
+
+def test_sqs_delete_queue(sqs):
+ url = sqs.create_queue(QueueName="intg-sqs-delete")["QueueUrl"]
+ sqs.delete_queue(QueueUrl=url)
+ with pytest.raises(ClientError):
+ sqs.get_queue_attributes(QueueUrl=url, AttributeNames=["All"])
+
+
+def test_sqs_list_queues(sqs):
+ sqs.create_queue(QueueName="intg-sqs-list-alpha")
+ sqs.create_queue(QueueName="intg-sqs-list-beta")
+ resp = sqs.list_queues(QueueNamePrefix="intg-sqs-list-")
+ urls = resp.get("QueueUrls", [])
+ assert len(urls) >= 2
+ assert any("intg-sqs-list-alpha" in u for u in urls)
+ assert any("intg-sqs-list-beta" in u for u in urls)
+
+
+def test_sqs_get_queue_url(sqs):
+ sqs.create_queue(QueueName="intg-sqs-geturl")
+ resp = sqs.get_queue_url(QueueName="intg-sqs-geturl")
+ assert "intg-sqs-geturl" in resp["QueueUrl"]
def test_sqs_get_queue_url(sqs):
sqs.create_queue(QueueName="intg-sqs-geturl")
@@ -4879,9 +4921,9 @@ def test_lambda_warm_start(lam, apigw):
def call():
req = _urlreq.Request(
- f"http://{api_id}.execute-api.localhost:4566/$default/ping", method="GET"
+ f"http://{api_id}.execute-api.localhost:{_EXECUTE_PORT}/$default/ping", method="GET"
)
- req.add_header("Host", f"{api_id}.execute-api.localhost:4566")
+ req.add_header("Host", f"{api_id}.execute-api.localhost:{_EXECUTE_PORT}")
return _urlreq.urlopen(req).read().decode()
t1 = call() # cold start — spawns worker, imports module
@@ -4936,9 +4978,9 @@ def test_apigw_execute_lambda_proxy(apigw, lam):
)["RouteId"]
apigw.create_stage(ApiId=api_id, StageName="$default")
- url = f"http://{api_id}.execute-api.localhost:4566/$default/hello"
+ url = f"http://{api_id}.execute-api.localhost:{_EXECUTE_PORT}/$default/hello"
req = _urlreq.Request(url, method="GET")
- req.add_header("Host", f"{api_id}.execute-api.localhost:4566")
+ req.add_header("Host", f"{api_id}.execute-api.localhost:{_EXECUTE_PORT}")
resp = _urlreq.urlopen(req)
assert resp.status == 200
body = json.loads(resp.read())
@@ -4958,9 +5000,9 @@ def test_apigw_execute_no_route(apigw):
api_id = apigw.create_api(Name="no-route-api", ProtocolType="HTTP")["ApiId"]
apigw.create_stage(ApiId=api_id, StageName="$default")
- url = f"http://{api_id}.execute-api.localhost:4566/$default/nonexistent"
+ url = f"http://{api_id}.execute-api.localhost:{_EXECUTE_PORT}/$default/nonexistent"
req = _urlreq.Request(url, method="GET")
- req.add_header("Host", f"{api_id}.execute-api.localhost:4566")
+ req.add_header("Host", f"{api_id}.execute-api.localhost:{_EXECUTE_PORT}")
try:
_urlreq.urlopen(req)
assert False, "Expected 404"
@@ -4993,9 +5035,9 @@ def test_apigw_execute_default_route(apigw, lam):
apigw.create_route(ApiId=api_id, RouteKey="$default", Target=f"integrations/{int_id}")
apigw.create_stage(ApiId=api_id, StageName="$default")
- url = f"http://{api_id}.execute-api.localhost:4566/$default/any/path/here"
+ url = f"http://{api_id}.execute-api.localhost:{_EXECUTE_PORT}/$default/any/path/here"
req = _urlreq.Request(url, method="POST")
- req.add_header("Host", f"{api_id}.execute-api.localhost:4566")
+ req.add_header("Host", f"{api_id}.execute-api.localhost:{_EXECUTE_PORT}")
resp = _urlreq.urlopen(req)
assert resp.status == 200
@@ -5087,9 +5129,9 @@ def test_apigw_path_param_route(apigw, lam):
apigw.create_route(ApiId=api_id, RouteKey="GET /items/{id}", Target=f"integrations/{int_id}")
apigw.create_stage(ApiId=api_id, StageName="$default")
- url = f"http://{api_id}.execute-api.localhost:4566/$default/items/abc123"
+ url = f"http://{api_id}.execute-api.localhost:{_EXECUTE_PORT}/$default/items/abc123"
req = _urlreq.Request(url, method="GET")
- req.add_header("Host", f"{api_id}.execute-api.localhost:4566")
+ req.add_header("Host", f"{api_id}.execute-api.localhost:{_EXECUTE_PORT}")
resp = _urlreq.urlopen(req)
assert resp.status == 200
body = json.loads(resp.read())
@@ -5119,9 +5161,9 @@ def test_apigw_greedy_path_param(apigw, lam):
apigw.create_stage(ApiId=api_id, StageName="$default")
# Path with multiple segments should match {proxy+}
- url = f"http://{api_id}.execute-api.localhost:4566/$default/files/a/b/c"
+ url = f"http://{api_id}.execute-api.localhost:{_EXECUTE_PORT}/$default/files/a/b/c"
req = _urlreq.Request(url, method="GET")
- req.add_header("Host", f"{api_id}.execute-api.localhost:4566")
+ req.add_header("Host", f"{api_id}.execute-api.localhost:{_EXECUTE_PORT}")
resp = _urlreq.urlopen(req)
assert resp.status == 200
# handler returns rawPath as body string
@@ -5188,9 +5230,9 @@ def test_apigw_routekey_in_lambda_event(apigw, lam):
apigw.create_route(ApiId=api_id, RouteKey="GET /ping", Target=f"integrations/{int_id}")
apigw.create_stage(ApiId=api_id, StageName="$default")
- url = f"http://{api_id}.execute-api.localhost:4566/$default/ping"
+ url = f"http://{api_id}.execute-api.localhost:{_EXECUTE_PORT}/$default/ping"
req = _urlreq.Request(url, method="GET")
- req.add_header("Host", f"{api_id}.execute-api.localhost:4566")
+ req.add_header("Host", f"{api_id}.execute-api.localhost:{_EXECUTE_PORT}")
resp = _urlreq.urlopen(req)
assert resp.status == 200
assert resp.read().decode() == "GET /ping"