def test_login_without_permission(self):
        self.client.login(username='unauthorized', password='pass')
        with self.settings(SU_LOGIN_CALLBACK=None):
            response = self.client.post(
                reverse('login_as_user', args=[self.destination_user.id])
            )
        self.assertEqual(response.status_code, 302)
        # User should still be logged in, but as the original user
        self.assertIn(auth.SESSION_KEY, self.client.session)
        self.assertEqual(str(self.client.session[auth.SESSION_KEY]), str(self.unauthorized_user.id))
        # Exit user should never get set
        self.assertNotIn('exit_users_pk', self.client.session)
Ensure login fails when the current user lacks permission
dataset/ETHPy150Open adamcharnock/django-su/django_su/tests/test_views.py/LoginAsUserViewTestCase.test_login_without_permission