mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-24 10:58:52 +01:00
Added test to check that wagtailadmin behaves correctly when LOGIN_URL is not set
This commit is contained in:
parent
1e5fdb0a63
commit
b35f6d9409
@ -103,6 +103,7 @@ if not settings.configured:
|
||||
WAGTAILSEARCH_BACKENDS=WAGTAILSEARCH_BACKENDS,
|
||||
WAGTAIL_SITE_NAME='Test Site',
|
||||
LOGIN_REDIRECT_URL = 'wagtailadmin_home',
|
||||
LOGIN_URL='wagtailadmin_login',
|
||||
)
|
||||
|
||||
|
||||
|
@ -67,7 +67,7 @@ class TestAuthentication(TestCase, WagtailTestUtils):
|
||||
"""
|
||||
This tests that the user can logout
|
||||
"""
|
||||
# Get logout page page
|
||||
# Get logout page
|
||||
response = self.client.get(reverse('wagtailadmin_logout'))
|
||||
|
||||
# Check that the user was redirected to the login page
|
||||
@ -77,6 +77,41 @@ class TestAuthentication(TestCase, WagtailTestUtils):
|
||||
# Check that the user was logged out
|
||||
self.assertFalse('_auth_user_id' in self.client.session)
|
||||
|
||||
def test_not_logged_in_redirect(self):
|
||||
"""
|
||||
This tests that a not logged in user is redirected to the
|
||||
login page
|
||||
"""
|
||||
# Logout
|
||||
self.client.logout()
|
||||
|
||||
# Get dashboard
|
||||
response = self.client.get(reverse('wagtailadmin_home'))
|
||||
|
||||
# Check that the user was redirected to the login page and that next was set correctly
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertURLEqual(response.url, reverse('wagtailadmin_login') + '?next=' + reverse('wagtailadmin_home'))
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_not_logged_in_redirect_default_settings(self):
|
||||
"""
|
||||
This does the same as the above test but checks that it
|
||||
redirects to the correct place when the user has not set
|
||||
the LOGIN_URL setting correctly
|
||||
"""
|
||||
# Logout
|
||||
self.client.logout()
|
||||
|
||||
# Get dashboard with default LOGIN_URL setting
|
||||
with self.settings(LOGIN_URL='django.contrib.auth.views.login'):
|
||||
response = self.client.get(reverse('wagtailadmin_home'))
|
||||
|
||||
# Check that the user was redirected to the login page and that next was set correctly
|
||||
# Note: The user will be redirected to 'django.contrib.auth.views.login' but
|
||||
# this must be the same URL as 'wagtailadmin_login'
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertURLEqual(response.url, reverse('wagtailadmin_login') + '?next=' + reverse('wagtailadmin_home'))
|
||||
|
||||
|
||||
class TestAccountSection(TestCase, WagtailTestUtils):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user