Skip to content

Commit e153430

Browse files
committed
minor fixes in wiremock extension
1 parent bd1956c commit e153430

5 files changed

Lines changed: 11 additions & 19 deletions

File tree

localstack-wiremock/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ test: ## Run integration tests (requires LocalStack running with the Extens
4040

4141
sample: ## Deploy sample app
4242
bin/create-stubs.sh
43-
(cd sample-app; tflocal init; tflocal apply)
43+
(cd sample-app; tflocal init; tflocal apply -auto-approve)
44+
apiId=$$(awslocal apigateway get-rest-apis | jq -r '.items[0].id'); \
45+
curl -k https://$$apiId.execute-api.us-east-1.localhost.localstack.cloud/dev/time-off
4446

4547
clean-dist: clean
4648
rm -rf dist/

localstack-wiremock/localstack_wiremock/utils/docker.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44
from typing import Callable
55
import requests
66

7-
from localstack_wiremock.utils.h2_proxy import (
8-
apply_http2_patches_for_grpc_support,
9-
ProxyRequestMatcher,
10-
)
117
from localstack.utils.docker_utils import DOCKER_CLIENT
128
from localstack.extensions.api import Extension, http
139
from localstack.http import Request
@@ -24,7 +20,7 @@
2420
# TODO: merge utils with code in TypeDB extension over time ...
2521

2622

27-
class ProxiedDockerContainerExtension(Extension, ProxyRequestMatcher):
23+
class ProxiedDockerContainerExtension(Extension):
2824
name: str
2925
"""Name of this extension"""
3026
image_name: str
@@ -80,12 +76,6 @@ def update_gateway_routes(self, router: http.Router[http.RouteHandler]):
8076
resource = WithHost(self.host, [resource])
8177
router.add(resource)
8278

83-
# apply patches to serve HTTP/2 requests
84-
for port in self.http2_ports or []:
85-
apply_http2_patches_for_grpc_support(
86-
get_addressable_container_host(), port, self
87-
)
88-
8979
def on_platform_shutdown(self):
9080
self._remove_container()
9181

@@ -127,7 +117,9 @@ def start_container(self) -> None:
127117

128118
def _ping_endpoint():
129119
# TODO: allow defining a custom healthcheck endpoint ...
130-
response = requests.get(f"http://{container_host}:{main_port}/")
120+
response = requests.get(
121+
f"http://{container_host}:{main_port}/__admin/health"
122+
)
131123
assert response.ok
132124

133125
try:

localstack-wiremock/pyproject.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ authors = [
1414
keywords = ["LocalStack", "WireMock"]
1515
classifiers = []
1616
dependencies = [
17-
"httpx",
18-
"h2",
19-
"priority",
17+
"priority"
2018
]
2119

2220
[project.urls]
@@ -35,4 +33,4 @@ dev = [
3533
]
3634

3735
[project.entry-points."localstack.extensions"]
38-
localstack_wiremock = "localstack_wiremock.extension:WireMockExtension"
36+
localstack-wiremock = "localstack_wiremock.extension:WireMockExtension"

localstack-wiremock/sample-app/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ resource "null_resource" "package_lambda" {
3333
command = <<-EOT
3434
rm -rf "${path.module}/build"
3535
mkdir -p "${path.module}/build"
36-
pip install --system -r "${path.module}/src/requirements.txt" -t "${path.module}/build"
3736
cp "${path.module}/src/handler.py" "${path.module}/build/"
37+
pip install -r "${path.module}/src/requirements.txt" -t "${path.module}/build"
3838
EOT
3939
interpreter = ["/bin/bash", "-c"]
4040
}

localstack-wiremock/sample-app/src/handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def get_time_off(event, context):
88
and returns a transformed JSON response.
99
"""
1010
try:
11-
# The mock API endpoint URL
11+
# Define the mock API endpoint URL (hardcoding `host.docker.internal` for now)
1212
# url = "http://wiremock.localhost.localstack.cloud:8080/company/time-offs/534813865"
1313
url = "http://host.docker.internal:8080/company/time-offs/534813865"
1414

0 commit comments

Comments
 (0)