Deprecate use of cert and key

There was a comment to deprecate creating a Session with cert and
key rather than a tuple to cert.

Also, fixed places where the deprecated usage was being used.

bp deprecations

Change-Id: I3596635bbc5611dd002a8beb063540a8c284c192
This commit is contained in:
Brant Knudson
2015-07-26 08:00:33 -05:00
parent 58cc453b20
commit afcf4a163e
2 changed files with 12 additions and 9 deletions

View File

@@ -574,8 +574,11 @@ class Session(object):
verify = cacert or True verify = cacert or True
if cert and key: if cert and key:
# passing cert and key together is deprecated in favour of the warnings.warn(
# requests lib form of having the cert and key as a tuple 'Passing cert and key together is deprecated as of the 1.7.0 '
'release in favor of the requests library form of having the '
'cert and key as a tuple and may be removed in the 2.0.0 '
'release.', DeprecationWarning)
cert = (cert, key) cert = (cert, key)
return cls(verify=verify, cert=cert, **kwargs) return cls(verify=verify, cert=cert, **kwargs)
@@ -846,8 +849,8 @@ class Session(object):
kwargs['insecure'] = c.insecure kwargs['insecure'] = c.insecure
kwargs['cacert'] = c.cafile kwargs['cacert'] = c.cafile
kwargs['cert'] = c.certfile if c.certfile and c.keyfile:
kwargs['key'] = c.keyfile kwargs['cert'] = (c.certfile, c.keyfile)
kwargs['timeout'] = c.timeout kwargs['timeout'] = c.timeout
return cls._make(**kwargs) return cls._make(**kwargs)
@@ -904,8 +907,8 @@ class Session(object):
""" """
kwargs['insecure'] = args.insecure kwargs['insecure'] = args.insecure
kwargs['cacert'] = args.os_cacert kwargs['cacert'] = args.os_cacert
kwargs['cert'] = args.os_cert if args.os_cert and args.os_key:
kwargs['key'] = args.os_key kwargs['cert'] = (args.os_cert, args.os_key)
kwargs['timeout'] = args.timeout kwargs['timeout'] = args.timeout
return cls._make(**kwargs) return cls._make(**kwargs)

View File

@@ -29,7 +29,7 @@ RESPONSE_BODY = '{"hi": "there"}'
def get_client(): def get_client():
cl = httpclient.HTTPClient(username="username", password="password", cl = httpclient.HTTPClient(username="username", password="password",
project_id="tenant", auth_url="auth_test", project_id="tenant", auth_url="auth_test",
cacert="ca.pem", key="key.pem", cert="cert.pem") cacert="ca.pem", cert=('cert.pem', "key.pem"))
return cl return cl
@@ -85,8 +85,8 @@ class ClientTest(utils.TestCase):
MOCK_REQUEST.return_value = FAKE_RESPONSE MOCK_REQUEST.return_value = FAKE_RESPONSE
cl = httpclient.HTTPClient( cl = httpclient.HTTPClient(
username="username", password="password", project_id="tenant", username="username", password="password", project_id="tenant",
auth_url="auth_test", cacert="ca.pem", key="key.pem", auth_url="auth_test", cacert="ca.pem", cert=('cert.pem', 'key.pem')
cert="cert.pem") )
cl.management_url = "https://127.0.0.1:5000" cl.management_url = "https://127.0.0.1:5000"
cl.auth_token = "token" cl.auth_token = "token"
with self.deprecations.expect_deprecations_here(): with self.deprecations.expect_deprecations_here():