XD-DENG commented on a change in pull request #4960: [AIRFLOW-4145] Allow RBAC
roles permissions , VM to be overridable
URL: https://github.com/apache/airflow/pull/4960#discussion_r268392663
##########
File path: tests/www/test_security.py
##########
@@ -271,29 +304,7 @@ def test_no_additional_dag_permission_views_created(self):
num_pv_after = self.db.session().query(ab_perm_view_role).count()
self.assertEqual(num_pv_before, num_pv_after)
- def expect_user_is_in_role(self, user, rolename):
- self.security_manager.init_role(rolename, [], [])
- role = self.security_manager.find_role(rolename)
- if not role:
- self.security_manager.add_role(rolename)
- role = self.security_manager.find_role(rolename)
- user.roles = [role]
- self.security_manager.update_user(user)
-
- def assert_user_has_dag_perms(self, perms, dag_id):
- for perm in perms:
- self.assertTrue(
- self._has_dag_perm(perm, dag_id),
- "User should have '{}' on DAG '{}'".format(perm, dag_id))
-
- def assert_user_does_not_have_dag_perms(self, dag_id, perms):
- for perm in perms:
- self.assertFalse(
- self._has_dag_perm(perm, dag_id),
- "User should not have '{}' on DAG '{}'".format(perm, dag_id))
-
- def _has_dag_perm(self, perm, dag_id):
- return self.security_manager.has_access(
- perm,
- dag_id,
- self.user)
Review comment:
Hi @feng-tao , I noticed these "helper" functions are moved to the top of
the test class definition.
I understand that it may be mainly for better structure/looking. May I
double confirm if it's the only reason? In case I'm missing anything. Thanks
----------------------------------------------------------------
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:
[email protected]
With regards,
Apache Git Services