def __init__(self, endpoint, **kwargs): self.endpoint = endpoint self.identity_headers = kwargs.get('identity_headers') self.auth_token = kwargs.get('token') if self.identity_headers: if self.identity_headers.get('X-Auth-Token'): self.auth_token = self.identity_headers.get('X-Auth-Token') del self.identity_headers['X-Auth-Token'] self.session = requests.Session() self.session.headers["User-Agent"] = USER_AGENT self.session.headers["X-Auth-Token"] = self.auth_token self.timeout = float(kwargs.get('timeout', 600)) if self.endpoint.startswith("https"): compression = kwargs.get('ssl_compression', True) if not compression: self.session.mount("https://", https.HTTPSAdapter()) self.session.verify = kwargs.get('cacert', not kwargs.get('insecure', True)) self.session.cert = (kwargs.get('cert_file'), kwargs.get('key_file'))
def test__create_glance_httpsconnectionpool(self): """Regression test Check that glanceclient's https pool is properly configured without any weird exception. """ url = 'https://127.0.0.1:8000' adapter = https.HTTPSAdapter() try: adapter._create_glance_httpsconnectionpool(url) except Exception: self.fail('Unexpected exception has been raised')