You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2025/03/05 14:54:03 UTC

(airflow) branch main updated: Fix test_python_client after adding permission (#47388)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 7bfe283cf4f Fix test_python_client after adding permission (#47388)
7bfe283cf4f is described below

commit 7bfe283cf4fa28453c857e659f4c1d5917f9e11c
Author: LIU ZHE YOU <68...@users.noreply.github.com>
AuthorDate: Wed Mar 5 22:53:56 2025 +0800

    Fix test_python_client after adding permission (#47388)
---
 clients/python/test_python_client.py | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/clients/python/test_python_client.py b/clients/python/test_python_client.py
index 80759cef3ca..d7168d37217 100644
--- a/clients/python/test_python_client.py
+++ b/clients/python/test_python_client.py
@@ -42,6 +42,9 @@ except ImportError:
 from airflow_client.client.api import config_api, dag_api, dag_run_api
 from airflow_client.client.model.dag_run import DAGRun
 
+from airflow.auth.managers.simple.simple_auth_manager import SimpleAuthManager
+from airflow.auth.managers.simple.user import SimpleAuthManagerUser
+
 # The client must use the authentication and authorization parameters
 # in accordance with the API server security policy.
 # Examples for each auth method are provided below, use the example that
@@ -57,8 +60,17 @@ from airflow_client.client.model.dag_run import DAGRun
 # privileges in Airflow
 
 # Configure HTTP basic authorization: Basic
+auth_manager = SimpleAuthManager()
 configuration = airflow_client.client.Configuration(
-    host="http://localhost:8080/public", username="admin", password="admin"
+    host="http://localhost:8080/public",
+    api_key={
+        "Authorization": "Bearer "
+        + auth_manager._get_token_signer().generate_signed_token(
+            {
+                **auth_manager.serialize_user(SimpleAuthManagerUser(username="test", role="admin")),
+            }
+        )
+    },
 )
 
 # Make sure in the [core] section, the  `load_examples` config is set to True in your airflow.cfg