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: 1 addition & 1 deletion airflow-core/src/airflow/api_fastapi/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def get_cookie_path() -> str:


# Fast API apps mounted under these prefixes are not allowed
RESERVED_URL_PREFIXES = ["/api/v2", "/ui", "/execution"]
RESERVED_URL_PREFIXES = ["/api/v2", "/ui", "/execution", "/auth", "/pluginsv2"]

log = logging.getLogger(__name__)

Expand Down
19 changes: 6 additions & 13 deletions airflow-core/tests/unit/api_fastapi/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,27 +98,20 @@ def test_catch_all_route_last(client):


@pytest.mark.parametrize(
("fastapi_apps", "expected_message", "invalid_path"),
("invalid_prefix", "expected_message"),
[
(
[{"name": "test", "app": FastAPI(), "url_prefix": ""}],
"'url_prefix' key is empty string for the fastapi app: test",
"",
),
(
[{"name": "test", "app": FastAPI(), "url_prefix": next(iter(app_module.RESERVED_URL_PREFIXES))}],
"attempted to use reserved url_prefix",
next(iter(app_module.RESERVED_URL_PREFIXES)),
),
("", "'url_prefix' key is empty string for the fastapi app: test"),
*((prefix, "attempted to use reserved url_prefix") for prefix in app_module.RESERVED_URL_PREFIXES),
],
)
def test_plugin_with_invalid_url_prefix(caplog, fastapi_apps, expected_message, invalid_path):
def test_plugin_with_invalid_url_prefix(caplog, invalid_prefix, expected_message):
fastapi_apps = [{"name": "test", "app": FastAPI(), "url_prefix": invalid_prefix}]
app = FastAPI()
with mock.patch.object(plugins_manager, "get_fastapi_plugins", return_value=(fastapi_apps, [])):
app_module.init_plugins(app)

assert any(expected_message in rec.message for rec in caplog.records)
assert not any(r.path == invalid_path for r in app.routes)
assert not any(r.path == invalid_prefix for r in app.routes)


class TestGetCookiePath:
Expand Down
Loading