You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/11/07 22:07:26 UTC
[13/14] git commit: [#6783] ticket:463 Fix test
[#6783] ticket:463 Fix test
Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/4c1a5f16
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/4c1a5f16
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/4c1a5f16
Branch: refs/heads/master
Commit: 4c1a5f16ea028f29b2b6675eb75dbcd4c42c3d7a
Parents: 0c86446
Author: Igor Bondarenko <je...@gmail.com>
Authored: Tue Nov 5 08:34:29 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Thu Nov 7 21:05:05 2013 +0000
----------------------------------------------------------------------
Allura/allura/tests/functional/test_auth.py | 28 ++++++++++++++----------
1 file changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/4c1a5f16/Allura/allura/tests/functional/test_auth.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_auth.py b/Allura/allura/tests/functional/test_auth.py
index 672bba8..7385ed1 100644
--- a/Allura/allura/tests/functional/test_auth.py
+++ b/Allura/allura/tests/functional/test_auth.py
@@ -26,7 +26,8 @@ from nose.tools import (
assert_not_equal,
assert_is_none,
assert_is_not_none,
- assert_in
+ assert_in,
+ assert_true
)
from pylons import tmpl_context as c
from allura.tests import TestController
@@ -715,7 +716,7 @@ class TestPreferences(TestController):
@patch('allura.lib.helpers.gen_message_id')
def test_forgot_password_reset(self, gen_message_id, sendmail):
user = M.User.query.get(username='test-admin')
- password1 = user.password
+ old_pw_hash = user.password
email = M.EmailAddress.query.find({'claimed_by_user_id': user._id}).first()
email.confirmed = False
@@ -746,15 +747,16 @@ class TestPreferences(TestController):
assert hash is not None
assert hash_expiry is not None
- new_password = '154321'
- r = self.app.post('/auth/forgotten_password/%s' % hash, {'pw': new_password, 'pw2': new_password})
+ r = self.app.get('/auth/forgotten_password/%s' % hash)
+ assert_in('New Password:', r)
+ assert_in('New Password (again):', r)
+ form = r.forms[0]
+ form['pw'] = form['pw2'] = new_password = '154321'
+ r = form.submit()
user = M.User.query.get(username='test-admin')
- password2 = user.password
- assert_not_equal(password1, password2)
- r = self.app.get('/auth/logout')
- r = self.app.post('/auth/do_login', params=dict(
- username='test-admin', password=new_password))
- assert 'Invalid login' not in str(r)
+ assert_not_equal(old_pw_hash, user.password)
+ provider = plugin.LocalAuthenticationProvider(None)
+ assert_true(provider._validate_password(user, new_password))
text = '''
To reset your password on %s, please visit the following URL:
@@ -779,8 +781,10 @@ To reset your password on %s, please visit the following URL:
r = self.app.post('/auth/password_recovery_hash', {'email': email._id})
user = M.User.by_username('test-admin')
hash = user.get_tool_data('AuthPasswordReset', 'hash')
- user.set_tool_data('AuthPasswordReset', hash_expiry= datetime.datetime(2000, 10, 10))
- r = self.app.post('/auth/forgotten_password/%s' % hash.encode('utf-8'), {'pw': '154321', 'pw2': '154321'})
+ user.set_tool_data('AuthPasswordReset', hash_expiry=datetime.datetime(2000, 10, 10))
+ r = self.app.post('/auth/set_new_password/%s' % hash.encode('utf-8'), {'pw': '154321', 'pw2': '154321'})
+ assert_in('Hash time was expired', r.follow().body)
+ r = self.app.get('/auth/forgotten_password/%s' % hash.encode('utf-8'))
assert_in('Hash time was expired', r.follow().body)