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 2020/08/31 12:51:42 UTC

[GitHub] [airflow] mik-laj commented on a change in pull request #10594: WIP: Add permissions for stable API

mik-laj commented on a change in pull request #10594:
URL: https://github.com/apache/airflow/pull/10594#discussion_r480108441



##########
File path: tests/test_utils/api_connexion_utils.py
##########
@@ -30,6 +30,19 @@ def create_user(app, username, role):
         )
 
 
+def create_role(app, name, permissions=None):

Review comment:
       What do you think about extending the create_user method to accept a list of permissions?
   ```
   def create_user(app, username, role=None, permissions=None):
       appbuilder = app.appbuilder
       current_role = None
       if role and permission:
       	raise IllegalArgument("role and permission are muttually exclussive")
       elif role:
   	    current_role = appbuilder.sm.find_role(role)
   	elif permission:
   		ranadom_suffix = get_random_string()
   	    current_role = create_role(app, get_random_string("test-role-{ranadom_suffix}"))
   
       tester = appbuilder.sm.find_user(username=username)
       if not tester:
           appbuilder.sm.add_user(
               username=username,
               first_name=username,
               last_name=username,
               email=f"{username}@fab.org",
               role=current_role,
               password=username,
           )
   ```
   This will simplify testing as we won't have to worry so much about side effects as each role will only be used once. This will also explicitly associate the user with a specific permission set.




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

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