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: 43673 [1] https://docs.openstack.org/barbican/latest/api/reference/secret_metadata.html#post-v1-secrets-uuid-metadata Change-Id: I5505a8c56ed7274519cac8ad1e6d7adf5086c8d1 (cherry picked from commit8bd16953eb
) (cherry picked from commit61aa13e970
) (cherry picked from commit49f3b2f0d1
) (cherry picked from commit841973caca
) (cherry picked from commit07ef50c187
)
This commit is contained in:
parent
f22739f1bc
commit
42feeeaea9
|
@ -103,9 +103,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'] = str(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_resp, secret_uuid = 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…
Reference in New Issue