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.
Files changed (116) hide show
  1. EGG-INFO/PKG-INFO +184 -0
  2. EGG-INFO/SOURCES.txt +93 -0
  3. EGG-INFO/dependency_links.txt +1 -0
  4. EGG-INFO/not-zip-safe +1 -0
  5. EGG-INFO/requires.txt +13 -0
  6. EGG-INFO/top_level.txt +2 -0
  7. pyramid_fullauth/__init__.py +106 -0
  8. pyramid_fullauth/__pycache__/__init__.cpython-34.pyc +0 -0
  9. pyramid_fullauth/__pycache__/auth.cpython-34.pyc +0 -0
  10. pyramid_fullauth/__pycache__/events.cpython-34.pyc +0 -0
  11. pyramid_fullauth/__pycache__/exceptions.cpython-34.pyc +0 -0
  12. pyramid_fullauth/__pycache__/request.cpython-34.pyc +0 -0
  13. pyramid_fullauth/__pycache__/tools.cpython-34.pyc +0 -0
  14. pyramid_fullauth/auth.py +67 -0
  15. pyramid_fullauth/config/default.yaml +26 -0
  16. pyramid_fullauth/events.py +281 -0
  17. pyramid_fullauth/exceptions.py +47 -0
  18. pyramid_fullauth/models/__init__.py +190 -0
  19. pyramid_fullauth/models/__pycache__/__init__.cpython-34.pyc +0 -0
  20. pyramid_fullauth/models/extensions/__init__.py +39 -0
  21. pyramid_fullauth/models/extensions/__pycache__/__init__.cpython-34.pyc +0 -0
  22. pyramid_fullauth/models/mixins/__init__.py +9 -0
  23. pyramid_fullauth/models/mixins/__pycache__/__init__.cpython-34.pyc +0 -0
  24. pyramid_fullauth/models/mixins/__pycache__/email.cpython-34.pyc +0 -0
  25. pyramid_fullauth/models/mixins/__pycache__/password.cpython-34.pyc +0 -0
  26. pyramid_fullauth/models/mixins/email.py +128 -0
  27. pyramid_fullauth/models/mixins/password.py +141 -0
  28. pyramid_fullauth/request.py +70 -0
  29. pyramid_fullauth/resources/helpers/social.mako +17 -0
  30. pyramid_fullauth/resources/locale/pyramid_fullauth.pot +216 -0
  31. pyramid_fullauth/resources/templates/403.mako +11 -0
  32. pyramid_fullauth/resources/templates/_form.login.mako +44 -0
  33. pyramid_fullauth/resources/templates/_form.register.mako +47 -0
  34. pyramid_fullauth/resources/templates/_social.login.mako +17 -0
  35. pyramid_fullauth/resources/templates/activate.mako +14 -0
  36. pyramid_fullauth/resources/templates/email_change.mako +33 -0
  37. pyramid_fullauth/resources/templates/layout.mako +13 -0
  38. pyramid_fullauth/resources/templates/login.mako +17 -0
  39. pyramid_fullauth/resources/templates/register.mako +22 -0
  40. pyramid_fullauth/resources/templates/reset.mako +34 -0
  41. pyramid_fullauth/resources/templates/reset.proceed.mako +41 -0
  42. pyramid_fullauth/routing/__init__.py +5 -0
  43. pyramid_fullauth/routing/__pycache__/__init__.cpython-34.pyc +0 -0
  44. pyramid_fullauth/routing/__pycache__/predicates.cpython-34.pyc +0 -0
  45. pyramid_fullauth/routing/predicates.py +86 -0
  46. pyramid_fullauth/tools.py +69 -0
  47. pyramid_fullauth/views/__init__.py +15 -0
  48. pyramid_fullauth/views/__pycache__/__init__.cpython-34.pyc +0 -0
  49. pyramid_fullauth/views/__pycache__/social.cpython-34.pyc +0 -0
  50. pyramid_fullauth/views/basic/__init__.py +5 -0
  51. pyramid_fullauth/views/basic/__pycache__/__init__.cpython-34.pyc +0 -0
  52. pyramid_fullauth/views/basic/__pycache__/activate.cpython-34.pyc +0 -0
  53. pyramid_fullauth/views/basic/__pycache__/forbidden.cpython-34.pyc +0 -0
  54. pyramid_fullauth/views/basic/__pycache__/login.cpython-34.pyc +0 -0
  55. pyramid_fullauth/views/basic/__pycache__/logout.cpython-34.pyc +0 -0
  56. pyramid_fullauth/views/basic/__pycache__/register.cpython-34.pyc +0 -0
  57. pyramid_fullauth/views/basic/activate.py +44 -0
  58. pyramid_fullauth/views/basic/forbidden.py +46 -0
  59. pyramid_fullauth/views/basic/login.py +128 -0
  60. pyramid_fullauth/views/basic/logout.py +28 -0
  61. pyramid_fullauth/views/basic/profile/__init__.py +5 -0
  62. pyramid_fullauth/views/basic/profile/__pycache__/__init__.cpython-34.pyc +0 -0
  63. pyramid_fullauth/views/basic/profile/__pycache__/email.cpython-34.pyc +0 -0
  64. pyramid_fullauth/views/basic/profile/__pycache__/password.cpython-34.pyc +0 -0
  65. pyramid_fullauth/views/basic/profile/email.py +108 -0
  66. pyramid_fullauth/views/basic/profile/password.py +129 -0
  67. pyramid_fullauth/views/basic/register.py +111 -0
  68. pyramid_fullauth/views/social.py +221 -0
  69. tests/__init__.py +1 -0
  70. tests/__pycache__/__init__.cpython-34.pyc +0 -0
  71. tests/__pycache__/conftest.cpython-34.pyc +0 -0
  72. tests/__pycache__/tools.cpython-34.pyc +0 -0
  73. tests/conftest.py +201 -0
  74. tests/tools.py +54 -0
  75. tests/unit/__pycache__/test_default_settings.cpython-34.pyc +0 -0
  76. tests/unit/__pycache__/test_groupfinder.cpython-34.pyc +0 -0
  77. tests/unit/__pycache__/test_social_view.cpython-34.pyc +0 -0
  78. tests/unit/__pycache__/test_tools.cpython-34.pyc +0 -0
  79. tests/unit/__pycache__/test_user_active.cpython-34.pyc +0 -0
  80. tests/unit/__pycache__/test_user_admin.cpython-34.pyc +0 -0
  81. tests/unit/__pycache__/test_user_email.cpython-34.pyc +0 -0
  82. tests/unit/__pycache__/test_user_password.cpython-34.pyc +0 -0
  83. tests/unit/__pycache__/test_user_providers.cpython-34.pyc +0 -0
  84. tests/unit/__pycache__/test_user_repr.cpython-34.pyc +0 -0
  85. tests/unit/__pycache__/test_validators.cpython-34.pyc +0 -0
  86. tests/unit/test_default_settings.py +15 -0
  87. tests/unit/test_groupfinder.py +20 -0
  88. tests/unit/test_social_view.py +69 -0
  89. tests/unit/test_tools.py +24 -0
  90. tests/unit/test_user_active.py +31 -0
  91. tests/unit/test_user_admin.py +61 -0
  92. tests/unit/test_user_email.py +37 -0
  93. tests/unit/test_user_password.py +52 -0
  94. tests/unit/test_user_providers.py +24 -0
  95. tests/unit/test_user_repr.py +29 -0
  96. tests/unit/test_validators.py +44 -0
  97. tests/views/__init__.py +1 -0
  98. tests/views/__pycache__/__init__.cpython-34.pyc +0 -0
  99. tests/views/__pycache__/conftest.cpython-34.pyc +0 -0
  100. tests/views/__pycache__/test_activation.cpython-34.pyc +0 -0
  101. tests/views/__pycache__/test_email.cpython-34.pyc +0 -0
  102. tests/views/__pycache__/test_events.cpython-34.pyc +0 -0
  103. tests/views/__pycache__/test_login.cpython-34.pyc +0 -0
  104. tests/views/__pycache__/test_login_social.cpython-34.pyc +0 -0
  105. tests/views/__pycache__/test_logout.cpython-34.pyc +0 -0
  106. tests/views/__pycache__/test_register.cpython-34.pyc +0 -0
  107. tests/views/__pycache__/test_reset.cpython-34.pyc +0 -0
  108. tests/views/conftest.py +20 -0
  109. tests/views/test_activation.py +86 -0
  110. tests/views/test_email.py +175 -0
  111. tests/views/test_events.py +558 -0
  112. tests/views/test_login.py +172 -0
  113. tests/views/test_login_social.py +289 -0
  114. tests/views/test_logout.py +42 -0
  115. tests/views/test_register.py +138 -0
  116. 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)