summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2012-02-09 18:56:23 +0000
committerJannis Leidel <jannis@leidel.info>2012-02-09 18:56:23 +0000
commit03eeb020a00dedba2594326bd606d8b41d51e80f (patch)
treeb9ced29168e8571c62b7aa35c27770c9f0491ffd /tests
parentbd5861251490758e189d6d657de4683897024c70 (diff)
Fixed #159 -- Prevent the `AdminSite` from logging users out when they try to log in form the logout page. Many thanks, ashchristopher.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17465 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
-rwxr-xr-x[-rw-r--r--]tests/regressiontests/admin_views/tests.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
index ab40c698de..6b001e97ab 100644..100755
--- a/tests/regressiontests/admin_views/tests.py
+++ b/tests/regressiontests/admin_views/tests.py
@@ -3385,3 +3385,31 @@ class AdminCustomSaveRelatedTests(TestCase):
self.assertEqual('Josh Stone', Parent.objects.latest('id').name)
self.assertEqual([u'Catherine Stone', u'Paul Stone'], children_names)
+
+
+class AdminViewLogoutTest(TestCase):
+ urls = "regressiontests.admin_views.urls"
+ fixtures = ['admin-views-users.xml']
+
+ def setUp(self):
+ self.client.login(username='super', password='secret')
+
+ def tearDown(self):
+ self.client.logout()
+
+ def test_client_logout_url_can_be_used_to_login(self):
+ response = self.client.get('/test_admin/admin/logout/')
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.template_name, 'registration/logged_out.html')
+ self.assertEqual(response.request['PATH_INFO'], '/test_admin/admin/logout/')
+
+ # we are now logged out
+ response = self.client.get('/test_admin/admin/logout/')
+ self.assertEqual(response.status_code, 302) # we should be redirected to the login page.
+
+ # follow the redirect and test results.
+ response = self.client.get('/test_admin/admin/logout/', follow=True)
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response.template_name, 'admin/login.html')
+ self.assertEqual(response.request['PATH_INFO'], '/test_admin/admin/')
+ self.assertContains(response, '<input type="hidden" name="next" value="/test_admin/admin/" />')