Merge "Code cleanup"
This commit is contained in:
commit
2f421d98c4
|
@ -321,8 +321,7 @@ def main():
|
||||||
|
|
||||||
# call the action with the remaining arguments
|
# call the action with the remaining arguments
|
||||||
try:
|
try:
|
||||||
ret = fn(*fn_args, **fn_kwargs)
|
return fn(*fn_args, **fn_kwargs)
|
||||||
return(ret)
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sys.exit("ERROR: %s" % e)
|
sys.exit("ERROR: %s" % e)
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ class KekRewrap(object):
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
script_desc = ('Utility to re-wrap project KEKs after rotating an MKEK.')
|
script_desc = 'Utility to re-wrap project KEKs after rotating an MKEK.'
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description=script_desc)
|
parser = argparse.ArgumentParser(description=script_desc)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
|
|
|
@ -343,4 +343,4 @@ def create_container(app, name=None, container_type=None, secret_refs=None,
|
||||||
container_ref = resp.json.get('container_ref', '')
|
container_ref = resp.json.get('container_ref', '')
|
||||||
_, created_uuid = os.path.split(container_ref)
|
_, created_uuid = os.path.split(container_ref)
|
||||||
|
|
||||||
return (resp, created_uuid)
|
return resp, created_uuid
|
||||||
|
|
|
@ -782,7 +782,7 @@ def create_order(app, order_type=None, meta=None, expect_errors=False):
|
||||||
order_ref = resp.json.get('order_ref', '')
|
order_ref = resp.json.get('order_ref', '')
|
||||||
_, created_uuid = os.path.split(order_ref)
|
_, created_uuid = os.path.split(order_ref)
|
||||||
|
|
||||||
return (resp, created_uuid)
|
return resp, created_uuid
|
||||||
|
|
||||||
|
|
||||||
def create_container(app, name=None, container_type=None, secret_refs=None,
|
def create_container(app, name=None, container_type=None, secret_refs=None,
|
||||||
|
@ -807,4 +807,4 @@ def create_container(app, name=None, container_type=None, secret_refs=None,
|
||||||
container_ref = resp.json.get('container_ref', '')
|
container_ref = resp.json.get('container_ref', '')
|
||||||
_, created_uuid = os.path.split(container_ref)
|
_, created_uuid = os.path.split(container_ref)
|
||||||
|
|
||||||
return (resp, created_uuid)
|
return resp, created_uuid
|
||||||
|
|
|
@ -750,4 +750,4 @@ def create_secret(app, name=None, algorithm=None, bit_length=None, mode=None,
|
||||||
secret_ref = resp.json.get('secret_ref', '')
|
secret_ref = resp.json.get('secret_ref', '')
|
||||||
_, created_uuid = os.path.split(secret_ref)
|
_, created_uuid = os.path.split(secret_ref)
|
||||||
|
|
||||||
return (resp, created_uuid)
|
return resp, created_uuid
|
||||||
|
|
|
@ -407,7 +407,7 @@ class WhenCreatingNewSecretACL(utils.BaseTestCase):
|
||||||
|
|
||||||
def test_new_secretacl_with_duplicate_userids_input(self):
|
def test_new_secretacl_with_duplicate_userids_input(self):
|
||||||
user_ids = list(self.user_ids)
|
user_ids = list(self.user_ids)
|
||||||
user_ids = user_ids * 2 # duplicate ids
|
user_ids *= 2 # duplicate ids
|
||||||
acl = models.SecretACL(self.secret_id, self.operation,
|
acl = models.SecretACL(self.secret_id, self.operation,
|
||||||
None, user_ids=user_ids)
|
None, user_ids=user_ids)
|
||||||
self.assertEqual(self.secret_id, acl.secret_id)
|
self.assertEqual(self.secret_id, acl.secret_id)
|
||||||
|
@ -470,7 +470,7 @@ class WhenCreatingNewContainerACL(utils.BaseTestCase):
|
||||||
|
|
||||||
def test_new_containeracl_with_duplicate_userids_input(self):
|
def test_new_containeracl_with_duplicate_userids_input(self):
|
||||||
user_ids = list(self.user_ids)
|
user_ids = list(self.user_ids)
|
||||||
user_ids = user_ids * 2 # duplicate ids
|
user_ids *= 2 # duplicate ids
|
||||||
acl = models.ContainerACL(self.container_id, self.operation,
|
acl = models.ContainerACL(self.container_id, self.operation,
|
||||||
True, user_ids=user_ids)
|
True, user_ids=user_ids)
|
||||||
self.assertEqual(self.container_id, acl.container_id)
|
self.assertEqual(self.container_id, acl.container_id)
|
||||||
|
|
|
@ -464,7 +464,7 @@ class WhenTestingKMIPSecretStore(utils.BaseTestCase):
|
||||||
|
|
||||||
def test_store_opaque_secret_assert_called(self):
|
def test_store_opaque_secret_assert_called(self):
|
||||||
key_spec = secret_store.KeySpec(None, None, None)
|
key_spec = secret_store.KeySpec(None, None, None)
|
||||||
opaque = (b'\x00\x01\x02\x03\x04\x05\x06\x07')
|
opaque = b'\x00\x01\x02\x03\x04\x05\x06\x07'
|
||||||
secret_dto = secret_store.SecretDTO(secret_store.SecretType.OPAQUE,
|
secret_dto = secret_store.SecretDTO(secret_store.SecretType.OPAQUE,
|
||||||
base64.b64encode(opaque),
|
base64.b64encode(opaque),
|
||||||
key_spec,
|
key_spec,
|
||||||
|
@ -487,7 +487,7 @@ class WhenTestingKMIPSecretStore(utils.BaseTestCase):
|
||||||
|
|
||||||
def test_store_opaque_secret_return_value(self):
|
def test_store_opaque_secret_return_value(self):
|
||||||
key_spec = secret_store.KeySpec(None, None, None)
|
key_spec = secret_store.KeySpec(None, None, None)
|
||||||
opaque = (b'\x00\x01\x02\x03\x04\x05\x06\x07')
|
opaque = b'\x00\x01\x02\x03\x04\x05\x06\x07'
|
||||||
secret_dto = secret_store.SecretDTO(secret_store.SecretType.OPAQUE,
|
secret_dto = secret_store.SecretDTO(secret_store.SecretType.OPAQUE,
|
||||||
base64.b64encode(opaque),
|
base64.b64encode(opaque),
|
||||||
key_spec,
|
key_spec,
|
||||||
|
|
|
@ -92,7 +92,7 @@ def demo_store_secret_two_step_binary():
|
||||||
pr = requests.post(ep_2step, data=json.dumps(payload), headers=hdrs)
|
pr = requests.post(ep_2step, data=json.dumps(payload), headers=hdrs)
|
||||||
pr_j = pr.json()
|
pr_j = pr.json()
|
||||||
secret_ref = pr_j.get('secret_ref')
|
secret_ref = pr_j.get('secret_ref')
|
||||||
assert(secret_ref)
|
assert secret_ref
|
||||||
|
|
||||||
# PUT data to store:
|
# PUT data to store:
|
||||||
hdrs_put = dict(hdrs)
|
hdrs_put = dict(hdrs)
|
||||||
|
@ -201,7 +201,7 @@ def demo_consumers_add(container_ref):
|
||||||
# POST metadata:
|
# POST metadata:
|
||||||
pr = requests.post(ep_add, data=json.dumps(payload_consumer), headers=hdrs)
|
pr = requests.post(ep_add, data=json.dumps(payload_consumer), headers=hdrs)
|
||||||
pr_consumers = pr.json().get('consumers')
|
pr_consumers = pr.json().get('consumers')
|
||||||
assert(pr_consumers)
|
assert pr_consumers
|
||||||
assert(len(pr_consumers) == 1)
|
assert(len(pr_consumers) == 1)
|
||||||
LOG.info('...Consumer response: {0}'.format(pr_consumers))
|
LOG.info('...Consumer response: {0}'.format(pr_consumers))
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ class FunctionalTestAuth(auth.AuthBase):
|
||||||
tenant_name=self.project_name,
|
tenant_name=self.project_name,
|
||||||
auth_url=self.endpoint
|
auth_url=self.endpoint
|
||||||
)
|
)
|
||||||
return (self._client.auth_token, self._client.tenant_id)
|
return self._client.auth_token, self._client.tenant_id
|
||||||
|
|
||||||
elif self.version.lower() == 'v3':
|
elif self.version.lower() == 'v3':
|
||||||
self._client = v3_client.Client(
|
self._client = v3_client.Client(
|
||||||
|
@ -67,7 +67,7 @@ class FunctionalTestAuth(auth.AuthBase):
|
||||||
project_name=self.project_name,
|
project_name=self.project_name,
|
||||||
auth_url=self.endpoint
|
auth_url=self.endpoint
|
||||||
)
|
)
|
||||||
return (self._client.auth_token, self._client.project_id)
|
return self._client.auth_token, self._client.project_id
|
||||||
else:
|
else:
|
||||||
raise Exception('Unknown authentication version')
|
raise Exception('Unknown authentication version')
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ class BarbicanClient(object):
|
||||||
str_request)
|
str_request)
|
||||||
|
|
||||||
def _status_is_2xx_success(self, status_code):
|
def _status_is_2xx_success(self, status_code):
|
||||||
return status_code >= 200 and status_code < 300
|
return 200 <= status_code < 300
|
||||||
|
|
||||||
def attempt_to_deserialize(self, response, model_type):
|
def attempt_to_deserialize(self, response, model_type):
|
||||||
if (self._status_is_2xx_success(response.status_code) and
|
if (self._status_is_2xx_success(response.status_code) and
|
||||||
|
|
Loading…
Reference in New Issue