kopia lustrzana https://github.com/wagtail/wagtail
Add unit tests for password management settings
rodzic
a11764d943
commit
d78c076809
|
@ -1,6 +1,6 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from django.test import TestCase
|
||||
from django.test import TestCase, override_settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.models import Group, Permission
|
||||
|
@ -156,6 +156,18 @@ class TestAccountSection(TestCase, WagtailTestUtils):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTemplateUsed(response, 'wagtailadmin/account/change_password.html')
|
||||
|
||||
@override_settings(WAGTAIL_PASSWORD_MANAGEMENT_ENABLED=False)
|
||||
def test_change_password_view_disabled(self):
|
||||
"""
|
||||
This tests that the change password view responds with a 404
|
||||
when setting WAGTAIL_PASSWORD_MANAGEMENT_ENABLED is False
|
||||
"""
|
||||
# Get change password page
|
||||
response = self.client.get(reverse('wagtailadmin_account_change_password'))
|
||||
|
||||
# Check that the user recieved a 404
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
def test_change_password_view_post(self):
|
||||
"""
|
||||
This posts a new password to the change password view and checks
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from django.test import TestCase, override_settings
|
||||
from django.core import mail
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from wagtail.tests.utils import WagtailTestUtils
|
||||
|
||||
|
@ -17,16 +18,30 @@ class TestUserPasswordReset(TestCase, WagtailTestUtils):
|
|||
from django.core.urlresolvers import clear_url_caches
|
||||
clear_url_caches()
|
||||
|
||||
@override_settings(WAGTAIL_PASSWORD_RESET_ENABLED=False)
|
||||
def test_password_reset_view_disabled(self):
|
||||
"""
|
||||
This tests that the password reset view responds with a 404
|
||||
when setting WAGTAIL_PASSWORD_RESET_ENABLED is False
|
||||
"""
|
||||
# Get password reset page
|
||||
response = self.client.get(reverse('wagtailadmin_password_reset'))
|
||||
|
||||
# Check that the user recieved a 404
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
@override_settings(ROOT_URLCONF="wagtail.wagtailadmin.urls")
|
||||
def test_email_found_default_url(self):
|
||||
response = self.client.post('/password_reset/', {'email': 'siteeditor@example.com'})
|
||||
response = self.client.post(reverse('wagtailadmin_password_reset'),
|
||||
{'email': 'siteeditor@example.com'})
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
self.assertIn("testserver", mail.outbox[0].body)
|
||||
|
||||
@override_settings(ROOT_URLCONF="wagtail.wagtailadmin.urls", BASE_URL='http://mysite.com')
|
||||
def test_email_found_base_url(self):
|
||||
response = self.client.post('/password_reset/', {'email': 'siteeditor@example.com'})
|
||||
response = self.client.post(reverse('wagtailadmin_password_reset'),
|
||||
{'email': 'siteeditor@example.com'})
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(len(mail.outbox), 1)
|
||||
self.assertIn("mysite.com", mail.outbox[0].body)
|
||||
|
|
Ładowanie…
Reference in New Issue