Skip to content

Commit 845a0d5

Browse files
committed
minor fix in build config
1 parent 6b3260b commit 845a0d5

File tree

4 files changed

+62
-13
lines changed

4 files changed

+62
-13
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/pyproject.toml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,27 @@ 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+
"cbor2",
24+
"jsonpatch",
25+
"localstack-core[base-runtime]",
26+
"rolo>=0.7",
27+
"xmltodict",
28+
# pytest and other test utils
29+
"h11",
2130
"pytest",
2231
"pytest-httpserver",
23-
"ruff"
32+
"ruff",
33+
# build tools
34+
"setuptools",
35+
"setuptools_scm",
36+
"wheel"
2437
]
2538

2639

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)