-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Tests for Jinja2 CQL2 filter.""" | ||
|
||
import pytest | ||
from fastapi.testclient import TestClient | ||
from utils import AppFactory | ||
|
||
app_factory = AppFactory( | ||
oidc_discovery_url="https://example-stac-api.com/.well-known/openid-configuration", | ||
default_public=False, | ||
) | ||
|
||
|
||
def test_collections_filter_contained_by_token(source_api_server, token_builder): | ||
"""""" | ||
app = app_factory( | ||
upstream_url=source_api_server, | ||
collections_filter={ | ||
"cls": "stac_auth_proxy.filters.Template", | ||
"args": [ | ||
"A_CONTAINEDBY(id, ( '{{ token.collections | join(\"', '\") }}' ))" | ||
], | ||
}, | ||
) | ||
client = TestClient( | ||
app, | ||
headers={ | ||
"Authorization": f"Bearer {token_builder({"collections": ["foo", "bar"]})}" | ||
}, | ||
) | ||
response = client.get("/collections") | ||
assert response.status_code == 200 | ||
|
||
# TODO: We need to verify that the upstream API was called with an applied filter |