Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[py] use get_timeout() for urllib pool manager timeouts in remote connection, prevents passing the default socket object directly #10563

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion py/selenium/webdriver/remote/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def _seperate_http_proxy_auth(self):

def _get_connection_manager(self):
pool_manager_init_args = {
'timeout': self._timeout
'timeout': self.get_timeout()
}
if self._ca_certs:
pool_manager_init_args['cert_reqs'] = 'CERT_REQUIRED'
Expand Down
17 changes: 10 additions & 7 deletions py/test/unit/selenium/webdriver/remote/remote_connection_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,10 @@
# specific language governing permissions and limitations
# under the License.


import urllib3
import pytest


from urllib import parse

import pytest
import urllib3

from selenium import __version__
from selenium.webdriver.remote.remote_connection import (
Expand Down Expand Up @@ -96,15 +93,21 @@ def test_get_connection_manager_without_proxy(mock_proxy_settings_missing):
assert type(conn) == urllib3.PoolManager


def test_get_connection_manager_for_certs_and_timeout():
def test_get_connection_manager_for_certs_and_timeout(monkeypatch):
monkeypatch.setattr(RemoteConnection, "get_timeout", lambda _: 10) # Class state; leaks into subsequent tests.
remote_connection = RemoteConnection('http://remote', keep_alive=False)
remote_connection.set_timeout(10)
conn = remote_connection._get_connection_manager()
assert conn.connection_pool_kw['timeout'] == 10
assert conn.connection_pool_kw['cert_reqs'] == 'CERT_REQUIRED'
assert 'certifi/cacert.pem' in conn.connection_pool_kw['ca_certs']


def test_default_socket_timeout_is_correct():
remote_connection = RemoteConnection("http://remote", keep_alive=True)
conn = remote_connection._get_connection_manager()
assert conn.connection_pool_kw['timeout'] is None


def test_get_connection_manager_with_proxy(mock_proxy_settings):
remote_connection = RemoteConnection('http://remote', keep_alive=False)
conn = remote_connection._get_connection_manager()
Expand Down