From ae0c30af292d6ec330e7eec064ca845f79496117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksi=20Ha=CC=88kli?= Date: Thu, 7 Feb 2019 17:39:38 +0200 Subject: [PATCH] Remove deprecated JSON testing shims MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aleksi Häkli --- axes/tests/test_access_attempt_config.py | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/axes/tests/test_access_attempt_config.py b/axes/tests/test_access_attempt_config.py index 6ab5523..078fc6b 100644 --- a/axes/tests/test_access_attempt_config.py +++ b/axes/tests/test_access_attempt_config.py @@ -1,5 +1,3 @@ -import json - from django.test import TestCase, override_settings from django.urls import reverse from django.contrib.auth.models import User @@ -24,8 +22,7 @@ class AccessAttemptConfigTest(TestCase): ALLOWED = 302 BLOCKED = 403 - def _login(self, username, password, ip_addr='127.0.0.1', - is_json=False, **kwargs): + def _login(self, username, password, ip_addr='127.0.0.1', **kwargs): """Login a user and get the response. IP address can be configured to test IP blocking functionality. """ @@ -39,17 +36,12 @@ class AccessAttemptConfigTest(TestCase): } post_data.update(kwargs) - if is_json: - headers.update({ - 'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest', - 'content_type': 'application/json', - }) - post_data = json.dumps(post_data) - - response = self.client.post( - reverse('admin:login'), post_data, REMOTE_ADDR=ip_addr, **headers + return self.client.post( + reverse('admin:login'), + post_data, + REMOTE_ADDR=ip_addr, + **headers ) - return response def _lockout_user_from_ip(self, username, ip_addr): for _ in range(settings.AXES_FAILURE_LIMIT):