adiranjan25 commented on code in PR #76965:
URL: https://github.com/apache/airflow/pull/76965#discussion_r4576835171
##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_triggers.py:
##########
@@ -365,6 +365,29 @@ def test_filters(self, test_client, triggers, params,
expected):
assert response.status_code == 200
assert sorted(_name(t) for t in response.json()["triggers"]) ==
expected
+ def test_pagination_counts_multi_watcher_trigger_once(self, test_client,
session, triggers):
Review Comment:
Thanks, @henry3260 . Added `test_pagination_excludes_unauthorized_triggers`,
which mocks `get_authorized_dag_ids`, verifies hidden triggers are excluded,
walks the results using `limit`/`offset`, and checks ordering and
`total_entries`. The updated trigger API test suite passes locally (57 tests).
##########
airflow-core/src/airflow/api_fastapi/core_api/security.py:
##########
@@ -1236,6 +1236,15 @@ def __init__(
self.asset_ids = asset_ids
self.can_read_an_owner = can_read_an_owner
+ def allows(self, *, dag_id: str | None, owner_ref: dict | None,
watched_asset_ids: set[int]) -> bool:
+ """Check trigger ownership permissions without expanding SQL IN
lists."""
+ owner_ref = owner_ref or {}
+ if owner_ref.get("ti_id") is not None:
+ return dag_id in self.task_dag_ids
+ if owner_ref.get("callback_id") is not None:
+ return dag_id in self.callback_dag_ids
+ return bool(watched_asset_ids & self.asset_ids)
+
def to_orm(self, select: Select) -> Select:
Review Comment:
Thanks, @henry3260 . Removed `PermittedTriggerFilter.to_orm()` and
`_select_triggers_watching()`, along with the unused imports. I also removed
the `OrmClause` inheritance because `to_orm()` was its required abstract
method. The existing `allows()` implementation remains unchanged. Ruff checks
and all 57 trigger API tests pass locally.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]