This is an automated email from the ASF dual-hosted git repository.
jedcunningham pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 1645298b0ec Fix non-integrated API calls from tests (#47327)
1645298b0ec is described below
commit 1645298b0ec05ea3813f12a5a64f929979c75a08
Author: Bugra Ozturk <[email protected]>
AuthorDate: Tue Mar 4 02:53:31 2025 +0100
Fix non-integrated API calls from tests (#47327)
---
airflow/api_fastapi/core_api/security.py | 10 +++++++++-
docker_tests/test_docker_compose_quick_start.py | 2 +-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/airflow/api_fastapi/core_api/security.py
b/airflow/api_fastapi/core_api/security.py
index 2eb40cef6fc..2b267beaa8e 100644
--- a/airflow/api_fastapi/core_api/security.py
+++ b/airflow/api_fastapi/core_api/security.py
@@ -61,7 +61,15 @@ def get_user(token_str: Annotated[str,
Depends(oauth2_scheme)]) -> BaseUser:
async def get_user_with_exception_handling(request: Request) -> BaseUser |
None:
# Currently the UI does not support JWT authentication, this method
defines a fallback if no token is provided by the UI.
# We can remove this method when issue
https://github.com/apache/airflow/issues/44884 is done.
- token_str = await oauth2_scheme(request)
+ token_str = None
+
+ # TODO remove try-except when authentication integrated everywhere,
safeguard for non integrated clients and endpoints
+ try:
+ token_str = await oauth2_scheme(request)
+ except HTTPException as e:
+ if e.status_code == status.HTTP_401_UNAUTHORIZED:
+ return None
+
if not token_str: # Handle None or empty token
return None
return get_user(token_str)
diff --git a/docker_tests/test_docker_compose_quick_start.py
b/docker_tests/test_docker_compose_quick_start.py
index fed2005daf4..9834a56e55e 100644
--- a/docker_tests/test_docker_compose_quick_start.py
+++ b/docker_tests/test_docker_compose_quick_start.py
@@ -112,7 +112,7 @@ def
test_trigger_dag_and_wait_for_result(default_docker_image, tmp_path_factory,
assert dag_state == "success"
except Exception:
print("HTTP: GET health")
- pprint(api_request("GET", "health"))
+ pprint(api_request("GET", "monitor/health"))
print(f"HTTP: GET dags/{DAG_ID}/dagRuns")
pprint(api_request("GET", f"dags/{DAG_ID}/dagRuns"))
print(f"HTTP: GET dags/{DAG_ID}/dagRuns/{DAG_RUN_ID}/taskInstances")