summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOndrej Novy <ondrej.novy@firma.seznam.cz>2015-08-08 16:09:22 +0200
committerOndřej Nový <ondrej.novy@firma.seznam.cz>2015-10-05 21:57:06 +0200
commitc0f473d9757afa680e6b6883cbd16d45ec3551fa (patch)
tree5181c7c090c3a61ec3f7492ddc76d705c8ef50ef /tests
parentd64b007deb99e3ac65034623993961f23351b78d (diff)
downloadswift-bench-c0f473d9757afa680e6b6883cbd16d45ec3551fa.tar.gz
Try to detect HTTP proxy and warn about it.
swift-bench test results could be altered when using HTTP proxy server. This patch add warning when HTTP proxy has been detected. Change-Id: Id818203345914efee37852e96541c259de6ae555
Diffstat (limited to 'tests')
-rw-r--r--tests/test_utils.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 295d795..c31d5af 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -104,6 +104,21 @@ log_name = %(yarr)s'''
os.unlink(temppath)
self.assertRaises(SystemExit, utils.readconf, temppath)
+ @mock.patch("swiftbench.utils.getproxies")
+ @mock.patch("swiftbench.utils.proxy_bypass")
+ def test_using_http_proxy(self, mock_proxy_bypass, mock_getproxies):
+ mock_getproxies.return_value = {'http': 'proxy', 'https': 'proxy'}
+
+ def fake_proxy_bypass(url):
+ return url == "localhost"
+ mock_proxy_bypass.side_effect = fake_proxy_bypass
+
+ self.assertTrue(utils.using_http_proxy("http://host1/"))
+ self.assertFalse(utils.using_http_proxy("http://localhost/"))
+ self.assertTrue(utils.using_http_proxy("https://host1/"))
+ self.assertFalse(utils.using_http_proxy("https://localhost/"))
+ self.assertFalse(utils.using_http_proxy("dummy://localhost/"))
+ self.assertFalse(utils.using_http_proxy("dummy://host1/"))
if __name__ == '__main__':
unittest.main()