ChickenBenny commented on code in PR #77311:
URL: https://github.com/apache/airflow/pull/77311#discussion_r4644501582


##########
providers/fab/tests/unit/fab/auth_manager/test_fab_auth_manager.py:
##########
@@ -1237,6 +1237,80 @@ def test_get_authorized_dag_ids(
 
         delete_user(flask_app, "username")
 
+    @pytest.mark.parametrize(
+        ("method", "role_permissions", "expected_results"),
+        [
+            pytest.param("GET", [(ACTION_CAN_READ, "DAG:test_dag1")], 
{"test_dag1"}, id="read-one-dag"),
+            pytest.param(
+                "PUT",
+                [(ACTION_CAN_EDIT, "DAG:test_dag1"), (ACTION_CAN_EDIT, 
"DAG:test_dag2")],
+                {"test_dag1", "test_dag2"},
+                id="edit-two-dags",
+            ),
+        ],
+    )
+    def test_get_authorized_dag_ids_for_public_user(

Review Comment:
   Fixed in 2fcfd5f. Merged it into `test_get_authorized_dag_ids` with an 
`as_public_user` parameter, so all scenarios now run for the public user too.



##########
providers/fab/tests/unit/fab/auth_manager/test_fab_auth_manager.py:
##########
@@ -1237,6 +1237,80 @@ def test_get_authorized_dag_ids(
 
         delete_user(flask_app, "username")
 
+    @pytest.mark.parametrize(
+        ("method", "role_permissions", "expected_results"),
+        [
+            pytest.param("GET", [(ACTION_CAN_READ, "DAG:test_dag1")], 
{"test_dag1"}, id="read-one-dag"),
+            pytest.param(
+                "PUT",
+                [(ACTION_CAN_EDIT, "DAG:test_dag1"), (ACTION_CAN_EDIT, 
"DAG:test_dag2")],
+                {"test_dag1", "test_dag2"},
+                id="edit-two-dags",
+            ),
+        ],
+    )
+    def test_get_authorized_dag_ids_for_public_user(
+        self, method, role_permissions, expected_results, 
auth_manager_with_appbuilder, flask_app, dag_maker
+    ):
+        for dag_id in ("test_dag1", "test_dag2", "test_dag3"):
+            with dag_maker(dag_id):
+                EmptyOperator(task_id="task")
+            if AIRFLOW_V_3_1_PLUS:
+                sync_dag_to_db(dag_maker.dag)
+        dag_maker.session.commit()
+        dag_maker.session.close()
+
+        security_manager = auth_manager_with_appbuilder.security_manager
+        security_manager.sync_perm_for_dag("test_dag1")
+        security_manager.sync_perm_for_dag("test_dag2")
+        delete_role(flask_app, "public_test")
+        create_role(flask_app, "public_test", role_permissions)
+
+        try:
+            with conf_vars({("fab", "auth_role_public"): "public_test"}):

Review Comment:
   After the merge, only the public user case sets the public role, so I kept 
`conf_vars` as a context manager around `build_public_user()`.



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