Merge "Make service_create return 400 with invalid json manifest"
This commit is contained in:
commit
38468479c8
|
@ -116,7 +116,10 @@ class Service(v1_base.K8sResourceBase):
|
|||
def parse_manifest(self):
|
||||
if not self.manifest and not self.manifest_url:
|
||||
raise exception.InvalidParameterValue("'manifest' can't be empty")
|
||||
manifest = k8s_manifest.parse(self._get_manifest())
|
||||
try:
|
||||
manifest = k8s_manifest.parse(self._get_manifest())
|
||||
except ValueError as e:
|
||||
raise exception.InvalidParameterValue(message=str(e))
|
||||
self.name = manifest["id"]
|
||||
if "port" in manifest:
|
||||
self.port = manifest["port"]
|
||||
|
|
|
@ -285,6 +285,14 @@ class TestPost(api_base.FunctionalTest):
|
|||
self.assertEqual(400, response.status_int)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
def test_create_service_invalid_manifest(self):
|
||||
sdict = apiutils.service_post_data()
|
||||
sdict['manifest'] = 'wrong_manifest'
|
||||
response = self.post_json('/services', sdict, expect_errors=True)
|
||||
self.assertEqual('application/json', response.content_type)
|
||||
self.assertEqual(400, response.status_int)
|
||||
self.assertTrue(response.json['error_message'])
|
||||
|
||||
|
||||
class TestDelete(api_base.FunctionalTest):
|
||||
|
||||
|
|
Loading…
Reference in New Issue