Fix the schema of assisted_volume_snapshots
The position of both 'required' and 'additionalProperties' was wrong and the additionalProperties validation didn't work at all. This patch fixes it by changing the position. Closes-Bug: #1572303 Change-Id: I8eaf7f7c3340321893edcb651983e9133a33e5a1
This commit is contained in:
parent
e276284791
commit
4ad8a86b30
|
@ -43,8 +43,8 @@ snapshots_create = {
|
|||
},
|
||||
'required': ['volume_id', 'create_info'],
|
||||
'additionalProperties': False,
|
||||
},
|
||||
'required': ['snapshot'],
|
||||
'additionalProperties': False,
|
||||
}
|
||||
},
|
||||
'required': ['snapshot'],
|
||||
'additionalProperties': False,
|
||||
}
|
||||
|
|
|
@ -884,11 +884,33 @@ class AssistedSnapshotCreateTestCaseV21(test.NoDBTestCase):
|
|||
self.assertRaises(self.bad_request, self.controller.create,
|
||||
req, body=body)
|
||||
|
||||
def test_assisted_create_with_unexpected_attr(self):
|
||||
req = fakes.HTTPRequest.blank('/v2/fake/os-assisted-volume-snapshots')
|
||||
body = {
|
||||
'snapshot': {
|
||||
'volume_id': '1',
|
||||
'create_info': {
|
||||
'type': 'qcow2',
|
||||
'new_file': 'new_file',
|
||||
'snapshot_id': 'snapshot_id'
|
||||
}
|
||||
},
|
||||
'unexpected': 0,
|
||||
}
|
||||
req.method = 'POST'
|
||||
self.assertRaises(self.bad_request, self.controller.create,
|
||||
req, body=body)
|
||||
|
||||
|
||||
class AssistedSnapshotCreateTestCaseV2(AssistedSnapshotCreateTestCaseV21):
|
||||
assisted_snaps = assisted_snaps_v2
|
||||
bad_request = webob.exc.HTTPBadRequest
|
||||
|
||||
def test_assisted_create_with_unexpected_attr(self):
|
||||
# NOTE: legacy v2.0 API cannot handle this kind of invalid requests.
|
||||
# So we need to skip the test on legacy v2.0 API.
|
||||
pass
|
||||
|
||||
|
||||
class AssistedSnapshotDeleteTestCaseV21(test.NoDBTestCase):
|
||||
assisted_snaps = assisted_snaps_v21
|
||||
|
|
Loading…
Reference in New Issue