def test_get_proxies_with_https_proxy(self): CONF.set_override('https_proxy', 'example.org', 'proxy') result = utils.get_proxies() self.assertIsNone(result.get('no_proxy')) self.assertIsNone(result.get('http')) self.assertEqual('example.org', result.get('https'))
def __init__(self, username, password): # Prepare a SUDS transport with the approperiate credentials transport = EnhancedDNSHttpAuthenticated(username=username, password=password, proxy=utils.get_proxies()) # Prepare a SUDS client self.client = SudsClient(CONF['backend:akamai'].enhanceddns_wsdl, transport=transport)
def test_get_proxies(self): CONF.set_override('no_proxy', 'example.com', 'proxy') CONF.set_override('http_proxy', 'example.org', 'proxy') CONF.set_override('https_proxy', 'example.net', 'proxy') result = utils.get_proxies() self.assertEqual(['example.com'], result.get('no_proxy')) self.assertEqual('example.org', result.get('http')) self.assertEqual('example.net', result.get('https'))
def __init__(self, username, password): # Prepare a SUDS transport with the approperiate credentials transport = EnhancedDNSHttpAuthenticated( username=username, password=password, proxy=utils.get_proxies()) # Prepare a SUDS client self.client = SudsClient(CONF['backend:akamai'].enhanceddns_wsdl, transport=transport)
def _request(self, method, url, **kwargs): """ Low level request helper that actually executes the request towards a wanted URL. This does NOT do any authentication. """ # NOTE: Allow passing the url as just the path or a full url if not url.startswith('http'): if not url.startswith('/REST'): url = '/REST' + url url = self.endpoint + url kwargs.setdefault("headers", kwargs.get("headers", {})) kwargs['proxies'] = utils.get_proxies() if self.token is not None: kwargs['headers']['Auth-Token'] = self.token if self.timeout is not None: kwargs.setdefault("timeout", self.timeout) data = kwargs.get('data') if data is not None: kwargs['data'] = data.copy() # NOTE: We don't want to log the credentials (password) that are # used in a auth request. if 'password' in kwargs['data']: kwargs['data']['password'] = '******' self._http_log_req(method, url, kwargs) # NOTE: Set it back to the original data and serialize it. kwargs['data'] = json.dumps(data) else: self._http_log_req(method, url, kwargs) if self.timings: start_time = time.time() resp = self.http.request(method, url, **kwargs) if self.timings: self.times.append(("%s %s" % (method, url), start_time, time.time())) self._http_log_resp(resp) if resp.status_code >= 400: LOG.debug( "Request returned failure status: %s" % resp.status_code) raise DynClientError.from_response(resp) return resp
def _request(self, method, url, **kwargs): """ Low level request helper that actually executes the request towards a wanted URL. This does NOT do any authentication. """ # NOTE: Allow passing the url as just the path or a full url if not url.startswith('http'): if not url.startswith('/REST'): url = '/REST' + url url = self.endpoint + url kwargs.setdefault("headers", kwargs.get("headers", {})) kwargs['proxies'] = utils.get_proxies() if self.token is not None: kwargs['headers']['Auth-Token'] = self.token if self.timeout is not None: kwargs.setdefault("timeout", self.timeout) data = kwargs.get('data') if data is not None: kwargs['data'] = data.copy() # NOTE: We don't want to log the credentials (password) that are # used in a auth request. if 'password' in kwargs['data']: kwargs['data']['password'] = '******' self._http_log_req(method, url, kwargs) # NOTE: Set it back to the original data and serialize it. kwargs['data'] = json.dumps(data) else: self._http_log_req(method, url, kwargs) if self.timings: start_time = time.time() resp = self.http.request(method, url, **kwargs) if self.timings: self.times.append(("%s %s" % (method, url), start_time, time.time())) self._http_log_resp(resp) if resp.status_code >= 400: LOG.debug( "Request returned failure status: %s", resp.status_code) raise DynClientError.from_response(resp) return resp
def __init__(self, username, password): # Ensure Suds (or suds-jerko) have been installed if SudsClient is None: raise EnhancedDNSException( "Dependancy missing, please install suds or suds-jurko") # Prepare a SUDS transport with the approperiate credentials transport = EnhancedDNSHttpAuthenticated(username=username, password=password, proxy=utils.get_proxies()) # Prepare a SUDS client self.client = SudsClient(CONF['backend:akamai'].enhanceddns_wsdl, transport=transport)
def __init__(self, username, password): # Ensure Suds (or suds-jerko) have been installed if SudsClient is None: raise EnhancedDNSException( "Dependency missing, please install suds or suds-jurko") # Prepare a SUDS transport with the appropriate credentials transport = EnhancedDNSHttpAuthenticated( username=username, password=password, proxy=utils.get_proxies()) # Prepare a SUDS client self.client = SudsClient(CONF['backend:akamai'].enhanceddns_wsdl, transport=transport)
def test_get_proxies_default_values(self): result = utils.get_proxies() self.assertIsNone(result.get('no_proxy')) self.assertIsNone(result.get('http')) self.assertIsNone(result.get('https'))