mirror of
https://github.com/OpenKMIP/PyKMIP.git
synced 2025-07-16 18:44:23 +02:00
Updated test for App Specific Info for Symmetric Key and added test for App Specific Info for SecretData
This commit is contained in:
parent
1773fba67c
commit
124f7db5cb
@ -275,11 +275,11 @@ class AttributeValueFactory(object):
|
|||||||
|
|
||||||
def _create_application_specific_information(self, info):
|
def _create_application_specific_information(self, info):
|
||||||
if info:
|
if info:
|
||||||
for k,v in info.items():
|
print(info.get("application_namespace"))
|
||||||
return attributes.ApplicationSpecificInformation(
|
return attributes.ApplicationSpecificInformation(
|
||||||
k,
|
application_namespace=info.get("application_namespace"),
|
||||||
v
|
application_data=info.get("application_data")
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return attributes.ApplicationSpecificInformation()
|
return attributes.ApplicationSpecificInformation()
|
||||||
|
|
||||||
|
@ -560,16 +560,11 @@ class ProxyKmipClient(object):
|
|||||||
|
|
||||||
if hasattr(managed_object, '_application_specific_informations'):
|
if hasattr(managed_object, '_application_specific_informations'):
|
||||||
if managed_object._application_specific_informations:
|
if managed_object._application_specific_informations:
|
||||||
for attr in managed_object._application_specific_informations:
|
attribute = self.attribute_factory.create_attribute(
|
||||||
app_dict = {}
|
enums.AttributeType.APPLICATION_SPECIFIC_INFORMATION,
|
||||||
app_dict[attr] = managed_object._application_specific_informations[attr]
|
managed_object._application_specific_informations
|
||||||
attribute = self.attribute_factory.create_attribute(
|
)
|
||||||
name=enums.AttributeType.APPLICATION_SPECIFIC_INFORMATION,
|
object_attributes.append(attribute)
|
||||||
value=app_dict,
|
|
||||||
index=1
|
|
||||||
)
|
|
||||||
object_attributes.append(attribute)
|
|
||||||
|
|
||||||
template = cobjects.TemplateAttribute(attributes=object_attributes)
|
template = cobjects.TemplateAttribute(attributes=object_attributes)
|
||||||
object_type = managed_object.object_type
|
object_type = managed_object.object_type
|
||||||
# Register the managed object and handle the results
|
# Register the managed object and handle the results
|
||||||
|
@ -198,17 +198,38 @@ class TestProxyKmipClientIntegration(testtools.TestCase):
|
|||||||
(b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E'
|
(b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E'
|
||||||
b'\x0F'),
|
b'\x0F'),
|
||||||
app_specific_info={
|
app_specific_info={
|
||||||
'application_namespace': 'Testing',
|
'application_namespace': 'Testing',
|
||||||
'application_data': 'Testing2'
|
'application_data': 'Testing2'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
key_id = self.client.register(key)
|
key_id = self.client.register(key)
|
||||||
result = self.client.get(key_id)
|
attribute_list = self.client.get_attribute_list(key_id)
|
||||||
app_specific_info = result.app_specific_info
|
self.assertIn('Application Specific Information', attribute_list)
|
||||||
|
result_id, attribute_list = self.client.get_attributes(
|
||||||
|
uid=key_id,
|
||||||
|
attribute_names=['Application Specific Information']
|
||||||
|
)
|
||||||
|
self.assertEqual(key_id, result_id)
|
||||||
|
self.assertEqual(1, len(attribute_list))
|
||||||
|
|
||||||
|
attribute = attribute_list[0]
|
||||||
|
self.assertEqual(
|
||||||
|
'Application Specific Information',
|
||||||
|
attribute.attribute_name.value
|
||||||
|
)
|
||||||
|
print(attribute.attribute_value)
|
||||||
|
self.assertEqual(
|
||||||
|
'Testing',
|
||||||
|
attribute.attribute_value.application_namespace
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'Testing2',
|
||||||
|
attribute.attribute_value.application_data
|
||||||
|
)
|
||||||
|
|
||||||
self.client.revoke(enums.RevocationReasonCode.KEY_COMPROMISE, key_id)
|
self.client.revoke(enums.RevocationReasonCode.KEY_COMPROMISE, key_id)
|
||||||
self.client.destroy(key_id)
|
self.client.destroy(key_id)
|
||||||
|
|
||||||
|
|
||||||
def test_asymmetric_key_pair_create_get_destroy(self):
|
def test_asymmetric_key_pair_create_get_destroy(self):
|
||||||
"""
|
"""
|
||||||
Test that the ProxyKmipClient can create, retrieve, and destroy an
|
Test that the ProxyKmipClient can create, retrieve, and destroy an
|
||||||
@ -515,6 +536,63 @@ class TestProxyKmipClientIntegration(testtools.TestCase):
|
|||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
exceptions.KmipOperationFailure, self.client.destroy, uid)
|
exceptions.KmipOperationFailure, self.client.destroy, uid)
|
||||||
|
|
||||||
|
def test_secret_data_register_get_destroy_app_specific(self):
|
||||||
|
"""
|
||||||
|
Test that the ProxyKmipClient can register, retrieve, and destroy a
|
||||||
|
secret with the app specific info field.
|
||||||
|
"""
|
||||||
|
# Secret encoding obtained from Section 3.1.5 of the KMIP 1.1 test
|
||||||
|
# documentation.
|
||||||
|
secret = objects.SecretData(
|
||||||
|
b'\x53\x65\x63\x72\x65\x74\x50\x61\x73\x73\x77\x6F\x72\x64',
|
||||||
|
enums.SecretDataType.PASSWORD,
|
||||||
|
app_specific_info={
|
||||||
|
'application_namespace': 'Testing',
|
||||||
|
'application_data': 'Testing2'
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
uid = self.client.register(secret)
|
||||||
|
self.assertIsInstance(uid, six.string_types)
|
||||||
|
|
||||||
|
try:
|
||||||
|
result = self.client.get(uid)
|
||||||
|
self.assertIsInstance(result, objects.SecretData)
|
||||||
|
self.assertEqual(
|
||||||
|
result, secret, "expected {0}\nobserved {1}".format(
|
||||||
|
result, secret))
|
||||||
|
attribute_list = self.client.get_attribute_list(uid)
|
||||||
|
self.assertIn('Application Specific Information', attribute_list)
|
||||||
|
result_id, attribute_list = self.client.get_attributes(
|
||||||
|
uid=uid,
|
||||||
|
attribute_names=['Application Specific Information']
|
||||||
|
)
|
||||||
|
self.assertEqual(uid, result_id)
|
||||||
|
self.assertEqual(1, len(attribute_list))
|
||||||
|
|
||||||
|
attribute = attribute_list[0]
|
||||||
|
self.assertEqual(
|
||||||
|
'Application Specific Information',
|
||||||
|
attribute.attribute_name.value
|
||||||
|
)
|
||||||
|
print(attribute.attribute_value)
|
||||||
|
self.assertEqual(
|
||||||
|
'Testing',
|
||||||
|
attribute.attribute_value.application_namespace
|
||||||
|
)
|
||||||
|
self.assertEqual(
|
||||||
|
'Testing2',
|
||||||
|
attribute.attribute_value.application_data
|
||||||
|
)
|
||||||
|
|
||||||
|
finally:
|
||||||
|
self.client.revoke(enums.RevocationReasonCode.KEY_COMPROMISE, uid)
|
||||||
|
self.client.destroy(uid)
|
||||||
|
self.assertRaises(
|
||||||
|
exceptions.KmipOperationFailure, self.client.get, uid)
|
||||||
|
self.assertRaises(
|
||||||
|
exceptions.KmipOperationFailure, self.client.destroy, uid)
|
||||||
|
|
||||||
def test_opaque_object_register_get_destroy(self):
|
def test_opaque_object_register_get_destroy(self):
|
||||||
"""
|
"""
|
||||||
Test that the ProxyKmipClient can register, retrieve, and destroy an
|
Test that the ProxyKmipClient can register, retrieve, and destroy an
|
||||||
|
Loading…
x
Reference in New Issue
Block a user