Show More
@@ -1,5 +1,4 b'' | |||
|
1 | ||
|
2 | # Copyright (C) 2010-2023 RhodeCode GmbH | |
|
1 | # Copyright (C) 2010-2024 RhodeCode GmbH | |
|
3 | 2 | # |
|
4 | 3 | # This program is free software: you can redistribute it and/or modify |
|
5 | 4 | # it under the terms of the GNU Affero General Public License, version 3 |
@@ -69,9 +68,9 b' def _create_project_tree():' | |||
|
69 | 68 | |
|
70 | 69 | """ |
|
71 | 70 | test_u1 = UserModel().create_or_update( |
|
72 |
username= |
|
|
73 |
email= |
|
|
74 |
lastname= |
|
|
71 | username='test_u1', password='qweqwe', | |
|
72 | email='test_u1@rhodecode.org', firstname='test_u1', | |
|
73 | lastname='test_u1') | |
|
75 | 74 | |
|
76 | 75 | fixture.create_repo_group('g0') |
|
77 | 76 | g0_1 = fixture.create_repo_group('g0/g0_1') |
@@ -84,8 +83,7 b' def _create_project_tree():' | |||
|
84 | 83 | fixture.create_repo('g0/g0_2/g0_2_r2', repo_group=g0_2) |
|
85 | 84 | g0_3 = fixture.create_repo_group('g0/g0_3') |
|
86 | 85 | fixture.create_repo('g0/g0_3/g0_3_r1', repo_group=g0_3) |
|
87 | fixture.create_repo( | |
|
88 | 'g0/g0_3/g0_3_r1_private', repo_group=g0_3, repo_private=True) | |
|
86 | fixture.create_repo('g0/g0_3/g0_3_r1_private', repo_group=g0_3, repo_private=True) | |
|
89 | 87 | return test_u1 |
|
90 | 88 | |
|
91 | 89 | |
@@ -100,14 +98,14 b' def expected_count(group_name, objects=F' | |||
|
100 | 98 | def _check_expected_count(items, repo_items, expected): |
|
101 | 99 | should_be = len(items + repo_items) |
|
102 | 100 | there_are = len(expected) |
|
103 | assert should_be == there_are, ( | |
|
104 | '%s != %s' % ((items + repo_items), expected)) | |
|
101 | assert should_be == there_are, f'{(items + repo_items)} != {expected}' | |
|
105 | 102 | |
|
106 | 103 | |
|
107 | def check_tree_perms(obj_name, repo_perm, prefix, expected_perm): | |
|
108 | assert repo_perm == expected_perm, ( | |
|
109 | 'obj:`%s` got perm:`%s` should:`%s`' % ( | |
|
110 | obj_name, repo_perm, expected_perm)) | |
|
104 | def check_tree_perms(obj_name, repo_perm, prefix, expected_perm, default_user=False): | |
|
105 | if 'r1_private' in obj_name and default_user: | |
|
106 | # private repo must be private even if "recursive" permissions apply | |
|
107 | expected_perm = 'repository.none' | |
|
108 | assert repo_perm == expected_perm, f'obj:`{obj_name}` got perm:`{repo_perm}` should:`{expected_perm}`' | |
|
111 | 109 | |
|
112 | 110 | |
|
113 | 111 | def _get_perms(filter_='', recursive=None, key=None, test_u1_id=None): |
@@ -139,6 +139,8 b' def test_user_permissions_on_group_with_' | |||
|
139 | 139 | |
|
140 | 140 | # set permission to g0 recursive mode, all children including |
|
141 | 141 | # other repos and groups should have this permission now set ! |
|
142 | # except the PRIVATE repo which must remain repository.none permissions | |
|
143 | # this is exclusive to the default user | |
|
142 | 144 | recursive = 'all' |
|
143 | 145 | group = 'g0' |
|
144 | 146 | default_user_id = User.get_default_user_id() |
@@ -156,10 +158,10 b' def test_user_permissions_on_group_with_' | |||
|
156 | 158 | _check_expected_count(items, repo_items, expected_count(group, True)) |
|
157 | 159 | |
|
158 | 160 | for name, perm in repo_items: |
|
159 | check_tree_perms(name, perm, group, 'repository.write') | |
|
161 | check_tree_perms(name, perm, group, 'repository.write', default_user=True) | |
|
160 | 162 | |
|
161 | 163 | for name, perm in items: |
|
162 | check_tree_perms(name, perm, group, 'group.write') | |
|
164 | check_tree_perms(name, perm, group, 'group.write', default_user=True) | |
|
163 | 165 | |
|
164 | 166 | |
|
165 | 167 | def test_user_permissions_on_group_with_recursive_mode_inner_group(): |
General Comments 0
You need to be logged in to leave comments.
Login now