Exemplo n.º 1
0
    def testProxyFromArgs(self):
        self.assertEqual(_get_proxy_info("echo.websocket.org", False, http_proxy_host="localhost"), ("localhost", 0, None))
        self.assertEqual(_get_proxy_info("echo.websocket.org", False, http_proxy_host="localhost", http_proxy_port=3128), ("localhost", 3128, None))
        self.assertEqual(_get_proxy_info("echo.websocket.org", True, http_proxy_host="localhost"), ("localhost", 0, None))
        self.assertEqual(_get_proxy_info("echo.websocket.org", True, http_proxy_host="localhost", http_proxy_port=3128), ("localhost", 3128, None))

        self.assertEqual(_get_proxy_info("echo.websocket.org", False, http_proxy_host="localhost", http_proxy_auth=("a", "b")),
            ("localhost", 0, ("a", "b")))
        self.assertEqual(_get_proxy_info("echo.websocket.org", False, http_proxy_host="localhost", http_proxy_port=3128, http_proxy_auth=("a", "b")), 
            ("localhost", 3128, ("a", "b")))
        self.assertEqual(_get_proxy_info("echo.websocket.org", True, http_proxy_host="localhost", http_proxy_auth=("a", "b")), 
            ("localhost", 0, ("a", "b")))
        self.assertEqual(_get_proxy_info("echo.websocket.org", True, http_proxy_host="localhost", http_proxy_port=3128, http_proxy_auth=("a", "b")),
            ("localhost", 3128, ("a", "b")))

        self.assertEqual(_get_proxy_info("echo.websocket.org", True, http_proxy_host="localhost", http_proxy_port=3128, http_no_proxy=["example.com"], http_proxy_auth=("a", "b")),
            ("localhost", 3128, ("a", "b")))
        self.assertEqual(_get_proxy_info("echo.websocket.org", True, http_proxy_host="localhost", http_proxy_port=3128, http_no_proxy=["echo.websocket.org"], http_proxy_auth=("a", "b")),
            (None, 0, None))
Exemplo n.º 2
0
    def testProxyFromArgs(self):
        self.assertEqual(_get_proxy_info(False, http_proxy_host="localhost"), ("localhost", 0, None))
        self.assertEqual(_get_proxy_info(False, http_proxy_host="localhost", http_proxy_port=3128), ("localhost", 3128, None))
        self.assertEqual(_get_proxy_info(True, http_proxy_host="localhost"), ("localhost", 0, None))
        self.assertEqual(_get_proxy_info(True, http_proxy_host="localhost", http_proxy_port=3128), ("localhost", 3128, None))

        self.assertEqual(_get_proxy_info(False, http_proxy_host="localhost", http_proxy_auth=("a", "b")),
            ("localhost", 0, ("a", "b")))
        self.assertEqual(_get_proxy_info(False, http_proxy_host="localhost", http_proxy_port=3128, http_proxy_auth=("a", "b")), 
            ("localhost", 3128, ("a", "b")))
        self.assertEqual(_get_proxy_info(True, http_proxy_host="localhost", http_proxy_auth=("a", "b")), 
            ("localhost", 0, ("a", "b")))
        self.assertEqual(_get_proxy_info(True, http_proxy_host="localhost", http_proxy_port=3128, http_proxy_auth=("a", "b")),
            ("localhost", 3128, ("a", "b")))
Exemplo n.º 3
0
    def testProxyFromEnv(self):
        os.environ["http_proxy"] = "http://localhost/"
        self.assertEqual(_get_proxy_info(False), ("localhost", None, None))
        os.environ["http_proxy"] = "http://*****:*****@localhost/"
        self.assertEqual(_get_proxy_info(False), ("localhost", None, ("a", "b")))
        os.environ["http_proxy"] = "http://*****:*****@localhost:3128/"
        self.assertEqual(_get_proxy_info(False), ("localhost", 3128, ("a", "b")))

        os.environ["http_proxy"] = "http://*****:*****@localhost/"
        os.environ["https_proxy"] = "http://*****:*****@localhost2/"
        self.assertEqual(_get_proxy_info(False), ("localhost", None, ("a", "b")))
        os.environ["http_proxy"] = "http://*****:*****@localhost:3128/"
        os.environ["https_proxy"] = "http://*****:*****@localhost2:3128/"
        self.assertEqual(_get_proxy_info(False), ("localhost", 3128, ("a", "b")))

        os.environ["http_proxy"] = "http://*****:*****@localhost/"
        os.environ["https_proxy"] = "http://*****:*****@localhost2/"
        self.assertEqual(_get_proxy_info(True), ("localhost2", None, ("a", "b")))
        os.environ["http_proxy"] = "http://*****:*****@localhost:3128/"
        os.environ["https_proxy"] = "http://*****:*****@localhost2:3128/"
        self.assertEqual(_get_proxy_info(True), ("localhost2", 3128, ("a", "b")))
Exemplo n.º 4
0
    def testProxyFromEnv(self):
        os.environ["http_proxy"] = "http://localhost/"
        self.assertEqual(_get_proxy_info("echo.websocket.org", False), ("localhost", None, None))
        os.environ["http_proxy"] = "http://*****:*****@localhost/"
        self.assertEqual(_get_proxy_info("echo.websocket.org", False), ("localhost", None, ("a", "b")))
        os.environ["http_proxy"] = "http://*****:*****@localhost:3128/"
        self.assertEqual(_get_proxy_info("echo.websocket.org", False), ("localhost", 3128, ("a", "b")))

        os.environ["http_proxy"] = "http://*****:*****@localhost/"
        os.environ["https_proxy"] = "http://*****:*****@localhost2/"
        self.assertEqual(_get_proxy_info("echo.websocket.org", False), ("localhost", None, ("a", "b")))
        os.environ["http_proxy"] = "http://*****:*****@localhost:3128/"
        os.environ["https_proxy"] = "http://*****:*****@localhost2:3128/"
        self.assertEqual(_get_proxy_info("echo.websocket.org", False), ("localhost", 3128, ("a", "b")))

        os.environ["http_proxy"] = "http://*****:*****@localhost/"
        os.environ["https_proxy"] = "http://*****:*****@localhost2/"
        self.assertEqual(_get_proxy_info("echo.websocket.org", True), ("localhost2", None, ("a", "b")))
        os.environ["http_proxy"] = "http://*****:*****@localhost:3128/"
        os.environ["https_proxy"] = "http://*****:*****@localhost2:3128/"
        self.assertEqual(_get_proxy_info("echo.websocket.org", True), ("localhost2", 3128, ("a", "b")))

        os.environ["http_proxy"] = "http://*****:*****@localhost/"
        os.environ["https_proxy"] = "http://*****:*****@localhost2/"
        os.environ["no_proxy"] = "example1.com,example2.com"
        self.assertEqual(_get_proxy_info("example.1.com", True), ("localhost2", None, ("a", "b")))
        os.environ["http_proxy"] = "http://*****:*****@localhost:3128/"
        os.environ["https_proxy"] = "http://*****:*****@localhost2:3128/"
        os.environ["no_proxy"] = "example1.com,example2.com, echo.websocket.org"
        self.assertEqual(_get_proxy_info("echo.websocket.org", True), (None, 0, None))