Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro-cf committed Apr 25, 2024
1 parent 5bcac32 commit c3ba028
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
desc = f.read()

install_requires = [
"stac-fastapi.core==2.1.0",
"stac-fastapi.core==2.2.0",
"motor==3.3.2",
"pymongo==4.6.2",
"uvicorn",
Expand Down
7 changes: 7 additions & 0 deletions stac_fastapi/tests/basic_auth/test_basic_auth.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import pytest
import os

# - BASIC_AUTH={"public_endpoints":[{"path":"/","method":"GET"},{"path":"/search","method":"GET"}],"users":[{"username":"admin","password":"admin","permissions":"*"},{"username":"reader","password":"reader","permissions":[{"path":"/conformance","method":["GET"]},{"path":"/collections/{collection_id}/items/{item_id}","method":["GET"]},{"path":"/search","method":["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"]}]}]}


@pytest.mark.asyncio
async def test_get_search_not_authenticated(app_client_basic_auth):
"""Test public endpoint search without authentication"""
if not os.getenv("BASIC_AUTH"):
pytest.skip()
params = {"query": '{"gsd": {"gt": 14}}'}

response = await app_client_basic_auth.get("/search", params=params)
Expand All @@ -22,6 +25,8 @@ async def test_get_search_not_authenticated(app_client_basic_auth):
@pytest.mark.asyncio
async def test_post_search_authenticated(app_client_basic_auth):
"""Test protected post search with reader auhtentication"""
if not os.getenv("BASIC_AUTH"):
pytest.skip()
params = {
"bbox": [97.504892, -45.254738, 174.321298, -2.431580],
"fields": {"exclude": ["properties"]},
Expand All @@ -42,6 +47,8 @@ async def test_post_search_authenticated(app_client_basic_auth):
@pytest.mark.asyncio
async def test_delete_resource_insufficient_permissions(app_client_basic_auth):
"""Test protected delete collection with reader auhtentication"""
if not os.getenv("BASIC_AUTH"):
pytest.skip()
headers = {
"Authorization": "Basic cmVhZGVyOnJlYWRlcg=="
} # Assuming this is a valid authorization token
Expand Down

0 comments on commit c3ba028

Please sign in to comment.