Skip to content

Commit 21b10ad

Browse files
authored
[py] Deprecate support for FTP proxies (#15906)
1 parent 367c8c1 commit 21b10ad

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

py/selenium/webdriver/common/proxy.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
1718
"""The Proxy implementation."""
1819

20+
import warnings
21+
1922

2023
class ProxyTypeFactory:
2124
"""Factory for proxy types."""
@@ -28,8 +31,8 @@ def make(ff_value, string):
2831
class ProxyType:
2932
"""Set of possible types of proxy.
3033
31-
Each proxy type has 2 properties: 'ff_value' is value of Firefox
32-
profile preference, 'string' is id of proxy type.
34+
Each proxy type has 2 properties: 'ff_value' is value of Firefox
35+
profile preference, 'string' is id of proxy type.
3336
"""
3437

3538
DIRECT = ProxyTypeFactory.make(0, "DIRECT") # Direct connection, no proxy (default on Windows).
@@ -63,6 +66,14 @@ def __get__(self, obj, cls):
6366
def __set__(self, obj, value):
6467
if self.name == "autodetect" and not isinstance(value, bool):
6568
raise ValueError("Autodetect proxy value needs to be a boolean")
69+
if self.name == "ftpProxy":
70+
# TODO: Remove ftpProxy in future version and remove deprecation warning
71+
# https://github.com/SeleniumHQ/selenium/issues/15905
72+
warnings.warn(
73+
"ftpProxy is deprecated and will be removed in the future",
74+
DeprecationWarning,
75+
stacklevel=2,
76+
)
6677
getattr(obj, "_verify_proxy_type_compatibility")(self.p_type)
6778
setattr(obj, "proxyType", self.p_type)
6879
setattr(obj, self.name, value)
@@ -74,7 +85,7 @@ class Proxy:
7485

7586
proxyType = ProxyType.UNSPECIFIED
7687
autodetect = False
77-
ftpProxy = ""
88+
ftpProxy = "" # TODO: Remove ftpProxy in future version and remove deprecation warning
7889
httpProxy = ""
7990
noProxy = ""
8091
proxyAutoconfigUrl = ""
@@ -100,6 +111,7 @@ class Proxy:
100111
`value`: `str`
101112
"""
102113

114+
# TODO: Remove ftpProxy in future version and remove deprecation warning
103115
ftp_proxy = _ProxyTypeDescriptor("ftpProxy", ProxyType.MANUAL)
104116
"""Gets and Sets `ftp_proxy`
105117
@@ -244,7 +256,14 @@ def __init__(self, raw=None):
244256
if raw:
245257
if "proxyType" in raw and raw["proxyType"]:
246258
self.proxy_type = ProxyType.load(raw["proxyType"])
259+
# TODO: Remove ftpProxy in future version and remove deprecation warning
260+
# https://github.com/SeleniumHQ/selenium/issues/15905
247261
if "ftpProxy" in raw and raw["ftpProxy"]:
262+
warnings.warn(
263+
"ftpProxy is deprecated and will be removed in the future",
264+
DeprecationWarning,
265+
stacklevel=2,
266+
)
248267
self.ftp_proxy = raw["ftpProxy"]
249268
if "httpProxy" in raw and raw["httpProxy"]:
250269
self.http_proxy = raw["httpProxy"]
@@ -288,6 +307,7 @@ def _verify_proxy_type_compatibility(self, compatible_proxy):
288307

289308
def to_capabilities(self):
290309
proxy_caps = {"proxyType": self.proxyType["string"].lower()}
310+
# TODO: Remove ftpProxy in future version and remove deprecation warning
291311
proxies = [
292312
"autodetect",
293313
"ftpProxy",

py/test/selenium/webdriver/common/proxy_tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222

2323
MANUAL_PROXY = {
2424
"httpProxy": "some.url:1234",
25+
# TODO: Remove ftpProxy in future (currently deprecated)
26+
# https://github.com/SeleniumHQ/selenium/issues/15905
2527
"ftpProxy": "ftp.proxy",
2628
"noProxy": "localhost, foo.localhost",
2729
"sslProxy": "ssl.proxy:1234",
@@ -43,6 +45,8 @@
4345
def test_can_add_manual_proxy_to_options():
4446
proxy = Proxy()
4547
proxy.http_proxy = MANUAL_PROXY["httpProxy"]
48+
# TODO: Remove ftpProxy in future (currently deprecated)
49+
# https://github.com/SeleniumHQ/selenium/issues/15905
4650
proxy.ftp_proxy = MANUAL_PROXY["ftpProxy"]
4751
proxy.no_proxy = MANUAL_PROXY["noProxy"]
4852
proxy.sslProxy = MANUAL_PROXY["sslProxy"]
@@ -98,6 +102,8 @@ def test_can_init_manual_proxy():
98102

99103
assert ProxyType.MANUAL == proxy.proxy_type
100104
assert MANUAL_PROXY["httpProxy"] == proxy.http_proxy
105+
# TODO: Remove ftpProxy in future (currently deprecated)
106+
# https://github.com/SeleniumHQ/selenium/issues/15905
101107
assert MANUAL_PROXY["ftpProxy"] == proxy.ftp_proxy
102108
assert MANUAL_PROXY["noProxy"] == proxy.no_proxy
103109
assert MANUAL_PROXY["sslProxy"] == proxy.sslProxy
@@ -123,6 +129,8 @@ def test_can_init_empty_proxy():
123129
proxy = Proxy()
124130
assert ProxyType.UNSPECIFIED == proxy.proxy_type
125131
assert "" == proxy.http_proxy
132+
# TODO: Remove ftpProxy in future (currently deprecated)
133+
# https://github.com/SeleniumHQ/selenium/issues/15905
126134
assert "" == proxy.ftp_proxy
127135
assert "" == proxy.no_proxy
128136
assert "" == proxy.sslProxy

0 commit comments

Comments
 (0)