Fix 500 error for secret PUT

Two issues here caused failure for secret PUT.

First, constructor for secret wasn't passing in the metadata repo when
saving off to self.repos.  Added the secret_meta_repo to self.repos.

Second the PUT controller wasn't passing in the right value to the plugin
to store the sercret.  It was sending in a function object rather than
the result of calling that function.  Two parens made things all better...

Also updated unit tests.

Change-Id: I89d329c718e10fb3e64c6a81867df86ada22b02e
Closes-Bug: 1339460
This commit is contained in:
Steve Heyman 2014-07-09 11:21:58 -05:00
parent 7530094cca
commit 4599de25c2
3 changed files with 8 additions and 6 deletions

View File

@ -64,7 +64,8 @@ class SecretController(object):
self.repos = repo.Repositories(tenant_repo=tenant_repo,
secret_repo=secret_repo,
datum_repo=datum_repo,
kek_repo=kek_repo)
kek_repo=kek_repo,
secret_meta_repo=secret_meta_repo)
@pecan.expose(generic=True)
@allow_all_content_types
@ -131,7 +132,7 @@ class SecretController(object):
content_encoding = pecan.request.headers.get('Content-Encoding')
plugin.store_secret(payload, content_type,
content_encoding, secret_model.to_dict_fields,
content_encoding, secret_model.to_dict_fields(),
secret_model, tenant_model, self.repos)
@index.when(method='DELETE')

View File

@ -954,7 +954,7 @@ class WhenGettingPuttingOrDeletingSecretUsingSecretResource(FunctionalTest):
mock_store_secret\
.assert_called_once_with('plain text', 'text/plain',
None, self.secret.to_dict_fields,
None, self.secret.to_dict_fields(),
self.secret, self.tenant, mock.ANY)
@mock.patch('barbican.plugin.resources.store_secret')
@ -974,7 +974,7 @@ class WhenGettingPuttingOrDeletingSecretUsingSecretResource(FunctionalTest):
mock_store_secret\
.assert_called_once_with('plain text', 'application/octet-stream',
None, self.secret.to_dict_fields,
None, self.secret.to_dict_fields(),
self.secret, self.tenant, mock.ANY)
@mock.patch('barbican.plugin.resources.store_secret')
@ -995,7 +995,7 @@ class WhenGettingPuttingOrDeletingSecretUsingSecretResource(FunctionalTest):
mock_store_secret\
.assert_called_once_with(payload, 'application/octet-stream',
'base64', self.secret.to_dict_fields,
'base64', self.secret.to_dict_fields(),
self.secret, self.tenant, mock.ANY)
def test_should_fail_to_put_secret_with_unsupported_encoding(self):

View File

@ -297,7 +297,8 @@ class WhenTestingSecretResource(BaseTestCase):
tenant_repo=mock.MagicMock(),
secret_repo=self.secret_repo,
datum_repo=mock.MagicMock(),
kek_repo=mock.MagicMock())
kek_repo=mock.MagicMock(),
secret_meta_repo=mock.MagicMock())
def test_rules_should_be_loaded(self):
self.assertIsNotNone(self.policy_enforcer.rules)