mirror of
https://github.com/jazzband/django-axes.git
synced 2026-03-16 22:30:23 +00:00
parent
9b73fc39d8
commit
f732719122
2 changed files with 17 additions and 8 deletions
|
|
@ -230,15 +230,10 @@ def get_client_str(
|
|||
path_info = path_info[0]
|
||||
client_dict["path_info"] = path_info
|
||||
|
||||
# Template the internal dictionary representation into a readable and concatenated key: "value" format
|
||||
# Template the internal dictionary representation into a readable and concatenated {key: "value"} format
|
||||
template = ", ".join(f'{key}: "{value}"' for key, value in client_dict.items())
|
||||
|
||||
# Wrap the internal dict into a single {key: "value"} bracing in the output
|
||||
# which requires double braces when done with the Python string templating system
|
||||
# i.e. {{key: "value"}} becomes {key: "value"} when run through a .format() call
|
||||
template = "{{" + template + "}}"
|
||||
|
||||
return template.format(client_dict)
|
||||
template = "{" + template + "}"
|
||||
return template
|
||||
|
||||
|
||||
def get_query_str(query: Type[QueryDict], max_length: int = 1024) -> str:
|
||||
|
|
|
|||
|
|
@ -97,6 +97,20 @@ class ClientStringTestCase(AxesTestCase):
|
|||
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
@override_settings(AXES_VERBOSE=True)
|
||||
def test_imbalanced_quotes(self):
|
||||
username = "butterfly.. },,,"
|
||||
ip_address = "127.0.0.1"
|
||||
user_agent = "Googlebot/2.1 (+http://www.googlebot.com/bot.html)"
|
||||
path_info = "/admin/"
|
||||
|
||||
expected = self.get_expected_client_str(
|
||||
username, ip_address, user_agent, path_info
|
||||
)
|
||||
actual = get_client_str(username, ip_address, user_agent, path_info)
|
||||
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
@override_settings(AXES_VERBOSE=True)
|
||||
def test_verbose_ip_only_client_details_tuple(self):
|
||||
username = "test@example.com"
|
||||
|
|
|
|||
Loading…
Reference in a new issue