pyramid-fullauth 0.4.0__py3.4.egg
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- EGG-INFO/PKG-INFO +184 -0
- EGG-INFO/SOURCES.txt +93 -0
- EGG-INFO/dependency_links.txt +1 -0
- EGG-INFO/not-zip-safe +1 -0
- EGG-INFO/requires.txt +13 -0
- EGG-INFO/top_level.txt +2 -0
- pyramid_fullauth/__init__.py +106 -0
- pyramid_fullauth/__pycache__/__init__.cpython-34.pyc +0 -0
- pyramid_fullauth/__pycache__/auth.cpython-34.pyc +0 -0
- pyramid_fullauth/__pycache__/events.cpython-34.pyc +0 -0
- pyramid_fullauth/__pycache__/exceptions.cpython-34.pyc +0 -0
- pyramid_fullauth/__pycache__/request.cpython-34.pyc +0 -0
- pyramid_fullauth/__pycache__/tools.cpython-34.pyc +0 -0
- pyramid_fullauth/auth.py +67 -0
- pyramid_fullauth/config/default.yaml +26 -0
- pyramid_fullauth/events.py +281 -0
- pyramid_fullauth/exceptions.py +47 -0
- pyramid_fullauth/models/__init__.py +190 -0
- pyramid_fullauth/models/__pycache__/__init__.cpython-34.pyc +0 -0
- pyramid_fullauth/models/extensions/__init__.py +39 -0
- pyramid_fullauth/models/extensions/__pycache__/__init__.cpython-34.pyc +0 -0
- pyramid_fullauth/models/mixins/__init__.py +9 -0
- pyramid_fullauth/models/mixins/__pycache__/__init__.cpython-34.pyc +0 -0
- pyramid_fullauth/models/mixins/__pycache__/email.cpython-34.pyc +0 -0
- pyramid_fullauth/models/mixins/__pycache__/password.cpython-34.pyc +0 -0
- pyramid_fullauth/models/mixins/email.py +128 -0
- pyramid_fullauth/models/mixins/password.py +141 -0
- pyramid_fullauth/request.py +70 -0
- pyramid_fullauth/resources/helpers/social.mako +17 -0
- pyramid_fullauth/resources/locale/pyramid_fullauth.pot +216 -0
- pyramid_fullauth/resources/templates/403.mako +11 -0
- pyramid_fullauth/resources/templates/_form.login.mako +44 -0
- pyramid_fullauth/resources/templates/_form.register.mako +47 -0
- pyramid_fullauth/resources/templates/_social.login.mako +17 -0
- pyramid_fullauth/resources/templates/activate.mako +14 -0
- pyramid_fullauth/resources/templates/email_change.mako +33 -0
- pyramid_fullauth/resources/templates/layout.mako +13 -0
- pyramid_fullauth/resources/templates/login.mako +17 -0
- pyramid_fullauth/resources/templates/register.mako +22 -0
- pyramid_fullauth/resources/templates/reset.mako +34 -0
- pyramid_fullauth/resources/templates/reset.proceed.mako +41 -0
- pyramid_fullauth/routing/__init__.py +5 -0
- pyramid_fullauth/routing/__pycache__/__init__.cpython-34.pyc +0 -0
- pyramid_fullauth/routing/__pycache__/predicates.cpython-34.pyc +0 -0
- pyramid_fullauth/routing/predicates.py +86 -0
- pyramid_fullauth/tools.py +69 -0
- pyramid_fullauth/views/__init__.py +15 -0
- pyramid_fullauth/views/__pycache__/__init__.cpython-34.pyc +0 -0
- pyramid_fullauth/views/__pycache__/social.cpython-34.pyc +0 -0
- pyramid_fullauth/views/basic/__init__.py +5 -0
- pyramid_fullauth/views/basic/__pycache__/__init__.cpython-34.pyc +0 -0
- pyramid_fullauth/views/basic/__pycache__/activate.cpython-34.pyc +0 -0
- pyramid_fullauth/views/basic/__pycache__/forbidden.cpython-34.pyc +0 -0
- pyramid_fullauth/views/basic/__pycache__/login.cpython-34.pyc +0 -0
- pyramid_fullauth/views/basic/__pycache__/logout.cpython-34.pyc +0 -0
- pyramid_fullauth/views/basic/__pycache__/register.cpython-34.pyc +0 -0
- pyramid_fullauth/views/basic/activate.py +44 -0
- pyramid_fullauth/views/basic/forbidden.py +46 -0
- pyramid_fullauth/views/basic/login.py +128 -0
- pyramid_fullauth/views/basic/logout.py +28 -0
- pyramid_fullauth/views/basic/profile/__init__.py +5 -0
- pyramid_fullauth/views/basic/profile/__pycache__/__init__.cpython-34.pyc +0 -0
- pyramid_fullauth/views/basic/profile/__pycache__/email.cpython-34.pyc +0 -0
- pyramid_fullauth/views/basic/profile/__pycache__/password.cpython-34.pyc +0 -0
- pyramid_fullauth/views/basic/profile/email.py +108 -0
- pyramid_fullauth/views/basic/profile/password.py +129 -0
- pyramid_fullauth/views/basic/register.py +111 -0
- pyramid_fullauth/views/social.py +221 -0
- tests/__init__.py +1 -0
- tests/__pycache__/__init__.cpython-34.pyc +0 -0
- tests/__pycache__/conftest.cpython-34.pyc +0 -0
- tests/__pycache__/tools.cpython-34.pyc +0 -0
- tests/conftest.py +201 -0
- tests/tools.py +54 -0
- tests/unit/__pycache__/test_default_settings.cpython-34.pyc +0 -0
- tests/unit/__pycache__/test_groupfinder.cpython-34.pyc +0 -0
- tests/unit/__pycache__/test_social_view.cpython-34.pyc +0 -0
- tests/unit/__pycache__/test_tools.cpython-34.pyc +0 -0
- tests/unit/__pycache__/test_user_active.cpython-34.pyc +0 -0
- tests/unit/__pycache__/test_user_admin.cpython-34.pyc +0 -0
- tests/unit/__pycache__/test_user_email.cpython-34.pyc +0 -0
- tests/unit/__pycache__/test_user_password.cpython-34.pyc +0 -0
- tests/unit/__pycache__/test_user_providers.cpython-34.pyc +0 -0
- tests/unit/__pycache__/test_user_repr.cpython-34.pyc +0 -0
- tests/unit/__pycache__/test_validators.cpython-34.pyc +0 -0
- tests/unit/test_default_settings.py +15 -0
- tests/unit/test_groupfinder.py +20 -0
- tests/unit/test_social_view.py +69 -0
- tests/unit/test_tools.py +24 -0
- tests/unit/test_user_active.py +31 -0
- tests/unit/test_user_admin.py +61 -0
- tests/unit/test_user_email.py +37 -0
- tests/unit/test_user_password.py +52 -0
- tests/unit/test_user_providers.py +24 -0
- tests/unit/test_user_repr.py +29 -0
- tests/unit/test_validators.py +44 -0
- tests/views/__init__.py +1 -0
- tests/views/__pycache__/__init__.cpython-34.pyc +0 -0
- tests/views/__pycache__/conftest.cpython-34.pyc +0 -0
- tests/views/__pycache__/test_activation.cpython-34.pyc +0 -0
- tests/views/__pycache__/test_email.cpython-34.pyc +0 -0
- tests/views/__pycache__/test_events.cpython-34.pyc +0 -0
- tests/views/__pycache__/test_login.cpython-34.pyc +0 -0
- tests/views/__pycache__/test_login_social.cpython-34.pyc +0 -0
- tests/views/__pycache__/test_logout.cpython-34.pyc +0 -0
- tests/views/__pycache__/test_register.cpython-34.pyc +0 -0
- tests/views/__pycache__/test_reset.cpython-34.pyc +0 -0
- tests/views/conftest.py +20 -0
- tests/views/test_activation.py +86 -0
- tests/views/test_email.py +175 -0
- tests/views/test_events.py +558 -0
- tests/views/test_login.py +172 -0
- tests/views/test_login_social.py +289 -0
- tests/views/test_logout.py +42 -0
- tests/views/test_register.py +138 -0
- tests/views/test_reset.py +105 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"""Reset password views."""
|
|
2
|
+
try:
|
|
3
|
+
from HTMLParser import HTMLParser
|
|
4
|
+
except ImportError:
|
|
5
|
+
from html.parser import HTMLParser
|
|
6
|
+
|
|
7
|
+
import transaction
|
|
8
|
+
from pyramid.compat import text_type
|
|
9
|
+
|
|
10
|
+
from pyramid_fullauth.models import User
|
|
11
|
+
|
|
12
|
+
NEW_PASSWORD = 'YouShallPass'
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def test_reset_view(default_app):
|
|
16
|
+
"""Simple get test."""
|
|
17
|
+
res = default_app.get('/password/reset')
|
|
18
|
+
assert res.form
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def test_reset_action(user, db_session, default_app):
|
|
22
|
+
"""Successful password reset request."""
|
|
23
|
+
user = db_session.merge(user)
|
|
24
|
+
assert user.reset_key is None
|
|
25
|
+
|
|
26
|
+
res = default_app.get('/password/reset')
|
|
27
|
+
res.form['email'] = user.email
|
|
28
|
+
res = res.form.submit()
|
|
29
|
+
|
|
30
|
+
transaction.commit()
|
|
31
|
+
|
|
32
|
+
user = db_session.query(User).filter(User.email == user.email).one()
|
|
33
|
+
assert user.reset_key is not None
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_reset_email_not_exists(user, db_session, default_app):
|
|
37
|
+
"""Reset password request with wrong email (not in database)."""
|
|
38
|
+
user = db_session.merge(user)
|
|
39
|
+
|
|
40
|
+
res = default_app.get('/password/reset')
|
|
41
|
+
res.form['email'] = text_type('wrong@example.com')
|
|
42
|
+
res = res.form.submit()
|
|
43
|
+
assert 'Error! User does not exists' in res
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_reset_proceed(user, db_session, default_app):
|
|
47
|
+
"""Actually change password."""
|
|
48
|
+
user = db_session.merge(user)
|
|
49
|
+
user.set_reset()
|
|
50
|
+
transaction.commit()
|
|
51
|
+
|
|
52
|
+
user = db_session.merge(user)
|
|
53
|
+
res = default_app.get('/password/reset/' + user.reset_key)
|
|
54
|
+
assert 'Recover your password - choose new password' in res
|
|
55
|
+
|
|
56
|
+
res.form['password'] = NEW_PASSWORD
|
|
57
|
+
res.form['confirm_password'] = NEW_PASSWORD
|
|
58
|
+
res = res.form.submit()
|
|
59
|
+
|
|
60
|
+
user = db_session.query(User).filter(User.email == user.email).one()
|
|
61
|
+
assert user.reset_key is None
|
|
62
|
+
assert user.check_password(NEW_PASSWORD) is True
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_reset_proceed_wrong_reset_key(user, db_session, default_app):
|
|
66
|
+
"""Try changing password with wrong reset_key."""
|
|
67
|
+
user = db_session.merge(user)
|
|
68
|
+
user.set_reset()
|
|
69
|
+
transaction.commit()
|
|
70
|
+
|
|
71
|
+
user = db_session.merge(user)
|
|
72
|
+
res = default_app.get(
|
|
73
|
+
'/password/reset/' + user.reset_key + 'randomchars', status=404)
|
|
74
|
+
assert res.status_code == 404
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def test_reset_proceed_wrong_confirm(user, db_session, default_app):
|
|
78
|
+
"""Reset test for reseting pasword with notmatched passwords."""
|
|
79
|
+
user = db_session.merge(user)
|
|
80
|
+
user.set_reset()
|
|
81
|
+
transaction.commit()
|
|
82
|
+
|
|
83
|
+
user = db_session.merge(user)
|
|
84
|
+
res = default_app.get('/password/reset/' + user.reset_key)
|
|
85
|
+
|
|
86
|
+
res.form['password'] = NEW_PASSWORD
|
|
87
|
+
res.form['confirm_password'] = NEW_PASSWORD + 'Typo'
|
|
88
|
+
res = res.form.submit()
|
|
89
|
+
|
|
90
|
+
assert 'Error! Password doesn\'t match' in HTMLParser().unescape(res.body.decode('unicode_escape'))
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def test_reset_proceed_wrong_csrf(user, db_session, default_app):
|
|
94
|
+
"""Reset test for reseting pasword with notmatched csrf."""
|
|
95
|
+
user = db_session.merge(user)
|
|
96
|
+
user.set_reset()
|
|
97
|
+
transaction.commit()
|
|
98
|
+
|
|
99
|
+
user = db_session.merge(user)
|
|
100
|
+
res = default_app.get('/password/reset/' + user.reset_key)
|
|
101
|
+
|
|
102
|
+
res.form['password'] = NEW_PASSWORD
|
|
103
|
+
res.form['confirm_password'] = NEW_PASSWORD
|
|
104
|
+
res.form['csrf_token'] = 'sadasere723612dassdgaSDs7a'
|
|
105
|
+
res.form.submit(status=401)
|