Skip to content

Commit 02cc950

Browse files
committed
[py] Add test for warning when embedding user:pass in URL
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 9ae1d7b commit 02cc950

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

py/selenium/webdriver/remote/client_config.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,10 @@ def auth_type(self) -> str:
209209
@auth_type.setter
210210
def auth_type(self, value: str) -> None:
211211
"""Sets the type of authentication to the remote server if it is not
212-
using basic with username and password."""
212+
using basic with username and password.
213+
214+
Support values: Bearer, X-API-Key. For others, please use `extra_headers` instead
215+
"""
213216
self._auth_type = value
214217

215218
@property
@@ -220,10 +223,7 @@ def token(self) -> str:
220223
@token.setter
221224
def token(self, value: str) -> None:
222225
"""Sets the token used for authentication to the remote server if
223-
auth_type is not basic.
224-
225-
Support values: Bearer, X-API-Key. For others, please use `extra_headers` instead.
226-
"""
226+
auth_type is not basic."""
227227
self._token = value
228228

229229
@property

py/test/unit/selenium/webdriver/remote/remote_connection_tests.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@ def test_get_remote_connection_headers_defaults():
6969

7070
def test_get_remote_connection_headers_adds_auth_header_if_pass():
7171
url = "http://user:pass@remote"
72-
headers = RemoteConnection.get_remote_connection_headers(parse.urlparse(url))
72+
with pytest.warns(None) as record:
73+
headers = RemoteConnection.get_remote_connection_headers(parse.urlparse(url))
7374
assert headers.get("Authorization") == "Basic dXNlcjpwYXNz"
75+
assert (
76+
record[0].message.args[0]
77+
== "Embedding username and password in URL could be insecure, use ClientConfig instead"
78+
)
7479

7580

7681
def test_get_remote_connection_headers_adds_keep_alive_if_requested():

0 commit comments

Comments
 (0)