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

fix: Removing extraneous space inserted during refactoring commit 894484a #3523

Merged
merged 1 commit into from
Sep 19, 2022
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
5 changes: 4 additions & 1 deletion insights/client/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ def get_proxy(self, proxy_info, no_proxy_info, environment):
if no_proxy_info:
insights_service_host = urlparse(self.base_url).hostname
logger.debug('Found NO_PROXY set. Checking NO_PROXY %s against base URL %s.', no_proxy_info, insights_service_host)
for no_proxy_host in no_proxy_info.split(', '):
# Split the no_proxy entries on ',', then strip any leading and trailing whitespace. Create a clean list for the
# for loop.
no_proxy_info = [host.strip() for host in no_proxy_info.split(',')]
for no_proxy_host in no_proxy_info:
logger.debug('Checking %s against %s', no_proxy_host, insights_service_host)
if no_proxy_host == '*':
proxies = None
Expand Down
40 changes: 40 additions & 0 deletions insights/tests/client/connection/test_init_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ def test_get_no_proxy_env():
connection.get_proxies()
assert connection.proxies is None

with patch.dict(os_environ, {"HTTPS_PROXY": "env.proxy.example.com", "NO_PROXY": "redhat.com,example.com"}, clear=True):
ahitacat marked this conversation as resolved.
Show resolved Hide resolved
connection.get_proxies()
assert connection.proxies is None

with patch.dict(os_environ, {"HTTPS_PROXY": "env.proxy.example.com", "NO_PROXY": "url.com,example.com"}, clear=True):
connection.get_proxies()
assert connection.proxies == {'https': 'env.proxy.example.com'}

with patch.dict(os_environ, {"HTTPS_PROXY": "env.proxy.example.com", "NO_PROXY": "url.com"}, clear=True):
connection.get_proxies()
assert connection.proxies == {'https': 'env.proxy.example.com'}
Expand Down Expand Up @@ -111,6 +119,38 @@ def test_get_no_proxy_rhsm():
connection.get_proxies()
assert connection.proxies == {"https": config.proxy}

config.no_proxy = "example.com,url.com"
connection.get_proxies()
assert connection.proxies == {"https": config.proxy}

config.no_proxy = "example.com, url.com"
connection.get_proxies()
assert connection.proxies == {"https": config.proxy}

config.no_proxy = "example.com , url.com"
connection.get_proxies()
assert connection.proxies == {"https": config.proxy}

config.no_proxy = "redhat.com, example.com"
connection.get_proxies()
assert connection.proxies is None

config.no_proxy = "example.com, redhat.com"
connection.get_proxies()
assert connection.proxies is None

config.no_proxy = "redhat.com,example.com"
connection.get_proxies()
assert connection.proxies is None

config.no_proxy = "example.com,redhat.com"
connection.get_proxies()
assert connection.proxies is None

config.no_proxy = "example.com , redhat.com"
connection.get_proxies()
assert connection.proxies is None


@patch("insights.client.connection.logger.debug")
def test_get_rhsm_and_env(logger):
Expand Down