11
22from castle .test import unittest
3- from castle .ip .extract import IPExtract
3+ from castle .ips .extract import IPsExtract
44from castle .configuration import configuration
55
66
7- class IPExtractTestCase (unittest .TestCase ):
7+ class IPsExtractTestCase (unittest .TestCase ):
88 def tearDown (self ):
99 configuration .ip_headers = []
1010 configuration .trusted_proxies = []
@@ -13,21 +13,21 @@ def tearDown(self):
1313
1414 def test_extract_ip (self ):
1515 headers = {'X-Forwarded-For' : '1.2.3.5' }
16- self .assertEqual (IPExtract (headers ).call (), '1.2.3.5' )
16+ self .assertEqual (IPsExtract (headers ).call (), '1.2.3.5' )
1717
1818 def test_extract_ip_when_second_header (self ):
1919 headers = {'Cf-Connecting-Ip' : '1.2.3.4' , 'X-Forwarded-For' : '1.1.1.1, 1.2.2.2, 1.2.3.5' }
2020 configuration .ip_headers = ["HTTP_CF_CONNECTING_IP" , "X-Forwarded-For" ]
2121 self .assertEqual (
22- IPExtract (headers ).call (),
22+ IPsExtract (headers ).call (),
2323 '1.2.3.4'
2424 )
2525
2626 def test_extract_ip_when_second_header_with_different_setting (self ):
2727 headers = {'Cf-Connecting-Ip' : '1.2.3.4' , 'X-Forwarded-For' : '1.1.1.1, 1.2.2.2, 1.2.3.5' }
2828 configuration .ip_headers = ["CF-CONNECTING-IP" , "X-Forwarded-For" ]
2929 self .assertEqual (
30- IPExtract (headers ).call (),
30+ IPsExtract (headers ).call (),
3131 '1.2.3.4'
3232 )
3333
@@ -37,7 +37,7 @@ def test_extract_ip_when_all_trusted_proxies(self):
3737 """
3838 headers = {'Remote-Addr' : '127.0.0.1' , 'X-Forwarded-For' : xf_header }
3939 self .assertEqual (
40- IPExtract (headers ).call (),
40+ IPsExtract (headers ).call (),
4141 '127.0.0.1'
4242 )
4343
@@ -48,7 +48,7 @@ def test_extract_ip_when_trust_proxy_chain(self):
4848 headers = {'Remote-Addr' : '6.6.6.4' , 'X-Forwarded-For' : xf_header }
4949 configuration .trust_proxy_chain = True
5050 self .assertEqual (
51- IPExtract (headers ).call (),
51+ IPsExtract (headers ).call (),
5252 '6.6.6.6'
5353 )
5454
@@ -59,21 +59,21 @@ def test_extract_ip_when_trust_proxy_depth(self):
5959 headers = {'Remote-Addr' : '6.6.6.4' , 'X-Forwarded-For' : xf_header }
6060 configuration .trusted_proxy_depth = 1
6161 self .assertEqual (
62- IPExtract (headers ).call (),
62+ IPsExtract (headers ).call (),
6363 '2.2.2.3'
6464 )
6565
6666 def test_extract_ip_for_spoof_ip_attempt (self ):
6767 headers = {'Client-Ip' : '6.6.6.6' , 'X-Forwarded-For' : '6.6.6.6, 2.2.2.3, 192.168.0.7' }
6868 self .assertEqual (
69- IPExtract (headers ).call (),
69+ IPsExtract (headers ).call (),
7070 '2.2.2.3'
7171 )
7272
7373 def test_extract_ip_for_spoof_ip_attempt_when_all_trusted_proxies (self ):
7474 headers = {'Client-Ip' : '6.6.6.6' , 'X-Forwarded-For' : '6.6.6.6, 2.2.2.3, 192.168.0.7' }
7575 configuration .trusted_proxies = [r'^2.2.2.\d$' ]
7676 self .assertEqual (
77- IPExtract (headers ).call (),
77+ IPsExtract (headers ).call (),
7878 '6.6.6.6'
7979 )
0 commit comments