Loading AUTHORS +1 −0 Original line number Diff line number Diff line Loading @@ -330,6 +330,7 @@ answer newbie questions, and generally made Django that much better: David Reynolds <david@reynoldsfamily.org.uk> rhettg@gmail.com ricardojbarrios@gmail.com Mike Richardson Matt Riggott Henrique Romano <onaiort@gmail.com> Armin Ronacher Loading django/contrib/auth/tests/__init__.py +5 −2 Original line number Diff line number Diff line from django.contrib.auth.tests.basic import BASIC_TESTS from django.contrib.auth.tests.views import PasswordResetTest from django.contrib.auth.tests.views import PasswordResetTest, ChangePasswordTest from django.contrib.auth.tests.forms import FORM_TESTS from django.contrib.auth.tests.tokens import TOKEN_GENERATOR_TESTS # The password for the fixture data users is 'password' __test__ = { 'BASIC_TESTS': BASIC_TESTS, 'PASSWORDRESET_TESTS': PasswordResetTest, 'FORM_TESTS': FORM_TESTS, 'TOKEN_GENERATOR_TESTS': TOKEN_GENERATOR_TESTS 'TOKEN_GENERATOR_TESTS': TOKEN_GENERATOR_TESTS, 'CHANGEPASSWORD_TESTS': ChangePasswordTest, } django/contrib/auth/tests/templates/registration/login.html 0 → 100644 +1 −0 Original line number Diff line number Diff line {{ form.as_ul }} No newline at end of file django/contrib/auth/tests/views.py +84 −8 Original line number Diff line number Diff line import os import re from django.conf import settings from django.contrib.auth.models import User from django.test import TestCase from django.core import mail Loading Loading @@ -86,3 +89,76 @@ class PasswordResetTest(TestCase): self.assertEquals(response.status_code, 200) self.assert_("The two password fields didn't match" in response.content) class ChangePasswordTest(TestCase): fixtures = ['authtestdata.json'] urls = 'django.contrib.auth.urls' def setUp(self): self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS settings.TEMPLATE_DIRS = ( os.path.join( os.path.dirname(__file__), 'templates' ) ,) def tearDown(self): settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS def login(self, password='password'): response = self.client.post('/login/', { 'username': 'testclient', 'password': password } ) self.assertEquals(response.status_code, 302) self.assert_(response['Location'].endswith('/accounts/profile/')) def fail_login(self, password='password'): response = self.client.post('/login/', { 'username': 'testclient', 'password': password } ) self.assertEquals(response.status_code, 200) self.assert_("Please enter a correct username and password. Note that both fields are case-sensitive." in response.content) def logout(self): response = self.client.get('/logout/') def test_password_change_fails_with_invalid_old_password(self): self.login() response = self.client.post('/password_change/', { 'old_password': 'donuts', 'new_password1': 'password1', 'new_password2': 'password1', } ) self.assertEquals(response.status_code, 200) self.assert_("Your old password was entered incorrectly. Please enter it again." in response.content) def test_password_change_fails_with_mismatched_passwords(self): self.login() response = self.client.post('/password_change/', { 'old_password': 'password', 'new_password1': 'password1', 'new_password2': 'donuts', } ) self.assertEquals(response.status_code, 200) self.assert_("The two password fields didn't match." in response.content) def test_password_change_succeeds(self): self.login() response = self.client.post('/password_change/', { 'old_password': 'password', 'new_password1': 'password1', 'new_password2': 'password1', } ) self.assertEquals(response.status_code, 302) self.assert_(response['Location'].endswith('/password_change/done/')) self.fail_login() self.login(password='password1') django/contrib/auth/urls.py +1 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^login/$', 'django.contrib.auth.views.login'), (r'^logout/$', 'django.contrib.auth.views.logout'), (r'^password_change/$', 'django.contrib.auth.views.password_change'), (r'^password_change/done/$', 'django.contrib.auth.views.password_change_done'), Loading Loading
AUTHORS +1 −0 Original line number Diff line number Diff line Loading @@ -330,6 +330,7 @@ answer newbie questions, and generally made Django that much better: David Reynolds <david@reynoldsfamily.org.uk> rhettg@gmail.com ricardojbarrios@gmail.com Mike Richardson Matt Riggott Henrique Romano <onaiort@gmail.com> Armin Ronacher Loading
django/contrib/auth/tests/__init__.py +5 −2 Original line number Diff line number Diff line from django.contrib.auth.tests.basic import BASIC_TESTS from django.contrib.auth.tests.views import PasswordResetTest from django.contrib.auth.tests.views import PasswordResetTest, ChangePasswordTest from django.contrib.auth.tests.forms import FORM_TESTS from django.contrib.auth.tests.tokens import TOKEN_GENERATOR_TESTS # The password for the fixture data users is 'password' __test__ = { 'BASIC_TESTS': BASIC_TESTS, 'PASSWORDRESET_TESTS': PasswordResetTest, 'FORM_TESTS': FORM_TESTS, 'TOKEN_GENERATOR_TESTS': TOKEN_GENERATOR_TESTS 'TOKEN_GENERATOR_TESTS': TOKEN_GENERATOR_TESTS, 'CHANGEPASSWORD_TESTS': ChangePasswordTest, }
django/contrib/auth/tests/templates/registration/login.html 0 → 100644 +1 −0 Original line number Diff line number Diff line {{ form.as_ul }} No newline at end of file
django/contrib/auth/tests/views.py +84 −8 Original line number Diff line number Diff line import os import re from django.conf import settings from django.contrib.auth.models import User from django.test import TestCase from django.core import mail Loading Loading @@ -86,3 +89,76 @@ class PasswordResetTest(TestCase): self.assertEquals(response.status_code, 200) self.assert_("The two password fields didn't match" in response.content) class ChangePasswordTest(TestCase): fixtures = ['authtestdata.json'] urls = 'django.contrib.auth.urls' def setUp(self): self.old_TEMPLATE_DIRS = settings.TEMPLATE_DIRS settings.TEMPLATE_DIRS = ( os.path.join( os.path.dirname(__file__), 'templates' ) ,) def tearDown(self): settings.TEMPLATE_DIRS = self.old_TEMPLATE_DIRS def login(self, password='password'): response = self.client.post('/login/', { 'username': 'testclient', 'password': password } ) self.assertEquals(response.status_code, 302) self.assert_(response['Location'].endswith('/accounts/profile/')) def fail_login(self, password='password'): response = self.client.post('/login/', { 'username': 'testclient', 'password': password } ) self.assertEquals(response.status_code, 200) self.assert_("Please enter a correct username and password. Note that both fields are case-sensitive." in response.content) def logout(self): response = self.client.get('/logout/') def test_password_change_fails_with_invalid_old_password(self): self.login() response = self.client.post('/password_change/', { 'old_password': 'donuts', 'new_password1': 'password1', 'new_password2': 'password1', } ) self.assertEquals(response.status_code, 200) self.assert_("Your old password was entered incorrectly. Please enter it again." in response.content) def test_password_change_fails_with_mismatched_passwords(self): self.login() response = self.client.post('/password_change/', { 'old_password': 'password', 'new_password1': 'password1', 'new_password2': 'donuts', } ) self.assertEquals(response.status_code, 200) self.assert_("The two password fields didn't match." in response.content) def test_password_change_succeeds(self): self.login() response = self.client.post('/password_change/', { 'old_password': 'password', 'new_password1': 'password1', 'new_password2': 'password1', } ) self.assertEquals(response.status_code, 302) self.assert_(response['Location'].endswith('/password_change/done/')) self.fail_login() self.login(password='password1')
django/contrib/auth/urls.py +1 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ from django.conf.urls.defaults import * urlpatterns = patterns('', (r'^login/$', 'django.contrib.auth.views.login'), (r'^logout/$', 'django.contrib.auth.views.logout'), (r'^password_change/$', 'django.contrib.auth.views.password_change'), (r'^password_change/done/$', 'django.contrib.auth.views.password_change_done'), Loading