diff --git a/axes/handlers/dummy.py b/axes/handlers/dummy.py new file mode 100644 index 0000000..6e7c1fb --- /dev/null +++ b/axes/handlers/dummy.py @@ -0,0 +1,12 @@ +from django.http import HttpRequest + +from axes.handlers.base import AxesBaseHandler + + +class AxesDummyHandler(AxesBaseHandler): # pylint: disable=unused-argument + """ + Signal handler implementation that does nothing and can be used to disable signal processing. + """ + + def is_allowed(self, request: HttpRequest, credentials: dict = None) -> bool: + return True diff --git a/axes/tests/test_handlers.py b/axes/tests/test_handlers.py index 3e93981..2ac109c 100644 --- a/axes/tests/test_handlers.py +++ b/axes/tests/test_handlers.py @@ -1,9 +1,9 @@ from unittest.mock import MagicMock, patch -from django.http import HttpRequest from django.test import override_settings from django.utils.timezone import timedelta +from axes.conf import settings from axes.handlers.proxy import AxesProxyHandler from axes.tests.base import AxesTestCase from axes.utils import get_client_str @@ -147,3 +147,14 @@ class AxesCacheHandlerTestCase(AxesHandlerTestCase): @patch('axes.handlers.cache.log') def test_whitelist(self, log): self.check_whitelist(log) + + +@override_settings( + AXES_HANDLER='axes.handlers.dummy.AxesDummyHandler', +) +class AxesDummyHandlerTestCase(AxesHandlerTestCase): + def test_handler(self): + for _ in range(settings.AXES_FAILURE_LIMIT): + self.login() + + self.check_login()