Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 #!/usr/bin/env python
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 # You can obtain one at http://mozilla.org/MPL/2.0/.
7 import mozhttpd
8 import urllib2
9 import os
10 import unittest
11 import re
13 here = os.path.dirname(os.path.abspath(__file__))
15 class FileListingTest(unittest.TestCase):
17 def check_filelisting(self, path=''):
18 filelist = os.listdir(here)
20 httpd = mozhttpd.MozHttpd(port=0, docroot=here)
21 httpd.start(block=False)
22 f = urllib2.urlopen("http://%s:%s/%s" % ('127.0.0.1', httpd.httpd.server_port, path))
23 for line in f.readlines():
24 webline = re.sub('\<[a-zA-Z0-9\-\_\.\=\"\'\/\\\%\!\@\#\$\^\&\*\(\) ]*\>', '', line.strip('\n')).strip('/').strip().strip('@')
26 if webline and not webline.startswith("Directory listing for"):
27 self.assertTrue(webline in filelist,
28 "File %s in dir listing corresponds to a file" % webline)
29 filelist.remove(webline)
30 self.assertFalse(filelist, "Should have no items in filelist (%s) unaccounted for" % filelist)
33 def test_filelist(self):
34 self.check_filelisting()
36 def test_filelist_params(self):
37 self.check_filelisting('?foo=bar&fleem=&foo=fleem')
40 if __name__ == '__main__':
41 unittest.main()