Browse Source

Properly pass the CA to requests

We store the CA in request.cert, but it's not compatible with a cert. To
pass the CA to requests, we need to set the verify argument.

Change-Id: Id0f39e3253b1486db8ae2da3d7dc6c0fdb41062a
changes/53/607553/2 stein-em
Thomas Herve 3 years ago
parent
commit
13e90a0ab5
  1. 6
      tests/unit/transport/test_http.py
  2. 10
      zaqarclient/transport/http.py

6
tests/unit/transport/test_http.py

@ -63,8 +63,7 @@ class TestHttpTransport(base.TestBase):
params=final_params,
headers=final_headers,
data=None,
verify=True,
cert=None)
verify=True)
@mock.patch.object(prequest.packages.urllib3.response.HTTPResponse,
'stream')
@ -91,8 +90,7 @@ class TestHttpTransport(base.TestBase):
params=params,
headers=final_headers,
data=None,
verify=True,
cert=None)
verify=True)
@mock.patch.object(prequest.packages.urllib3.response.HTTPResponse,
'stream')

10
zaqarclient/transport/http.py

@ -89,13 +89,19 @@ class HttpTransport(base.Transport):
if osprofiler_web:
headers.update(osprofiler_web.get_trace_id_headers())
if request.verify:
if request.cert:
verify = request.cert
else:
verify = True
else:
verify = False
resp = self.client.request(method,
url=url,
params=request.params,
headers=headers,
data=request.content,
verify=request.verify,
cert=request.cert)
verify=verify)
if resp.status_code in self.http_to_zaqar:
kwargs = {}

Loading…
Cancel
Save