Merge "Make rc_create return 400 with invalid json manifest"
This commit is contained in:
commit
255428cc8e
|
@ -109,7 +109,10 @@ class ReplicationController(v1_base.K8sResourceBase):
|
||||||
return cls._convert_with_links(sample, 'http://localhost:9511', expand)
|
return cls._convert_with_links(sample, 'http://localhost:9511', expand)
|
||||||
|
|
||||||
def parse_manifest(self):
|
def parse_manifest(self):
|
||||||
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"]
|
self.name = manifest["id"]
|
||||||
if "labels" in manifest:
|
if "labels" in manifest:
|
||||||
self.labels = manifest["labels"]
|
self.labels = manifest["labels"]
|
||||||
|
|
|
@ -323,6 +323,14 @@ class TestPost(api_base.FunctionalTest):
|
||||||
self.assertEqual(400, response.status_int)
|
self.assertEqual(400, response.status_int)
|
||||||
self.assertTrue(response.json['error_message'])
|
self.assertTrue(response.json['error_message'])
|
||||||
|
|
||||||
|
def test_create_rc_with_invalid_manifest(self):
|
||||||
|
rc_dict = apiutils.rc_post_data()
|
||||||
|
rc_dict['manifest'] = 'wrong_manifest'
|
||||||
|
response = self.post_json('/rcs', rc_dict, 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):
|
class TestDelete(api_base.FunctionalTest):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue