Skip to content

Commit 4429fe4

Browse files
committed
Add stub test
1 parent 1069f41 commit 4429fe4

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/test_filters_jinja2.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Tests for Jinja2 CQL2 filter."""
2+
3+
import pytest
4+
from fastapi.testclient import TestClient
5+
from utils import AppFactory
6+
7+
app_factory = AppFactory(
8+
oidc_discovery_url="https://example-stac-api.com/.well-known/openid-configuration",
9+
default_public=False,
10+
)
11+
12+
13+
def test_collections_filter_contained_by_token(source_api_server, token_builder):
14+
""""""
15+
app = app_factory(
16+
upstream_url=source_api_server,
17+
collections_filter={
18+
"cls": "stac_auth_proxy.filters.Template",
19+
"args": [
20+
"A_CONTAINEDBY(id, ( '{{ token.collections | join(\"', '\") }}' ))"
21+
],
22+
},
23+
)
24+
client = TestClient(
25+
app,
26+
headers={
27+
"Authorization": f"Bearer {token_builder({"collections": ["foo", "bar"]})}"
28+
},
29+
)
30+
response = client.get("/collections")
31+
assert response.status_code == 200
32+
33+
# TODO: We need to verify that the upstream API was called with an applied filter

0 commit comments

Comments
 (0)