diff --git a/rhodecode/apps/admin/tests/test_admin_main_views.py b/rhodecode/apps/admin/tests/test_admin_main_views.py --- a/rhodecode/apps/admin/tests/test_admin_main_views.py +++ b/rhodecode/apps/admin/tests/test_admin_main_views.py @@ -46,10 +46,10 @@ def route_path(name, params=None, **kwar class TestAdminMainView(TestController): - def test_redirect_admin_home(self): + def test_access_admin_home(self): self.log_user() - response = self.app.get(route_path('admin_home'), status=302) - assert response.location.endswith('/audit_logs') + response = self.app.get(route_path('admin_home'), status=200) + response.mustcontain("Administration area") def test_redirect_pull_request_view(self, view): self.log_user() diff --git a/rhodecode/tests/functional/test_delegated_admin.py b/rhodecode/tests/functional/test_delegated_admin.py --- a/rhodecode/tests/functional/test_delegated_admin.py +++ b/rhodecode/tests/functional/test_delegated_admin.py @@ -30,6 +30,7 @@ def route_path(name, params=None, **kwar base_url = { 'home': '/', + 'admin_home': ADMIN_PREFIX, 'repos': ADMIN_PREFIX + '/repos', 'repo_groups': @@ -50,19 +51,14 @@ fixture = Fixture() class TestAdminDelegatedUser(TestController): - def test_regular_user_cannot_see_admin_interfaces( - self, user_util, xhr_header): + def test_regular_user_cannot_see_admin_interfaces(self, user_util, xhr_header): user = user_util.create_user(password='qweqwe') + user_util.inherit_default_user_permissions(user.username, False) + self.log_user(user.username, 'qweqwe') - # check if in home view, such user doesn't see the "admin" menus - response = self.app.get(route_path('home')) - - assert_response = response.assert_response() - - assert_response.no_element_exists('li.local-admin-repos') - assert_response.no_element_exists('li.local-admin-repo-groups') - assert_response.no_element_exists('li.local-admin-user-groups') + # user doesn't have any access to resources so main admin page should 404 + self.app.get(route_path('admin_home'), status=404) response = self.app.get(route_path('repos'), status=200) response.mustcontain('data: []') @@ -74,8 +70,7 @@ class TestAdminDelegatedUser(TestControl status=200, extra_environ=xhr_header) assert response.json['data'] == [] - def test_regular_user_can_see_admin_interfaces_if_owner( - self, user_util, xhr_header): + def test_regular_user_can_see_admin_interfaces_if_owner(self, user_util, xhr_header): user = user_util.create_user(password='qweqwe') username = user.username @@ -89,14 +84,14 @@ class TestAdminDelegatedUser(TestControl user_group_name = user_group.users_group_name self.log_user(username, 'qweqwe') - # check if in home view, such user doesn't see the "admin" menus - response = self.app.get(route_path('home')) + + response = self.app.get(route_path('admin_home')) assert_response = response.assert_response() - assert_response.one_element_exists('li.local-admin-repos') - assert_response.one_element_exists('li.local-admin-repo-groups') - assert_response.one_element_exists('li.local-admin-user-groups') + assert_response.element_contains('td.delegated-admin-repos', '1') + assert_response.element_contains('td.delegated-admin-repo-groups', '1') + assert_response.element_contains('td.delegated-admin-user-groups', '1') # admin interfaces have visible elements response = self.app.get(route_path('repos'), status=200) @@ -132,13 +127,13 @@ class TestAdminDelegatedUser(TestControl self.log_user(username, 'qweqwe') # check if in home view, such user doesn't see the "admin" menus - response = self.app.get(route_path('home')) + response = self.app.get(route_path('admin_home')) assert_response = response.assert_response() - assert_response.one_element_exists('li.local-admin-repos') - assert_response.one_element_exists('li.local-admin-repo-groups') - assert_response.one_element_exists('li.local-admin-user-groups') + assert_response.element_contains('td.delegated-admin-repos', '1') + assert_response.element_contains('td.delegated-admin-repo-groups', '1') + assert_response.element_contains('td.delegated-admin-user-groups', '1') # admin interfaces have visible elements response = self.app.get(route_path('repos'), status=200) diff --git a/rhodecode/tests/plugin.py b/rhodecode/tests/plugin.py --- a/rhodecode/tests/plugin.py +++ b/rhodecode/tests/plugin.py @@ -1224,7 +1224,7 @@ class UserUtility(object): return user_group def grant_user_permission(self, user_name, permission_name): - self._inherit_default_user_permissions(user_name, False) + self.inherit_default_user_permissions(user_name, False) self.user_permissions.append((user_name, permission_name)) def grant_user_permission_to_repo_group( @@ -1276,10 +1276,10 @@ class UserUtility(object): return permission def revoke_user_permission(self, user_name, permission_name): - self._inherit_default_user_permissions(user_name, True) + self.inherit_default_user_permissions(user_name, True) UserModel().revoke_perm(user_name, permission_name) - def _inherit_default_user_permissions(self, user_name, value): + def inherit_default_user_permissions(self, user_name, value): user = UserModel().get_by_username(user_name) user.inherit_default_permissions = value Session().add(user)