Fix DEFAULT_SCHEMA to validate host_aggreates

Audit scope JSON schema should restrict key of host_aggregates
to "id" or "name", but that is not working now.
This patch fixes DEFAULT_SCHEMA to validate host_aggregates.

Change-Id: Iea42da41d61435780e247736599a56c026f47914
Closes-Bug: #1714448
This commit is contained in:
Hidekazu Nakamura
2017-09-01 18:12:57 +09:00
parent 50935af15f
commit 4c3c84dee9
2 changed files with 44 additions and 16 deletions

View File

@@ -511,7 +511,7 @@ class TestPost(FunctionalTestWithSetup):
response.json['created_at']).replace(tzinfo=None)
self.assertEqual(test_time, return_created_at)
def test_create_audit_template_vlidation_with_aggregates(self):
def test_create_audit_template_validation_with_aggregates(self):
scope = [{'host_aggregates': [{'id': '*'}]},
{'availability_zones': [{'name': 'AZ1'},
{'name': 'AZ2'}]},
@@ -532,6 +532,14 @@ class TestPost(FunctionalTestWithSetup):
"be included and excluded together"):
self.post_json('/audit_templates', audit_template_dict)
scope = [{'host_aggregates': [{'id1': '*'}]}]
audit_template_dict = post_get_test_audit_template(
goal=self.fake_goal1.uuid,
strategy=self.fake_strategy1.uuid, scope=scope)
response = self.post_json('/audit_templates',
audit_template_dict, expect_errors=True)
self.assertEqual(500, response.status_int)
def test_create_audit_template_does_autogenerate_id(self):
audit_template_dict = post_get_test_audit_template(
goal=self.fake_goal1.uuid, strategy=None)