mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Fixed #25163 -- Added hint for non-staff users to admin login page.
This commit is contained in:
committed by
Tim Graham
parent
537818af87
commit
635ffc3c37
@@ -1558,6 +1558,25 @@ class AdminViewPermissionsTest(TestCase):
|
||||
self.assertFalse(login.context)
|
||||
self.client.get(reverse('admin:logout'))
|
||||
|
||||
def test_login_page_notice_for_non_staff_users(self):
|
||||
"""
|
||||
A logged-in non-staff user trying to access the admin index should be
|
||||
presented with the login page and a hint indicating that the current
|
||||
user doesn't have access to it.
|
||||
"""
|
||||
hint_template = 'You are authenticated as {}'
|
||||
|
||||
# Anonymous user should not be shown the hint
|
||||
response = self.client.get(self.index_url, follow=True)
|
||||
self.assertContains(response, 'login-form')
|
||||
self.assertNotContains(response, hint_template.format(''), status_code=200)
|
||||
|
||||
# Non-staff user should be shown the hint
|
||||
self.client.login(**self.nostaff_login)
|
||||
response = self.client.get(self.index_url, follow=True)
|
||||
self.assertContains(response, 'login-form')
|
||||
self.assertContains(response, hint_template.format(self.u6.username), status_code=200)
|
||||
|
||||
def test_add_view(self):
|
||||
"""Test add view restricts access and actually adds items."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user