added test for remove_prefix method

This commit is contained in:
Dashgin 2022-05-22 20:05:48 +04:00 committed by Ken Cochrane
parent 428968b238
commit d90dfa8db7

View file

@ -1169,3 +1169,10 @@ class TestUtils(DefenderTestCase):
req = HttpRequest()
req.META["HTTP_X_FORWARDED_FOR"] = "[2001:db8::1]:123456"
self.assertEqual(utils.get_ip(req), "2001:db8::1")
def test_remove_prefix(self):
""" test the remove_prefix() method """
self.assertEqual(utils.remove_prefix(
"defender:blocked:ip:192.168.24.24", "defender:blocked:"), "ip:192.168.24.24")
self.assertEqual(utils.remove_prefix(
"defender:blocked:username:johndoe", "defender:blocked:"), "username:johndoe")