Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def inner(
request: Request,
user: GetUserDep,
) -> None:
dag_id: str | None = request.path_params.get("dag_id")
dag_id = request.path_params.get("dag_id") or request.query_params.get("dag_id")
dag_id = dag_id if dag_id != "~" else None
team_name = DagModel.get_team_name(dag_id) if dag_id else None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class TestGetDagWarnings:
],
)
def test_get_dag_warnings(self, test_client, query_params, expected_total_entries, expected_messages):
with assert_queries_count(3):
with assert_queries_count(3 if query_params.get("dag_id") is None else 4):
response = test_client.get("/dagWarnings", params=query_params)
assert response.status_code == 200
response_json = response.json()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def test_should_response_200(
expected_response = []
for backfill in response_params:
expected_response.append(backfill_responses[backfill])
with assert_queries_count(2):
with assert_queries_count(2 if test_params.get("dag_id") is None else 3):
response = test_client.get("/backfills", params=test_params)
assert response.status_code == 200
assert response.json() == {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,15 @@ class TestStructureDataEndpoint:
},
],
},
3,
6,
),
(
{
"dag_id": DAG_ID,
"root": "unknown_task",
},
{"edges": [], "nodes": []},
3,
6,
),
(
{
Expand All @@ -298,7 +298,7 @@ class TestStructureDataEndpoint:
},
],
},
3,
6,
),
(
{"dag_id": DAG_ID_EXTERNAL_TRIGGER, "external_dependencies": True},
Expand Down Expand Up @@ -337,7 +337,7 @@ class TestStructureDataEndpoint:
},
],
},
10,
13,
),
],
)
Expand Down Expand Up @@ -534,7 +534,7 @@ def test_should_return_200_with_asset(self, test_client, asset1_id, asset2_id, a
],
}

with assert_queries_count(10):
with assert_queries_count(13):
response = test_client.get("/structure/structure_data", params=params)
assert response.status_code == 200
assert response.json() == expected
Expand Down
3 changes: 3 additions & 0 deletions airflow-core/tests/unit/api_fastapi/core_api/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ async def test_requires_access_dag_authorized(self, mock_get_auth_manager):
mock_get_auth_manager.return_value = auth_manager
fastapi_request = Mock()
fastapi_request.path_params = {}
fastapi_request.query_params = {}

requires_access_dag("GET", DagAccessEntity.CODE)(fastapi_request, Mock())

Expand All @@ -167,9 +168,11 @@ async def test_requires_access_dag_unauthorized(self, mock_get_auth_manager):
mock_get_auth_manager.return_value = auth_manager
fastapi_request = Mock()
fastapi_request.path_params = {}
fastapi_request.query_params = {}

mock_request = Mock()
mock_request.path_params.return_value = {}
mock_request.query_params.return_value = {}

with pytest.raises(HTTPException, match="Forbidden"):
requires_access_dag("GET", DagAccessEntity.CODE)(fastapi_request, Mock())
Expand Down