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