Show More
@@ -249,7 +249,7 b' class TestRepoAccess(object):' | |||
|
249 | 249 | fake_repo = Mock() |
|
250 | 250 | with self.repo_perm_patch as rmock: |
|
251 | 251 | rmock.return_value = repo_mock |
|
252 |
assert utils. |
|
|
252 | assert utils.validate_repo_permissions( | |
|
253 | 253 | 'fake_user', 'fake_repo_id', fake_repo, |
|
254 | 254 | ['perm1', 'perm2']) |
|
255 | 255 | rmock.assert_called_once_with(*['perm1', 'perm2']) |
@@ -263,6 +263,6 b' class TestRepoAccess(object):' | |||
|
263 | 263 | with self.repo_perm_patch as rmock: |
|
264 | 264 | rmock.return_value = repo_mock |
|
265 | 265 | with pytest.raises(JSONRPCError) as excinfo: |
|
266 |
utils. |
|
|
266 | utils.validate_repo_permissions( | |
|
267 | 267 | 'fake_user', 'fake_repo_id', fake_repo, 'perms') |
|
268 | 268 | assert 'fake_repo_id' in excinfo |
@@ -154,7 +154,7 b' def has_superadmin_permission(apiuser):' | |||
|
154 | 154 | return False |
|
155 | 155 | |
|
156 | 156 | |
|
157 |
def |
|
|
157 | def validate_repo_permissions(apiuser, repoid, repo, perms): | |
|
158 | 158 | """ |
|
159 | 159 | Raise JsonRPCError if apiuser is not authorized or return True |
|
160 | 160 | |
@@ -188,7 +188,7 b' def validate_repo_group_permissions(apiu' | |||
|
188 | 188 | return True |
|
189 | 189 | |
|
190 | 190 | |
|
191 |
def |
|
|
191 | def validate_set_owner_permissions(apiuser, owner): | |
|
192 | 192 | if isinstance(owner, Optional): |
|
193 | 193 | owner = get_user_or_error(apiuser.user_id) |
|
194 | 194 | else: |
@@ -25,7 +25,7 b' from rhodecode.api import jsonrpc_method' | |||
|
25 | 25 | from rhodecode.api.utils import ( |
|
26 | 26 | has_superadmin_permission, Optional, OAttr, get_repo_or_error, |
|
27 | 27 | get_pull_request_or_error, get_commit_or_error, get_user_or_error, |
|
28 |
|
|
|
28 | validate_repo_permissions, resolve_ref_or_error) | |
|
29 | 29 | from rhodecode.lib.auth import (HasRepoPermissionAnyApi) |
|
30 | 30 | from rhodecode.lib.base import vcs_operation_context |
|
31 | 31 | from rhodecode.lib.utils2 import str2bool |
@@ -215,7 +215,7 b' def get_pull_requests(request, apiuser, ' | |||
|
215 | 215 | if not has_superadmin_permission(apiuser): |
|
216 | 216 | _perms = ( |
|
217 | 217 | 'repository.admin', 'repository.write', 'repository.read',) |
|
218 |
|
|
|
218 | validate_repo_permissions(apiuser, repoid, repo, _perms) | |
|
219 | 219 | |
|
220 | 220 | status = Optional.extract(status) |
|
221 | 221 | pull_requests = PullRequestModel().get_all(repo, statuses=[status]) |
@@ -504,7 +504,7 b' def create_pull_request(' | |||
|
504 | 504 | target = get_repo_or_error(target_repo) |
|
505 | 505 | if not has_superadmin_permission(apiuser): |
|
506 | 506 | _perms = ('repository.admin', 'repository.write', 'repository.read',) |
|
507 |
|
|
|
507 | validate_repo_permissions(apiuser, source_repo, source, _perms) | |
|
508 | 508 | |
|
509 | 509 | full_source_ref = resolve_ref_or_error(source_ref, source) |
|
510 | 510 | full_target_ref = resolve_ref_or_error(target_ref, target) |
General Comments 0
You need to be logged in to leave comments.
Login now