eoapi-cdk 8.1.0 → 8.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +594 -26
- package/lib/bastion-host/index.js +1 -1
- package/lib/database/PgBouncer.js +2 -2
- package/lib/database/index.d.ts +1 -0
- package/lib/database/index.js +5 -5
- package/lib/database/pgbouncer-setup.sh +6 -2
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -1
- package/lib/ingestor-api/index.js +1 -1
- package/lib/stac-api/index.js +1 -1
- package/lib/stac-browser/index.js +1 -1
- package/lib/stac-item-loader/index.d.ts +322 -0
- package/lib/stac-item-loader/index.js +251 -0
- package/lib/stac-item-loader/runtime/Dockerfile +18 -0
- package/lib/stac-item-loader/runtime/pyproject.toml +17 -0
- package/lib/stac-item-loader/runtime/src/stac_item_loader/handler.py +241 -0
- package/lib/stactools-item-generator/index.d.ts +243 -0
- package/lib/stactools-item-generator/index.js +204 -0
- package/lib/stactools-item-generator/runtime/Dockerfile +20 -0
- package/lib/stactools-item-generator/runtime/pyproject.toml +16 -0
- package/lib/stactools-item-generator/runtime/src/stactools_item_generator/__init__.py +2 -0
- package/lib/stactools-item-generator/runtime/src/stactools_item_generator/handler.py +176 -0
- package/lib/stactools-item-generator/runtime/src/stactools_item_generator/item.py +77 -0
- package/lib/tipg-api/index.js +1 -1
- package/lib/titiler-pgstac-api/index.js +1 -1
- package/package.json +1 -1
- package/pyproject.toml +45 -0
- package/uv.lock +1065 -0
- package/.devcontainer/devcontainer.json +0 -4
- package/.github/pull_request_template.md +0 -4
- package/.github/workflows/build.yaml +0 -73
- package/.github/workflows/build_and_release.yaml +0 -13
- package/.github/workflows/conventional-pr.yaml +0 -26
- package/.github/workflows/deploy.yaml +0 -84
- package/.github/workflows/distribute.yaml +0 -46
- package/.github/workflows/docs.yaml +0 -26
- package/.github/workflows/lint.yaml +0 -26
- package/.github/workflows/tox.yaml +0 -26
- package/.nvmrc +0 -1
- package/.pre-commit-config.yaml +0 -23
- package/CHANGELOG.md +0 -464
- package/diagrams/bastion_diagram.excalidraw +0 -1416
- package/diagrams/bastion_diagram.png +0 -0
- package/diagrams/ingestor_diagram.excalidraw +0 -2274
- package/diagrams/ingestor_diagram.png +0 -0
- package/integration_tests/cdk/README.md +0 -55
- package/integration_tests/cdk/app.py +0 -186
- package/integration_tests/cdk/cdk.json +0 -32
- package/integration_tests/cdk/config.py +0 -52
- package/integration_tests/cdk/package-lock.json +0 -42
- package/integration_tests/cdk/package.json +0 -7
- package/integration_tests/cdk/requirements.txt +0 -7
- package/lib/database/lambda/package-lock.json +0 -1324
- package/lib/ingestor-api/runtime/tests/conftest.py +0 -270
- package/lib/ingestor-api/runtime/tests/test_collection.py +0 -87
- package/lib/ingestor-api/runtime/tests/test_collection_endpoint.py +0 -41
- package/lib/ingestor-api/runtime/tests/test_ingestor.py +0 -60
- package/lib/ingestor-api/runtime/tests/test_registration.py +0 -207
- package/lib/ingestor-api/runtime/tests/test_utils.py +0 -35
- package/lib/ingestor-api/runtime/tests/test_validators.py +0 -164
- package/ruff.toml +0 -23
- package/tox.ini +0 -16
- package/tsconfig.tsbuildinfo +0 -1
- /package/lib/{ingestor-api/runtime/tests → stac-item-loader/runtime/src/stac_item_loader}/__init__.py +0 -0
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
from unittest.mock import MagicMock, patch
|
|
2
|
-
|
|
3
|
-
import pytest
|
|
4
|
-
import requests
|
|
5
|
-
from pydantic import AnyHttpUrl
|
|
6
|
-
from src import validators
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@pytest.fixture
|
|
10
|
-
def mock_settings():
|
|
11
|
-
"""Fixture to instantiate and patch settings with proper types."""
|
|
12
|
-
from src.config import Settings
|
|
13
|
-
|
|
14
|
-
mock_settings = Settings(
|
|
15
|
-
dynamodb_table="test-table",
|
|
16
|
-
stac_url=AnyHttpUrl("https://test-stac.url"),
|
|
17
|
-
data_access_role="arn:aws:iam::123456789012:role/test-role",
|
|
18
|
-
requester_pays=False,
|
|
19
|
-
jwks_url=AnyHttpUrl("https://test-jwks.url"),
|
|
20
|
-
root_path="testing",
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
with patch("src.config.settings", mock_settings):
|
|
24
|
-
yield mock_settings
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@pytest.fixture
|
|
28
|
-
def mock_requests():
|
|
29
|
-
"""Fixture to mock requests library."""
|
|
30
|
-
with patch("src.validators.requests") as mock_requests:
|
|
31
|
-
mock_response = MagicMock()
|
|
32
|
-
mock_response.ok = True
|
|
33
|
-
mock_response.raise_for_status.return_value = None
|
|
34
|
-
mock_requests.get.return_value = mock_response
|
|
35
|
-
mock_requests.head.return_value = mock_response
|
|
36
|
-
|
|
37
|
-
mock_requests.exceptions = requests.exceptions
|
|
38
|
-
|
|
39
|
-
yield mock_requests
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
@pytest.fixture
|
|
43
|
-
def mock_boto3():
|
|
44
|
-
"""Fixture to mock boto3 library."""
|
|
45
|
-
with patch("src.validators.boto3") as mock_boto3:
|
|
46
|
-
mock_client = MagicMock()
|
|
47
|
-
mock_client.exceptions.ClientError = Exception
|
|
48
|
-
|
|
49
|
-
mock_sts_client = MagicMock()
|
|
50
|
-
mock_sts_client.assume_role.return_value = {
|
|
51
|
-
"Credentials": {
|
|
52
|
-
"AccessKeyId": "test_access_key",
|
|
53
|
-
"SecretAccessKey": "test_secret_key",
|
|
54
|
-
"SessionToken": "test_session_token",
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
def mock_client_factory(service_name, **kwargs):
|
|
59
|
-
if service_name == "sts":
|
|
60
|
-
return mock_sts_client
|
|
61
|
-
return mock_client
|
|
62
|
-
|
|
63
|
-
mock_boto3.client.side_effect = mock_client_factory
|
|
64
|
-
|
|
65
|
-
yield mock_boto3, mock_client
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
class TestValidators:
|
|
69
|
-
def test_collection_exists_success(self, mock_settings, mock_requests):
|
|
70
|
-
"""Test collection_exists when the collection exists."""
|
|
71
|
-
validators.collection_exists.cache_clear()
|
|
72
|
-
|
|
73
|
-
result = validators.collection_exists("test-collection")
|
|
74
|
-
|
|
75
|
-
assert result
|
|
76
|
-
|
|
77
|
-
expected_url = f"{mock_settings.stac_url}collections/test-collection"
|
|
78
|
-
mock_requests.get.assert_called_once_with(expected_url)
|
|
79
|
-
|
|
80
|
-
def test_collection_exists_failure(self, mock_settings, mock_requests):
|
|
81
|
-
"""Test collection_exists when the collection doesn't exist."""
|
|
82
|
-
validators.collection_exists.cache_clear()
|
|
83
|
-
|
|
84
|
-
mock_response = MagicMock()
|
|
85
|
-
mock_response.ok = False
|
|
86
|
-
mock_response.status_code = 404
|
|
87
|
-
mock_requests.get.return_value = mock_response
|
|
88
|
-
|
|
89
|
-
with pytest.raises(ValueError) as excinfo:
|
|
90
|
-
validators.collection_exists("nonexistent-collection")
|
|
91
|
-
|
|
92
|
-
assert "Invalid collection 'nonexistent-collection'" in str(excinfo.value)
|
|
93
|
-
assert "404 response code" in str(excinfo.value)
|
|
94
|
-
|
|
95
|
-
def test_url_is_accessible_success(self, mock_requests):
|
|
96
|
-
"""Test url_is_accessible when the URL is accessible."""
|
|
97
|
-
validators.url_is_accessible("https://example.com/asset.tif")
|
|
98
|
-
|
|
99
|
-
mock_requests.head.assert_called_once_with("https://example.com/asset.tif")
|
|
100
|
-
|
|
101
|
-
def test_url_is_accessible_failure(self, mock_requests):
|
|
102
|
-
"""Test url_is_accessible when the URL is not accessible."""
|
|
103
|
-
mock_response = MagicMock()
|
|
104
|
-
mock_response.raise_for_status.side_effect = requests.exceptions.HTTPError(
|
|
105
|
-
response=MagicMock(status_code=403, reason="Forbidden")
|
|
106
|
-
)
|
|
107
|
-
mock_requests.head.return_value = mock_response
|
|
108
|
-
|
|
109
|
-
with pytest.raises(ValueError) as excinfo:
|
|
110
|
-
validators.url_is_accessible("https://example.com/private.tif")
|
|
111
|
-
|
|
112
|
-
assert "Asset not accessible" in str(excinfo.value)
|
|
113
|
-
|
|
114
|
-
def test_s3_object_is_accessible_success(self, mock_settings, mock_boto3):
|
|
115
|
-
"""Test s3_object_is_accessible when the object is accessible."""
|
|
116
|
-
_, mock_s3_client = mock_boto3
|
|
117
|
-
|
|
118
|
-
validators.s3_object_is_accessible("test-bucket", "test-key")
|
|
119
|
-
|
|
120
|
-
mock_s3_client.head_object.assert_called_once_with(
|
|
121
|
-
Bucket="test-bucket", Key="test-key"
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
def test_s3_object_is_accessible_with_requester_pays(self, mock_settings, mock_boto3):
|
|
125
|
-
"""Test s3_object_is_accessible with requester pays enabled."""
|
|
126
|
-
_, mock_s3_client = mock_boto3
|
|
127
|
-
|
|
128
|
-
mock_settings.requester_pays = True
|
|
129
|
-
|
|
130
|
-
validators.s3_object_is_accessible("test-bucket", "test-key")
|
|
131
|
-
|
|
132
|
-
mock_s3_client.head_object.assert_called_once_with(
|
|
133
|
-
Bucket="test-bucket", Key="test-key", RequestPayer="requester"
|
|
134
|
-
)
|
|
135
|
-
|
|
136
|
-
def test_s3_object_is_accessible_failure(self, mock_settings, mock_boto3):
|
|
137
|
-
"""Test s3_object_is_accessible when the object is not accessible."""
|
|
138
|
-
_, mock_s3_client = mock_boto3
|
|
139
|
-
|
|
140
|
-
_ = {"Error": {"Message": "Access Denied"}}
|
|
141
|
-
mock_s3_client.head_object.side_effect = Exception()
|
|
142
|
-
mock_s3_client.head_object.side_effect.__dict__["response"] = {
|
|
143
|
-
"Error": {"Message": "Access Denied"}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
with pytest.raises(ValueError) as excinfo:
|
|
147
|
-
validators.s3_object_is_accessible("test-bucket", "private-key")
|
|
148
|
-
|
|
149
|
-
assert "Asset not accessible" in str(excinfo.value)
|
|
150
|
-
|
|
151
|
-
def test_get_s3_credentials(self, mock_boto3):
|
|
152
|
-
"""Test get_s3_credentials returns the expected credentials."""
|
|
153
|
-
_, _ = mock_boto3
|
|
154
|
-
|
|
155
|
-
validators.get_s3_credentials.cache_clear()
|
|
156
|
-
|
|
157
|
-
credentials = validators.get_s3_credentials()
|
|
158
|
-
|
|
159
|
-
expected_credentials = {
|
|
160
|
-
"aws_access_key_id": "test_access_key",
|
|
161
|
-
"aws_secret_access_key": "test_secret_key",
|
|
162
|
-
"aws_session_token": "test_session_token",
|
|
163
|
-
}
|
|
164
|
-
assert credentials == expected_credentials
|
package/ruff.toml
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
line-length = 90
|
|
2
|
-
|
|
3
|
-
[lint]
|
|
4
|
-
select = [
|
|
5
|
-
"F", # flake8
|
|
6
|
-
"C", # flake8-comprehensions
|
|
7
|
-
"B", # flake8-bugbear
|
|
8
|
-
"I001", # isort
|
|
9
|
-
]
|
|
10
|
-
|
|
11
|
-
ignore = [
|
|
12
|
-
"E203",
|
|
13
|
-
"E266",
|
|
14
|
-
"F403",
|
|
15
|
-
"E231",
|
|
16
|
-
"E501", # line too long, handled by black
|
|
17
|
-
"B008", # do not perform function calls in argument defaults
|
|
18
|
-
"B905", # ignore zip() without an explicit strict= parameter, only support with python >3.10
|
|
19
|
-
]
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
[lint.mccabe]
|
|
23
|
-
max-complexity = 18
|
package/tox.ini
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
[tox]
|
|
2
|
-
skipsdist = True
|
|
3
|
-
envlist = py39
|
|
4
|
-
|
|
5
|
-
[testenv]
|
|
6
|
-
extras = test
|
|
7
|
-
envdir = toxenv
|
|
8
|
-
passenv = AWS_DEFAULT_REGION
|
|
9
|
-
commands =
|
|
10
|
-
pip install -r ./lib/ingestor-api/runtime/requirements.txt
|
|
11
|
-
pip install -r ./lib/ingestor-api/runtime/dev_requirements.txt
|
|
12
|
-
python -m pytest -s -vv
|
|
13
|
-
|
|
14
|
-
[pytest]
|
|
15
|
-
addopts = -ra -q
|
|
16
|
-
testpaths = lib/ingestor-api
|