Adds timeouts to Quobyte driver file

To appease Bandit, timeouts have to be
everywhere. So here are some timeouts
so Bandit stops crying.

Change-Id: I2a913f3b87e16554b1bd68543fcf254cc4226031
This commit is contained in:
Ubuntu 2024-04-09 03:07:52 +00:00
parent 36549c8b97
commit 32ac176053
2 changed files with 20 additions and 10 deletions

View File

@ -82,16 +82,19 @@ class JsonRpc(object):
json=post_data,
auth=self._credentials,
verify=self._ca_file,
cert=(self._cert_file, self._key_file))
cert=(self._cert_file, self._key_file),
timeout=60)
else:
result = requests.post(url=self._url,
json=post_data,
auth=self._credentials,
verify=self._ca_file)
verify=self._ca_file,
timeout=60)
else:
result = requests.post(url=self._url,
json=post_data,
auth=self._credentials)
auth=self._credentials,
timeout=60)
# eval request response
if result.status_code == codes['OK']:

View File

@ -53,7 +53,8 @@ class QuobyteJsonRpcTestCase(test.TestCase):
req_get_mock.assert_called_once_with(
url='http://test',
auth=auth.HTTPBasicAuth("me", "team"),
json=mock.ANY)
json=mock.ANY,
timeout=60)
def test_jsonrpc_init_with_ca(self):
foofile = tempfile.TemporaryFile()
@ -98,7 +99,8 @@ class QuobyteJsonRpcTestCase(test.TestCase):
mock_req_get.assert_called_once_with(
url=self.rpc._url,
json=mock.ANY, # not checking here as of undefined order in dict
auth=self.rpc._credentials)
auth=self.rpc._credentials,
timeout=60)
self.assertEqual("Sweet gorilla of Manila", result)
@mock.patch.object(requests, "post",
@ -119,7 +121,8 @@ class QuobyteJsonRpcTestCase(test.TestCase):
json=mock.ANY, # not checking here as of undefined order in dict
auth=self.rpc._credentials,
verify=False,
cert=(fake_cert_file, fake_key_file))
cert=(fake_cert_file, fake_key_file),
timeout=60)
self.assertEqual("Sweet gorilla of Manila", result)
@mock.patch.object(requests, "post",
@ -137,7 +140,8 @@ class QuobyteJsonRpcTestCase(test.TestCase):
url=self.rpc._url,
json=mock.ANY, # not checking here as of undefined order in dict
auth=self.rpc._credentials,
verify=fake_ca_file)
verify=fake_ca_file,
timeout=60)
self.assertEqual("Sweet gorilla of Manila", result)
@mock.patch.object(jsonrpc.JsonRpc, "_checked_for_application_error",
@ -158,7 +162,8 @@ class QuobyteJsonRpcTestCase(test.TestCase):
url=self.rpc._url,
json=mock.ANY, # not checking here as of undefined order in dict
auth=self.rpc._credentials,
verify=fake_ca_file)
verify=fake_ca_file,
timeout=60)
mock_check.assert_called_once_with(
{'result': 'Sweet gorilla of Manila'}, [42])
self.assertEqual("Sweet gorilla of Manila", result)
@ -171,7 +176,8 @@ class QuobyteJsonRpcTestCase(test.TestCase):
req_get_mock.assert_called_once_with(
url=self.rpc._url,
json=mock.ANY, # not checking here as of undefined order in dict
auth=self.rpc._credentials)
auth=self.rpc._credentials,
timeout=60)
@mock.patch.object(requests, "post",
return_value=FakeResponse(
@ -183,7 +189,8 @@ class QuobyteJsonRpcTestCase(test.TestCase):
req_get_mock.assert_called_once_with(
url=self.rpc._url,
json=mock.ANY, # not checking here as of undefined order in dict
auth=self.rpc._credentials)
auth=self.rpc._credentials,
timeout=60)
def test_checked_for_application_error(self):
resultdict = {"result": "Sweet gorilla of Manila"}