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

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

corrects when netloc is empty and path is not

  • 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
8import socket
9
10
11class Test(unittest.TestCase):
12
13
14    def test_calculate_remote_ip(self):
15        self._check_remote_ip('http://www.google.com')
16        self._check_remote_ip('http://www.google.com/intl/it/ads/')
17        self._check_remote_ip('http://www.google.com/intl/it/about.html')
18        self._check_remote_ip('http://www.google.com:80/intl/it/about.html')
19        self._check_remote_ip(socket.getfqdn())
20        #self._check_remote_ip('http://localhost:80')
21
22    def _check_remote_ip(self, url_path):
23        remote_ip = _calculate_remote_ip(url_path)
24        self.assertTrue(remote_ip, "Failed to identify: %s " % url_path)
25
26
27if __name__ == "__main__":
28    #import sys;sys.argv = ['', 'Test.test_calculate_remote_ip']
29    unittest.main()
Note: See TracBrowser for help on using the repository browser.