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
2 changes: 2 additions & 0 deletions airflow/api_fastapi/core_api/openapi/v1-generated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/HTTPExceptionResponse'
security:
- OAuth2PasswordBearer: []
/ui/dags/recent_dag_runs:
get:
tags:
Expand Down
4 changes: 3 additions & 1 deletion airflow/api_fastapi/core_api/routes/ui/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

from typing import Any

from fastapi import status
from fastapi import Depends, status

from airflow.api_fastapi.common.router import AirflowRouter
from airflow.api_fastapi.core_api.datamodels.ui.config import ConfigResponse
from airflow.api_fastapi.core_api.openapi.exceptions import create_openapi_http_exception_doc
from airflow.api_fastapi.core_api.security import requires_access_configuration
from airflow.configuration import conf
from airflow.settings import STATE_COLORS

Expand All @@ -49,6 +50,7 @@
@config_router.get(
"/config",
responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND]),
dependencies=[Depends(requires_access_configuration("GET"))],
)
def get_configs() -> ConfigResponse:
"""Get configs for UI."""
Expand Down
23 changes: 16 additions & 7 deletions tests/api_fastapi/core_api/routes/ui/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,21 @@ def mock_config_data():
yield mock_conf


def test_get_configs_basic(mock_config_data, test_client):
"""
Test the /ui/config endpoint to verify response matches mock data.
"""
class TestGetConfig:
def test_should_response_200(self, mock_config_data, test_client):
"""
Test the /ui/config endpoint to verify response matches mock data.
"""

response = test_client.get("/ui/config")

assert response.status_code == 200
assert response.json() == mock_config_response

response = test_client.get("/ui/config")
def test_get_config_should_response_401(self, unauthenticated_test_client):
response = unauthenticated_test_client.get("/ui/config")
assert response.status_code == 401

assert response.status_code == 200
assert response.json() == mock_config_response
def test_get_config_should_response_403(self, unauthorized_test_client):
response = unauthorized_test_client.get("/ui/config")
assert response.status_code == 403