annotate rhodecode/tests/functional/test_admin_users_groups.py @ 3738:752a57988a48 beta

fixed tests for usersgroups
author Marcin Kuzminski <marcin@python-works.com>
date Thu, 11 Apr 2013 03:36:39 +0200
parents a8f2d78d14ea
children d7488551578e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
956
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
4 TEST_USER_GROUP = 'admins_test'
1382
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
5
2064
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
6
1382
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
7 class TestAdminUsersGroupsController(TestController):
956
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 def test_index(self):
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 response = self.app.get(url('users_groups'))
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 # Test response...
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13 def test_index_as_xml(self):
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 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
15
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16 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
17 self.log_user()
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
18 users_group_name = TEST_USER_GROUP
1382
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
19 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
20 {'users_group_name': users_group_name,
1382
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
21 'active':True})
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
22 response.follow()
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
23
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
24 self.checkSessionFlash(response,
3565
a8f2d78d14ea consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents: 3417
diff changeset
25 'Created user group %s' % TEST_USER_GROUP)
1382
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
26
956
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27 def test_new(self):
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 response = self.app.get(url('new_users_group'))
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 def test_new_as_xml(self):
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31 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
32
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
33 def test_update(self):
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34 response = self.app.put(url('users_group', id=1))
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
36 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
37 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
38 params=dict(_method='put'))
956
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40 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
41 self.log_user()
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
42 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
43 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
44 {'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
45 'active':True})
88d13c1c6a55 removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents: 1398
diff changeset
46 response.follow()
88d13c1c6a55 removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents: 1398
diff changeset
47
88d13c1c6a55 removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents: 1398
diff changeset
48 self.checkSessionFlash(response,
3565
a8f2d78d14ea consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents: 3417
diff changeset
49 '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
50
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
51 gr = self.Session.query(UserGroup)\
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
52 .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
53 users_group_name).one()
88d13c1c6a55 removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents: 1398
diff changeset
54
88d13c1c6a55 removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents: 1398
diff changeset
55 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
56
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
57 gr = self.Session.query(UserGroup)\
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
58 .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
59 users_group_name).scalar()
88d13c1c6a55 removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents: 1398
diff changeset
60
88d13c1c6a55 removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents: 1398
diff changeset
61 self.assertEqual(gr, None)
88d13c1c6a55 removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents: 1398
diff changeset
62
2064
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
63 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
64 self.log_user()
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
65 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
66 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
67 {'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
68 'active': True})
2064
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
69 response.follow()
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
70
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
71 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
72 self.checkSessionFlash(response,
3565
a8f2d78d14ea consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents: 3417
diff changeset
73 '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
74 ## 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
75 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
76 {'create_repo_perm': True})
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
77
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
78 response.follow()
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
79 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
80 p = Permission.get_by_key('hg.create.repository')
3738
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
81 p2 = Permission.get_by_key('hg.usergroup.create.false')
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
82 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
83 # 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
84 # defaults are on
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
85 perms = UserGroupToPerm.query()\
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
86 .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
87
2064
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
88 self.assertEqual(
3738
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
89 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
90 sorted([[ug.users_group_id, p.permission_id],
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
91 [ug.users_group_id, p2.permission_id],
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
92 [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
93 )
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 ## 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
96 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
97 {})
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 response.follow()
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
100 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
101 p = Permission.get_by_key('hg.create.none')
3738
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
102 p2 = Permission.get_by_key('hg.usergroup.create.false')
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
103 p3 = Permission.get_by_key('hg.fork.none')
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
104
2709
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
105 # 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
106 # defaults are on
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
107 perms = UserGroupToPerm.query()\
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
108 .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
109
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
110 self.assertEqual(
2741
a89d375c5788 fixed test from failing under different conditions
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
111 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
112 sorted([[ug.users_group_id, p.permission_id],
3738
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
113 [ug.users_group_id, p2.permission_id],
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
114 [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
115 )
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 # DELETE !
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
118 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
119 ugid = ug.users_group_id
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
120 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
121 response = response.follow()
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
122 gr = self.Session.query(UserGroup)\
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
123 .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
124 users_group_name).scalar()
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
125
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
126 self.assertEqual(gr, None)
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
127 p = Permission.get_by_key('hg.create.repository')
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
128 perms = UserGroupToPerm.query()\
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
129 .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
130 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
131 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
132 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
133 perms,
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
134 []
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 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
138 self.log_user()
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
139 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
140 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
141 {'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
142 '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
143 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
144
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
145 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
146 self.checkSessionFlash(response,
3565
a8f2d78d14ea consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents: 3417
diff changeset
147 '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
148 ## 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
149 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
150 {'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
151
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
152 response.follow()
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
153 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
154 p = Permission.get_by_key('hg.create.none')
3738
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
155 p2 = Permission.get_by_key('hg.usergroup.create.false')
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
156 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
157 # 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
158 # defaults are on
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
159 perms = UserGroupToPerm.query()\
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
160 .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
161
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
162 self.assertEqual(
3738
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
163 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
164 sorted([[ug.users_group_id, p.permission_id],
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
165 [ug.users_group_id, p2.permission_id],
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
166 [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
167 )
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 ## 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
170 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
171 {})
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 response.follow()
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
174 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
175 p = Permission.get_by_key('hg.create.none')
3738
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
176 p2 = Permission.get_by_key('hg.usergroup.create.false')
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
177 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
178 # 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
179 # defaults are on
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
180 perms = UserGroupToPerm.query()\
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
181 .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
182
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
183 self.assertEqual(
3738
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
184 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
185 sorted([[ug.users_group_id, p.permission_id],
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
186 [ug.users_group_id, p2.permission_id],
752a57988a48 fixed tests for usersgroups
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
187 [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
188 )
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 # DELETE !
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
191 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
192 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
193 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
194 response = response.follow()
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
195 gr = self.Session.query(UserGroup)\
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
196 .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
197 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
198
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
199 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
200 p = Permission.get_by_key('hg.fork.repository')
3417
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
201 perms = UserGroupToPerm.query()\
fa6ba6727475 further cleanup of UsersGroup
Mads Kiilerich <madski@unity3d.com>
parents: 3415
diff changeset
202 .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
203 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
204 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
205 self.assertEqual(
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
206 perms,
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
207 []
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
208 )
956
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
209
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
210 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
211 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
212 params=dict(_method='delete'))
956
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
213
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
214 def test_show(self):
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
215 response = self.app.get(url('users_group', id=1))
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
216
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
217 def test_show_as_xml(self):
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
218 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
219
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
220 def test_edit(self):
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
221 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
222
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
223 def test_edit_as_xml(self):
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
224 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
225
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
226 def test_assign_members(self):
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
227 pass
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
228
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
229 def test_add_create_permission(self):
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
230 pass
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
231
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
232 def test_revoke_members(self):
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
233 pass