Fix POST /v1/secret/{secret-id}/metadata response
This patch fixes the response to POST requests in the metadata API so it actually matches the documentation. [1] Story: 2009247 Task: 43424 [1] https://docs.openstack.org/barbican/latest/api/reference/secret_metadata.html#post-v1-secrets-uuid-metadata Change-Id: I5505a8c56ed7274519cac8ad1e6d7adf5086c8d1
This commit is contained in:
parent
6cf0c70337
commit
8bd16953eb
@ -102,9 +102,8 @@ class SecretMetadataController(controllers.ACLMixin):
|
||||
LOG.debug('URI to secret metadata is %s', url)
|
||||
|
||||
pecan.response.status = 201
|
||||
return {'metadata_ref': url + "/%s {key: %s, value:%s}" % (key,
|
||||
key,
|
||||
value)}
|
||||
pecan.response.headers['Location'] = url + '/' + key
|
||||
return {'key': key, 'value': value}
|
||||
|
||||
|
||||
class SecretMetadatumController(controllers.ACLMixin):
|
||||
|
@ -35,6 +35,29 @@ class WhenTestingSecretMetadataResource(utils.BarbicanAPIBaseTestCase):
|
||||
}
|
||||
}
|
||||
|
||||
def test_post_secret_metadata(self):
|
||||
secret_id, secret_resp = create_secret(self.app)
|
||||
resp = self.app.post_json(
|
||||
'/secrets/{}/metadata'.format(secret_id),
|
||||
{'key': 'foo',
|
||||
'value': 'bar'}
|
||||
)
|
||||
meta = json.loads(resp.body)
|
||||
self.assertIn('key', meta.keys())
|
||||
self.assertIn('value', meta.keys())
|
||||
self.assertEqual('foo', meta['key'])
|
||||
self.assertEqual('bar', meta['value'])
|
||||
|
||||
def test_post_secret_metadata_response_sets_location_header(self):
|
||||
secret_id, secret_resp = create_secret(self.app)
|
||||
resp = self.app.post_json(
|
||||
'/secrets/{}/metadata'.format(secret_id),
|
||||
{'key': 'foo',
|
||||
'value': 'bar'}
|
||||
)
|
||||
self.assertIn('Location', resp.headers)
|
||||
self.assertTrue(resp.headers['Location'].endswith('foo'))
|
||||
|
||||
def test_create_secret_metadata(self):
|
||||
secret_id, secret_resp = create_secret(self.app)
|
||||
meta_resp = create_secret_metadata(self.app,
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixed Story #2009247 - Fixed the response for
|
||||
POST /v1/secrets/{secret-id}/metadata so it matches the documented
|
||||
behavior.
|
Loading…
x
Reference in New Issue
Block a user