Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
un33k committed Nov 22, 2023
1 parent 82cb843 commit ad8b2f7
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ipware/tests/tests_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,27 @@ def test_load(self):
}
result = get_client_ip(request)
self.assertEqual(result, ("177.139.233.139", True))

def test_meta_proxy_order_left_most(self):
request = HttpRequest()
request.META = {
'HTTP_X_FORWARDED_FOR': '177.139.233.139, 198.84.193.157, 198.84.193.158',
}
result = get_client_ip(request, proxy_order='left-most')
self.assertEqual(result, ("177.139.233.139", True))

def test_meta_singleton_proxy_count(self):
request = HttpRequest()
request.META = {
'HTTP_X_FORWARDED_FOR': '177.139.233.139, 198.84.193.157, 198.84.193.158',
}
result = get_client_ip(request, proxy_count=2)
self.assertEqual(result, ("177.139.233.139", True))

def test_meta_proxy_trusted_ips_exact_ip_check(self):
request = HttpRequest()
request.META = {
'HTTP_X_FORWARDED_FOR': '177.139.233.139, 198.84.193.157, 198.84.193.158',
}
result = get_client_ip(request, proxy_trusted_ips=['198.84.193.157', '198.84.193.158'])
self.assertEqual(result, ("177.139.233.139", True))

0 comments on commit ad8b2f7

Please sign in to comment.