def test_proxy_port_conversion(self):
        proxy_port = "8888"
        proxy_options = ProxyOptions(
            proxy_type=socks.HTTP, proxy_addr="127.0.0.1", proxy_port=proxy_port
        )

        assert proxy_options.proxy_port == int(proxy_port)
    def test_proxy_type(self, proxy_type_input, expected_proxy_type, expected_proxy_type_socks):
        proxy_options = ProxyOptions(
            proxy_type=proxy_type_input, proxy_addr="127.0.0.1", proxy_port=8888
        )

        assert proxy_options.proxy_type == expected_proxy_type
        assert proxy_options.proxy_type_socks == expected_proxy_type_socks
    def test_proxy_port(self):
        proxy_port = 8888
        proxy_options = ProxyOptions(
            proxy_type=socks.HTTP, proxy_addr="127.0.0.1", proxy_port=proxy_port
        )

        assert proxy_options.proxy_port == proxy_port
    def test_proxy_port(self, mocker):
        proxy_port = 8888
        proxy_options = ProxyOptions(proxy_type=mocker.MagicMock(),
                                     proxy_addr="127.0.0.1",
                                     proxy_port=proxy_port)

        assert proxy_options.proxy_port == proxy_port
    def test_proxy_password(self):
        proxy_password = "******"
        proxy_options = ProxyOptions(
            proxy_type=socks.HTTP,
            proxy_addr="127.0.0.1",
            proxy_port=8888,
            proxy_password=proxy_password,
        )

        assert proxy_options.proxy_password == proxy_password
    def test_proxy_username(self):
        proxy_username = "******"
        proxy_options = ProxyOptions(
            proxy_type=socks.HTTP,
            proxy_addr="127.0.0.1",
            proxy_port=8888,
            proxy_username=proxy_username,
        )

        assert proxy_options.proxy_username == proxy_username
    def test_proxy_username(self, mocker):
        proxy_username = "******"
        proxy_options = ProxyOptions(
            proxy_type=mocker.MagicMock(),
            proxy_addr="127.0.0.1",
            proxy_port=8888,
            proxy_username=proxy_username,
        )

        assert proxy_options.proxy_username == proxy_username
    def test_proxy_password(self, mocker):
        proxy_password = "******"
        proxy_options = ProxyOptions(
            proxy_type=mocker.MagicMock(),
            proxy_addr="127.0.0.1",
            proxy_port=8888,
            proxy_password=proxy_password,
        )

        assert proxy_options.proxy_password == proxy_password
예제 #9
0
    def proxy_options(self, request):
        if "HTTP" in request.param:
            proxy_type = "HTTP"
        elif "SOCKS4" in request.param:
            proxy_type = "SOCKS4"
        else:
            proxy_type = "SOCKS5"

        if "No Auth" in request.param:
            proxy = ProxyOptions(proxy_type=proxy_type,
                                 proxy_addr="127.0.0.1",
                                 proxy_port=1080)
        else:
            proxy = ProxyOptions(
                proxy_type=proxy_type,
                proxy_addr="127.0.0.1",
                proxy_port=1080,
                proxy_username="******",
                proxy_password="******",
            )
        return proxy
 def test_proxy_port_read_only(self):
     proxy_options = ProxyOptions(proxy_type=socks.HTTP, proxy_addr="127.0.0.1", proxy_port=8888)
     with pytest.raises(AttributeError):
         proxy_options.proxy_port = "new value"
    def test_proxy_address(self):
        proxy_addr = "127.0.0.1"
        proxy_options = ProxyOptions(proxy_type=socks.HTTP, proxy_addr=proxy_addr, proxy_port=8888)

        assert proxy_options.proxy_address == proxy_addr
 def test_invalid_proxy_type(self):
     with pytest.raises(ValueError):
         ProxyOptions(proxy_type="INVALID", proxy_addr="127.0.0.1", proxy_port=8888)
 def test_proxy_password_default(self):
     proxy_options = ProxyOptions(proxy_type=socks.HTTP, proxy_addr="127.0.0.1", proxy_port=8888)
     assert proxy_options.proxy_password is None
 def test_proxy_username_read_only(self, mocker):
     proxy_options = ProxyOptions(proxy_type=mocker.MagicMock(),
                                  proxy_addr="127.0.0.1",
                                  proxy_port=8888)
     with pytest.raises(AttributeError):
         proxy_options.proxy_username = "******"
 def test_proxy_username_default(self, mocker):
     proxy_options = ProxyOptions(proxy_type=mocker.MagicMock(),
                                  proxy_addr="127.0.0.1",
                                  proxy_port=8888)
     assert proxy_options.proxy_username is None