Merge "Make rc_create return 400 with invalid json manifest"

This commit is contained in:
Jenkins 2015-03-09 23:19:46 +00:00 committed by Gerrit Code Review
commit 255428cc8e
2 changed files with 12 additions and 1 deletions

View File

@ -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"]

View File

@ -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):