From 4429fe4e9e927d8df8e1f357ae8108fa501310c9 Mon Sep 17 00:00:00 2001 From: Anthony Lukach Date: Thu, 12 Dec 2024 21:06:35 -0800 Subject: [PATCH] Add stub test --- tests/test_filters_jinja2.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/test_filters_jinja2.py diff --git a/tests/test_filters_jinja2.py b/tests/test_filters_jinja2.py new file mode 100644 index 0000000..ff8a2c4 --- /dev/null +++ b/tests/test_filters_jinja2.py @@ -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