jason810496 commented on code in PR #47194:
URL: https://github.com/apache/airflow/pull/47194#discussion_r1975288463
##########
tests/api_fastapi/core_api/routes/public/test_connections.py:
##########
@@ -104,6 +104,14 @@ def test_delete_should_respond_204(self, test_client,
session):
assert len(connection) == 0
_check_last_log(session, dag_id=None, event="delete_connection",
logical_date=None)
+ def test_should_respond_401(self, unauthenticated_test_client):
Review Comment:
For the test cases naming, should we use `_response_` instead of `_respond_`
?
##########
airflow/api_fastapi/core_api/security.py:
##########
@@ -82,6 +82,23 @@ def callback():
return inner
+def requires_access_connection(method: ResourceMethod) -> Callable:
+ def inner(
+ connection_id: str | None = None,
+ user: Annotated[BaseUser | None, Depends(get_user)] = None,
+ ) -> None:
+ def callback():
+ return get_auth_manager().is_authorized_dag(
+ method=method,
details=ConnectionDetails(conn_id=connection_id), user=user
+ )
+
+ _requires_access(
+ is_authorized_callback=callback,
Review Comment:
Not blocking, just a discussion point—would using `lambda` be more
appropriate here? Since we are adding a new `callback` function in each
`requires_access_<entity>` factory, `lambda` might help keep it more concise.
cc @pierrejeambrun
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]