kaxil commented on code in PR #61675:
URL: https://github.com/apache/airflow/pull/61675#discussion_r2784515555
##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_dag_versions.py:
##########
@@ -316,6 +316,23 @@ def test_get_dag_versions(
assert response.status_code == 200
assert response.json() == expected_response
+ @pytest.mark.usefixtures("make_dag_with_multiple_versions")
+ @mock.patch(
+
"airflow.api_fastapi.auth.managers.base_auth_manager.BaseAuthManager.get_authorized_dag_ids",
+ return_value=[("dag_with_multiple_versions")],
+ )
+ def test_get_dag_versions_permission_filtering(self, _, test_client):
+ """
+ Test that the endpoint correctly filters DAG versions based on user
permissions.
+
+ Here the user do not have permission on the ANOTHER_DAG_ID dag.
+ """
+ with assert_queries_count(4):
+ response = test_client.get("/dags/~/dagVersions")
+
+ assert response.status_code == 200
+ assert response.json()["total_entries"] == 3
Review Comment:
wdyt of the following test instead?
```suggestion
@pytest.mark.usefixtures("make_dag_with_multiple_versions")
@mock.patch(
"airflow.api_fastapi.auth.managers.base_auth_manager.BaseAuthManager.get_authorized_dag_ids",
return_value={"dag_with_multiple_versions"},
)
def test_get_dag_versions_permission_filtering(self,
mock_get_authorized_dag_ids, test_client):
"""Test that listing all DAG versions with ~ only returns versions
for permitted DAGs."""
response = test_client.get("/dags/~/dagVersions")
assert response.status_code == 200
body = response.json()
assert body["total_entries"] == 3
dag_ids = {v["dag_id"] for v in body["dag_versions"]}
assert dag_ids == {"dag_with_multiple_versions"}
assert "ANOTHER_DAG_ID" not in dag_ids
```
--
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]