Expand secrets list API to allow for filters on name, mode, algorithm,
and bit length Change-Id: I9d13d8b13b9121740a2b03870aa3e996d85749ad Implements: blueprint expanded-secrets-query-api
This commit is contained in:
parent
faab02e9b0
commit
f29a9d7e6a
@ -334,6 +334,10 @@ class SecretsResource(api.ApiResource):
|
||||
keystone_id,
|
||||
offset_arg=req.get_param('offset'),
|
||||
limit_arg=req.get_param('limit'),
|
||||
name=req.get_param('name'),
|
||||
alg=req.get_param('alg'),
|
||||
mode=req.get_param('mode'),
|
||||
bits=req.get_param('bits'),
|
||||
suppress_exception=True
|
||||
)
|
||||
|
||||
|
@ -488,6 +488,7 @@ class SecretRepo(BaseRepo):
|
||||
"""Repository for the Secret entity."""
|
||||
|
||||
def get_by_create_date(self, keystone_id, offset_arg=None, limit_arg=None,
|
||||
name=None, alg=None, mode=None, bits=0,
|
||||
suppress_exception=False, session=None):
|
||||
"""
|
||||
Returns a list of secrets, ordered by the date they were created at
|
||||
@ -509,6 +510,15 @@ class SecretRepo(BaseRepo):
|
||||
query = query.filter(or_(models.Secret.expiration == None,
|
||||
models.Secret.expiration > utcnow))
|
||||
|
||||
if name:
|
||||
query = query.filter(models.Secret.name.like(name))
|
||||
if alg:
|
||||
query = query.filter(models.Secret.algorithm.like(alg))
|
||||
if mode:
|
||||
query = query.filter(models.Secret.mode.like(mode))
|
||||
if bits > 0:
|
||||
query = query.filter(models.Secret.bit_length == bits)
|
||||
|
||||
query = query.join(models.TenantSecret,
|
||||
models.Secret.tenant_assocs) \
|
||||
.join(models.Tenant, models.TenantSecret.tenants) \
|
||||
|
@ -494,7 +494,8 @@ class WhenGettingSecretsListUsingSecretsResource(unittest.TestCase):
|
||||
self.req = mock.MagicMock()
|
||||
self.req.accept = 'application/json'
|
||||
self.req.get_param = mock.Mock()
|
||||
self.req.get_param.side_effect = [self.offset, self.limit]
|
||||
self.req.get_param.side_effect = [self.offset, self.limit, None, None,
|
||||
None, 0]
|
||||
self.resp = mock.MagicMock()
|
||||
self.resource = res.SecretsResource(self.crypto_mgr, self.tenant_repo,
|
||||
self.secret_repo,
|
||||
@ -509,7 +510,9 @@ class WhenGettingSecretsListUsingSecretsResource(unittest.TestCase):
|
||||
.assert_called_once_with(self.keystone_id,
|
||||
offset_arg=self.offset,
|
||||
limit_arg=self.limit,
|
||||
suppress_exception=True)
|
||||
suppress_exception=True,
|
||||
name=None, alg=None, mode=None,
|
||||
bits=0)
|
||||
|
||||
resp_body = jsonutils.loads(self.resp.body)
|
||||
self.assertTrue('previous' in resp_body)
|
||||
@ -543,7 +546,9 @@ class WhenGettingSecretsListUsingSecretsResource(unittest.TestCase):
|
||||
.assert_called_once_with(self.keystone_id,
|
||||
offset_arg=self.offset,
|
||||
limit_arg=self.limit,
|
||||
suppress_exception=True)
|
||||
suppress_exception=True,
|
||||
name=None, alg=None, mode=None,
|
||||
bits=0)
|
||||
|
||||
resp_body = jsonutils.loads(self.resp.body)
|
||||
self.assertFalse('previous' in resp_body)
|
||||
@ -1335,7 +1340,8 @@ class WhenGettingVerificationsListUsingResource(unittest.TestCase):
|
||||
self.req = mock.MagicMock()
|
||||
self.req.accept = 'application/json'
|
||||
self.req.get_param = mock.Mock()
|
||||
self.req.get_param.side_effect = [self.offset, self.limit]
|
||||
self.req.get_param.side_effect = [self.offset, self.limit, None, None,
|
||||
None, 0]
|
||||
self.resp = mock.MagicMock()
|
||||
self.resource = res.VerificationsResource(self.tenant_repo,
|
||||
self.verif_repo,
|
||||
|
Loading…
Reference in New Issue
Block a user