Support "-" in region name for FIP's
After moving to raw strings for regular expressions region names with a "-" in name have been broken because raw string duplicates backslashes and it was two backslashes in inital regular experession. With this changes extra back slash deleted what is correct to r'' string. Closes-Bug: 2096623 Change-Id: Ibdf8d93bdb8926b22c3ac978ccb72d795ad4c581 (cherry picked from commitfed6500d22) (cherry picked from commit5490df4e6b) (cherry picked from commita33f737640)
This commit is contained in:
@@ -75,7 +75,7 @@ RE_CERT_TYPE = re.compile(r'(^[A-Z]+$)|(^[0-9]+$)')
|
||||
RE_CERT_ALGO = re.compile(r'(^[A-Z]+[A-Z0-9\-]+[A-Z0-9]$)|(^[0-9]+$)')
|
||||
|
||||
# Floating IP regexes
|
||||
RE_FIP = re.compile(r'^(?P<region>[A-Za-z0-9\\.\\-_]{1,100}):(?P<id>[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$') # noqa
|
||||
RE_FIP = re.compile(r'^(?P<region>[A-Za-z0-9\.\-_]{1,100}):(?P<id>[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$') # noqa
|
||||
|
||||
# Error Validation regexes
|
||||
RE_REQUIRED = re.compile(r'\'([\w]*)\' is a required property')
|
||||
|
||||
@@ -33,6 +33,37 @@ class FloatingIPTest(oslotest.base.BaseTestCase):
|
||||
)
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
('region-one', '2fc6745d-1631-4f34-b13d-90f9014236c0'),
|
||||
floatingips.fip_key_to_data(
|
||||
'region-one:2fc6745d-1631-4f34-b13d-90f9014236c0'
|
||||
)
|
||||
)
|
||||
self.assertEqual(
|
||||
('region-1', '2fc6745d-1631-4f34-b13d-90f9014236c0'),
|
||||
floatingips.fip_key_to_data(
|
||||
'region-1:2fc6745d-1631-4f34-b13d-90f9014236c0'
|
||||
)
|
||||
)
|
||||
self.assertEqual(
|
||||
('region-1-test', '2fc6745d-1631-4f34-b13d-90f9014236c0'),
|
||||
floatingips.fip_key_to_data(
|
||||
'region-1-test:2fc6745d-1631-4f34-b13d-90f9014236c0'
|
||||
)
|
||||
)
|
||||
self.assertEqual(
|
||||
('region.1.test', '2fc6745d-1631-4f34-b13d-90f9014236c0'),
|
||||
floatingips.fip_key_to_data(
|
||||
'region.1.test:2fc6745d-1631-4f34-b13d-90f9014236c0'
|
||||
)
|
||||
)
|
||||
self.assertEqual(
|
||||
('region.test', '2fc6745d-1631-4f34-b13d-90f9014236c0'),
|
||||
floatingips.fip_key_to_data(
|
||||
'region.test:2fc6745d-1631-4f34-b13d-90f9014236c0'
|
||||
)
|
||||
)
|
||||
|
||||
def test_fip_key_to_data_bad_request(self):
|
||||
self.assertRaisesRegex(
|
||||
exceptions.BadRequest,
|
||||
|
||||
Reference in New Issue
Block a user