ChickenBenny commented on code in PR #77311:
URL: https://github.com/apache/airflow/pull/77311#discussion_r4640723359
##########
providers/fab/tests/unit/fab/auth_manager/test_fab_auth_manager.py:
##########
@@ -1089,6 +1089,46 @@ 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)
+
+ previous = flask_app.config.get("AUTH_ROLE_PUBLIC")
+ flask_app.config["AUTH_ROLE_PUBLIC"] = "public_test"
+ try:
+ user = auth_manager_with_appbuilder.build_public_user()
+ results =
auth_manager_with_appbuilder.get_authorized_dag_ids(user=user, method=method)
+ finally:
+ flask_app.config["AUTH_ROLE_PUBLIC"] = previous
+ delete_role(flask_app, "public_test")
Review Comment:
Fix with cadfa83
--
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]