Mercurial > kallithea
annotate rhodecode/tests/functional/test_admin_users_groups.py @ 3937:2f5e6f1c5bdc beta
Bumped mercurial version
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 03 Jun 2013 14:18:07 +0200 |
parents | d7488551578e |
children |
rev | line source |
---|---|
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
1 from rhodecode.tests import * |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
2 from rhodecode.model.db import UserGroup, UserGroupToPerm, Permission |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3738
diff
changeset
|
3 from rhodecode.model.meta import Session |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
4 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
5 TEST_USER_GROUP = 'admins_test' |
1382
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
6 |
2064
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
7 |
1382
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
8 class TestAdminUsersGroupsController(TestController): |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
9 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
10 def test_index(self): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 response = self.app.get(url('users_groups')) |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
12 # Test response... |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
13 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
14 def test_index_as_xml(self): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
15 response = self.app.get(url('formatted_users_groups', format='xml')) |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
16 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
17 def test_create(self): |
1398
6dee43453f58
added test for non ascii repositories and fixed users_groups test
Marcin Kuzminski <marcin@python-works.com>
parents:
1382
diff
changeset
|
18 self.log_user() |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
19 users_group_name = TEST_USER_GROUP |
1382
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
20 response = self.app.post(url('users_groups'), |
2064
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
21 {'users_group_name': users_group_name, |
1382
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
22 'active':True}) |
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
23 response.follow() |
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
24 |
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
25 self.checkSessionFlash(response, |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3417
diff
changeset
|
26 'Created user group %s' % TEST_USER_GROUP) |
1382
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
27 |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 def test_new(self): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 response = self.app.get(url('new_users_group')) |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
31 def test_new_as_xml(self): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 response = self.app.get(url('formatted_new_users_group', format='xml')) |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 def test_update(self): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 response = self.app.put(url('users_group', id=1)) |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 def test_update_browser_fakeout(self): |
1436
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
38 response = self.app.post(url('users_group', id=1), |
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
39 params=dict(_method='put')) |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
41 def test_delete(self): |
1436
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
42 self.log_user() |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
43 users_group_name = TEST_USER_GROUP + 'another' |
1436
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
44 response = self.app.post(url('users_groups'), |
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
45 {'users_group_name':users_group_name, |
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
46 'active':True}) |
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
47 response.follow() |
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
48 |
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
49 self.checkSessionFlash(response, |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3417
diff
changeset
|
50 'Created user group %s' % users_group_name) |
1436
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
51 |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3738
diff
changeset
|
52 gr = Session().query(UserGroup)\ |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
53 .filter(UserGroup.users_group_name == |
1436
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
54 users_group_name).one() |
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
55 |
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
56 response = self.app.delete(url('users_group', id=gr.users_group_id)) |
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
57 |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3738
diff
changeset
|
58 gr = Session().query(UserGroup)\ |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
59 .filter(UserGroup.users_group_name == |
1436
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
60 users_group_name).scalar() |
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
61 |
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
62 self.assertEqual(gr, None) |
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
63 |
2064
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
64 def test_enable_repository_read_on_group(self): |
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
65 self.log_user() |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
66 users_group_name = TEST_USER_GROUP + 'another2' |
2064
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
67 response = self.app.post(url('users_groups'), |
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
68 {'users_group_name': users_group_name, |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
69 'active': True}) |
2064
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
70 response.follow() |
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
71 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
72 ug = UserGroup.get_by_group_name(users_group_name) |
2064
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
73 self.checkSessionFlash(response, |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3417
diff
changeset
|
74 'Created user group %s' % users_group_name) |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
75 ## ENABLE REPO CREATE ON A GROUP |
2064
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
76 response = self.app.put(url('users_group_perm', id=ug.users_group_id), |
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
77 {'create_repo_perm': True}) |
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
78 |
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
79 response.follow() |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
80 ug = UserGroup.get_by_group_name(users_group_name) |
2064
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
81 p = Permission.get_by_key('hg.create.repository') |
3738
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
82 p2 = Permission.get_by_key('hg.usergroup.create.false') |
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
83 p3 = Permission.get_by_key('hg.fork.none') |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
84 # check if user has this perms, they should be here since |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
85 # defaults are on |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
86 perms = UserGroupToPerm.query()\ |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
87 .filter(UserGroupToPerm.users_group == ug).all() |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
88 |
2064
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
89 self.assertEqual( |
3738
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
90 sorted([[x.users_group_id, x.permission_id, ] for x in perms]), |
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
91 sorted([[ug.users_group_id, p.permission_id], |
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
92 [ug.users_group_id, p2.permission_id], |
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
93 [ug.users_group_id, p3.permission_id]]) |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
94 ) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
95 |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
96 ## DISABLE REPO CREATE ON A GROUP |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
97 response = self.app.put(url('users_group_perm', id=ug.users_group_id), |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
98 {}) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
99 |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
100 response.follow() |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
101 ug = UserGroup.get_by_group_name(users_group_name) |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
102 p = Permission.get_by_key('hg.create.none') |
3738
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
103 p2 = Permission.get_by_key('hg.usergroup.create.false') |
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
104 p3 = Permission.get_by_key('hg.fork.none') |
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
105 |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
106 # check if user has this perms, they should be here since |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
107 # defaults are on |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
108 perms = UserGroupToPerm.query()\ |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
109 .filter(UserGroupToPerm.users_group == ug).all() |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
110 |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
111 self.assertEqual( |
2741
a89d375c5788
fixed test from failing under different conditions
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
112 sorted([[x.users_group_id, x.permission_id, ] for x in perms]), |
a89d375c5788
fixed test from failing under different conditions
Marcin Kuzminski <marcin@python-works.com>
parents:
2709
diff
changeset
|
113 sorted([[ug.users_group_id, p.permission_id], |
3738
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
114 [ug.users_group_id, p2.permission_id], |
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
115 [ug.users_group_id, p3.permission_id]]) |
2064
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
116 ) |
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
117 |
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
118 # DELETE ! |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
119 ug = UserGroup.get_by_group_name(users_group_name) |
2064
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
120 ugid = ug.users_group_id |
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
121 response = self.app.delete(url('users_group', id=ug.users_group_id)) |
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
122 response = response.follow() |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3738
diff
changeset
|
123 gr = Session().query(UserGroup)\ |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
124 .filter(UserGroup.users_group_name == |
2064
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
125 users_group_name).scalar() |
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
126 |
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
127 self.assertEqual(gr, None) |
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
128 p = Permission.get_by_key('hg.create.repository') |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
129 perms = UserGroupToPerm.query()\ |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
130 .filter(UserGroupToPerm.users_group_id == ugid).all() |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
131 perms = [[x.users_group_id, |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
132 x.permission_id, ] for x in perms] |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
133 self.assertEqual( |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
134 perms, |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
135 [] |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
136 ) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
137 |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
138 def test_enable_repository_fork_on_group(self): |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
139 self.log_user() |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
140 users_group_name = TEST_USER_GROUP + 'another2' |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
141 response = self.app.post(url('users_groups'), |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
142 {'users_group_name': users_group_name, |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
143 'active': True}) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
144 response.follow() |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
145 |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
146 ug = UserGroup.get_by_group_name(users_group_name) |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
147 self.checkSessionFlash(response, |
3565
a8f2d78d14ea
consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents:
3417
diff
changeset
|
148 'Created user group %s' % users_group_name) |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
149 ## ENABLE REPO CREATE ON A GROUP |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
150 response = self.app.put(url('users_group_perm', id=ug.users_group_id), |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
151 {'fork_repo_perm': True}) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
152 |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
153 response.follow() |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
154 ug = UserGroup.get_by_group_name(users_group_name) |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
155 p = Permission.get_by_key('hg.create.none') |
3738
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
156 p2 = Permission.get_by_key('hg.usergroup.create.false') |
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
157 p3 = Permission.get_by_key('hg.fork.repository') |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
158 # check if user has this perms, they should be here since |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
159 # defaults are on |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
160 perms = UserGroupToPerm.query()\ |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
161 .filter(UserGroupToPerm.users_group == ug).all() |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
162 |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
163 self.assertEqual( |
3738
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
164 sorted([[x.users_group_id, x.permission_id, ] for x in perms]), |
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
165 sorted([[ug.users_group_id, p.permission_id], |
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
166 [ug.users_group_id, p2.permission_id], |
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
167 [ug.users_group_id, p3.permission_id]]) |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
168 ) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
169 |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
170 ## DISABLE REPO CREATE ON A GROUP |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
171 response = self.app.put(url('users_group_perm', id=ug.users_group_id), |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
172 {}) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
173 |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
174 response.follow() |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
175 ug = UserGroup.get_by_group_name(users_group_name) |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
176 p = Permission.get_by_key('hg.create.none') |
3738
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
177 p2 = Permission.get_by_key('hg.usergroup.create.false') |
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
178 p3 = Permission.get_by_key('hg.fork.none') |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
179 # check if user has this perms, they should be here since |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
180 # defaults are on |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
181 perms = UserGroupToPerm.query()\ |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
182 .filter(UserGroupToPerm.users_group == ug).all() |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
183 |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
184 self.assertEqual( |
3738
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
185 sorted([[x.users_group_id, x.permission_id, ] for x in perms]), |
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
186 sorted([[ug.users_group_id, p.permission_id], |
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
187 [ug.users_group_id, p2.permission_id], |
752a57988a48
fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents:
3565
diff
changeset
|
188 [ug.users_group_id, p3.permission_id]]) |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
189 ) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
190 |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
191 # DELETE ! |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
192 ug = UserGroup.get_by_group_name(users_group_name) |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
193 ugid = ug.users_group_id |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
194 response = self.app.delete(url('users_group', id=ug.users_group_id)) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
195 response = response.follow() |
3797
d7488551578e
synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents:
3738
diff
changeset
|
196 gr = Session().query(UserGroup)\ |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
197 .filter(UserGroup.users_group_name == |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
198 users_group_name).scalar() |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
199 |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
200 self.assertEqual(gr, None) |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
201 p = Permission.get_by_key('hg.fork.repository') |
3417
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
202 perms = UserGroupToPerm.query()\ |
fa6ba6727475
further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents:
3415
diff
changeset
|
203 .filter(UserGroupToPerm.users_group_id == ugid).all() |
2709
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
204 perms = [[x.users_group_id, |
d2d35cf2b351
RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents:
2064
diff
changeset
|
205 x.permission_id, ] for x in perms] |
2064
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
206 self.assertEqual( |
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
207 perms, |
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
208 [] |
c9adf2a4929a
added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents:
1818
diff
changeset
|
209 ) |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
210 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
211 def test_delete_browser_fakeout(self): |
1436
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
212 response = self.app.post(url('users_group', id=1), |
88d13c1c6a55
removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents:
1398
diff
changeset
|
213 params=dict(_method='delete')) |
956
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
214 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
215 def test_show(self): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
216 response = self.app.get(url('users_group', id=1)) |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
217 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
218 def test_show_as_xml(self): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
219 response = self.app.get(url('formatted_users_group', id=1, format='xml')) |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
220 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
221 def test_edit(self): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
222 response = self.app.get(url('edit_users_group', id=1)) |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
223 |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
224 def test_edit_as_xml(self): |
83d35d716a02
started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
225 response = self.app.get(url('formatted_edit_users_group', id=1, format='xml')) |
1382
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
226 |
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
227 def test_assign_members(self): |
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
228 pass |
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
229 |
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
230 def test_add_create_permission(self): |
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
231 pass |
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
232 |
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
233 def test_revoke_members(self): |
c310e1e1e757
Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents:
956
diff
changeset
|
234 pass |