You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/11/11 14:51:09 UTC

[GitHub] [airflow] khalidmammadov commented on a change in pull request #18961: Convert www.security test suite to pytest and remove residuals

khalidmammadov commented on a change in pull request #18961:
URL: https://github.com/apache/airflow/pull/18961#discussion_r747564817



##########
File path: tests/test_utils/api_connexion_utils.py
##########
@@ -80,15 +81,29 @@ def create_role(app, name, permissions=None):
     return role
 
 
+def set_user_single_role(app, username, role_name):
+    role = create_role(app, role_name)
+    user = app.appbuilder.sm.find_user(username)
+    if role not in user.roles:
+        user.roles = [role]
+        app.appbuilder.sm.update_user(user)
+
+
 def delete_role(app, name):
-    if app.appbuilder.sm.find_role(name):
-        app.appbuilder.sm.delete_role(name)
+    if name not in EXISTING_ROLES:
+        if app.appbuilder.sm.find_role(name):
+            app.appbuilder.sm.delete_role(name)
 
 
 def delete_roles(app):
     for role in app.appbuilder.sm.get_all_roles():
-        if role.name not in EXISTING_ROLES:
-            app.appbuilder.sm.delete_role(role.name)
+        delete_role(app, role.name)
+
+
+def delete_user_roles(app, username):
+    user = app.appbuilder.sm.find_user(username)
+    for role in user.roles:
+        delete_role(app, role.name)

Review comment:
       You are right, removed




-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org