annotate rhodecode/tests/functional/test_admin_users.py @ 3797:d7488551578e beta

synced vcs with upstream - moved subprocessio module to VCS - many small changes to make embedded vcs as similar to to external lib - use only absolute imports - patch vcs config during load pylons env
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 27 Apr 2013 11:24:25 +0200
parents 4f80df0d45c8
children ffd45b185016
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
1 from sqlalchemy.orm.exc import NoResultFound
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
2
547
1e757ac98988 renamed project to rhodecode
Marcin Kuzminski <marcin@python-works.com>
parents: 47
diff changeset
3 from rhodecode.tests import *
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
4 from rhodecode.model.db import User, Permission
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
5 from rhodecode.lib.auth import check_password
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
6 from rhodecode.model.user import UserModel
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
7 from rhodecode.model import validators
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
8 from rhodecode.lib import helpers as h
2709
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
9 from rhodecode.model.meta import Session
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
10
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
11
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
12 class TestAdminUsersController(TestController):
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
13
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
14 def test_index(self):
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
15 self.log_user()
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
16 response = self.app.get(url('users'))
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
17 # Test response...
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
18
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
19 def test_index_as_xml(self):
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
20 response = self.app.get(url('formatted_users', format='xml'))
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
21
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
22 def test_create(self):
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
23 self.log_user()
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
24 username = 'newtestuser'
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
25 password = 'test12'
1597
019026a8cf67 implements #237 added password confirmation for my account and admin edit user.
Marcin Kuzminski <marcin@python-works.com>
parents: 895
diff changeset
26 password_confirmation = password
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
27 name = 'name'
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
28 lastname = 'lastname'
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
29 email = 'mail@mail.com'
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
30
1818
cf51bbfb120e auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents: 1758
diff changeset
31 response = self.app.post(url('users'),
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
32 {'username': username,
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
33 'password': password,
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
34 'password_confirmation': password_confirmation,
2544
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
35 'firstname': name,
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
36 'active': True,
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
37 'lastname': lastname,
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
38 'email': email})
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
39
3565
a8f2d78d14ea consistently capitalize initial letter in flash messages
Mads Kiilerich <madski@unity3d.com>
parents: 2709
diff changeset
40 self.checkSessionFlash(response, '''Created user %s''' % (username))
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
41
3797
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3640
diff changeset
42 new_user = Session().query(User).\
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
43 filter(User.username == username).one()
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
44
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
45 self.assertEqual(new_user.username, username)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
46 self.assertEqual(check_password(password, new_user.password), True)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
47 self.assertEqual(new_user.name, name)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
48 self.assertEqual(new_user.lastname, lastname)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
49 self.assertEqual(new_user.email, email)
688
8acbfa837180 Tests rewrite for 1.2 added some globals configs to make tests easier.
Marcin Kuzminski <marcin@python-works.com>
parents: 547
diff changeset
50
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
51 response.follow()
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
52 response = response.follow()
2661
09e54a646eb6 fixed test after users table rewrite
Marcin Kuzminski <marcin@python-works.com>
parents: 2544
diff changeset
53 response.mustcontain("""newtestuser""")
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
54
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
55 def test_create_err(self):
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
56 self.log_user()
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
57 username = 'new_user'
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
58 password = ''
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
59 name = 'name'
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
60 lastname = 'lastname'
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
61 email = 'errmail.com'
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
62
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
63 response = self.app.post(url('users'), {'username': username,
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
64 'password': password,
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
65 'name': name,
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
66 'active': False,
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
67 'lastname': lastname,
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
68 'email': email})
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
69
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
70 msg = validators.ValidUsername(False, {})._messages['system_invalid_username']
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
71 msg = h.html_escape(msg % {'username': 'new_user'})
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
72 response.mustcontain("""<span class="error-message">%s</span>""" % msg)
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
73 response.mustcontain("""<span class="error-message">Please enter a value</span>""")
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
74 response.mustcontain("""<span class="error-message">An email address must contain a single @</span>""")
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
75
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
76 def get_user():
3797
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3640
diff changeset
77 Session().query(User).filter(User.username == username).one()
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
78
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
79 self.assertRaises(NoResultFound, get_user), 'found user in database'
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
80
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
81 def test_new(self):
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
82 self.log_user()
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
83 response = self.app.get(url('new_user'))
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
84
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
85 def test_new_as_xml(self):
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
86 response = self.app.get(url('formatted_new_user', format='xml'))
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
87
2544
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
88 @parameterized.expand([('firstname', 'new_username'),
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
89 ('lastname', 'new_username'),
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
90 ('admin', True),
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
91 ('admin', False),
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
92 ('ldap_dn', 'test'),
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
93 ('ldap_dn', None),
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
94 ('active', False),
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
95 ('active', True),
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
96 ('email', 'some@email.com'),
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
97 ])
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
98 def test_update(self, name, expected):
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
99 self.log_user()
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
100 uname = 'testme'
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
101 usr = UserModel().create_or_update(username=uname, password='qweqwe',
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
102 email='testme@rhodecod.org')
3797
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3640
diff changeset
103 Session().commit()
2544
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
104 params = usr.get_api_data()
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
105 params.update({name: expected})
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
106 params.update({'password_confirmation': ''})
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
107 params.update({'new_password': ''})
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
108 if name == 'email':
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
109 params['emails'] = [expected]
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
110 if name == 'ldap_dn':
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
111 #cannot update this via form
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
112 params['ldap_dn'] = None
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
113 try:
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
114 response = self.app.put(url('user', id=usr.user_id), params)
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
115
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
116 self.checkSessionFlash(response, '''User updated successfully''')
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
117
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
118 updated_user = User.get_by_username(uname)
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
119 updated_params = updated_user.get_api_data()
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
120 updated_params.update({'password_confirmation': ''})
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
121 updated_params.update({'new_password': ''})
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
122
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
123 self.assertEqual(params, updated_params)
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
124
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
125 finally:
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
126 UserModel().delete('testme')
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
127
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
128 def test_update_browser_fakeout(self):
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
129 response = self.app.post(url('user', id=1), params=dict(_method='put'))
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
130
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
131 def test_delete(self):
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
132 self.log_user()
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
133 username = 'newtestuserdeleteme'
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
134 password = 'test12'
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
135 name = 'name'
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
136 lastname = 'lastname'
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
137 email = 'todeletemail@mail.com'
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
138
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
139 response = self.app.post(url('users'), {'username': username,
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
140 'password': password,
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
141 'password_confirmation': password,
2544
6ce3387bf0ce Renamed name to firstname in forms
Marcin Kuzminski <marcin@python-works.com>
parents: 2467
diff changeset
142 'firstname': name,
2467
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
143 'active': True,
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
144 'lastname': lastname,
4419551b2915 Switched forms to new validators
Marcin Kuzminski <marcin@python-works.com>
parents: 1818
diff changeset
145 'email': email})
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
146
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
147 response = response.follow()
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
148
3797
d7488551578e synced vcs with upstream
Marcin Kuzminski <marcin@python-works.com>
parents: 3640
diff changeset
149 new_user = Session().query(User)\
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
150 .filter(User.username == username).one()
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
151 response = self.app.delete(url('user', id=new_user.user_id))
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
152
3640
4f80df0d45c8 unified flash msg tests
Marcin Kuzminski <marcin@python-works.com>
parents: 3565
diff changeset
153 self.checkSessionFlash(response, 'Successfully deleted user')
691
7486da5f0628 Refactor codes for scm model
Marcin Kuzminski <marcin@python-works.com>
parents: 688
diff changeset
154
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
155 def test_delete_browser_fakeout(self):
1818
cf51bbfb120e auto white-space removal
Marcin Kuzminski <marcin@python-works.com>
parents: 1758
diff changeset
156 response = self.app.post(url('user', id=1),
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
157 params=dict(_method='delete'))
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
158
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
159 def test_show(self):
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
160 response = self.app.get(url('user', id=1))
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
161
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
162 def test_show_as_xml(self):
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
163 response = self.app.get(url('formatted_user', id=1, format='xml'))
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
164
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
165 def test_edit(self):
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
166 self.log_user()
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
167 user = User.get_by_username(TEST_USER_ADMIN_LOGIN)
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
168 response = self.app.get(url('edit_user', id=user.user_id))
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
169
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
170 def test_add_perm_create_repo(self):
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
171 self.log_user()
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
172 perm_none = Permission.get_by_key('hg.create.none')
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
173 perm_create = Permission.get_by_key('hg.create.repository')
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
174
2709
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
175 user = UserModel().create_or_update(username='dummy', password='qwe',
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
176 email='dummy', firstname='a',
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
177 lastname='b')
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
178 Session().commit()
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
179 uid = user.user_id
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
180
2709
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
181 try:
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
182 #User should have None permission on creation repository
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
183 self.assertEqual(UserModel().has_perm(user, perm_none), False)
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
184 self.assertEqual(UserModel().has_perm(user, perm_create), False)
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
185
2709
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
186 response = self.app.post(url('user_perm', id=uid),
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
187 params=dict(_method='put',
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
188 create_repo_perm=True))
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
189
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
190 perm_none = 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: 2661
diff changeset
191 perm_create = Permission.get_by_key('hg.create.repository')
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
192
2709
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
193 #User should have None permission on creation repository
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
194 self.assertEqual(UserModel().has_perm(uid, perm_none), False)
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
195 self.assertEqual(UserModel().has_perm(uid, perm_create), True)
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
196 finally:
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
197 UserModel().delete(uid)
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
198 Session().commit()
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
199
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
200 def test_revoke_perm_create_repo(self):
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
201 self.log_user()
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
202 perm_none = Permission.get_by_key('hg.create.none')
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
203 perm_create = Permission.get_by_key('hg.create.repository')
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
204
2709
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
205 user = UserModel().create_or_update(username='dummy', password='qwe',
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
206 email='dummy', firstname='a',
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
207 lastname='b')
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
208 Session().commit()
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
209 uid = user.user_id
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
210
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
211 try:
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
212 #User should have None permission on creation repository
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
213 self.assertEqual(UserModel().has_perm(user, perm_none), False)
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
214 self.assertEqual(UserModel().has_perm(user, perm_create), False)
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
215
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
216 response = self.app.post(url('user_perm', id=uid),
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
217 params=dict(_method='put'))
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
218
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
219 perm_none = 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: 2661
diff changeset
220 perm_create = Permission.get_by_key('hg.create.repository')
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
221
2709
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
222 #User should have None permission on creation repository
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
223 self.assertEqual(UserModel().has_perm(uid, perm_none), True)
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
224 self.assertEqual(UserModel().has_perm(uid, perm_create), False)
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
225 finally:
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
226 UserModel().delete(uid)
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
227 Session().commit()
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
228
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
229 def test_add_perm_fork_repo(self):
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
230 self.log_user()
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
231 perm_none = 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: 2661
diff changeset
232 perm_fork = 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: 2661
diff changeset
233
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
234 user = UserModel().create_or_update(username='dummy', password='qwe',
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
235 email='dummy', firstname='a',
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
236 lastname='b')
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
237 Session().commit()
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
238 uid = user.user_id
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
239
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
240 try:
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
241 #User should have None permission on creation repository
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
242 self.assertEqual(UserModel().has_perm(user, perm_none), False)
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
243 self.assertEqual(UserModel().has_perm(user, perm_fork), False)
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
244
2709
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
245 response = self.app.post(url('user_perm', id=uid),
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
246 params=dict(_method='put',
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
247 create_repo_perm=True))
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
248
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
249 perm_none = 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: 2661
diff changeset
250 perm_create = Permission.get_by_key('hg.create.repository')
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
251
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
252 #User should have None permission on creation repository
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
253 self.assertEqual(UserModel().has_perm(uid, perm_none), False)
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
254 self.assertEqual(UserModel().has_perm(uid, perm_create), True)
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
255 finally:
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
256 UserModel().delete(uid)
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
257 Session().commit()
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
258
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
259 def test_revoke_perm_fork_repo(self):
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
260 self.log_user()
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
261 perm_none = 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: 2661
diff changeset
262 perm_fork = Permission.get_by_key('hg.fork.repository')
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
263
2709
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
264 user = UserModel().create_or_update(username='dummy', password='qwe',
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
265 email='dummy', firstname='a',
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
266 lastname='b')
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
267 Session().commit()
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
268 uid = user.user_id
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
269
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
270 try:
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
271 #User should have None permission on creation repository
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
272 self.assertEqual(UserModel().has_perm(user, perm_none), False)
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
273 self.assertEqual(UserModel().has_perm(user, perm_fork), False)
1758
a87aa385f21c fixed repo_create permission by adding missing commit statements
Marcin Kuzminski <marcin@python-works.com>
parents: 1749
diff changeset
274
2709
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
275 response = self.app.post(url('user_perm', id=uid),
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
276 params=dict(_method='put'))
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
277
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
278 perm_none = 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: 2661
diff changeset
279 perm_create = Permission.get_by_key('hg.create.repository')
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
280
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
281 #User should have None permission on creation repository
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
282 self.assertEqual(UserModel().has_perm(uid, perm_none), True)
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
283 self.assertEqual(UserModel().has_perm(uid, perm_create), False)
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
284 finally:
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
285 UserModel().delete(uid)
d2d35cf2b351 RhodeCode now has a option to explicitly set forking permissions. ref #508
Marcin Kuzminski <marcin@python-works.com>
parents: 2661
diff changeset
286 Session().commit()
47
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
287
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
288 def test_edit_as_xml(self):
f6ac79182600 Added rest controllers for repos and users,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
289 response = self.app.get(url('formatted_edit_user', id=1, format='xml'))