jazzband / django-axes

Keep track of failed login attempts in Django-powered sites.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`AccessLogTestCase` logout tests fails with django main

hirotasoshu opened this issue · comments

____________________________________ AccessLogTestCase.test_access_log_on_logout ____________________________________

self = <tests.test_logging.AccessLogTestCase testMethod=test_access_log_on_logout>

    def test_access_log_on_logout(self):
        """
        Test a valid logout and make sure the logout_time is updated.
        """

        self.login(is_valid_username=True, is_valid_password=True)
        self.assertIsNone(AccessLog.objects.latest("id").logout_time)

        response = self.client.get(reverse("admin:logout"))
>       self.assertContains(response, "Logged out")

tests/test_logging.py:68:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py311-djmain/lib/python3.11/site-packages/django/test/testcases.py:523: in assertContains
    text_repr, real_count, msg_prefix = self._assert_contains(
.tox/py311-djmain/lib/python3.11/site-packages/django/test/testcases.py:486: in _assert_contains
    self.assertEqual(
E   AssertionError: 405 != 200 : Couldn't retrieve content: Response code was 405 (expected 200)
----------------------------------------------- Captured stderr call ------------------------------------------------
AXES: Successful login by {username: "axes-valid-username", ip_address: "127.0.0.1", user_agent: "axes-user-agent", path_info: "/admin/login/"}.
------------------------------------------------- Captured log call -------------------------------------------------
WARNING  django.request:base.py:146 Method Not Allowed (GET): /admin/logout/
WARNING  django.request:log.py:241 Method Not Allowed: /admin/logout/
__________________________________ AccessLogTestCase.test_valid_logout_without_log __________________________________

self = <tests.test_logging.AccessLogTestCase testMethod=test_valid_logout_without_log>

    @override_settings(AXES_DISABLE_ACCESS_LOG=True)
    def test_valid_logout_without_log(self):
        AccessLog.objects.all().delete()

        response = self.login(is_valid_username=True, is_valid_password=True)
        response = self.client.get(reverse("admin:logout"))

        self.assertEqual(AccessLog.objects.count(), 0)
>       self.assertContains(response, "Logged out", html=True)

tests/test_logging.py:114:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py311-djmain/lib/python3.11/site-packages/django/test/testcases.py:523: in assertContains
    text_repr, real_count, msg_prefix = self._assert_contains(
.tox/py311-djmain/lib/python3.11/site-packages/django/test/testcases.py:486: in _assert_contains
    self.assertEqual(
E   AssertionError: 405 != 200 : Couldn't retrieve content: Response code was 405 (expected 200)
----------------------------------------------- Captured stderr call ------------------------------------------------
AXES: Successful login by {username: "axes-valid-username", ip_address: "127.0.0.1", user_agent: "axes-user-agent", path_info: "/admin/login/"}.
------------------------------------------------- Captured log call -------------------------------------------------
WARNING  django.request:base.py:146 Method Not Allowed (GET): /admin/logout/
WARNING  django.request:log.py:241 Method Not Allowed: /admin/logout/
______________________________ AccessLogTestCase.test_valid_logout_without_success_log ______________________________

self = <tests.test_logging.AccessLogTestCase testMethod=test_valid_logout_without_success_log>

    @override_settings(AXES_DISABLE_ACCESS_LOG=True)
    def test_valid_logout_without_success_log(self):
        AccessLog.objects.all().delete()

        response = self.login(is_valid_username=True, is_valid_password=True)
        response = self.client.get(reverse("admin:logout"))

        self.assertEqual(AccessLog.objects.all().count(), 0)
>       self.assertContains(response, "Logged out", html=True)

tests/test_logging.py:91:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py311-djmain/lib/python3.11/site-packages/django/test/testcases.py:523: in assertContains
    text_repr, real_count, msg_prefix = self._assert_contains(
.tox/py311-djmain/lib/python3.11/site-packages/django/test/testcases.py:486: in _assert_contains
    self.assertEqual(
E   AssertionError: 405 != 200 : Couldn't retrieve content: Response code was 405 (expected 200)