Skip to content

Commit 8a6a3e6

Browse files
authored
Use shared app config (#399)
**Related Issue(s):** - #394 - #392 **Description:** - Refactored test configuration to use shared app config pattern - Fixed api route spelling mistakes **PR Checklist:** - [x] Code is formatted and linted (run `pre-commit run --all-files`) - [x] Tests pass (run `make test`) - [x] Documentation has been updated to reflect changes, if applicable - [x] Changes are added to the changelog
1 parent a569587 commit 8a6a3e6

File tree

7 files changed

+111
-251
lines changed

7 files changed

+111
-251
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1515
### Changed
1616

1717
- Optimize data_loader.py script [#395](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/395)
18+
- Refactored test configuration to use shared app config pattern [#399](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/399)
1819

1920
### Removed
2021

examples/auth/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ limited permissions to specific read-only endpoints.
123123
{"path": "/collections/{collection_id}", "method": ["GET"]},
124124
{"path": "/collections/{collection_id}/items", "method": ["GET"]},
125125
{"path": "/queryables", "method": ["GET"]},
126-
{"path": "/queryables/collections/{collection_id}/queryables", "method": ["GET"]},
126+
{"path": "/collections/{collection_id}/queryables", "method": ["GET"]},
127127
{"path": "/_mgmt/ping", "method": ["GET"]}
128128
],
129129
"dependencies": [

examples/auth/compose.basic_auth.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ services:
2121
- ES_USE_SSL=false
2222
- ES_VERIFY_CERTS=false
2323
- BACKEND=elasticsearch
24-
- STAC_FASTAPI_ROUTE_DEPENDENCIES=[{"routes":[{"method":"*","path":"*"}],"dependencies":[{"method":"stac_fastapi.core.basic_auth.BasicAuth","kwargs":{"credentials":[{"username":"admin","password":"admin"}]}}]},{"routes":[{"path":"/","method":["GET"]},{"path":"/conformance","method":["GET"]},{"path":"/collections/{collection_id}/items/{item_id}","method":["GET"]},{"path":"/search","method":["GET","POST"]},{"path":"/collections","method":["GET"]},{"path":"/collections/{collection_id}","method":["GET"]},{"path":"/collections/{collection_id}/items","method":["GET"]},{"path":"/queryables","method":["GET"]},{"path":"/queryables/collections/{collection_id}/queryables","method":["GET"]},{"path":"/_mgmt/ping","method":["GET"]}],"dependencies":[{"method":"stac_fastapi.core.basic_auth.BasicAuth","kwargs":{"credentials":[{"username":"reader","password":"reader"}]}}]}]
24+
- STAC_FASTAPI_ROUTE_DEPENDENCIES=[{"routes":[{"method":"*","path":"*"}],"dependencies":[{"method":"stac_fastapi.core.basic_auth.BasicAuth","kwargs":{"credentials":[{"username":"admin","password":"admin"}]}}]},{"routes":[{"path":"/","method":["GET"]},{"path":"/conformance","method":["GET"]},{"path":"/collections/{collection_id}/items/{item_id}","method":["GET"]},{"path":"/search","method":["GET","POST"]},{"path":"/collections","method":["GET"]},{"path":"/collections/{collection_id}","method":["GET"]},{"path":"/collections/{collection_id}/items","method":["GET"]},{"path":"/queryables","method":["GET"]},{"path":"/collections/{collection_id}/queryables","method":["GET"]},{"path":"/_mgmt/ping","method":["GET"]}],"dependencies":[{"method":"stac_fastapi.core.basic_auth.BasicAuth","kwargs":{"credentials":[{"username":"reader","password":"reader"}]}}]}]
2525
ports:
2626
- "8080:8080"
2727
volumes:
@@ -55,7 +55,7 @@ services:
5555
- ES_USE_SSL=false
5656
- ES_VERIFY_CERTS=false
5757
- BACKEND=opensearch
58-
- STAC_FASTAPI_ROUTE_DEPENDENCIES=[{"routes":[{"method":"*","path":"*"}],"dependencies":[{"method":"stac_fastapi.core.basic_auth.BasicAuth","kwargs":{"credentials":[{"username":"admin","password":"admin"}]}}]},{"routes":[{"path":"/","method":["GET"]},{"path":"/conformance","method":["GET"]},{"path":"/collections/{collection_id}/items/{item_id}","method":["GET"]},{"path":"/search","method":["GET","POST"]},{"path":"/collections","method":["GET"]},{"path":"/collections/{collection_id}","method":["GET"]},{"path":"/collections/{collection_id}/items","method":["GET"]},{"path":"/queryables","method":["GET"]},{"path":"/queryables/collections/{collection_id}/queryables","method":["GET"]},{"path":"/_mgmt/ping","method":["GET"]}],"dependencies":[{"method":"stac_fastapi.core.basic_auth.BasicAuth","kwargs":{"credentials":[{"username":"reader","password":"reader"}]}}]}]
58+
- STAC_FASTAPI_ROUTE_DEPENDENCIES=[{"routes":[{"method":"*","path":"*"}],"dependencies":[{"method":"stac_fastapi.core.basic_auth.BasicAuth","kwargs":{"credentials":[{"username":"admin","password":"admin"}]}}]},{"routes":[{"path":"/","method":["GET"]},{"path":"/conformance","method":["GET"]},{"path":"/collections/{collection_id}/items/{item_id}","method":["GET"]},{"path":"/search","method":["GET","POST"]},{"path":"/collections","method":["GET"]},{"path":"/collections/{collection_id}","method":["GET"]},{"path":"/collections/{collection_id}/items","method":["GET"]},{"path":"/queryables","method":["GET"]},{"path":"/collections/{collection_id}/queryables","method":["GET"]},{"path":"/_mgmt/ping","method":["GET"]}],"dependencies":[{"method":"stac_fastapi.core.basic_auth.BasicAuth","kwargs":{"credentials":[{"username":"reader","password":"reader"}]}}]}]
5959
ports:
6060
- "8082:8082"
6161
volumes:

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/app.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,24 @@
104104

105105
post_request_model = create_post_request_model(search_extensions)
106106

107-
api = StacApi(
108-
title=os.getenv("STAC_FASTAPI_TITLE", "stac-fastapi-elasticsearch"),
109-
description=os.getenv("STAC_FASTAPI_DESCRIPTION", "stac-fastapi-elasticsearch"),
110-
api_version=os.getenv("STAC_FASTAPI_VERSION", "5.0.0a1"),
111-
settings=settings,
112-
extensions=extensions,
113-
client=CoreClient(
107+
app_config = {
108+
"title": os.getenv("STAC_FASTAPI_TITLE", "stac-fastapi-elasticsearch"),
109+
"description": os.getenv("STAC_FASTAPI_DESCRIPTION", "stac-fastapi-elasticsearch"),
110+
"api_version": os.getenv("STAC_FASTAPI_VERSION", "5.0.0a1"),
111+
"settings": settings,
112+
"extensions": extensions,
113+
"client": CoreClient(
114114
database=database_logic,
115115
session=session,
116116
post_request_model=post_request_model,
117117
landing_page_id=os.getenv("STAC_FASTAPI_LANDING_PAGE_ID", "stac-fastapi"),
118118
),
119-
search_get_request_model=create_get_request_model(search_extensions),
120-
search_post_request_model=post_request_model,
121-
route_dependencies=get_route_dependencies(),
122-
)
119+
"search_get_request_model": create_get_request_model(search_extensions),
120+
"search_post_request_model": post_request_model,
121+
"route_dependencies": get_route_dependencies(),
122+
}
123+
124+
api = StacApi(**app_config)
123125

124126

125127
@asynccontextmanager

stac_fastapi/opensearch/stac_fastapi/opensearch/app.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,24 @@
105105

106106
post_request_model = create_post_request_model(search_extensions)
107107

108-
api = StacApi(
109-
title=os.getenv("STAC_FASTAPI_TITLE", "stac-fastapi-opensearch"),
110-
description=os.getenv("STAC_FASTAPI_DESCRIPTION", "stac-fastapi-opensearch"),
111-
api_version=os.getenv("STAC_FASTAPI_VERSION", "5.0.0a1"),
112-
settings=settings,
113-
extensions=extensions,
114-
client=CoreClient(
108+
app_config = {
109+
"title": os.getenv("STAC_FASTAPI_TITLE", "stac-fastapi-opensearch"),
110+
"description": os.getenv("STAC_FASTAPI_DESCRIPTION", "stac-fastapi-opensearch"),
111+
"api_version": os.getenv("STAC_FASTAPI_VERSION", "5.0.0a1"),
112+
"settings": settings,
113+
"extensions": extensions,
114+
"client": CoreClient(
115115
database=database_logic,
116116
session=session,
117117
post_request_model=post_request_model,
118118
landing_page_id=os.getenv("STAC_FASTAPI_LANDING_PAGE_ID", "stac-fastapi"),
119119
),
120-
search_get_request_model=create_get_request_model(search_extensions),
121-
search_post_request_model=post_request_model,
122-
route_dependencies=get_route_dependencies(),
123-
)
120+
"search_get_request_model": create_get_request_model(search_extensions),
121+
"search_post_request_model": post_request_model,
122+
"route_dependencies": get_route_dependencies(),
123+
}
124+
125+
api = StacApi(**app_config)
124126

125127

126128
@asynccontextmanager

stac_fastapi/tests/api/test_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"POST /collections/{collection_id}/items",
3535
"PUT /collections/{collection_id}",
3636
"PUT /collections/{collection_id}/items/{item_id}",
37+
"POST /collections/{collection_id}/bulk_items",
3738
"GET /aggregations",
3839
"GET /aggregate",
3940
"POST /aggregations",

0 commit comments

Comments
 (0)