henry3260 commented on code in PR #72862:
URL: https://github.com/apache/airflow/pull/72862#discussion_r4115650573


##########
airflow-core/tests/unit/api_fastapi/core_api/routes/ui/test_assets.py:
##########
@@ -118,6 +119,86 @@ def test_should_response_200(self, test_client, dag_maker):
             "pending_partition_count": None,
         }
 
+    @mock.patch(
+        
"airflow.api_fastapi.auth.managers.base_auth_manager.BaseAuthManager.get_authorized_assets",
+        autospec=True,
+    )
+    def test_should_return_only_assets_the_caller_may_read(
+        self, mock_get_authorized_assets, test_client, dag_maker, session
+    ):
+        with dag_maker(
+            dag_id="hidden_upstream",
+            schedule=[
+                Asset(uri="s3://bucket/visible", name="visible_asset"),
+                Asset(uri="s3://bucket/hidden", name="hidden_asset"),
+            ],
+            serialized=True,
+        ):
+            EmptyOperator(task_id="task1")
+        dag_maker.sync_dagbag_to_db()
+        visible_id = 
session.scalar(select(AssetModel.id).where(AssetModel.name == "visible_asset"))
+        mock_get_authorized_assets.return_value = {visible_id}
+
+        response = test_client.get("/next_run_assets/hidden_upstream")
+
+        mock_get_authorized_assets.assert_called_once_with(mock.ANY, 
user=mock.ANY, method="GET")

Review Comment:
   > After the rebase, this assertion no longer distinguishes the change: 
`main` already calls `get_authorized_assets` here for expression redaction, so 
it passes without the `to_orm` line. The `events` assertion below is what fails 
on `main`, so I think this line can be removed.
   
   good catch!



-- 
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]

Reply via email to