Add missing get_failures handler proxy implementation

This missing implementation prevented custom implementations
for the failure fetching logic in the handler classes
because Axes would not invoke them from them,
and would use the base handler class implementation instead.
This commit is contained in:
Aleksi Häkli 2020-01-08 22:00:33 +02:00
parent 245ba0310d
commit e4929d2c11
No known key found for this signature in database
GPG key ID: DD4F689C5382F16A
2 changed files with 20 additions and 0 deletions

View file

@ -82,6 +82,11 @@ class AxesProxyHandler(AxesHandler):
cls.update_request(request)
return cls.get_implementation().is_allowed(request, credentials)
@classmethod
def get_failures(cls, request, credentials: dict = None) -> int:
cls.update_request(request)
return cls.get_implementation().get_failures(request, credentials)
@classmethod
@toggleable
def user_login_failed(cls, sender, credentials: dict, request=None, **kwargs):

View file

@ -275,3 +275,18 @@ class AxesDummyHandlerTestCase(AxesHandlerBaseTestCase):
self.login()
self.check_login()
@override_settings(AXES_HANDLER="axes.handlers.test.AxesTestHandler")
class AxesTestHandlerTestCase(AxesHandlerBaseTestCase):
def test_handler_reset_attempts(self):
self.assertEqual(0, AxesProxyHandler.reset_attempts())
def test_handler_reset_logs(self):
self.assertEqual(0, AxesProxyHandler.reset_logs())
def test_handler_is_allowed(self):
self.assertEqual(True, AxesProxyHandler.is_allowed(self.request, {}))
def test_handler_get_failures(self):
self.assertEqual(0, AxesProxyHandler.get_failures(self.request, {}))