From 687153838b73dc950993d08fc5405ccf6d52b996 Mon Sep 17 00:00:00 2001 From: Valeriy Ponomaryov Date: Thu, 6 Aug 2015 14:13:24 +0300 Subject: [PATCH] Make QuobyteHttpsConnectionWithCaVerification py3 compatible Class 'QuobyteHttpsConnectionWithCaVerification' inherits 'http_client.HTTPConnection' and the latter does not have param 'strict' in py3 anymore. So, remove it as it is not used anyway. Also, fix some quobyte things mocking to satisfy py2/3 compatibility. Change-Id: I422f816c4fa134e08cce811bd44e7021893516bd Partially-Implements: bp py3-compatibility --- manila/share/drivers/quobyte/jsonrpc.py | 4 ++-- manila/tests/share/drivers/quobyte/test_jsonrpc.py | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/manila/share/drivers/quobyte/jsonrpc.py b/manila/share/drivers/quobyte/jsonrpc.py index f06854aa44..05bc04fc40 100644 --- a/manila/share/drivers/quobyte/jsonrpc.py +++ b/manila/share/drivers/quobyte/jsonrpc.py @@ -61,9 +61,9 @@ class HTTPSConnectionWithCaVerification(http_client.HTTPConnection): default_port = http_client.HTTPS_PORT def __init__(self, host, port=None, key_file=None, cert_file=None, - ca_file=None, strict=None, + ca_file=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT): - http_client.HTTPConnection.__init__(self, host, port, strict, timeout) + http_client.HTTPConnection.__init__(self, host, port, timeout=timeout) self.key_file = key_file self.cert_file = cert_file self.ca_file = ca_file diff --git a/manila/tests/share/drivers/quobyte/test_jsonrpc.py b/manila/tests/share/drivers/quobyte/test_jsonrpc.py index a17cf8498a..b24c54f9f1 100644 --- a/manila/tests/share/drivers/quobyte/test_jsonrpc.py +++ b/manila/tests/share/drivers/quobyte/test_jsonrpc.py @@ -61,7 +61,6 @@ class QuobyteHttpsConnectionWithCaVerificationTestCase(test.TestCase): key_file=key_file, cert_file=cert_file, ca_file=ca_file, - strict="anything", port=1234, timeout=999)) @@ -90,7 +89,6 @@ class QuobyteHttpsConnectionWithCaVerificationTestCase(test.TestCase): key_file=key_file, cert_file=cert_file, ca_file=ca_file, - strict="anything", port=1234, timeout=999)) mycon._tunnel_host = "fake_tunnel_host" @@ -180,13 +178,17 @@ class QuobyteJsonRpcTestCase(test.TestCase): self.rpc._connection, 'request', mock.Mock(side_effect=ssl.SSLError)) + self.mock_object( + self.rpc._connection, + 'getresponse', + mock.Mock(return_value=FakeResponse( + 403, '{"error":{"code":28,"message":"text"}}'))) self.mock_object(jsonrpc.LOG, 'warning') - self.mock_object(http_client, 'HTTPSConnection') self.assertRaises(exception.QBException, self.rpc.call, 'method', {'param': 'value'}) - http_client.HTTPSConnection.assert_called_once_with(self.rpc._netloc) + self.assertTrue(self.rpc._disabled_cert_verification) jsonrpc.LOG.warning.assert_called_once_with( "Could not verify server certificate of "