#import test_msger
import test_runner
import test_chroot
+import test_proxy
if os.getuid() != 0:
raise SystemExit("Root permission is needed")
#suite.addTests(test_msger.suite())
suite.addTests(test_runner.suite())
suite.addTests(test_chroot.suite())
+suite.addTests(test_proxy.suite())
result = unittest.TextTestRunner(verbosity=2).run(suite)
sys.exit(not result.wasSuccessful())
--- /dev/null
+#!/usr/bin/python
+
+import unittest
+from mic.utils import proxy
+
+def suite():
+ return unittest.makeSuite(ProxyTest)
+
+class ProxyTest(unittest.TestCase):
+
+ def test_proxy(self):
+ proxy.set_proxies('http://proxy.some.com:11', '1.2.3.4')
+ self.assertEqual(proxy.get_proxy_for('http://1.2.3.4'), None)
+ self.assertEqual(proxy.get_proxy_for('http://download.tizen.org'), 'http://proxy.some.com:11')
+
+ proxy.set_proxies('http://proxy.some.com:11', 'download.am.org')
+ self.assertEqual(proxy.get_proxy_for('http://download.am.org'), None)
+ self.assertEqual(proxy.get_proxy_for('https://download.am.org'), None)
+ self.assertEqual(proxy.get_proxy_for('http://download.tizen.org'), 'http://proxy.some.com:11')
+
+ proxy.set_proxies('http://proxy.some.com:11', '1.2.3.0/24')
+ self.assertEqual(proxy.get_proxy_for('http://1.2.3.4'), None)
+ self.assertEqual(proxy.get_proxy_for('http://1.2.3.0'), None)
+ self.assertEqual(proxy.get_proxy_for('http://1.2.3.255'), None)
+ self.assertEqual(proxy.get_proxy_for('http://download.tizen.org'), 'http://proxy.some.com:11')
+
+ proxy.set_proxies('http://proxy.some.com:11', '.hello.com')
+ self.assertEqual(proxy.get_proxy_for('http://linux.hello.com'), None)
+ self.assertEqual(proxy.get_proxy_for('http://linux.hello.com.org'), 'http://proxy.some.com:11')
+
+
+
+if __name__ == "__main__":
+ unittest.main()