Skip to content

Commit 340c768

Browse files
committed
chore: add tests to the auth0-ai package
1 parent 4f5df33 commit 340c768

File tree

5 files changed

+467
-124
lines changed

5 files changed

+467
-124
lines changed

packages/auth0-ai/auth0_ai/authorizers/fga/fga_filter.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
build_openfga_client,
44
build_openfga_client_sync,
55
)
6-
from pydantic import PrivateAttr
76
from openfga_sdk import ClientConfiguration
87
from openfga_sdk.client.models import ClientBatchCheckItem
98
from openfga_sdk.client.client import ClientBatchCheckRequest
109

1110

1211
class FGAFilter[T]:
13-
_query_builder: Callable[[T], ClientBatchCheckItem] = PrivateAttr()
12+
_query_builder: Callable[[T], ClientBatchCheckItem]
1413
_fga_configuration: Optional[ClientConfiguration]
1514

1615
def __init__(
@@ -43,6 +42,9 @@ async def filter(
4342
Returns:
4443
List[T]: Filtered list of documents authorized by FGA.
4544
"""
45+
if len(documents) == 0:
46+
return []
47+
4648
async with build_openfga_client(self._fga_configuration) as fga_client:
4749
all_checks = [self._query_builder(doc) for doc in documents]
4850
unique_checks = list(
@@ -94,6 +96,9 @@ def filter_sync(
9496
Returns:
9597
List[T]: Filtered list of documents authorized by FGA.
9698
"""
99+
if len(documents) == 0:
100+
return []
101+
97102
with build_openfga_client_sync(self._fga_configuration) as fga_client:
98103
all_checks = [self._query_builder(doc) for doc in documents]
99104
unique_checks = list(

0 commit comments

Comments
 (0)