Validate provider_location while managing snapshot
Change-Id: Iec2ceb8a4d8519e5ed716e771dc17388ab5d4d7f Closes-Bug: #2031048 Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com> (cherry-picked from commitf6725f7c14
) (cherry picked from commitdba08c221c
) (cherry picked from commit3badc8633b
) (cherry picked from commitf533bdb942
)
This commit is contained in:
parent
0bc9107e57
commit
312a3b4a74
@ -162,6 +162,9 @@ class ShareSnapshotsController(share_snapshots.ShareSnapshotMixin,
|
|||||||
if not data.get(parameter):
|
if not data.get(parameter):
|
||||||
msg = _("Required parameter %s is empty.") % parameter
|
msg = _("Required parameter %s is empty.") % parameter
|
||||||
raise exc_response(explanation=msg)
|
raise exc_response(explanation=msg)
|
||||||
|
if not isinstance(data[parameter], str):
|
||||||
|
msg = _("Parameter %s must be a string.") % parameter
|
||||||
|
raise exc_response(explanation=msg)
|
||||||
|
|
||||||
def _check_if_share_share_network_is_active(self, context, snapshot):
|
def _check_if_share_share_network_is_active(self, context, snapshot):
|
||||||
share_network_id = snapshot['share'].get('share_network_id')
|
share_network_id = snapshot['share'].get('share_network_id')
|
||||||
|
@ -701,7 +701,8 @@ class ShareSnapshotAdminActionsAPITest(test.TestCase):
|
|||||||
{},
|
{},
|
||||||
{'snapshots': {}},
|
{'snapshots': {}},
|
||||||
{'snapshot': get_fake_manage_body(share_id='xxxxxxxx')},
|
{'snapshot': get_fake_manage_body(share_id='xxxxxxxx')},
|
||||||
{'snapshot': get_fake_manage_body(provider_location='xxxxxxxx')}
|
{'snapshot': get_fake_manage_body(provider_location='xxxxxxxx')},
|
||||||
|
{'snapshot': {'provider_location': {'x': 'y'}, 'share_id': 'xyzzy'}},
|
||||||
)
|
)
|
||||||
def test_snapshot_manage_invalid_body(self, body):
|
def test_snapshot_manage_invalid_body(self, body):
|
||||||
self.mock_policy_check = self.mock_object(
|
self.mock_policy_check = self.mock_object(
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
The "manage" API for snapshots now validates the format of
|
||||||
|
"provider_location" and "share_id" fields and handles errors
|
||||||
|
appropriately. These fields are expected to contain string values.
|
Loading…
Reference in New Issue
Block a user