source: mauRepo/dj_security/trunk/dj_security/test/test_middleware.py @ 8689

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/dj_security/trunk/dj_security/test/test_middleware.py@8689
Revision 8689, 855 bytes checked in by mnagni, 7 years ago (diff)

corrected how the remote_ip is retrieved from the remote_url

  • Property svn:mime-type set to text/plain
Line 
1'''
2Created on 21 Nov 2012
3
4@author: mnagni
5'''
6import unittest
7from dj_security.middleware import _calculate_remote_ip
8
9
10class Test(unittest.TestCase):
11
12
13    def test_calculate_remote_ip(self):
14        self._check_remote_ip('http://www.google.com')
15        self._check_remote_ip('http://www.google.com/intl/it/ads/')
16        self._check_remote_ip('http://www.google.com/intl/it/about.html')
17        self._check_remote_ip('http://www.google.com:80/intl/it/about.html')
18        #self._check_remote_ip('http://localhost')
19        #self._check_remote_ip('http://localhost:80')
20
21    def _check_remote_ip(self, url_path):
22        remote_ip = _calculate_remote_ip(url_path)
23        self.assertTrue(remote_ip, "Failed to identify: %s " % url_path)
24
25
26if __name__ == "__main__":
27    #import sys;sys.argv = ['', 'Test.test_calculate_remote_ip']
28    unittest.main()
Note: See TracBrowser for help on using the repository browser.