annotate rhodecode/tests/functional/test_admin_users_groups.py @ 3141:a45191e7c7bb beta

access control: fix owner checks - they were always true The lambda expressions seems to be left over from something else. They were no longer executed and thus always evaluated to true. Some of the functions also failed if they were executed.
author Mads Kiilerich <madski@unity3d.com>
date Wed, 02 Jan 2013 13:56:44 +0100
parents a89d375c5788
children b8f929bff7e3
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 *
2064
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
2 from rhodecode.model.db import UsersGroup, UsersGroupToPerm, Permission
956
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3
1382
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
4 TEST_USERS_GROUP = 'admins_test'
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()
1382
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
18 users_group_name = TEST_USERS_GROUP
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,
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
25 'created users group %s' % TEST_USERS_GROUP)
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()
88d13c1c6a55 removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents: 1398
diff changeset
42 users_group_name = TEST_USERS_GROUP + 'another'
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,
88d13c1c6a55 removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents: 1398
diff changeset
49 'created users group %s' % users_group_name)
88d13c1c6a55 removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents: 1398
diff changeset
50
1749
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1713
diff changeset
51 gr = self.Session.query(UsersGroup)\
1436
88d13c1c6a55 removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents: 1398
diff changeset
52 .filter(UsersGroup.users_group_name ==
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
1749
8ecc6b8229a5 commit less models
Marcin Kuzminski <marcin@python-works.com>
parents: 1713
diff changeset
57 gr = self.Session.query(UsersGroup)\
1436
88d13c1c6a55 removed users_group controller in replace for model methods,
Marcin Kuzminski <marcin@python-works.com>
parents: 1398
diff changeset
58 .filter(UsersGroup.users_group_name ==
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()
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
65 users_group_name = TEST_USERS_GROUP + 'another2'
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
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
71 ug = UsersGroup.get_by_group_name(users_group_name)
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
72 self.checkSessionFlash(response,
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
73 'created users 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()
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
79 ug = UsersGroup.get_by_group_name(users_group_name)
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')
2709
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
81 p2 = Permission.get_by_key('hg.fork.none')
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
82 # 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
83 # defaults are on
2064
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
84 perms = UsersGroupToPerm.query()\
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
85 .filter(UsersGroupToPerm.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
86
2064
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
87 self.assertEqual(
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 [[x.users_group_id, 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
89 [[ug.users_group_id, p.permission_id],
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
90 [ug.users_group_id, p2.permission_id]]
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
91 )
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
92
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
93 ## 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
94 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
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
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.follow()
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
98 ug = UsersGroup.get_by_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
99 p = Permission.get_by_key('hg.create.none')
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
100 p2 = Permission.get_by_key('hg.fork.none')
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
101 # 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
102 # defaults are on
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
103 perms = UsersGroupToPerm.query()\
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
104 .filter(UsersGroupToPerm.users_group == ug).all()
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
105
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
106 self.assertEqual(
2741
a89d375c5788 fixed test from failing under different conditions
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
107 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
108 sorted([[ug.users_group_id, p.permission_id],
a89d375c5788 fixed test from failing under different conditions
Marcin Kuzminski <marcin@python-works.com>
parents: 2709
diff changeset
109 [ug.users_group_id, p2.permission_id]])
2064
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
110 )
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
111
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
112 # DELETE !
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
113 ug = UsersGroup.get_by_group_name(users_group_name)
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
114 ugid = ug.users_group_id
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
115 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
116 response = response.follow()
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
117 gr = self.Session.query(UsersGroup)\
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
118 .filter(UsersGroup.users_group_name ==
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
119 users_group_name).scalar()
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
120
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
121 self.assertEqual(gr, None)
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
122 p = Permission.get_by_key('hg.create.repository')
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
123 perms = UsersGroupToPerm.query()\
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
124 .filter(UsersGroupToPerm.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
125 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
126 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
127 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
128 perms,
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
129 []
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
130 )
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
131
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
132 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
133 self.log_user()
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
134 users_group_name = TEST_USERS_GROUP + 'another2'
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
135 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
136 {'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
137 '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
138 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
139
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
140 ug = UsersGroup.get_by_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
141 self.checkSessionFlash(response,
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
142 'created users group %s' % 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 ## 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
144 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
145 {'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
146
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
147 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
148 ug = UsersGroup.get_by_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
149 p = Permission.get_by_key('hg.create.none')
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
150 p2 = Permission.get_by_key('hg.fork.repository')
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
151 # 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
152 # defaults are on
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
153 perms = UsersGroupToPerm.query()\
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
154 .filter(UsersGroupToPerm.users_group == ug).all()
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
155
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
156 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
157 [[x.users_group_id, 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
158 [[ug.users_group_id, p.permission_id],
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
159 [ug.users_group_id, p2.permission_id]]
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
160 )
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 ## 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
163 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
164 {})
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
165
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
166 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
167 ug = UsersGroup.get_by_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
168 p = Permission.get_by_key('hg.create.none')
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
169 p2 = Permission.get_by_key('hg.fork.none')
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
170 # 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
171 # defaults are on
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
172 perms = UsersGroupToPerm.query()\
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
173 .filter(UsersGroupToPerm.users_group == ug).all()
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
174
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
175 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
176 [[x.users_group_id, 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
177 [[ug.users_group_id, p.permission_id],
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
178 [ug.users_group_id, p2.permission_id]]
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
179 )
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
180
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
181 # DELETE !
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
182 ug = UsersGroup.get_by_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
183 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
184 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
185 response = 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
186 gr = self.Session.query(UsersGroup)\
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
187 .filter(UsersGroup.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
188 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
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 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
191 p = Permission.get_by_key('hg.fork.repository')
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
192 perms = UsersGroupToPerm.query()\
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
193 .filter(UsersGroupToPerm.users_group_id == ugid).all()
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2064
diff changeset
194 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
195 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
196 self.assertEqual(
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
197 perms,
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
198 []
c9adf2a4929a added tests for users_group and issue #373
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
199 )
956
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
200
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
201 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
202 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
203 params=dict(_method='delete'))
956
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
204
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
205 def test_show(self):
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
206 response = self.app.get(url('users_group', id=1))
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
207
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
208 def test_show_as_xml(self):
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
209 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
210
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
211 def test_edit(self):
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
212 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
213
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
214 def test_edit_as_xml(self):
83d35d716a02 started working on issue #56
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
215 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
216
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
217 def test_assign_members(self):
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
218 pass
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
219
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
220 def test_add_create_permission(self):
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
221 pass
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
222
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
223 def test_revoke_members(self):
c310e1e1e757 Added CheckSessionFlash into init.
Marcin Kuzminski <marcin@python-works.com>
parents: 956
diff changeset
224 pass