Skip to content

Commit

Permalink
Fix proxy formating when user or password aren't set
Browse files Browse the repository at this point in the history
  • Loading branch information
hush-hush committed Aug 20, 2018
1 parent 76e6b04 commit 2085639
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion checks/check_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,21 @@ def validate_api_key(config):
proxy = get_proxy(agentConfig=config)
request_proxy = {}
if proxy:
request_proxy = {'https': "http://{user}:{password}@{host}:{port}".format(**proxy)}
# key might set to None
user = proxy.get("user", "") or ""
password = proxy.get("password", "") or ""
if user:
if password:
user += ":" + password
user += "@"

host = proxy.get("host", "") or ""
port = proxy.get("port", "") or ""
if host and port:
host += ":" + str(proxy["port"])

request_proxy = {'https': "http://%s%s" % (user, host)}

r = requests.get("%s/api/v1/validate" % config['dd_url'].rstrip('/'),
params={'api_key': config.get('api_key')}, proxies=request_proxy,
timeout=3, verify=(not config.get('skip_ssl_validation', False)))
Expand Down

0 comments on commit 2085639

Please sign in to comment.