diff --git a/py/selenium/webdriver/common/proxy.py b/py/selenium/webdriver/common/proxy.py index 328a3a46ce464..187f00418a421 100644 --- a/py/selenium/webdriver/common/proxy.py +++ b/py/selenium/webdriver/common/proxy.py @@ -14,8 +14,11 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. + """The Proxy implementation.""" +import warnings + class ProxyTypeFactory: """Factory for proxy types.""" @@ -28,8 +31,8 @@ def make(ff_value, string): class ProxyType: """Set of possible types of proxy. - Each proxy type has 2 properties: 'ff_value' is value of Firefox - profile preference, 'string' is id of proxy type. + Each proxy type has 2 properties: 'ff_value' is value of Firefox + profile preference, 'string' is id of proxy type. """ DIRECT = ProxyTypeFactory.make(0, "DIRECT") # Direct connection, no proxy (default on Windows). @@ -63,6 +66,14 @@ def __get__(self, obj, cls): def __set__(self, obj, value): if self.name == "autodetect" and not isinstance(value, bool): raise ValueError("Autodetect proxy value needs to be a boolean") + if self.name == "ftpProxy": + # TODO: Remove ftpProxy in future version and remove deprecation warning + # https://github.com/SeleniumHQ/selenium/issues/15905 + warnings.warn( + "ftpProxy is deprecated and will be removed in the future", + DeprecationWarning, + stacklevel=2, + ) getattr(obj, "_verify_proxy_type_compatibility")(self.p_type) setattr(obj, "proxyType", self.p_type) setattr(obj, self.name, value) @@ -74,7 +85,7 @@ class Proxy: proxyType = ProxyType.UNSPECIFIED autodetect = False - ftpProxy = "" + ftpProxy = "" # TODO: Remove ftpProxy in future version and remove deprecation warning httpProxy = "" noProxy = "" proxyAutoconfigUrl = "" @@ -100,6 +111,7 @@ class Proxy: `value`: `str` """ + # TODO: Remove ftpProxy in future version and remove deprecation warning ftp_proxy = _ProxyTypeDescriptor("ftpProxy", ProxyType.MANUAL) """Gets and Sets `ftp_proxy` @@ -244,7 +256,14 @@ def __init__(self, raw=None): if raw: if "proxyType" in raw and raw["proxyType"]: self.proxy_type = ProxyType.load(raw["proxyType"]) + # TODO: Remove ftpProxy in future version and remove deprecation warning + # https://github.com/SeleniumHQ/selenium/issues/15905 if "ftpProxy" in raw and raw["ftpProxy"]: + warnings.warn( + "ftpProxy is deprecated and will be removed in the future", + DeprecationWarning, + stacklevel=2, + ) self.ftp_proxy = raw["ftpProxy"] if "httpProxy" in raw and raw["httpProxy"]: self.http_proxy = raw["httpProxy"] @@ -288,6 +307,7 @@ def _verify_proxy_type_compatibility(self, compatible_proxy): def to_capabilities(self): proxy_caps = {"proxyType": self.proxyType["string"].lower()} + # TODO: Remove ftpProxy in future version and remove deprecation warning proxies = [ "autodetect", "ftpProxy", diff --git a/py/test/selenium/webdriver/common/proxy_tests.py b/py/test/selenium/webdriver/common/proxy_tests.py index 6654b5b6c1cbd..df287593f3640 100644 --- a/py/test/selenium/webdriver/common/proxy_tests.py +++ b/py/test/selenium/webdriver/common/proxy_tests.py @@ -22,6 +22,8 @@ MANUAL_PROXY = { "httpProxy": "some.url:1234", + # TODO: Remove ftpProxy in future (currently deprecated) + # https://github.com/SeleniumHQ/selenium/issues/15905 "ftpProxy": "ftp.proxy", "noProxy": "localhost, foo.localhost", "sslProxy": "ssl.proxy:1234", @@ -43,6 +45,8 @@ def test_can_add_manual_proxy_to_options(): proxy = Proxy() proxy.http_proxy = MANUAL_PROXY["httpProxy"] + # TODO: Remove ftpProxy in future (currently deprecated) + # https://github.com/SeleniumHQ/selenium/issues/15905 proxy.ftp_proxy = MANUAL_PROXY["ftpProxy"] proxy.no_proxy = MANUAL_PROXY["noProxy"] proxy.sslProxy = MANUAL_PROXY["sslProxy"] @@ -98,6 +102,8 @@ def test_can_init_manual_proxy(): assert ProxyType.MANUAL == proxy.proxy_type assert MANUAL_PROXY["httpProxy"] == proxy.http_proxy + # TODO: Remove ftpProxy in future (currently deprecated) + # https://github.com/SeleniumHQ/selenium/issues/15905 assert MANUAL_PROXY["ftpProxy"] == proxy.ftp_proxy assert MANUAL_PROXY["noProxy"] == proxy.no_proxy assert MANUAL_PROXY["sslProxy"] == proxy.sslProxy @@ -123,6 +129,8 @@ def test_can_init_empty_proxy(): proxy = Proxy() assert ProxyType.UNSPECIFIED == proxy.proxy_type assert "" == proxy.http_proxy + # TODO: Remove ftpProxy in future (currently deprecated) + # https://github.com/SeleniumHQ/selenium/issues/15905 assert "" == proxy.ftp_proxy assert "" == proxy.no_proxy assert "" == proxy.sslProxy