diff --git a/cinder/tests/unit/volume/drivers/synology/test_synology_common.py b/cinder/tests/unit/volume/drivers/synology/test_synology_common.py index 93755fbb69f..94c7425dfb4 100644 --- a/cinder/tests/unit/volume/drivers/synology/test_synology_common.py +++ b/cinder/tests/unit/volume/drivers/synology/test_synology_common.py @@ -23,6 +23,7 @@ from unittest import mock from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.asymmetric import padding from cryptography.hazmat.primitives.asymmetric import rsa +import ddt from oslo_utils import units import requests from six.moves import http_client @@ -323,6 +324,7 @@ class SynoSessionTestCase(test.TestCase): ) +@ddt.ddt class SynoAPIRequestTestCase(test.TestCase): @mock.patch('requests.post') def setUp(self, _mock_post): @@ -427,7 +429,8 @@ class SynoAPIRequestTestCase(test.TestCase): {'http_status': http_client.INTERNAL_SERVER_ERROR}, result) @mock.patch.object(common.LOG, 'debug') - def test_request_auth_error(self, _log): + @ddt.data(105, 119) + def test_request_auth_error(self, _code, _log): version = 1 self.request._start = mock.Mock(return_value='fake.cgi') @@ -435,7 +438,7 @@ class SynoAPIRequestTestCase(test.TestCase): self.request.new_session = mock.Mock() requests.post = mock.Mock(return_value= MockResponse({ - 'error': {'code': 105}, + 'error': {'code': _code}, 'success': False }, http_client.OK)) diff --git a/cinder/volume/drivers/synology/synology_common.py b/cinder/volume/drivers/synology/synology_common.py index 9badbb28535..dc2d1b87b2a 100644 --- a/cinder/volume/drivers/synology/synology_common.py +++ b/cinder/volume/drivers/synology/synology_common.py @@ -400,7 +400,7 @@ class APIRequest(object): reason=reason) if ('error' in result and 'code' in result["error"] - and result['error']['code'] == 105): + and result['error']['code'] in [105, 119]): raise SynoAuthError(reason=_('Session might have expired.')) return result