Fixes #2580
Check annotations field before parsing Add test case for annotations
This commit is contained in:
@@ -793,6 +793,11 @@ void Task::parseJSON (const json::object* root_obj)
|
|||||||
{
|
{
|
||||||
std::map <std::string, std::string> annos;
|
std::map <std::string, std::string> annos;
|
||||||
|
|
||||||
|
// Fail if 'annotations' is not an array
|
||||||
|
if (i.second->type() != json::j_array) {
|
||||||
|
throw format ("Annotations is malformed: {1}", i.second->dump ());
|
||||||
|
}
|
||||||
|
|
||||||
auto atts = (json::array*)i.second;
|
auto atts = (json::array*)i.second;
|
||||||
for (auto& annotations : atts->_data)
|
for (auto& annotations : atts->_data)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -292,6 +292,12 @@ class TestImportValidate(TestCase):
|
|||||||
code, out, err = self.t.runError("import", input=j)
|
code, out, err = self.t.runError("import", input=j)
|
||||||
self.assertIn("The status 'foo' is not valid.", err)
|
self.assertIn("The status 'foo' is not valid.", err)
|
||||||
|
|
||||||
|
def test_import_malformed_annotation(self):
|
||||||
|
"""Verify invalid 'annnotations' is caught"""
|
||||||
|
j = '{"description": "bad", "annotations": "bad"}'
|
||||||
|
code, out, err = self.t.runError("import", input=j)
|
||||||
|
self.assertIn('Annotations is malformed: "bad"', err)
|
||||||
|
|
||||||
|
|
||||||
class TestImportWithoutISO(TestCase):
|
class TestImportWithoutISO(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user