Show More
@@ -1,164 +1,165 b'' | |||||
1 | import os |
|
1 | import os | |
2 | import unittest |
|
2 | import unittest | |
3 | import functools |
|
3 | import functools | |
4 | from rhodecode.tests import * |
|
4 | from rhodecode.tests import * | |
5 |
|
5 | |||
6 | from rhodecode.model.repos_group import ReposGroupModel |
|
6 | from rhodecode.model.repos_group import ReposGroupModel | |
7 | from rhodecode.model.db import RepoGroup, Repository, User |
|
7 | from rhodecode.model.db import RepoGroup, Repository, User | |
8 |
|
8 | |||
9 | from rhodecode.model.meta import Session |
|
9 | from rhodecode.model.meta import Session | |
10 | from nose.tools import with_setup |
|
10 | from nose.tools import with_setup | |
11 | from rhodecode.tests.models.common import _create_project_tree, check_tree_perms, \ |
|
11 | from rhodecode.tests.models.common import _create_project_tree, check_tree_perms, \ | |
12 | _get_perms, _check_expected_count, expected_count, _destroy_project_tree |
|
12 | _get_perms, _check_expected_count, expected_count, _destroy_project_tree | |
13 | from rhodecode.model.repo import RepoModel |
|
13 | from rhodecode.model.repo import RepoModel | |
14 |
|
14 | |||
15 |
|
15 | |||
16 | test_u1_id = None |
|
16 | test_u1_id = None | |
17 | _get_repo_perms = None |
|
17 | _get_repo_perms = None | |
18 | _get_group_perms = None |
|
18 | _get_group_perms = None | |
19 |
|
19 | |||
20 |
|
20 | |||
21 | def permissions_setup_func(group_name='g0', perm='group.read', recursive=True): |
|
21 | def permissions_setup_func(group_name='g0', perm='group.read', recursive=True): | |
22 | """ |
|
22 | """ | |
23 | Resets all permissions to perm attribute |
|
23 | Resets all permissions to perm attribute | |
24 | """ |
|
24 | """ | |
25 | repos_group = RepoGroup.get_by_group_name(group_name=group_name) |
|
25 | repos_group = RepoGroup.get_by_group_name(group_name=group_name) | |
26 | if not repos_group: |
|
26 | if not repos_group: | |
27 | raise Exception('Cannot get group %s' % group_name) |
|
27 | raise Exception('Cannot get group %s' % group_name) | |
28 | perms_updates = [[test_u1_id, perm, 'user']] |
|
28 | perms_updates = [[test_u1_id, perm, 'user']] | |
29 | ReposGroupModel()._update_permissions(repos_group, |
|
29 | ReposGroupModel()._update_permissions(repos_group, | |
30 | perms_updates=perms_updates, |
|
30 | perms_updates=perms_updates, | |
31 |
recursive=recursive |
|
31 | recursive=recursive, | |
|
32 | check_perms=False) | |||
32 | Session().commit() |
|
33 | Session().commit() | |
33 |
|
34 | |||
34 |
|
35 | |||
35 | def setup_module(): |
|
36 | def setup_module(): | |
36 | global test_u1_id, _get_repo_perms, _get_group_perms |
|
37 | global test_u1_id, _get_repo_perms, _get_group_perms | |
37 | test_u1 = _create_project_tree() |
|
38 | test_u1 = _create_project_tree() | |
38 | Session().commit() |
|
39 | Session().commit() | |
39 | test_u1_id = test_u1.user_id |
|
40 | test_u1_id = test_u1.user_id | |
40 | _get_repo_perms = functools.partial(_get_perms, key='repositories', |
|
41 | _get_repo_perms = functools.partial(_get_perms, key='repositories', | |
41 | test_u1_id=test_u1_id) |
|
42 | test_u1_id=test_u1_id) | |
42 | _get_group_perms = functools.partial(_get_perms, key='repositories_groups', |
|
43 | _get_group_perms = functools.partial(_get_perms, key='repositories_groups', | |
43 | test_u1_id=test_u1_id) |
|
44 | test_u1_id=test_u1_id) | |
44 |
|
45 | |||
45 |
|
46 | |||
46 | def teardown_module(): |
|
47 | def teardown_module(): | |
47 | _destroy_project_tree(test_u1_id) |
|
48 | _destroy_project_tree(test_u1_id) | |
48 |
|
49 | |||
49 |
|
50 | |||
50 | @with_setup(permissions_setup_func) |
|
51 | @with_setup(permissions_setup_func) | |
51 | def test_user_permissions_on_group_without_recursive_mode(): |
|
52 | def test_user_permissions_on_group_without_recursive_mode(): | |
52 | # set permission to g0 non-recursive mode |
|
53 | # set permission to g0 non-recursive mode | |
53 | recursive = False |
|
54 | recursive = False | |
54 | group = 'g0' |
|
55 | group = 'g0' | |
55 | permissions_setup_func(group, 'group.write', recursive=recursive) |
|
56 | permissions_setup_func(group, 'group.write', recursive=recursive) | |
56 |
|
57 | |||
57 | items = [x for x in _get_repo_perms(group, recursive)] |
|
58 | items = [x for x in _get_repo_perms(group, recursive)] | |
58 | expected = 0 |
|
59 | expected = 0 | |
59 | assert len(items) == expected, ' %s != %s' % (len(items), expected) |
|
60 | assert len(items) == expected, ' %s != %s' % (len(items), expected) | |
60 | for name, perm in items: |
|
61 | for name, perm in items: | |
61 | yield check_tree_perms, name, perm, group, 'repository.read' |
|
62 | yield check_tree_perms, name, perm, group, 'repository.read' | |
62 |
|
63 | |||
63 | items = [x for x in _get_group_perms(group, recursive)] |
|
64 | items = [x for x in _get_group_perms(group, recursive)] | |
64 | expected = 1 |
|
65 | expected = 1 | |
65 | assert len(items) == expected, ' %s != %s' % (len(items), expected) |
|
66 | assert len(items) == expected, ' %s != %s' % (len(items), expected) | |
66 | for name, perm in items: |
|
67 | for name, perm in items: | |
67 | yield check_tree_perms, name, perm, group, 'group.write' |
|
68 | yield check_tree_perms, name, perm, group, 'group.write' | |
68 |
|
69 | |||
69 |
|
70 | |||
70 | @with_setup(permissions_setup_func) |
|
71 | @with_setup(permissions_setup_func) | |
71 | def test_user_permissions_on_group_without_recursive_mode_subgroup(): |
|
72 | def test_user_permissions_on_group_without_recursive_mode_subgroup(): | |
72 | # set permission to g0 non-recursive mode |
|
73 | # set permission to g0 non-recursive mode | |
73 | recursive = False |
|
74 | recursive = False | |
74 | group = 'g0/g0_1' |
|
75 | group = 'g0/g0_1' | |
75 | permissions_setup_func(group, 'group.write', recursive=recursive) |
|
76 | permissions_setup_func(group, 'group.write', recursive=recursive) | |
76 |
|
77 | |||
77 | items = [x for x in _get_repo_perms(group, recursive)] |
|
78 | items = [x for x in _get_repo_perms(group, recursive)] | |
78 | expected = 0 |
|
79 | expected = 0 | |
79 | assert len(items) == expected, ' %s != %s' % (len(items), expected) |
|
80 | assert len(items) == expected, ' %s != %s' % (len(items), expected) | |
80 | for name, perm in items: |
|
81 | for name, perm in items: | |
81 | yield check_tree_perms, name, perm, group, 'repository.read' |
|
82 | yield check_tree_perms, name, perm, group, 'repository.read' | |
82 |
|
83 | |||
83 | items = [x for x in _get_group_perms(group, recursive)] |
|
84 | items = [x for x in _get_group_perms(group, recursive)] | |
84 | expected = 1 |
|
85 | expected = 1 | |
85 | assert len(items) == expected, ' %s != %s' % (len(items), expected) |
|
86 | assert len(items) == expected, ' %s != %s' % (len(items), expected) | |
86 | for name, perm in items: |
|
87 | for name, perm in items: | |
87 | yield check_tree_perms, name, perm, group, 'group.write' |
|
88 | yield check_tree_perms, name, perm, group, 'group.write' | |
88 |
|
89 | |||
89 |
|
90 | |||
90 | @with_setup(permissions_setup_func) |
|
91 | @with_setup(permissions_setup_func) | |
91 | def test_user_permissions_on_group_with_recursive_mode(): |
|
92 | def test_user_permissions_on_group_with_recursive_mode(): | |
92 |
|
93 | |||
93 | # set permission to g0 recursive mode, all children including |
|
94 | # set permission to g0 recursive mode, all children including | |
94 | # other repos and groups should have this permission now set ! |
|
95 | # other repos and groups should have this permission now set ! | |
95 | recursive = True |
|
96 | recursive = True | |
96 | group = 'g0' |
|
97 | group = 'g0' | |
97 | permissions_setup_func(group, 'group.write', recursive=recursive) |
|
98 | permissions_setup_func(group, 'group.write', recursive=recursive) | |
98 |
|
99 | |||
99 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
|
100 | repo_items = [x for x in _get_repo_perms(group, recursive)] | |
100 | items = [x for x in _get_group_perms(group, recursive)] |
|
101 | items = [x for x in _get_group_perms(group, recursive)] | |
101 | _check_expected_count(items, repo_items, expected_count(group, True)) |
|
102 | _check_expected_count(items, repo_items, expected_count(group, True)) | |
102 |
|
103 | |||
103 | for name, perm in repo_items: |
|
104 | for name, perm in repo_items: | |
104 | if name == 'g0/g0_3/g0_3_r1_private': |
|
105 | if name == 'g0/g0_3/g0_3_r1_private': | |
105 | yield check_tree_perms, name, perm, group, 'repository.none' |
|
106 | yield check_tree_perms, name, perm, group, 'repository.none' | |
106 | else: |
|
107 | else: | |
107 | yield check_tree_perms, name, perm, group, 'repository.write' |
|
108 | yield check_tree_perms, name, perm, group, 'repository.write' | |
108 |
|
109 | |||
109 | for name, perm in items: |
|
110 | for name, perm in items: | |
110 | yield check_tree_perms, name, perm, group, 'group.write' |
|
111 | yield check_tree_perms, name, perm, group, 'group.write' | |
111 |
|
112 | |||
112 |
|
113 | |||
113 | @with_setup(permissions_setup_func) |
|
114 | @with_setup(permissions_setup_func) | |
114 | def test_user_permissions_on_group_with_recursive_mode_inner_group(): |
|
115 | def test_user_permissions_on_group_with_recursive_mode_inner_group(): | |
115 | ## set permission to g0_3 group to none |
|
116 | ## set permission to g0_3 group to none | |
116 | recursive = True |
|
117 | recursive = True | |
117 | group = 'g0/g0_3' |
|
118 | group = 'g0/g0_3' | |
118 | permissions_setup_func(group, 'group.none', recursive=recursive) |
|
119 | permissions_setup_func(group, 'group.none', recursive=recursive) | |
119 |
|
120 | |||
120 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
|
121 | repo_items = [x for x in _get_repo_perms(group, recursive)] | |
121 | items = [x for x in _get_group_perms(group, recursive)] |
|
122 | items = [x for x in _get_group_perms(group, recursive)] | |
122 | _check_expected_count(items, repo_items, expected_count(group, True)) |
|
123 | _check_expected_count(items, repo_items, expected_count(group, True)) | |
123 |
|
124 | |||
124 | for name, perm in repo_items: |
|
125 | for name, perm in repo_items: | |
125 | yield check_tree_perms, name, perm, group, 'repository.none' |
|
126 | yield check_tree_perms, name, perm, group, 'repository.none' | |
126 |
|
127 | |||
127 | for name, perm in items: |
|
128 | for name, perm in items: | |
128 | yield check_tree_perms, name, perm, group, 'group.none' |
|
129 | yield check_tree_perms, name, perm, group, 'group.none' | |
129 |
|
130 | |||
130 |
|
131 | |||
131 | @with_setup(permissions_setup_func) |
|
132 | @with_setup(permissions_setup_func) | |
132 | def test_user_permissions_on_group_with_recursive_mode_deepest(): |
|
133 | def test_user_permissions_on_group_with_recursive_mode_deepest(): | |
133 | ## set permission to g0_3 group to none |
|
134 | ## set permission to g0_3 group to none | |
134 | recursive = True |
|
135 | recursive = True | |
135 | group = 'g0/g0_1/g0_1_1' |
|
136 | group = 'g0/g0_1/g0_1_1' | |
136 | permissions_setup_func(group, 'group.write', recursive=recursive) |
|
137 | permissions_setup_func(group, 'group.write', recursive=recursive) | |
137 |
|
138 | |||
138 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
|
139 | repo_items = [x for x in _get_repo_perms(group, recursive)] | |
139 | items = [x for x in _get_group_perms(group, recursive)] |
|
140 | items = [x for x in _get_group_perms(group, recursive)] | |
140 | _check_expected_count(items, repo_items, expected_count(group, True)) |
|
141 | _check_expected_count(items, repo_items, expected_count(group, True)) | |
141 |
|
142 | |||
142 | for name, perm in repo_items: |
|
143 | for name, perm in repo_items: | |
143 | yield check_tree_perms, name, perm, group, 'repository.write' |
|
144 | yield check_tree_perms, name, perm, group, 'repository.write' | |
144 |
|
145 | |||
145 | for name, perm in items: |
|
146 | for name, perm in items: | |
146 | yield check_tree_perms, name, perm, group, 'group.write' |
|
147 | yield check_tree_perms, name, perm, group, 'group.write' | |
147 |
|
148 | |||
148 |
|
149 | |||
149 | @with_setup(permissions_setup_func) |
|
150 | @with_setup(permissions_setup_func) | |
150 | def test_user_permissions_on_group_with_recursive_mode_only_with_repos(): |
|
151 | def test_user_permissions_on_group_with_recursive_mode_only_with_repos(): | |
151 | ## set permission to g0_3 group to none |
|
152 | ## set permission to g0_3 group to none | |
152 | recursive = True |
|
153 | recursive = True | |
153 | group = 'g0/g0_2' |
|
154 | group = 'g0/g0_2' | |
154 | permissions_setup_func(group, 'group.admin', recursive=recursive) |
|
155 | permissions_setup_func(group, 'group.admin', recursive=recursive) | |
155 |
|
156 | |||
156 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
|
157 | repo_items = [x for x in _get_repo_perms(group, recursive)] | |
157 | items = [x for x in _get_group_perms(group, recursive)] |
|
158 | items = [x for x in _get_group_perms(group, recursive)] | |
158 | _check_expected_count(items, repo_items, expected_count(group, True)) |
|
159 | _check_expected_count(items, repo_items, expected_count(group, True)) | |
159 |
|
160 | |||
160 | for name, perm in repo_items: |
|
161 | for name, perm in repo_items: | |
161 | yield check_tree_perms, name, perm, group, 'repository.admin' |
|
162 | yield check_tree_perms, name, perm, group, 'repository.admin' | |
162 |
|
163 | |||
163 | for name, perm in items: |
|
164 | for name, perm in items: | |
164 | yield check_tree_perms, name, perm, group, 'group.admin' |
|
165 | yield check_tree_perms, name, perm, group, 'group.admin' |
@@ -1,171 +1,172 b'' | |||||
1 | import os |
|
1 | import os | |
2 | import unittest |
|
2 | import unittest | |
3 | import functools |
|
3 | import functools | |
4 | from rhodecode.tests import * |
|
4 | from rhodecode.tests import * | |
5 |
|
5 | |||
6 | from rhodecode.model.repos_group import ReposGroupModel |
|
6 | from rhodecode.model.repos_group import ReposGroupModel | |
7 | from rhodecode.model.db import RepoGroup |
|
7 | from rhodecode.model.db import RepoGroup | |
8 |
|
8 | |||
9 | from rhodecode.model.meta import Session |
|
9 | from rhodecode.model.meta import Session | |
10 | from nose.tools import with_setup |
|
10 | from nose.tools import with_setup | |
11 | from rhodecode.tests.models.common import _create_project_tree, check_tree_perms, \ |
|
11 | from rhodecode.tests.models.common import _create_project_tree, check_tree_perms, \ | |
12 | _get_perms, _check_expected_count, expected_count, _destroy_project_tree |
|
12 | _get_perms, _check_expected_count, expected_count, _destroy_project_tree | |
13 | from rhodecode.model.users_group import UserGroupModel |
|
13 | from rhodecode.model.users_group import UserGroupModel | |
14 | from rhodecode.tests.fixture import Fixture |
|
14 | from rhodecode.tests.fixture import Fixture | |
15 |
|
15 | |||
16 | fixture = Fixture() |
|
16 | fixture = Fixture() | |
17 |
|
17 | |||
18 | test_u2_id = None |
|
18 | test_u2_id = None | |
19 | test_u2_gr_id = None |
|
19 | test_u2_gr_id = None | |
20 | _get_repo_perms = None |
|
20 | _get_repo_perms = None | |
21 | _get_group_perms = None |
|
21 | _get_group_perms = None | |
22 |
|
22 | |||
23 |
|
23 | |||
24 | def permissions_setup_func(group_name='g0', perm='group.read', recursive=True): |
|
24 | def permissions_setup_func(group_name='g0', perm='group.read', recursive=True): | |
25 | """ |
|
25 | """ | |
26 | Resets all permissions to perm attribute |
|
26 | Resets all permissions to perm attribute | |
27 | """ |
|
27 | """ | |
28 | repos_group = RepoGroup.get_by_group_name(group_name=group_name) |
|
28 | repos_group = RepoGroup.get_by_group_name(group_name=group_name) | |
29 | if not repos_group: |
|
29 | if not repos_group: | |
30 | raise Exception('Cannot get group %s' % group_name) |
|
30 | raise Exception('Cannot get group %s' % group_name) | |
31 | perms_updates = [[test_u2_gr_id, perm, 'users_group']] |
|
31 | perms_updates = [[test_u2_gr_id, perm, 'users_group']] | |
32 | ReposGroupModel()._update_permissions(repos_group, |
|
32 | ReposGroupModel()._update_permissions(repos_group, | |
33 | perms_updates=perms_updates, |
|
33 | perms_updates=perms_updates, | |
34 |
recursive=recursive |
|
34 | recursive=recursive, | |
|
35 | check_perms=False) | |||
35 | Session().commit() |
|
36 | Session().commit() | |
36 |
|
37 | |||
37 |
|
38 | |||
38 | def setup_module(): |
|
39 | def setup_module(): | |
39 | global test_u2_id, test_u2_gr_id, _get_repo_perms, _get_group_perms |
|
40 | global test_u2_id, test_u2_gr_id, _get_repo_perms, _get_group_perms | |
40 | test_u2 = _create_project_tree() |
|
41 | test_u2 = _create_project_tree() | |
41 | Session().commit() |
|
42 | Session().commit() | |
42 | test_u2_id = test_u2.user_id |
|
43 | test_u2_id = test_u2.user_id | |
43 |
|
44 | |||
44 | gr1 = fixture.create_user_group('perms_group_1') |
|
45 | gr1 = fixture.create_user_group('perms_group_1') | |
45 | Session().commit() |
|
46 | Session().commit() | |
46 | test_u2_gr_id = gr1.users_group_id |
|
47 | test_u2_gr_id = gr1.users_group_id | |
47 | UserGroupModel().add_user_to_group(gr1, user=test_u2_id) |
|
48 | UserGroupModel().add_user_to_group(gr1, user=test_u2_id) | |
48 | Session().commit() |
|
49 | Session().commit() | |
49 |
|
50 | |||
50 | _get_repo_perms = functools.partial(_get_perms, key='repositories', |
|
51 | _get_repo_perms = functools.partial(_get_perms, key='repositories', | |
51 | test_u1_id=test_u2_id) |
|
52 | test_u1_id=test_u2_id) | |
52 | _get_group_perms = functools.partial(_get_perms, key='repositories_groups', |
|
53 | _get_group_perms = functools.partial(_get_perms, key='repositories_groups', | |
53 | test_u1_id=test_u2_id) |
|
54 | test_u1_id=test_u2_id) | |
54 |
|
55 | |||
55 |
|
56 | |||
56 | def teardown_module(): |
|
57 | def teardown_module(): | |
57 | _destroy_project_tree(test_u2_id) |
|
58 | _destroy_project_tree(test_u2_id) | |
58 |
|
59 | |||
59 |
|
60 | |||
60 | @with_setup(permissions_setup_func) |
|
61 | @with_setup(permissions_setup_func) | |
61 | def test_user_permissions_on_group_without_recursive_mode(): |
|
62 | def test_user_permissions_on_group_without_recursive_mode(): | |
62 | # set permission to g0 non-recursive mode |
|
63 | # set permission to g0 non-recursive mode | |
63 | recursive = False |
|
64 | recursive = False | |
64 | group = 'g0' |
|
65 | group = 'g0' | |
65 | permissions_setup_func(group, 'group.write', recursive=recursive) |
|
66 | permissions_setup_func(group, 'group.write', recursive=recursive) | |
66 |
|
67 | |||
67 | items = [x for x in _get_repo_perms(group, recursive)] |
|
68 | items = [x for x in _get_repo_perms(group, recursive)] | |
68 | expected = 0 |
|
69 | expected = 0 | |
69 | assert len(items) == expected, ' %s != %s' % (len(items), expected) |
|
70 | assert len(items) == expected, ' %s != %s' % (len(items), expected) | |
70 | for name, perm in items: |
|
71 | for name, perm in items: | |
71 | yield check_tree_perms, name, perm, group, 'repository.read' |
|
72 | yield check_tree_perms, name, perm, group, 'repository.read' | |
72 |
|
73 | |||
73 | items = [x for x in _get_group_perms(group, recursive)] |
|
74 | items = [x for x in _get_group_perms(group, recursive)] | |
74 | expected = 1 |
|
75 | expected = 1 | |
75 | assert len(items) == expected, ' %s != %s' % (len(items), expected) |
|
76 | assert len(items) == expected, ' %s != %s' % (len(items), expected) | |
76 | for name, perm in items: |
|
77 | for name, perm in items: | |
77 | yield check_tree_perms, name, perm, group, 'group.write' |
|
78 | yield check_tree_perms, name, perm, group, 'group.write' | |
78 |
|
79 | |||
79 |
|
80 | |||
80 | @with_setup(permissions_setup_func) |
|
81 | @with_setup(permissions_setup_func) | |
81 | def test_user_permissions_on_group_without_recursive_mode_subgroup(): |
|
82 | def test_user_permissions_on_group_without_recursive_mode_subgroup(): | |
82 | # set permission to g0 non-recursive mode |
|
83 | # set permission to g0 non-recursive mode | |
83 | recursive = False |
|
84 | recursive = False | |
84 | group = 'g0/g0_1' |
|
85 | group = 'g0/g0_1' | |
85 | permissions_setup_func(group, 'group.write', recursive=recursive) |
|
86 | permissions_setup_func(group, 'group.write', recursive=recursive) | |
86 |
|
87 | |||
87 | items = [x for x in _get_repo_perms(group, recursive)] |
|
88 | items = [x for x in _get_repo_perms(group, recursive)] | |
88 | expected = 0 |
|
89 | expected = 0 | |
89 | assert len(items) == expected, ' %s != %s' % (len(items), expected) |
|
90 | assert len(items) == expected, ' %s != %s' % (len(items), expected) | |
90 | for name, perm in items: |
|
91 | for name, perm in items: | |
91 | yield check_tree_perms, name, perm, group, 'repository.read' |
|
92 | yield check_tree_perms, name, perm, group, 'repository.read' | |
92 |
|
93 | |||
93 | items = [x for x in _get_group_perms(group, recursive)] |
|
94 | items = [x for x in _get_group_perms(group, recursive)] | |
94 | expected = 1 |
|
95 | expected = 1 | |
95 | assert len(items) == expected, ' %s != %s' % (len(items), expected) |
|
96 | assert len(items) == expected, ' %s != %s' % (len(items), expected) | |
96 | for name, perm in items: |
|
97 | for name, perm in items: | |
97 | yield check_tree_perms, name, perm, group, 'group.write' |
|
98 | yield check_tree_perms, name, perm, group, 'group.write' | |
98 |
|
99 | |||
99 |
|
100 | |||
100 | @with_setup(permissions_setup_func) |
|
101 | @with_setup(permissions_setup_func) | |
101 | def test_user_permissions_on_group_with_recursive_mode(): |
|
102 | def test_user_permissions_on_group_with_recursive_mode(): | |
102 |
|
103 | |||
103 | # set permission to g0 recursive mode, all children including |
|
104 | # set permission to g0 recursive mode, all children including | |
104 | # other repos and groups should have this permission now set ! |
|
105 | # other repos and groups should have this permission now set ! | |
105 | recursive = True |
|
106 | recursive = True | |
106 | group = 'g0' |
|
107 | group = 'g0' | |
107 | permissions_setup_func(group, 'group.write', recursive=recursive) |
|
108 | permissions_setup_func(group, 'group.write', recursive=recursive) | |
108 |
|
109 | |||
109 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
|
110 | repo_items = [x for x in _get_repo_perms(group, recursive)] | |
110 | items = [x for x in _get_group_perms(group, recursive)] |
|
111 | items = [x for x in _get_group_perms(group, recursive)] | |
111 | _check_expected_count(items, repo_items, expected_count(group, True)) |
|
112 | _check_expected_count(items, repo_items, expected_count(group, True)) | |
112 |
|
113 | |||
113 | for name, perm in repo_items: |
|
114 | for name, perm in repo_items: | |
114 | yield check_tree_perms, name, perm, group, 'repository.write' |
|
115 | yield check_tree_perms, name, perm, group, 'repository.write' | |
115 |
|
116 | |||
116 | for name, perm in items: |
|
117 | for name, perm in items: | |
117 | yield check_tree_perms, name, perm, group, 'group.write' |
|
118 | yield check_tree_perms, name, perm, group, 'group.write' | |
118 |
|
119 | |||
119 |
|
120 | |||
120 | @with_setup(permissions_setup_func) |
|
121 | @with_setup(permissions_setup_func) | |
121 | def test_user_permissions_on_group_with_recursive_mode_inner_group(): |
|
122 | def test_user_permissions_on_group_with_recursive_mode_inner_group(): | |
122 | ## set permission to g0_3 group to none |
|
123 | ## set permission to g0_3 group to none | |
123 | recursive = True |
|
124 | recursive = True | |
124 | group = 'g0/g0_3' |
|
125 | group = 'g0/g0_3' | |
125 | permissions_setup_func(group, 'group.none', recursive=recursive) |
|
126 | permissions_setup_func(group, 'group.none', recursive=recursive) | |
126 |
|
127 | |||
127 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
|
128 | repo_items = [x for x in _get_repo_perms(group, recursive)] | |
128 | items = [x for x in _get_group_perms(group, recursive)] |
|
129 | items = [x for x in _get_group_perms(group, recursive)] | |
129 | _check_expected_count(items, repo_items, expected_count(group, True)) |
|
130 | _check_expected_count(items, repo_items, expected_count(group, True)) | |
130 |
|
131 | |||
131 | for name, perm in repo_items: |
|
132 | for name, perm in repo_items: | |
132 | yield check_tree_perms, name, perm, group, 'repository.none' |
|
133 | yield check_tree_perms, name, perm, group, 'repository.none' | |
133 |
|
134 | |||
134 | for name, perm in items: |
|
135 | for name, perm in items: | |
135 | yield check_tree_perms, name, perm, group, 'group.none' |
|
136 | yield check_tree_perms, name, perm, group, 'group.none' | |
136 |
|
137 | |||
137 |
|
138 | |||
138 | @with_setup(permissions_setup_func) |
|
139 | @with_setup(permissions_setup_func) | |
139 | def test_user_permissions_on_group_with_recursive_mode_deepest(): |
|
140 | def test_user_permissions_on_group_with_recursive_mode_deepest(): | |
140 | ## set permission to g0_3 group to none |
|
141 | ## set permission to g0_3 group to none | |
141 | recursive = True |
|
142 | recursive = True | |
142 | group = 'g0/g0_1/g0_1_1' |
|
143 | group = 'g0/g0_1/g0_1_1' | |
143 | permissions_setup_func(group, 'group.write', recursive=recursive) |
|
144 | permissions_setup_func(group, 'group.write', recursive=recursive) | |
144 |
|
145 | |||
145 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
|
146 | repo_items = [x for x in _get_repo_perms(group, recursive)] | |
146 | items = [x for x in _get_group_perms(group, recursive)] |
|
147 | items = [x for x in _get_group_perms(group, recursive)] | |
147 | _check_expected_count(items, repo_items, expected_count(group, True)) |
|
148 | _check_expected_count(items, repo_items, expected_count(group, True)) | |
148 |
|
149 | |||
149 | for name, perm in repo_items: |
|
150 | for name, perm in repo_items: | |
150 | yield check_tree_perms, name, perm, group, 'repository.write' |
|
151 | yield check_tree_perms, name, perm, group, 'repository.write' | |
151 |
|
152 | |||
152 | for name, perm in items: |
|
153 | for name, perm in items: | |
153 | yield check_tree_perms, name, perm, group, 'group.write' |
|
154 | yield check_tree_perms, name, perm, group, 'group.write' | |
154 |
|
155 | |||
155 |
|
156 | |||
156 | @with_setup(permissions_setup_func) |
|
157 | @with_setup(permissions_setup_func) | |
157 | def test_user_permissions_on_group_with_recursive_mode_only_with_repos(): |
|
158 | def test_user_permissions_on_group_with_recursive_mode_only_with_repos(): | |
158 | ## set permission to g0_3 group to none |
|
159 | ## set permission to g0_3 group to none | |
159 | recursive = True |
|
160 | recursive = True | |
160 | group = 'g0/g0_2' |
|
161 | group = 'g0/g0_2' | |
161 | permissions_setup_func(group, 'group.admin', recursive=recursive) |
|
162 | permissions_setup_func(group, 'group.admin', recursive=recursive) | |
162 |
|
163 | |||
163 | repo_items = [x for x in _get_repo_perms(group, recursive)] |
|
164 | repo_items = [x for x in _get_repo_perms(group, recursive)] | |
164 | items = [x for x in _get_group_perms(group, recursive)] |
|
165 | items = [x for x in _get_group_perms(group, recursive)] | |
165 | _check_expected_count(items, repo_items, expected_count(group, True)) |
|
166 | _check_expected_count(items, repo_items, expected_count(group, True)) | |
166 |
|
167 | |||
167 | for name, perm in repo_items: |
|
168 | for name, perm in repo_items: | |
168 | yield check_tree_perms, name, perm, group, 'repository.admin' |
|
169 | yield check_tree_perms, name, perm, group, 'repository.admin' | |
169 |
|
170 | |||
170 | for name, perm in items: |
|
171 | for name, perm in items: | |
171 | yield check_tree_perms, name, perm, group, 'group.admin' |
|
172 | yield check_tree_perms, name, perm, group, 'group.admin' |
General Comments 0
You need to be logged in to leave comments.
Login now