Show More
@@ -46,10 +46,10 b' def route_path(name, params=None, **kwar' | |||
|
46 | 46 | |
|
47 | 47 | class TestAdminMainView(TestController): |
|
48 | 48 | |
|
49 |
def test_ |
|
|
49 | def test_access_admin_home(self): | |
|
50 | 50 | self.log_user() |
|
51 |
response = self.app.get(route_path('admin_home'), status= |
|
|
52 | assert response.location.endswith('/audit_logs') | |
|
51 | response = self.app.get(route_path('admin_home'), status=200) | |
|
52 | response.mustcontain("Administration area") | |
|
53 | 53 | |
|
54 | 54 | def test_redirect_pull_request_view(self, view): |
|
55 | 55 | self.log_user() |
@@ -30,6 +30,7 b' def route_path(name, params=None, **kwar' | |||
|
30 | 30 | |
|
31 | 31 | base_url = { |
|
32 | 32 | 'home': '/', |
|
33 | 'admin_home': ADMIN_PREFIX, | |
|
33 | 34 | 'repos': |
|
34 | 35 | ADMIN_PREFIX + '/repos', |
|
35 | 36 | 'repo_groups': |
@@ -50,19 +51,14 b' fixture = Fixture()' | |||
|
50 | 51 | |
|
51 | 52 | class TestAdminDelegatedUser(TestController): |
|
52 | 53 | |
|
53 | def test_regular_user_cannot_see_admin_interfaces( | |
|
54 | self, user_util, xhr_header): | |
|
54 | def test_regular_user_cannot_see_admin_interfaces(self, user_util, xhr_header): | |
|
55 | 55 | user = user_util.create_user(password='qweqwe') |
|
56 | user_util.inherit_default_user_permissions(user.username, False) | |
|
57 | ||
|
56 | 58 | self.log_user(user.username, 'qweqwe') |
|
57 | 59 | |
|
58 | # check if in home view, such user doesn't see the "admin" menus | |
|
59 |
|
|
|
60 | ||
|
61 | assert_response = response.assert_response() | |
|
62 | ||
|
63 | assert_response.no_element_exists('li.local-admin-repos') | |
|
64 | assert_response.no_element_exists('li.local-admin-repo-groups') | |
|
65 | assert_response.no_element_exists('li.local-admin-user-groups') | |
|
60 | # user doesn't have any access to resources so main admin page should 404 | |
|
61 | self.app.get(route_path('admin_home'), status=404) | |
|
66 | 62 | |
|
67 | 63 | response = self.app.get(route_path('repos'), status=200) |
|
68 | 64 | response.mustcontain('data: []') |
@@ -74,8 +70,7 b' class TestAdminDelegatedUser(TestControl' | |||
|
74 | 70 | status=200, extra_environ=xhr_header) |
|
75 | 71 | assert response.json['data'] == [] |
|
76 | 72 | |
|
77 | def test_regular_user_can_see_admin_interfaces_if_owner( | |
|
78 | self, user_util, xhr_header): | |
|
73 | def test_regular_user_can_see_admin_interfaces_if_owner(self, user_util, xhr_header): | |
|
79 | 74 | user = user_util.create_user(password='qweqwe') |
|
80 | 75 | username = user.username |
|
81 | 76 | |
@@ -89,14 +84,14 b' class TestAdminDelegatedUser(TestControl' | |||
|
89 | 84 | user_group_name = user_group.users_group_name |
|
90 | 85 | |
|
91 | 86 | self.log_user(username, 'qweqwe') |
|
92 | # check if in home view, such user doesn't see the "admin" menus | |
|
93 | response = self.app.get(route_path('home')) | |
|
87 | ||
|
88 | response = self.app.get(route_path('admin_home')) | |
|
94 | 89 | |
|
95 | 90 | assert_response = response.assert_response() |
|
96 | 91 | |
|
97 |
assert_response. |
|
|
98 |
assert_response. |
|
|
99 |
assert_response. |
|
|
92 | assert_response.element_contains('td.delegated-admin-repos', '1') | |
|
93 | assert_response.element_contains('td.delegated-admin-repo-groups', '1') | |
|
94 | assert_response.element_contains('td.delegated-admin-user-groups', '1') | |
|
100 | 95 | |
|
101 | 96 | # admin interfaces have visible elements |
|
102 | 97 | response = self.app.get(route_path('repos'), status=200) |
@@ -132,13 +127,13 b' class TestAdminDelegatedUser(TestControl' | |||
|
132 | 127 | |
|
133 | 128 | self.log_user(username, 'qweqwe') |
|
134 | 129 | # check if in home view, such user doesn't see the "admin" menus |
|
135 | response = self.app.get(route_path('home')) | |
|
130 | response = self.app.get(route_path('admin_home')) | |
|
136 | 131 | |
|
137 | 132 | assert_response = response.assert_response() |
|
138 | 133 | |
|
139 |
assert_response. |
|
|
140 |
assert_response. |
|
|
141 |
assert_response. |
|
|
134 | assert_response.element_contains('td.delegated-admin-repos', '1') | |
|
135 | assert_response.element_contains('td.delegated-admin-repo-groups', '1') | |
|
136 | assert_response.element_contains('td.delegated-admin-user-groups', '1') | |
|
142 | 137 | |
|
143 | 138 | # admin interfaces have visible elements |
|
144 | 139 | response = self.app.get(route_path('repos'), status=200) |
@@ -1224,7 +1224,7 b' class UserUtility(object):' | |||
|
1224 | 1224 | return user_group |
|
1225 | 1225 | |
|
1226 | 1226 | def grant_user_permission(self, user_name, permission_name): |
|
1227 |
self. |
|
|
1227 | self.inherit_default_user_permissions(user_name, False) | |
|
1228 | 1228 | self.user_permissions.append((user_name, permission_name)) |
|
1229 | 1229 | |
|
1230 | 1230 | def grant_user_permission_to_repo_group( |
@@ -1276,10 +1276,10 b' class UserUtility(object):' | |||
|
1276 | 1276 | return permission |
|
1277 | 1277 | |
|
1278 | 1278 | def revoke_user_permission(self, user_name, permission_name): |
|
1279 |
self. |
|
|
1279 | self.inherit_default_user_permissions(user_name, True) | |
|
1280 | 1280 | UserModel().revoke_perm(user_name, permission_name) |
|
1281 | 1281 | |
|
1282 |
def |
|
|
1282 | def inherit_default_user_permissions(self, user_name, value): | |
|
1283 | 1283 | user = UserModel().get_by_username(user_name) |
|
1284 | 1284 | user.inherit_default_permissions = value |
|
1285 | 1285 | Session().add(user) |
General Comments 0
You need to be logged in to leave comments.
Login now