Skip to content

Commit

Permalink
Remove 'resolve_ip' option from RemoteConnection
Browse files Browse the repository at this point in the history
Resolving the IP within Selenium is never necessary; This is always the wrong thing to do when dealing with HTTPS connections, as no certificates are issued for IP-addresses.

This is a conflict-free update of PR #3515.

Fixes #1729
Fixes #2509
  • Loading branch information
GQAssurance authored and AutomatedTester committed Jul 27, 2019
1 parent b300c35 commit db9ce7f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 36 deletions.
1 change: 0 additions & 1 deletion py/selenium/webdriver/edge/webdriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def __init__(self, executable_path='MicrosoftWebDriver.exe',
RemoteWebDriver.__init__(
self,
command_executor=RemoteConnection(self.service.service_url,
resolve_ip=False,
keep_alive=keep_alive),
desired_capabilities=capabilities)
self._is_remote = False
Expand Down
42 changes: 7 additions & 35 deletions py/selenium/webdriver/remote/remote_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
from urllib import parse
except ImportError: # above is available in py3+, below is py2.7
import urlparse as parse

from selenium.webdriver.common import utils as common_utils
from selenium import __version__
from .command import Command
from .errorhandler import ErrorCode
Expand Down Expand Up @@ -103,42 +101,16 @@ def get_remote_connection_headers(cls, parsed_url, keep_alive=False):

return headers

def __init__(self, remote_server_addr, keep_alive=False, resolve_ip=True):
# Attempt to resolve the hostname and get an IP address.
def __init__(self, remote_server_addr, keep_alive=False, resolve_ip=None):
if resolve_ip is not None:
import warnings
warnings.warn(
"'resolve_ip' option removed; ip addresses are now always resolved by urllib3.",
DeprecationWarning)
self.keep_alive = keep_alive
parsed_url = parse.urlparse(remote_server_addr)
if parsed_url.hostname and resolve_ip:
port = parsed_url.port or None
if parsed_url.scheme == "https":
ip = parsed_url.hostname
elif port and not common_utils.is_connectable(port, parsed_url.hostname):
ip = None
LOGGER.info('Could not connect to port {} on host '
'{}'.format(port, parsed_url.hostname))
else:
ip = common_utils.find_connectable_ip(parsed_url.hostname,
port=port)
if ip:
netloc = ip
if parsed_url.port:
netloc = common_utils.join_host_port(netloc,
parsed_url.port)
if parsed_url.username:
auth = parsed_url.username
if parsed_url.password:
auth += ':%s' % parsed_url.password
netloc = '%s@%s' % (auth, netloc)
remote_server_addr = parse.urlunparse(
(parsed_url.scheme, netloc, parsed_url.path,
parsed_url.params, parsed_url.query, parsed_url.fragment))
else:
LOGGER.info('Could not get IP address for host: %s' %
parsed_url.hostname)

self._url = remote_server_addr
if keep_alive:
self._conn = urllib3.PoolManager(timeout=self._timeout)

self._commands = {
Command.STATUS: ('GET', '/status'),
Command.NEW_SESSION: ('POST', '/session'),
Expand Down Expand Up @@ -357,7 +329,7 @@ def execute(self, command, params):
"""
Send a command to the remote server.
Any path subtitutions required for the URL mapped to the command should be
Any path substitutions required for the URL mapped to the command should be
included in the command parameters.
:Args:
Expand Down

0 comments on commit db9ce7f

Please sign in to comment.