def test_noproxy_url_nondefault_port(self): hm = HTTPMonitor("192.168.20.100", "tester.test", "http://www.tester.test:8050") hm._hostnameIp.append("192.168.20.100") hm.makeURL() self.assertEqual(hm._reqURL, "http://www.tester.test:8050") self.assertIsNone(hm._proxyIp)
def test_proxy_url_has_default_port(self): hm = HTTPMonitor("10.20.30.40", "tester.test", "http://www.tester.test:80") hm._hostnameIp.append("192.168.20.100") hm.makeURL() self.assertEqual(hm._reqURL, "http://www.tester.test") self.assertEqual(hm._proxyIp, "10.20.30.40")
def test_noproxy_pathonlyurl(self): hm = HTTPMonitor( "192.168.20.100", "tester.test", "/path" ) hm._hostnameIp.append("192.168.20.100") hm.makeURL() self.assertEqual(hm._reqURL, "http://tester.test/path") self.assertIsNone(hm._proxyIp)
def test_proxy_withurl(self): hm = HTTPMonitor( "10.20.30.40", "tester.test", "http://www.tester.test" ) hm._hostnameIp.append("192.168.20.100") hm.makeURL() self.assertEqual(hm._reqURL, "http://www.tester.test") self.assertEqual(hm._proxyIp, "10.20.30.40")
def test_noproxy_url_nondefault_port(self): hm = HTTPMonitor( "192.168.20.100", "tester.test", "http://www.tester.test:8050" ) hm._hostnameIp.append("192.168.20.100") hm.makeURL() self.assertEqual(hm._reqURL, "http://www.tester.test:8050") self.assertIsNone(hm._proxyIp)
def test_proxy_url_default_port_with_path(self): hm = HTTPMonitor( "10.20.30.40", "tester.test", "http://www.tester.test:80/path" ) hm._hostnameIp.append("192.168.20.100") hm.makeURL() self.assertEqual(hm._reqURL, "http://www.tester.test/path") self.assertEqual(hm._proxyIp, "10.20.30.40")
def test_redirect_sticky_with_proxy(self): location = "http://example.org/" hm = HTTPMonitor("10.20.30.40", "tester.test", "http://tester.test:8888/path", 3128) hm._follow = "sticky" hm._proxyIp = "10.10.10.10" hm._hostnameIp.append("10.20.30.50") hm.makeURL() agent = RedirectAgentZ(Agent, onRedirect=hm._follow, port=hm._port, proxy=hm._proxyIp) self.assertEqual(agent._resolveLocation(hm._reqURL, location), "http://tester.test/")
def test_redirect_stickyport_443(self): location = "http://example.org/" hm = HTTPMonitor("10.20.30.40", "tester.test", "/path", 443) hm._follow = "stickyport" hm._proxyIp = "" hm._hostnameIp.append("10.20.30.40") hm.makeURL() agent = RedirectAgentZ(Agent, onRedirect=hm._follow, port=hm._port, proxy=hm._proxyIp) self.assertEqual(agent._resolveLocation(hm._reqURL, location), "http://example.org:443/")
def test_proxyport_url_nondefault_port(self): hm = HTTPMonitor( "10.20.30.40", "tester.test", "http://www.tester.test:8050", port=6000 ) hm._hostnameIp.append("192.168.20.100") hm.makeURL() self.assertEqual(hm._reqURL, "http://www.tester.test:8050") self.assertEqual(hm._proxyIp, "10.20.30.40") self.assertEqual(hm._port, 6000)
def test_proxy_nourl_nondefault_port(self): hm = HTTPMonitor("10.20.30.40", "tester.test", port=8050) hm._hostnameIp.append("192.168.20.100") hm.makeURL() self.assertEqual(hm._reqURL, "http://tester.test/") self.assertEqual(hm._proxyIp, "10.20.30.40")
def test_noproxy_pathonlyurl(self): hm = HTTPMonitor("192.168.20.100", "tester.test", "/path") hm._hostnameIp.append("192.168.20.100") hm.makeURL() self.assertEqual(hm._reqURL, "http://tester.test/path") self.assertIsNone(hm._proxyIp)