Add testcase to test invalid region id in request
Regions use ID differently. The user can specify the ID or it will be generated automatically. So, there is schema validation that region ID should be the string type, these testcases test where region id could be passed in request body but not a string type. Change-Id: I0623e8e97132b9c2e60d03fca8fa98de798b5494 Closes-Bug: #1487663
This commit is contained in:
parent
909ed85053
commit
0b4f585fdd
|
@ -884,6 +884,14 @@ class RegionValidationTestCase(unit.BaseTestCase):
|
|||
'parent_region_id': uuid.uuid4().hex}
|
||||
self.create_region_validator.validate(request_to_validate)
|
||||
|
||||
def test_validate_region_create_fails_with_invalid_region_id(self):
|
||||
"""Exception raised when passing invalid `id` in request."""
|
||||
request_to_validate = {'id': 1234,
|
||||
'description': 'US East Region'}
|
||||
self.assertRaises(exception.SchemaValidationError,
|
||||
self.create_region_validator.validate,
|
||||
request_to_validate)
|
||||
|
||||
def test_validate_region_create_succeeds_with_extra_parameters(self):
|
||||
"""Validate create region request with extra values."""
|
||||
request_to_validate = {'other_attr': uuid.uuid4().hex}
|
||||
|
@ -1176,6 +1184,26 @@ class EndpointValidationTestCase(unit.BaseTestCase):
|
|||
self.create_endpoint_validator.validate,
|
||||
request_to_validate)
|
||||
|
||||
def test_validate_endpoint_create_fails_with_invalid_region_id(self):
|
||||
"""Exception raised when passing invalid `region(_id)` in request."""
|
||||
request_to_validate = {'interface': 'admin',
|
||||
'region_id': 1234,
|
||||
'service_id': uuid.uuid4().hex,
|
||||
'url': 'https://service.example.com:5000/'}
|
||||
|
||||
self.assertRaises(exception.SchemaValidationError,
|
||||
self.create_endpoint_validator.validate,
|
||||
request_to_validate)
|
||||
|
||||
request_to_validate = {'interface': 'admin',
|
||||
'region': 1234,
|
||||
'service_id': uuid.uuid4().hex,
|
||||
'url': 'https://service.example.com:5000/'}
|
||||
|
||||
self.assertRaises(exception.SchemaValidationError,
|
||||
self.create_endpoint_validator.validate,
|
||||
request_to_validate)
|
||||
|
||||
def test_validate_endpoint_update_fails_with_invalid_enabled(self):
|
||||
"""Exception raised when `enabled` is boolean-like value."""
|
||||
for invalid_enabled in _INVALID_ENABLED_FORMATS:
|
||||
|
@ -1243,6 +1271,26 @@ class EndpointValidationTestCase(unit.BaseTestCase):
|
|||
self.update_endpoint_validator.validate,
|
||||
request_to_validate)
|
||||
|
||||
def test_validate_endpoint_update_fails_with_invalid_region_id(self):
|
||||
"""Exception raised when passing invalid `region(_id)` in request."""
|
||||
request_to_validate = {'interface': 'admin',
|
||||
'region_id': 1234,
|
||||
'service_id': uuid.uuid4().hex,
|
||||
'url': 'https://service.example.com:5000/'}
|
||||
|
||||
self.assertRaises(exception.SchemaValidationError,
|
||||
self.update_endpoint_validator.validate,
|
||||
request_to_validate)
|
||||
|
||||
request_to_validate = {'interface': 'admin',
|
||||
'region': 1234,
|
||||
'service_id': uuid.uuid4().hex,
|
||||
'url': 'https://service.example.com:5000/'}
|
||||
|
||||
self.assertRaises(exception.SchemaValidationError,
|
||||
self.update_endpoint_validator.validate,
|
||||
request_to_validate)
|
||||
|
||||
|
||||
class EndpointGroupValidationTestCase(unit.BaseTestCase):
|
||||
"""Test for V3 Endpoint Group API validation."""
|
||||
|
|
Loading…
Reference in New Issue