jason810496 commented on code in PR #76515:
URL: https://github.com/apache/airflow/pull/76515#discussion_r4675090812
##########
airflow-core/tests/unit/api_fastapi/core_api/test_security.py:
##########
@@ -1109,7 +1090,6 @@ async def
test_requires_access_connection_non_string_team_name_returns_400(
assert exc_info.value.status_code == 400
assert "team_name" in exc_info.value.detail
auth_manager.is_authorized_connection.assert_not_called()
Review Comment:
This drops the check that a non-string `team_name` never reaches the DB.
Could we keep it?
```python
assert lookup_session.scalar.call_count == (0 if method == "POST" else 1)
```
##########
airflow-core/src/airflow/api_fastapi/core_api/security.py:
##########
@@ -1412,49 +1411,63 @@ def inner(
return inner
+# Request parameter identifying a team-scoped resource, and the columns to
read its team from.
+TEAM_SCOPED_RESOURCES = {
+ "pool_name": (Pool.team_name, Pool.pool),
+ "variable_key": (Variable.team_name, Variable.key),
+ "connection_id": (Connection.team_name, Connection.conn_id),
+}
+
+
async def _collect_teams_to_check(
method: ResourceMethod,
request: Request,
- resource_id: str | None,
- get_existing_team: Callable[[str], str | None],
+ resource_param: str,
Review Comment:
Let’s restrict them as literal type instead of str.
--
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]