Skip to content

Commit 02fbfd3

Browse files
committed
minor fix in build config
1 parent 6b3260b commit 02fbfd3

File tree

6 files changed

+67
-16
lines changed

6 files changed

+67
-16
lines changed

aws-proxy/Makefile

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ usage: ## Show this help
1010

1111
install: ## Install dependencies
1212
test -d .venv || $(VENV_BIN) .venv
13+
$(VENV_RUN); pip install -e .
1314
$(VENV_RUN); pip install -e .[test]
1415
touch $(VENV_DIR)/bin/activate
1516

@@ -25,18 +26,18 @@ format: ## Run ruff to format the whole codebase
2526
lint: ## Run code linter to check code style
2627
($(VENV_RUN); python -m ruff check --output-format=full . && python -m ruff format --check .)
2728

28-
test: venv ## Run tests
29+
test: ## Run tests
2930
$(VENV_RUN); python -m pytest $(PYTEST_ARGS) $(TEST_PATH)
3031

31-
dist: venv ## Create distribution package
32-
$(VENV_RUN); python setup.py sdist bdist_wheel
32+
entrypoints: ## Generate plugin entrypoints for Python package
33+
$(VENV_RUN); python -m plux entrypoints
3334

34-
build: ## Build the extension
35-
mkdir -p build
36-
cp -r setup.py setup.cfg README.md aws_proxy build/
37-
(cd build && python setup.py sdist)
35+
build: entrypoints ## Build the extension
36+
$(VENV_RUN); python -m build --no-isolation . --outdir build
37+
@# make sure that the entrypoints are contained in the dist folder and are non-empty
38+
@test -s localstack_extension_aws_proxy.egg-info/entry_points.txt || (echo "Entrypoints were not correctly created! Aborting!" && exit 1)
3839

39-
enable: $(wildcard ./build/dist/localstack_extension_aws_proxy-*.tar.gz) ## Enable the extension in LocalStack
40+
enable: $(wildcard ./build/localstack_extension_aws_proxy-*.tar.gz) ## Enable the extension in LocalStack
4041
$(VENV_RUN); \
4142
pip uninstall --yes localstack-extension-aws-proxy; \
4243
localstack extensions -v install file://$?

aws-proxy/aws_proxy/client/auth_proxy.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@
4646
from aws_proxy.shared.constants import HEADER_HOST_ORIGINAL
4747
from aws_proxy.shared.models import AddProxyRequest, ProxyConfig
4848

49-
from .http2_server import run_server
50-
5149
LOG = logging.getLogger(__name__)
5250
LOG.setLevel(logging.INFO)
5351
if localstack_config.DEBUG:
@@ -73,6 +71,9 @@ def __init__(self, config: ProxyConfig, port: int = None):
7371
super().__init__(port=port)
7472

7573
def do_run(self):
74+
# note: keep import here, to avoid runtime errors
75+
from .http2_server import run_server
76+
7677
self.register_in_instance()
7778
bind_host = self.config.get("bind_host") or DEFAULT_BIND_HOST
7879
proxy = run_server(

aws-proxy/aws_proxy/server/request_handler.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from typing import Dict, List
77

88
import yaml
9-
from flask import redirect
109
from localstack.constants import (
1110
APPLICATION_OCTET_STREAM,
1211
INTERNAL_RESOURCE_PATH,
@@ -77,10 +76,14 @@ def set_status(self, request: Request, **kwargs):
7776

7877
@route("/", methods=["GET"], host=ROUTE_HOST)
7978
def forward_from_root(self, request: Request, **kwargs):
79+
from flask import redirect
80+
8081
return redirect(f"{INTERNAL_RESOURCE_PATH}/aws-proxy/index.html")
8182

8283
@route(f"{INTERNAL_RESOURCE_PATH}/aws-proxy", methods=["GET"])
8384
def forward_from_extension_root(self, request: Request, **kwargs):
85+
from flask import redirect
86+
8487
return redirect(f"{INTERNAL_RESOURCE_PATH}/aws-proxy/index.html")
8588

8689
@route("/favicon.png", methods=["GET"], host=ROUTE_HOST)

aws-proxy/pyproject.toml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,25 @@ authors = [
1313
]
1414

1515
dependencies = [
16-
"localstack-ext"
16+
"localstack"
1717
]
1818

1919
[project.optional-dependencies]
2020
test=[
21+
# couple of dependencies required to import localstack test tools
22+
"boto3",
23+
"localstack-core[base-runtime]>4.9",
24+
"moto-ext",
25+
"rolo>=0.7",
26+
# pytest and other test utils
27+
"hypercorn",
2128
"pytest",
2229
"pytest-httpserver",
23-
"ruff"
30+
"ruff",
31+
# build tools
32+
"setuptools",
33+
"setuptools_scm",
34+
"wheel"
2435
]
2536

2637

aws-proxy/tests/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
13
import pytest
24
from localstack.testing.aws.util import (
35
base_aws_client_factory,
@@ -15,6 +17,9 @@
1517
# binding proxy to 0.0.0.0 to enable testing in CI
1618
PROXY_BIND_HOST = "0.0.0.0"
1719

20+
# run tests in us-east-1 region by default
21+
os.environ.setdefault("AWS_DEFAULT_REGION", "us-east-1")
22+
1823

1924
@pytest.fixture(scope="session")
2025
def aws_session():
Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,33 @@
1-
def test_secretsmanager_requests(start_aws_proxy):
2-
# TODO implement
3-
pass
1+
import boto3
2+
from localstack.aws.connect import connect_to
3+
4+
from aws_proxy.shared.models import ProxyConfig
5+
from localstack.utils.strings import short_uid
6+
7+
8+
def test_proxy_create_secret(start_aws_proxy, cleanups):
9+
# start proxy
10+
config = ProxyConfig(services={"secretsmanager": {"resources": ".*"}})
11+
start_aws_proxy(config)
12+
13+
# create clients
14+
sm_client = connect_to().secretsmanager
15+
sm_client_aws = boto3.client("secretsmanager")
16+
17+
# list buckets to assert that proxy is up and running
18+
secrets_proxied = sm_client.list_secrets()["SecretList"]
19+
secrets_aws = sm_client_aws.list_secrets()["SecretList"]
20+
assert secrets_proxied == secrets_aws
21+
22+
# create secret in AWS
23+
secret_name = f"s_{short_uid()}"
24+
result = sm_client_aws.create_secret(Name=secret_name, SecretString="test")
25+
secret_id = result["ARN"]
26+
cleanups.append(lambda: sm_client_aws.delete_secret(SecretId=secret_id))
27+
28+
# assert that the secret can be retrieved via the proxy
29+
secret_details = sm_client.describe_secret(SecretId=secret_id)
30+
secret_details_aws = sm_client.describe_secret(SecretId=secret_id)
31+
secret_details.pop("ResponseMetadata")
32+
secret_details_aws.pop("ResponseMetadata")
33+
assert secret_details == secret_details_aws

0 commit comments

Comments
 (0)