You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by je...@apache.org on 2021/08/30 18:35:17 UTC
[airflow] branch main updated: Fix
`TestSecurity.test_current_user_has_permissions` (#17916)
This is an automated email from the ASF dual-hosted git repository.
jedcunningham 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 4a0711c Fix `TestSecurity.test_current_user_has_permissions` (#17916)
4a0711c is described below
commit 4a0711c91e51e5208fc767cd43cfc0daf90052d9
Author: Jed Cunningham <66...@users.noreply.github.com>
AuthorDate: Mon Aug 30 12:35:01 2021 -0600
Fix `TestSecurity.test_current_user_has_permissions` (#17916)
This test wasn't working on python > 3.7.
---
tests/www/test_security.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tests/www/test_security.py b/tests/www/test_security.py
index 829f7a7..b2de823 100644
--- a/tests/www/test_security.py
+++ b/tests/www/test_security.py
@@ -343,8 +343,8 @@ class TestSecurity(unittest.TestCase):
mock_get_user_roles.return_value = []
assert len(self.security_manager.get_current_user_permissions()) == 0
- @mock.patch('airflow.www.security.g')
- def test_current_user_has_permissions(self, mock_g):
+ @mock.patch('airflow.www.security.AirflowSecurityManager.get_user_roles')
+ def test_current_user_has_permissions(self, mock_get_user_roles):
with self.app.app_context():
user = api_connexion_utils.create_user(
self.app,
@@ -352,16 +352,16 @@ class TestSecurity(unittest.TestCase):
"current_user_has_permissions",
permissions=[("can_some_action", "SomeBaseView")],
)
- mock_g.user = user
+ role = user.roles[0]
+ mock_get_user_roles.return_value = [role]
assert self.security_manager.current_user_has_permissions()
# Role, but no permissions
- role = user.roles[0]
role.permissions = []
assert not self.security_manager.current_user_has_permissions()
# No role
- user.roles = []
+ mock_get_user_roles.return_value = []
assert not self.security_manager.current_user_has_permissions()
def test_get_accessible_dag_ids(self):