Handle error for missing minor api version

Change the api version regex to forbid empty minor versions,
thereby ensuring that manilaclient raises an UnsupportedVersion
exception as one would expect in this case.

Change-Id: I93268b15ec0b5ee95ea3599bb75bf6fa364e0b91
Closes-Bug: #1590409
This commit is contained in:
Daniel Gonzalez 2016-06-08 14:07:10 +02:00
parent ef38f0565c
commit 0cf64700c3
3 changed files with 5 additions and 1 deletions

View File

@ -49,7 +49,7 @@ class APIVersion(object):
self.ver_minor = 0
if version_str is not None:
match = re.match(r"^([1-9]\d*)\.([1-9]\d*|0|)$", version_str)
match = re.match(r"^([1-9]\d*)\.([1-9]\d*|0)$", version_str)
if match:
self.ver_major = int(match.group(1))
self.ver_minor = int(match.group(2))

View File

@ -54,6 +54,7 @@ class APIVersionTestCase(utils.TestCase):
"",
" 2.1",
"2.1 ",
"2.",
)
def test_invalid_version_strings(self, version):
self.assertRaises(exceptions.UnsupportedVersion,

View File

@ -0,0 +1,3 @@
---
fixes:
- Added proper error handling for missing API minor version number.