mirror of
https://github.com/jazzband/django-defender.git
synced 2026-03-16 22:10:32 +00:00
Remove incorrect tests
This commit is contained in:
parent
5139005106
commit
374971bfc5
2 changed files with 6 additions and 23 deletions
|
|
@ -45,17 +45,12 @@ def get_approx_account_lockouts_from_login_attempts(ip_address=None, username=No
|
|||
and not config.DISABLE_IP_LOCKOUT and not config.DISABLE_USERNAME_LOCKOUT
|
||||
):
|
||||
q = q & Q(ip_address=ip_address) & Q(username=username)
|
||||
elif not config.LOCKOUT_BY_IP_USERNAME:
|
||||
if ip_address and not config.DISABLE_IP_LOCKOUT:
|
||||
failure_limit = config.IP_FAILURE_LIMIT
|
||||
q = q & Q(ip_address=ip_address)
|
||||
elif username and not config.DISABLE_USERNAME_LOCKOUT:
|
||||
failure_limit = config.USERNAME_FAILURE_LIMIT
|
||||
q = q & Q(username=username)
|
||||
else:
|
||||
# If we've made it this far and didn't hit one of the other if or elif
|
||||
# conditions, we're in an inappropriate context.
|
||||
raise Exception("Invalid state requested")
|
||||
elif ip_address and not config.DISABLE_IP_LOCKOUT:
|
||||
failure_limit = config.IP_FAILURE_LIMIT
|
||||
q = q & Q(ip_address=ip_address)
|
||||
elif username and not config.DISABLE_USERNAME_LOCKOUT:
|
||||
failure_limit = config.USERNAME_FAILURE_LIMIT
|
||||
q = q & Q(username=username)
|
||||
else:
|
||||
# If we've made it this far and didn't hit one of the other if or elif
|
||||
# conditions, we're in an inappropriate context.
|
||||
|
|
|
|||
|
|
@ -995,18 +995,6 @@ class AccessAttemptTest(DefenderTestCase):
|
|||
def test_approx_account_lockout_count_default_case_invalid_args_pt2(self):
|
||||
with self.assertRaises(Exception):
|
||||
get_approx_account_lockouts_from_login_attempts(username=VALID_USERNAME)
|
||||
|
||||
@patch("defender.config.DISABLE_IP_LOCKOUT", True)
|
||||
@patch("defender.config.LOCKOUT_BY_IP_USERNAME", True)
|
||||
def test_approx_account_lockout_count_default_case_invalid_args_pt3(self):
|
||||
with self.assertRaises(Exception):
|
||||
get_approx_account_lockouts_from_login_attempts(ip_address="127.0.0.1", username=VALID_USERNAME)
|
||||
|
||||
@patch("defender.config.DISABLE_USERNAME_LOCKOUT", True)
|
||||
@patch("defender.config.LOCKOUT_BY_IP_USERNAME", True)
|
||||
def test_approx_account_lockout_count_default_case_invalid_args_pt4(self):
|
||||
with self.assertRaises(Exception):
|
||||
get_approx_account_lockouts_from_login_attempts(ip_address="127.0.0.1", username=VALID_USERNAME)
|
||||
|
||||
|
||||
class SignalTest(DefenderTestCase):
|
||||
|
|
|
|||
Loading…
Reference in a new issue