Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 35 additions & 73 deletions examples/test_ibm_key_protect_api_v2_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,10 @@ def test_get_key_collection_metadata_example(self):
try:
# begin-getKeyCollectionMetadata

response = (
self.__class__.ibm_key_protect_api_service.get_key_collection_metadata(
bluemix_instance=self.__class__.bluemix_instance,
state=[0, 1, 2, 3],
extractable=True,
)
response = self.__class__.ibm_key_protect_api_service.get_key_collection_metadata(
bluemix_instance=self.__class__.bluemix_instance,
state=[0, 1, 2, 3],
extractable=True,
)

# end-getKeyCollectionMetadata
Expand Down Expand Up @@ -319,11 +317,9 @@ def test_unset_key_for_deletion_example(self):
try:
# begin-unsetKeyForDeletion

response = (
self.__class__.ibm_key_protect_api_service.unset_key_for_deletion(
id=self.__class__.policies_overriden_key_id,
bluemix_instance=self.__class__.bluemix_instance,
)
response = self.__class__.ibm_key_protect_api_service.unset_key_for_deletion(
id=self.__class__.policies_overriden_key_id,
bluemix_instance=self.__class__.bluemix_instance,
)

# end-unsetKeyForDeletion
Expand Down Expand Up @@ -398,9 +394,7 @@ def test_wrap_key_example(self):
response = self.__class__.ibm_key_protect_api_service.wrap_key(
id=self.__class__.created_key_id,
bluemix_instance=self.__class__.bluemix_instance,
key_action_wrap_body=io.BytesIO(
json.dumps(key_action_wrap_body).encode("utf-8")
),
key_action_wrap_body=io.BytesIO(json.dumps(key_action_wrap_body).encode("utf-8")),
)
wrap_key_response_body = response.get_result()
wrap_key_response_data = wrap_key_response_body.json()
Expand Down Expand Up @@ -433,9 +427,7 @@ def test_unwrap_key_example(self):
response = self.__class__.ibm_key_protect_api_service.unwrap_key(
id=self.__class__.created_key_id,
bluemix_instance=self.__class__.bluemix_instance,
key_action_unwrap_body=io.BytesIO(
json.dumps(key_action_unwrap_body).encode("utf-8")
),
key_action_unwrap_body=io.BytesIO(json.dumps(key_action_unwrap_body).encode("utf-8")),
)
unwrap_key_response_body = response.get_result()

Expand Down Expand Up @@ -463,9 +455,7 @@ def test_rewrap_key_example(self):
response = self.__class__.ibm_key_protect_api_service.rewrap_key(
id=self.__class__.created_key_id,
bluemix_instance=self.__class__.bluemix_instance,
key_action_rewrap_body=io.BytesIO(
json.dumps(key_action_rewrap_body).encode("utf-8")
),
key_action_rewrap_body=io.BytesIO(json.dumps(key_action_rewrap_body).encode("utf-8")),
)
rewrap_key_response_body = response.get_result()

Expand All @@ -491,9 +481,7 @@ def test_rotate_key_example(self):
response = self.__class__.ibm_key_protect_api_service.rotate_key(
id=self.__class__.created_key_id,
bluemix_instance=self.__class__.bluemix_instance,
key_action_rotate_body=io.BytesIO(
json.dumps(key_action_rotate_body).encode("utf-8")
),
key_action_rotate_body=io.BytesIO(json.dumps(key_action_rotate_body).encode("utf-8")),
prefer="return=representation",
)

Expand Down Expand Up @@ -646,9 +634,7 @@ def test_put_instance_policy_example(self):

set_instance_policies_one_of_model = {
"metadata": collection_metadata_model,
"resources": [
set_instance_policies_one_of_set_instance_policy_allowed_network_resources_item_model
],
"resources": [set_instance_policies_one_of_set_instance_policy_allowed_network_resources_item_model],
}

response = self.__class__.ibm_key_protect_api_service.put_instance_policy(
Expand Down Expand Up @@ -688,9 +674,7 @@ def test_get_instance_policy_example(self):
except ApiException as e:
pytest.fail(str(e))

@pytest.mark.skip(
reason="Skipping because the instance has to be public to test api calls using integration tests"
)
@pytest.mark.skip(reason="Skipping because the instance has to be public to test api calls using integration tests")
@needscredentials
def test_get_allowed_ip_port_example(self):
"""
Expand Down Expand Up @@ -790,10 +774,8 @@ def test_get_registrations_all_keys_example(self):

# begin-getRegistrationsAllKeys

response = (
self.__class__.ibm_key_protect_api_service.get_registrations_all_keys(
bluemix_instance=self.__class__.bluemix_instance,
)
response = self.__class__.ibm_key_protect_api_service.get_registrations_all_keys(
bluemix_instance=self.__class__.bluemix_instance,
)
registration_with_total_count = response.get_result()

Expand Down Expand Up @@ -910,9 +892,7 @@ def test_create_key_ring_example(self):
)

# end-createKeyRing
print(
"\ncreate_key_ring() response status code: ", response.get_status_code()
)
print("\ncreate_key_ring() response status code: ", response.get_status_code())

except ApiException as e:
pytest.fail(str(e))
Expand Down Expand Up @@ -1155,15 +1135,11 @@ def test_get_kmip_client_certificates_example(self):

# begin-get_kmip_client_certificates

response = (
self.__class__.ibm_key_protect_api_service.get_kmip_client_certificates(
adapter_id=self.__class__.kmip_name,
bluemix_instance=self.__class__.bluemix_instance,
)
)
list_kmip_partial_client_certificates_with_total_count = (
response.get_result()
response = self.__class__.ibm_key_protect_api_service.get_kmip_client_certificates(
adapter_id=self.__class__.kmip_name,
bluemix_instance=self.__class__.bluemix_instance,
)
list_kmip_partial_client_certificates_with_total_count = response.get_result()

print(list_kmip_partial_client_certificates_with_total_count)

Expand Down Expand Up @@ -1195,13 +1171,11 @@ def test_add_kmip_client_certificate_example(self):
"name": self.__class__.kmip_cert_name,
}

response = (
self.__class__.ibm_key_protect_api_service.add_kmip_client_certificate(
adapter_id=self.__class__.kmip_name,
bluemix_instance=self.__class__.bluemix_instance,
metadata=collection_metadata_model,
resources=[create_kmip_client_certificate_object_model],
)
response = self.__class__.ibm_key_protect_api_service.add_kmip_client_certificate(
adapter_id=self.__class__.kmip_name,
bluemix_instance=self.__class__.bluemix_instance,
metadata=collection_metadata_model,
resources=[create_kmip_client_certificate_object_model],
)
list_kmip_client_certificates = response.get_result()

Expand All @@ -1222,12 +1196,10 @@ def test_get_kmip_client_certificate_example(self):

# begin-get_kmip_client_certificate

response = (
self.__class__.ibm_key_protect_api_service.get_kmip_client_certificate(
adapter_id=self.__class__.kmip_name,
id=self.__class__.kmip_cert_name,
bluemix_instance=self.__class__.bluemix_instance,
)
response = self.__class__.ibm_key_protect_api_service.get_kmip_client_certificate(
adapter_id=self.__class__.kmip_name,
id=self.__class__.kmip_cert_name,
bluemix_instance=self.__class__.bluemix_instance,
)
list_kmip_client_certificates = response.get_result()

Expand Down Expand Up @@ -1262,9 +1234,7 @@ def test_delete_key_ring_example(self):
)

# end-deleteKeyRing
print(
"\ndelete_key_ring() response status code: ", response.get_status_code()
)
print("\ndelete_key_ring() response status code: ", response.get_status_code())

except ApiException as e:
pytest.fail(str(e))
Expand All @@ -1277,11 +1247,9 @@ def test_sync_associated_resources_example(self):
try:
# begin-syncAssociatedResources

response = (
self.__class__.ibm_key_protect_api_service.sync_associated_resources(
id=self.__class__.policies_overriden_key_id,
bluemix_instance=self.__class__.bluemix_instance,
)
response = self.__class__.ibm_key_protect_api_service.sync_associated_resources(
id=self.__class__.policies_overriden_key_id,
bluemix_instance=self.__class__.bluemix_instance,
)

# end-syncAssociatedResources
Expand Down Expand Up @@ -1325,7 +1293,6 @@ def test_delete_kmip_client_certificate_example(self):
delete_kmip_client_certificate request example
"""
try:

# begin-delete_kmip_object

response = self.__class__.ibm_key_protect_api_service.delete_kmip_client_certificate(
Expand All @@ -1350,7 +1317,6 @@ def test_delete_kmip_adapter_example(self):
delete_kmip_adapter request example
"""
try:

# begin-delete_kmip_adapter

response = self.__class__.ibm_key_protect_api_service.delete_kmip_adapter(
Expand Down Expand Up @@ -1398,9 +1364,7 @@ def test_cleanup_resources(self):

if self.__class__.policies_overriden_key_id:
try:
print(
f"Deleting policies overridden key: {self.__class__.policies_overriden_key_id}"
)
print(f"Deleting policies overridden key: {self.__class__.policies_overriden_key_id}")
self.__class__.ibm_key_protect_api_service.delete_key(
id=self.__class__.policies_overriden_key_id,
bluemix_instance=self.__class__.bluemix_instance,
Expand All @@ -1411,9 +1375,7 @@ def test_cleanup_resources(self):
print(f"Failed deleting policies overridden key: {e}")

try:
print(
f"Purging policies overridden key: {self.__class__.policies_overriden_key_id}"
)
print(f"Purging policies overridden key: {self.__class__.policies_overriden_key_id}")
self.__class__.ibm_key_protect_api_service.purge_key(
id=self.__class__.policies_overriden_key_id,
bluemix_instance=self.__class__.bluemix_instance,
Expand Down
Loading
Loading