Mercurial > kallithea
changeset 2248:72542dc597be beta
fixed issue with empty APIKEYS on registration #438
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 08 May 2012 23:59:27 +0200 |
parents | 99536f257644 |
children | a3eb31cc4ab4 |
files | docs/changelog.rst rhodecode/model/db.py rhodecode/model/user.py rhodecode/tests/functional/test_login.py |
diffstat | 4 files changed, 31 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/docs/changelog.rst Tue May 08 22:18:46 2012 +0200 +++ b/docs/changelog.rst Tue May 08 23:59:27 2012 +0200 @@ -38,6 +38,7 @@ - fixed remote-pulling for git remotes remopositories - fixed #434: Error when accessing files or changesets of a git repository with submodules +- fixed issue with empty APIKEYS for users after registration ref. #438 1.3.4 (**2012-03-28**) ----------------------
--- a/rhodecode/model/db.py Tue May 08 22:18:46 2012 +0200 +++ b/rhodecode/model/db.py Tue May 08 23:59:27 2012 +0200 @@ -1233,7 +1233,8 @@ @property def recipients(self): return [x.user for x in UserNotification.query()\ - .filter(UserNotification.notification == self).all()] + .filter(UserNotification.notification == self)\ + .order_by(UserNotification.user).all()] @classmethod def create(cls, created_by, subject, body, recipients, type_=None):
--- a/rhodecode/model/user.py Tue May 08 22:18:46 2012 +0200 +++ b/rhodecode/model/user.py Tue May 08 23:59:27 2012 +0200 @@ -225,10 +225,8 @@ from rhodecode.model.notification import NotificationModel try: - new_user = User() - for k, v in form_data.items(): - if k != 'admin': - setattr(new_user, k, v) + form_data['admin'] = False + new_user = self.create(form_data) self.sa.add(new_user) self.sa.flush()
--- a/rhodecode/tests/functional/test_login.py Tue May 08 22:18:46 2012 +0200 +++ b/rhodecode/tests/functional/test_login.py Tue May 08 23:59:27 2012 +0200 @@ -54,7 +54,6 @@ self.assertEqual(response.status, '200 OK') self.assertTrue('Users administration' in response.body) - def test_login_short_password(self): response = self.app.post(url(controller='login', action='index'), {'username':'test_admin', @@ -101,7 +100,7 @@ 'lastname':'test'}) self.assertEqual(response.status , '200 OK') - assert 'This e-mail address is already taken' in response.body + response.mustcontain('This e-mail address is already taken') def test_register_err_same_email_case_sensitive(self): response = self.app.post(url(controller='login', action='register'), @@ -112,7 +111,7 @@ 'name':'test', 'lastname':'test'}) self.assertEqual(response.status , '200 OK') - assert 'This e-mail address is already taken' in response.body + response.mustcontain('This e-mail address is already taken') def test_register_err_wrong_data(self): response = self.app.post(url(controller='login', action='register'), @@ -123,9 +122,8 @@ 'name':'test', 'lastname':'test'}) self.assertEqual(response.status , '200 OK') - assert 'An email address must contain a single @' in response.body - assert 'Enter a value 6 characters long or more' in response.body - + response.mustcontain('An email address must contain a single @') + response.mustcontain('Enter a value 6 characters long or more') def test_register_err_username(self): response = self.app.post(url(controller='login', action='register'), @@ -137,11 +135,11 @@ 'lastname':'test'}) self.assertEqual(response.status , '200 OK') - assert 'An email address must contain a single @' in response.body - assert ('Username may only contain ' + response.mustcontain('An email address must contain a single @') + response.mustcontain('Username may only contain ' 'alphanumeric characters underscores, ' 'periods or dashes and must begin with ' - 'alphanumeric character') in response.body + 'alphanumeric character') def test_register_err_case_sensitive(self): response = self.app.post(url(controller='login', action='register'), @@ -156,8 +154,6 @@ self.assertTrue('An email address must contain a single @' in response.body) self.assertTrue('This username already exists' in response.body) - - def test_register_special_chars(self): response = self.app.post(url(controller='login', action='register'), {'username':'xxxaxn', @@ -170,7 +166,6 @@ self.assertEqual(response.status , '200 OK') self.assertTrue('Invalid characters in password' in response.body) - def test_register_password_mismatch(self): response = self.app.post(url(controller='login', action='register'), {'username':'xs', @@ -180,8 +175,8 @@ 'name':'test', 'lastname':'test'}) - self.assertEqual(response.status , '200 OK') - assert 'Passwords do not match' in response.body + self.assertEqual(response.status, '200 OK') + response.mustcontain('Passwords do not match') def test_register_ok(self): username = 'test_regular4' @@ -196,28 +191,32 @@ 'password_confirmation':password, 'email':email, 'name':name, - 'lastname':lastname}) - self.assertEqual(response.status , '302 Found') - assert 'You have successfully registered into rhodecode' in response.session['flash'][0], 'No flash message about user registration' + 'lastname':lastname, + 'admin':True}) # This should be overriden + self.assertEqual(response.status, '302 Found') + self.checkSessionFlash(response, 'You have successfully registered into rhodecode') ret = self.Session.query(User).filter(User.username == 'test_regular4').one() - assert ret.username == username , 'field mismatch %s %s' % (ret.username, username) - assert check_password(password, ret.password) == True , 'password mismatch' - assert ret.email == email , 'field mismatch %s %s' % (ret.email, email) - assert ret.name == name , 'field mismatch %s %s' % (ret.name, name) - assert ret.lastname == lastname , 'field mismatch %s %s' % (ret.lastname, lastname) - + self.assertEqual(ret.username, username) + self.assertEqual(check_password(password, ret.password), True) + self.assertEqual(ret.email, email) + self.assertEqual(ret.name, name) + self.assertEqual(ret.lastname, lastname) + self.assertNotEqual(ret.api_key, None) + self.assertEqual(ret.admin, False) def test_forgot_password_wrong_mail(self): - response = self.app.post(url(controller='login', action='password_reset'), - {'email':'marcin@wrongmail.org', }) + response = self.app.post( + url(controller='login', action='password_reset'), + {'email': 'marcin@wrongmail.org',} + ) - assert "This e-mail address doesn't exist" in response.body, 'Missing error message about wrong email' + response.mustcontain("This e-mail address doesn't exist") def test_forgot_password(self): response = self.app.get(url(controller='login', action='password_reset')) - self.assertEqual(response.status , '200 OK') + self.assertEqual(response.status, '200 OK') username = 'test_password_reset_1' password = 'qweqwe'