File tree Expand file tree Collapse file tree 3 files changed +21
-8
lines changed
airflow/api_fastapi/core_api
tests/api_fastapi/core_api/routes/ui Expand file tree Collapse file tree 3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 5656 application/json :
5757 schema :
5858 $ref : ' #/components/schemas/HTTPExceptionResponse'
59+ security :
60+ - OAuth2PasswordBearer : []
5961 /ui/dags/recent_dag_runs :
6062 get :
6163 tags :
Original file line number Diff line number Diff line change 1818
1919from typing import Any
2020
21- from fastapi import status
21+ from fastapi import Depends , status
2222
2323from airflow .api_fastapi .common .router import AirflowRouter
2424from airflow .api_fastapi .core_api .datamodels .ui .config import ConfigResponse
2525from airflow .api_fastapi .core_api .openapi .exceptions import create_openapi_http_exception_doc
26+ from airflow .api_fastapi .core_api .security import requires_access_configuration
2627from airflow .configuration import conf
2728from airflow .settings import STATE_COLORS
2829
4950@config_router .get (
5051 "/config" ,
5152 responses = create_openapi_http_exception_doc ([status .HTTP_404_NOT_FOUND ]),
53+ dependencies = [Depends (requires_access_configuration ("GET" ))],
5254)
5355def get_configs () -> ConfigResponse :
5456 """Get configs for UI."""
Original file line number Diff line number Diff line change @@ -105,12 +105,21 @@ def mock_config_data():
105105 yield mock_conf
106106
107107
108- def test_get_configs_basic (mock_config_data , test_client ):
109- """
110- Test the /ui/config endpoint to verify response matches mock data.
111- """
108+ class TestGetConfig :
109+ def test_should_response_200 (self , mock_config_data , test_client ):
110+ """
111+ Test the /ui/config endpoint to verify response matches mock data.
112+ """
113+
114+ response = test_client .get ("/ui/config" )
115+
116+ assert response .status_code == 200
117+ assert response .json () == mock_config_response
112118
113- response = test_client .get ("/ui/config" )
119+ def test_get_config_should_response_401 (self , unauthenticated_test_client ):
120+ response = unauthenticated_test_client .get ("/ui/config" )
121+ assert response .status_code == 401
114122
115- assert response .status_code == 200
116- assert response .json () == mock_config_response
123+ def test_get_config_should_response_403 (self , unauthorized_test_client ):
124+ response = unauthorized_test_client .get ("/ui/config" )
125+ assert response .status_code == 403
You can’t perform that action at this time.
0 commit comments