def get_http_proxy(http_proxy): """Returns proxy URL to be used for HTTP requests Pass a value configured by the user using the HTTPProxyReference valuespec to this function and you will get back ether a proxy URL, an empty string to enforce no proxy usage or None to use the proxy configuration from the process environment. """ return _config.get_http_proxy(http_proxy)
def add_to_event_context(plugin_context, prefix, param, log_function): if isinstance(param, list): plugin_context[prefix + "S"] = " ".join(param) for nr, value in enumerate(param): add_to_event_context(plugin_context, "%s_%d" % (prefix, nr + 1), value, log_function) elif isinstance(param, dict): for key, value in param.items(): varname = "%s_%s" % (prefix, key.upper()) if varname == "PARAMETER_PROXY_URL": # Compatibility for 1.5 pushover explicitly configured proxy URL format if isinstance(value, str): value = ("url", value) value = config.get_http_proxy(value) if value is None: continue add_to_event_context(plugin_context, varname, value, log_function) else: plugin_context[prefix] = plugin_param_to_string(param)
def test_http_proxy(http_proxy, result, monkeypatch): monkeypatch.setattr( config, "http_proxies", { "http_blub": { "ident": "blub", "title": "HTTP blub", "proxy_url": "http://*****:*****@socks.proxy:443", }, }) assert config.get_http_proxy(http_proxy) == result