Skip to content

Commit

Permalink
Merge branch 'develop' into full-transaction-support
Browse files Browse the repository at this point in the history
  • Loading branch information
slesaad committed Jul 24, 2024
2 parents 15e0286 + f15740f commit 84c8273
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 14 deletions.
1 change: 1 addition & 0 deletions .example.env
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ CERT_ARN=
VEDA_CLOUDFRONT=
VEDA_CLOUDFRONT_OAC=[OPTIONAL, CONFIGURES ORIGIN ACCESS CONTROL, DEFAULTS TO TRUE]
VEDA_CUSTOM_HOST=
VEDA_SHARED_WEB_ACL_ID=[OPTIONAL ID ARN for WEB ACL]
95 changes: 84 additions & 11 deletions .github/workflows/tests/test_stac.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,125 @@

import httpx

seeded_collection = "noaa-emergency-response"
seeded_id = "20200307aC0853300w361200"
stac_endpoint = "http://0.0.0.0:8081"
index_endpoint = "index.html"
docs_endpoint = "docs"
health_endpoint = "_mgmt/ping"
search_endpoint = "search"
collections_endpoint = "collections"


def test_stac_health():
"""test stac health endpoint."""

assert httpx.get(f"{stac_endpoint}/{health_endpoint}").status_code == 200


def test_stac_viewer():
"""test stac viewer."""
resp = httpx.get(f"{stac_endpoint}/{index_endpoint}")
assert resp.status_code == 200
assert resp.headers.get("x-correlation-id") == "local"
assert "<title>Simple STAC API Viewer</title>" in resp.text


def test_stac_docs():
"""test stac docs."""
resp = httpx.get(f"{stac_endpoint}/{docs_endpoint}")
assert resp.status_code == 200
assert "Swagger UI" in resp.text


def test_stac_get_search():
"""test stac get search."""
default_limit_param = "?limit=10"
resp = httpx.get(f"{stac_endpoint}/{search_endpoint}{default_limit_param}")
assert resp.status_code == 200
features = resp.json()["features"]
assert len(features) > 0
collections = [c["collection"] for c in features]
assert seeded_collection in collections


def test_stac_post_search():
"""test stac post search."""
request_body = {"collections": [seeded_collection]}
resp = httpx.post(f"{stac_endpoint}/{search_endpoint}", json=request_body)
assert resp.status_code == 200
features = resp.json()["features"]
assert len(features) > 0
collections = [c["collection"] for c in features]
assert seeded_collection in collections


def test_stac_get_collections():
"""test stac get collections"""
resp = httpx.get(f"{stac_endpoint}/{collections_endpoint}")
assert resp.status_code == 200
collections = resp.json()["collections"]
assert len(collections) > 0
id = [c["id"] for c in collections]
assert seeded_collection in id


def test_stac_get_collections_by_id():
"""test stac get collection by id"""
resp = httpx.get(f"{stac_endpoint}/{collections_endpoint}/{seeded_collection}")
assert resp.status_code == 200
collection = resp.json()
assert collection["id"] == seeded_collection


def test_stac_get_collection_items_by_id():
"""test stac get items in collection by collection id"""
resp = httpx.get(
f"{stac_endpoint}/{collections_endpoint}/{seeded_collection}/items"
)
assert resp.status_code == 200
collection = resp.json()
assert collection["type"] == "FeatureCollection"


def test_stac_api():
"""test stac."""
# Ping
assert httpx.get(f"{stac_endpoint}/_mgmt/ping").status_code == 200

# viewer
assert httpx.get(f"{stac_endpoint}/index.html").status_code == 200

# Collections
resp = httpx.get(f"{stac_endpoint}/collections")
assert resp.status_code == 200
collections = resp.json()["collections"]
assert len(collections) > 0
ids = [c["id"] for c in collections]
assert "noaa-emergency-response" in ids
assert seeded_collection in ids

# items
resp = httpx.get(f"{stac_endpoint}/collections/noaa-emergency-response/items")
resp = httpx.get(f"{stac_endpoint}/collections/{seeded_collection}/items")
assert resp.status_code == 200
items = resp.json()["features"]
assert len(items) == 10

# item
resp = httpx.get(
f"{stac_endpoint}/collections/noaa-emergency-response/items/20200307aC0853300w361200"
f"{stac_endpoint}/collections/{seeded_collection}/items/{seeded_id}"
)
assert resp.status_code == 200
item = resp.json()
assert item["id"] == "20200307aC0853300w361200"
assert item["id"] == seeded_id


def test_stac_to_raster():
"""test link to raster api."""
# tilejson
resp = httpx.get(
f"{stac_endpoint}/collections/noaa-emergency-response/items/20200307aC0853300w361200/tilejson.json",
f"{stac_endpoint}/collections/{seeded_collection}/items/{seeded_id}/tilejson.json",
params={"assets": "cog"},
)
assert resp.status_code == 307

# viewer
resp = httpx.get(
f"{stac_endpoint}/collections/noaa-emergency-response/items/20200307aC0853300w361200/viewer",
f"{stac_endpoint}/collections/{seeded_collection}/items/{seeded_id}/viewer",
params={"assets": "cog"},
)
assert resp.status_code == 307
3 changes: 0 additions & 3 deletions ingest_api/runtime/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ python-multipart==0.0.7
requests>=2.27.1
s3fs==2023.3.0
stac-pydantic @ git+https://github.com/ividito/stac-pydantic.git@3f4cb381c85749bb4b15d1181179057ec0f51a94
xarray==2023.1.0
xstac==1.1.0
zarr==2.13.6
boto3==1.24.59
aws_xray_sdk>=2.6.0,<3
aws-lambda-powertools>=1.18.0
4 changes: 4 additions & 0 deletions routes/infrastructure/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ class vedaRouteSettings(BaseSettings):
description="Certificate’s ARN",
)

shared_web_acl_id: Optional[str] = Field(
None, description="Shared Web ACL ID ARN for CloudFront Distribution"
)

class Config:
"""model config"""

Expand Down
1 change: 1 addition & 0 deletions routes/infrastructure/construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def __init__(
certificate=domain_cert,
default_root_object="index.html",
enable_logging=True,
web_acl_id=veda_route_settings.shared_web_acl_id,
domain_names=[
f"{stage}.{veda_route_settings.domain_hosted_zone_name}"
]
Expand Down

0 comments on commit 84c8273

Please sign in to comment.