Skip to content

Commit

Permalink
[py] Add test for warning when embedding user:pass in URL
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 committed Nov 6, 2024
1 parent 9ae1d7b commit 02cc950
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 5 additions & 5 deletions py/selenium/webdriver/remote/client_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,10 @@ def auth_type(self) -> str:
@auth_type.setter
def auth_type(self, value: str) -> None:
"""Sets the type of authentication to the remote server if it is not
using basic with username and password."""
using basic with username and password.
Support values: Bearer, X-API-Key. For others, please use `extra_headers` instead
"""
self._auth_type = value

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

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@ def test_get_remote_connection_headers_defaults():

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


def test_get_remote_connection_headers_adds_keep_alive_if_requested():
Expand Down

0 comments on commit 02cc950

Please sign in to comment.