Update the Register payloads

This change updates the Register payloads to the current payload
format, adding properties for different payload attributes and
adding comparison and string operators. Changes are also made to
the PyKMIP clients and the surrounding testing infrastructure to
reflect the payload changes. An official unit test suite for the
Register payloads has also been included, which will eventually
replace the existing Register message tests elsewhere in the test
suite.

This change prepares the Register payloads for future updates to
support KMIP 2.0.
This commit is contained in:
Peter Hamilton 2019-03-04 17:38:26 -05:00 committed by Peter Hamilton
parent 1a723f224d
commit a81233aa2a
11 changed files with 1841 additions and 117 deletions

View File

@ -13,136 +13,462 @@
# License for the specific language governing permissions and limitations
# under the License.
from kmip.core.factories.secrets import SecretFactory
import six
from kmip.core import attributes
from kmip.core import enums
from kmip.core import exceptions
from kmip.core import objects
from kmip.core import primitives
from kmip.core import secrets
from kmip.core import utils
from kmip.core.objects import TemplateAttribute
from kmip.core.primitives import Struct
from kmip.core.utils import BytearrayStream
from kmip.core.factories import secrets as secret_factory
# 4.3
class RegisterRequestPayload(Struct):
class RegisterRequestPayload(primitives.Struct):
"""
A request payload for the Register operation.
Attributes:
object_type: The type of the object to register.
template_attribute: A group of attributes to set on the new object.
managed_object: The object to register.
"""
def __init__(self,
object_type=None,
template_attribute=None,
secret=None):
managed_object=None):
"""
Construct a Register request payload structure.
Args:
object_type (enum): An ObjectType enumeration specifying the type
of object to register. Optional, defaults to None. Required for
read/write.
template_attribute (TemplateAttribute): A TemplateAttribute
structure containing a set of attributes to set on the new
object. Optional, defaults to None. Required for read/write.
managed_object (Struct): A managed object structure representing
the object to register. Must be one of:
* secrets.Certificate
* secrets.OpaqueObject
* secrets.PrivateKey
* secrets.PublicKey
* secrets.SecretData
* secrets.SplitKey
* secrets.SymmetricKey
* secrets.Template
Optional, defaults to None. Required for read/write.
"""
super(RegisterRequestPayload, self).__init__(
enums.Tags.REQUEST_PAYLOAD
)
self.secret_factory = SecretFactory()
self.secret_factory = secret_factory.SecretFactory()
self._object_type = None
self._template_attribute = None
self._secret = None
self.object_type = object_type
self.template_attribute = template_attribute
self.secret = secret
self.managed_object = managed_object
self.validate()
@property
def object_type(self):
if self._object_type:
return self._object_type.value
else:
return None
def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
@object_type.setter
def object_type(self, value):
if value is None:
self._object_type = None
elif isinstance(value, enums.ObjectType):
self._object_type = primitives.Enumeration(
enums.ObjectType,
value=value,
tag=enums.Tags.OBJECT_TYPE
)
else:
raise TypeError(
"Object type must be an ObjectType enumeration."
)
@property
def template_attribute(self):
return self._template_attribute
@template_attribute.setter
def template_attribute(self, value):
if value is None:
self._template_attribute = None
elif isinstance(value, objects.TemplateAttribute):
self._template_attribute = value
else:
raise TypeError(
"Template attribute must be a TemplateAttribute structure."
)
@property
def managed_object(self):
return self._managed_object
@managed_object.setter
def managed_object(self, value):
if value is None:
self._managed_object = None
elif isinstance(
value,
(
secrets.Certificate,
secrets.OpaqueObject,
secrets.PrivateKey,
secrets.PublicKey,
secrets.SecretData,
secrets.SplitKey,
secrets.SymmetricKey,
secrets.Template
)
):
self._managed_object = value
else:
raise TypeError(
"Managed object must be a supported managed object structure."
)
def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the Register request payload and decode it into
its constituent parts.
Args:
input_buffer (stream): A data buffer containing encoded object
data, supporting a read method.
kmip_version (KMIPVersion): An enumeration defining the KMIP
version with which the object will be decoded. Optional,
defaults to KMIP 1.0.
Raises:
InvalidKmipEncoding: Raised if the object type, template attribute,
or managed object is missing from the encoded payload.
"""
super(RegisterRequestPayload, self).read(
istream,
input_buffer,
kmip_version=kmip_version
)
tstream = BytearrayStream(istream.read(self.length))
local_buffer = utils.BytearrayStream(input_buffer.read(self.length))
self.object_type = attributes.ObjectType()
self.template_attribute = TemplateAttribute()
if self.is_tag_next(enums.Tags.OBJECT_TYPE, local_buffer):
self._object_type = primitives.Enumeration(
enums.ObjectType,
tag=enums.Tags.OBJECT_TYPE
)
self._object_type.read(local_buffer, kmip_version=kmip_version)
else:
raise exceptions.InvalidKmipEncoding(
"The Register request payload encoding is missing the object "
"type."
)
self.object_type.read(tstream, kmip_version=kmip_version)
self.template_attribute.read(tstream, kmip_version=kmip_version)
if self.is_tag_next(enums.Tags.TEMPLATE_ATTRIBUTE, local_buffer):
self._template_attribute = objects.TemplateAttribute()
self._template_attribute.read(
local_buffer,
kmip_version=kmip_version
)
else:
raise exceptions.InvalidKmipEncoding(
"The Register request payload encoding is missing the "
"template attribute."
)
secret_type = self.object_type.value
secret = self.secret_factory.create(secret_type)
managed_object = self.secret_factory.create(self.object_type)
if self.is_tag_next(secret.tag, tstream):
self.secret = secret
self.secret.read(tstream, kmip_version=kmip_version)
if self.is_tag_next(managed_object.tag, local_buffer):
self._managed_object = managed_object
self._managed_object.read(local_buffer, kmip_version=kmip_version)
else:
raise exceptions.InvalidKmipEncoding(
"The Register request payload encoding is missing the managed "
"object."
)
self.is_oversized(tstream)
self.validate()
self.is_oversized(local_buffer)
def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
tstream = BytearrayStream()
def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the Register request payload to a buffer.
# Write the contents of the request payload
self.object_type.write(tstream, kmip_version=kmip_version)
self.template_attribute.write(tstream, kmip_version=kmip_version)
Args:
output_buffer (stream): A data buffer in which to encode object
data, supporting a write method.
kmip_version (KMIPVersion): An enumeration defining the KMIP
version with which the object will be encoded. Optional,
defaults to KMIP 1.0.
if self.secret is not None:
self.secret.write(tstream, kmip_version=kmip_version)
Raises:
InvalidField: Raised if the object type attribute, template
attribute, or managed object is not defined.
"""
local_buffer = utils.BytearrayStream()
# Write the length and value of the request payload
self.length = tstream.length()
if self._object_type:
self._object_type.write(local_buffer, kmip_version=kmip_version)
else:
raise exceptions.InvalidField(
"The Register request payload is missing the object type "
"field."
)
if self._template_attribute:
self._template_attribute.write(
local_buffer,
kmip_version=kmip_version
)
else:
raise exceptions.InvalidField(
"The Register request payload is missing the template "
"attribute field."
)
if self._managed_object:
self._managed_object.write(local_buffer, kmip_version=kmip_version)
else:
raise exceptions.InvalidField(
"The Register request payload is missing the managed object "
"field."
)
self.length = local_buffer.length()
super(RegisterRequestPayload, self).write(
ostream,
output_buffer,
kmip_version=kmip_version
)
ostream.write(tstream.buffer)
output_buffer.write(local_buffer.buffer)
def validate(self):
self.__validate()
def __eq__(self, other):
if isinstance(other, RegisterRequestPayload):
if self.object_type != other.object_type:
return False
elif self.template_attribute != other.template_attribute:
return False
elif self.managed_object != other.managed_object:
return False
else:
return True
else:
return NotImplemented
def __validate(self):
# TODO (peter-hamilton) Finish implementation.
pass
def __ne__(self, other):
if isinstance(other, RegisterRequestPayload):
return not (self == other)
else:
return NotImplemented
def __repr__(self):
args = ", ".join([
"object_type={}".format(self.object_type),
"template_attribute={}".format(repr(self.template_attribute)),
"managed_object={}".format(repr(self.managed_object))
])
return "RegisterRequestPayload({})".format(args)
def __str__(self):
value = ", ".join(
[
'"object_type": {}'.format(self.object_type),
'"template_attribute": {}'.format(self.template_attribute),
'"managed_object": {}'.format(self.managed_object)
]
)
return '{' + value + '}'
class RegisterResponsePayload(Struct):
class RegisterResponsePayload(primitives.Struct):
"""
A response payload for the Register operation.
Attributes:
unique_identifier: The unique ID of the new object.
template_attribute: A group of attributes that were set on the new
object.
"""
def __init__(self,
unique_identifier=None,
template_attribute=None):
"""
Construct a Register response payload structure.
Args:
unique_identifier (string): The ID of the new object. Optional,
defaults to None. Required for read/write.
template_attribute (TemplateAttribute): A TemplateAttribute
structure containing a set of attributes that were set on the
new object. Optional, defaults to None.
"""
super(RegisterResponsePayload, self).__init__(
enums.Tags.RESPONSE_PAYLOAD
)
self._unique_identifier = None
self._template_attribute = None
self.unique_identifier = unique_identifier
self.template_attribute = template_attribute
self.validate()
@property
def unique_identifier(self):
if self._unique_identifier:
return self._unique_identifier.value
else:
return None
def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
@unique_identifier.setter
def unique_identifier(self, value):
if value is None:
self._unique_identifier = None
elif isinstance(value, six.string_types):
self._unique_identifier = primitives.TextString(
value=value,
tag=enums.Tags.UNIQUE_IDENTIFIER
)
else:
raise TypeError("Unique identifier must be a string.")
@property
def template_attribute(self):
return self._template_attribute
@template_attribute.setter
def template_attribute(self, value):
if value is None:
self._template_attribute = None
elif isinstance(value, objects.TemplateAttribute):
self._template_attribute = value
else:
raise TypeError(
"Template attribute must be a TemplateAttribute structure."
)
def read(self, input_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Read the data encoding the Register response payload and decode it
into its constituent parts.
Args:
input_buffer (stream): A data buffer containing encoded object
data, supporting a read method.
kmip_version (KMIPVersion): An enumeration defining the KMIP
version with which the object will be decoded. Optional,
defaults to KMIP 1.0.
Raises:
InvalidKmipEncoding: Raised if the unique identifier is missing
from the encoded payload.
"""
super(RegisterResponsePayload, self).read(
istream,
input_buffer,
kmip_version=kmip_version
)
tstream = BytearrayStream(istream.read(self.length))
local_buffer = utils.BytearrayStream(input_buffer.read(self.length))
self.unique_identifier = attributes.UniqueIdentifier()
self.unique_identifier.read(tstream, kmip_version=kmip_version)
if self.is_tag_next(enums.Tags.UNIQUE_IDENTIFIER, local_buffer):
self._unique_identifier = primitives.TextString(
tag=enums.Tags.UNIQUE_IDENTIFIER
)
self._unique_identifier.read(
local_buffer,
kmip_version=kmip_version
)
else:
raise exceptions.InvalidKmipEncoding(
"The Register response payload encoding is missing the unique "
"identifier."
)
if self.is_tag_next(enums.Tags.TEMPLATE_ATTRIBUTE, tstream):
self.template_attribute = TemplateAttribute()
self.template_attribute.read(tstream, kmip_version=kmip_version)
if self.is_tag_next(enums.Tags.TEMPLATE_ATTRIBUTE, local_buffer):
self._template_attribute = objects.TemplateAttribute()
self._template_attribute.read(
local_buffer,
kmip_version=kmip_version
)
self.is_oversized(tstream)
self.validate()
self.is_oversized(local_buffer)
def write(self, ostream, kmip_version=enums.KMIPVersion.KMIP_1_0):
tstream = BytearrayStream()
def write(self, output_buffer, kmip_version=enums.KMIPVersion.KMIP_1_0):
"""
Write the data encoding the Register response payload to a buffer.
# Write the contents of the request payload
self.unique_identifier.write(tstream, kmip_version=kmip_version)
Args:
output_buffer (stream): A data buffer in which to encode object
data, supporting a write method.
kmip_version (KMIPVersion): An enumeration defining the KMIP
version with which the object will be encoded. Optional,
defaults to KMIP 1.0.
if self.template_attribute is not None:
self.template_attribute.write(tstream, kmip_version=kmip_version)
Raises:
InvalidField: Raised if the unique identifier is not defined.
"""
local_buffer = utils.BytearrayStream()
# Write the length and value of the request payload
self.length = tstream.length()
if self._unique_identifier:
self._unique_identifier.write(
local_buffer,
kmip_version=kmip_version
)
else:
raise exceptions.InvalidField(
"The Register response payload is missing the unique "
"identifier field."
)
if self._template_attribute:
self._template_attribute.write(
local_buffer,
kmip_version=kmip_version
)
self.length = local_buffer.length()
super(RegisterResponsePayload, self).write(
ostream,
output_buffer,
kmip_version=kmip_version
)
ostream.write(tstream.buffer)
output_buffer.write(local_buffer.buffer)
def validate(self):
self.__validate()
def __eq__(self, other):
if isinstance(other, RegisterResponsePayload):
if self.unique_identifier != other.unique_identifier:
return False
elif self.template_attribute != other.template_attribute:
return False
else:
return True
else:
return NotImplemented
def __validate(self):
# TODO (peter-hamilton) Finish implementation.
pass
def __ne__(self, other):
if isinstance(other, RegisterResponsePayload):
return not (self == other)
else:
return NotImplemented
def __repr__(self):
args = ", ".join([
"unique_identifier='{}'".format(self.unique_identifier),
"template_attribute={}".format(repr(self.template_attribute))
])
return "RegisterResponsePayload({})".format(args)
def __str__(self):
value = ", ".join(
[
'"unique_identifier": "{}"'.format(self.unique_identifier),
'"template_attribute": {}'.format(self.template_attribute)
]
)
return '{' + value + '}'

View File

@ -83,7 +83,7 @@ if __name__ == '__main__':
result.result_status.value))
if result.result_status.value == ResultStatus.SUCCESS:
logger.info('registered UUID: {0}'.format(result.uuid.value))
logger.info('registered UUID: {0}'.format(result.uuid))
logger.info('registered template attribute: {0}'.
format(result.template_attribute))
else:

View File

@ -426,8 +426,7 @@ class ProxyKmipClient(object):
status = result.result_status.value
if status == enums.ResultStatus.SUCCESS:
uid = result.uuid.value
return uid
return result.uuid
else:
reason = result.result_reason.value
message = result.result_message.value

View File

@ -672,7 +672,6 @@ class KMIPProxy(object):
def register(self, object_type, template_attribute, secret,
credential=None):
object_type = attr.ObjectType(object_type)
return self._register(object_type=object_type,
template_attribute=template_attribute,
secret=secret,
@ -1449,7 +1448,7 @@ class KMIPProxy(object):
req_pl = payloads.RegisterRequestPayload(
object_type=object_type,
template_attribute=template_attribute,
secret=secret)
managed_object=secret)
batch_item = messages.RequestBatchItem(operation=operation,
request_payload=req_pl)

View File

@ -1285,7 +1285,7 @@ class KmipEngine(object):
def _process_register(self, payload):
self._logger.info("Processing operation: Register")
object_type = payload.object_type.value
object_type = payload.object_type
template_attribute = payload.template_attribute
if self._object_map.get(object_type) is None:
@ -1298,8 +1298,8 @@ class KmipEngine(object):
)
)
if payload.secret:
secret = payload.secret
if payload.managed_object:
secret = payload.managed_object
else:
# TODO (peterhamilton) It is possible to register 'empty' secrets
# like Private Keys. For now, that feature is not supported.
@ -1340,9 +1340,7 @@ class KmipEngine(object):
)
response_payload = payloads.RegisterResponsePayload(
unique_identifier=attributes.UniqueIdentifier(
str(managed_object.unique_identifier)
)
unique_identifier=str(managed_object.unique_identifier)
)
self._id_placeholder = str(managed_object.unique_identifier)

View File

@ -427,10 +427,10 @@ class TestIntegration(TestCase):
credential=None)
self._check_result_status(result, ResultStatus, ResultStatus.SUCCESS)
self._check_uuid(result.uuid.value, str)
self._check_uuid(result.uuid, str)
# Check that the returned key bytes match what was provided
uuid = result.uuid.value
uuid = result.uuid
result = self.client.get(uuid=uuid, credential=None)
self._check_result_status(result, ResultStatus, ResultStatus.SUCCESS)
@ -654,10 +654,10 @@ class TestIntegration(TestCase):
self._check_result_status(priv_key_result, ResultStatus,
ResultStatus.SUCCESS)
self._check_uuid(priv_key_result.uuid.value, str)
self._check_uuid(priv_key_result.uuid, str)
# Check that the returned key bytes match what was provided
priv_uuid = priv_key_result.uuid.value
priv_uuid = priv_key_result.uuid
priv_key_result = self.client.get(uuid=priv_uuid, credential=None)
@ -766,7 +766,7 @@ class TestIntegration(TestCase):
self._check_result_status(pub_key_result, ResultStatus,
ResultStatus.SUCCESS)
# Check that the returned key bytes match what was provided
pub_uuid = pub_key_result.uuid.value
pub_uuid = pub_key_result.uuid
pub_key_result = self.client.get(uuid=pub_uuid, credential=None)
self._check_result_status(pub_key_result, ResultStatus,
ResultStatus.SUCCESS)
@ -901,10 +901,10 @@ class TestIntegration(TestCase):
self._check_result_status(cert_result, ResultStatus,
ResultStatus.SUCCESS)
self._check_uuid(cert_result.uuid.value, str)
self._check_uuid(cert_result.uuid, str)
# Check that the returned key bytes match what was provided
cert_uuid = cert_result.uuid.value
cert_uuid = cert_result.uuid
cert_result = self.client.get(uuid=cert_uuid, credential=None)
@ -1008,10 +1008,10 @@ class TestIntegration(TestCase):
self._check_result_status(pass_result, ResultStatus,
ResultStatus.SUCCESS)
self._check_uuid(pass_result.uuid.value, str)
self._check_uuid(pass_result.uuid, str)
# Check that the returned key bytes match what was provided
pass_uuid = pass_result.uuid.value
pass_uuid = pass_result.uuid
pass_result = self.client.get(uuid=pass_uuid, credential=None)
@ -1102,10 +1102,10 @@ class TestIntegration(TestCase):
self._check_result_status(opaque_obj_result, ResultStatus,
ResultStatus.SUCCESS)
self._check_uuid(opaque_obj_result.uuid.value, str)
self._check_uuid(opaque_obj_result.uuid, str)
# Check that the returned key bytes match what was provided
opaque_obj_uuid = opaque_obj_result.uuid.value
opaque_obj_uuid = opaque_obj_result.uuid
opaque_obj_result = self.client.get(uuid=opaque_obj_uuid,
credential=None)

View File

@ -230,7 +230,7 @@ class TestKMIPClientIntegration(TestCase):
self._check_result_status(result.result_status.value, ResultStatus,
ResultStatus.SUCCESS)
self._check_uuid(result.uuid.value, str)
self._check_uuid(result.uuid, str)
# Check the template attribute type
self._check_template_attribute(result.template_attribute,
@ -238,7 +238,7 @@ class TestKMIPClientIntegration(TestCase):
[[str, 'Unique Identifier', str,
None]])
# Check that the returned key bytes match what was provided
uuid = result.uuid.value
uuid = result.uuid
result = self.client.get(uuid=uuid, credential=credential)
self._check_result_status(result.result_status.value, ResultStatus,

File diff suppressed because it is too large Load Diff

View File

@ -715,12 +715,12 @@ class TestRequestMessage(TestCase):
object_type = request_payload.object_type
msg = "Bad object type type: expected {0}, received {1}"
self.assertIsInstance(object_type, attr.ObjectType,
msg.format(attr.ObjectType,
self.assertIsInstance(object_type, enums.ObjectType,
msg.format(enums.ObjectType,
type(object_type)))
msg = "Bad object type value: expected {0}, received {1}"
exp_value = enums.ObjectType.TEMPLATE
rcv_value = object_type.value
rcv_value = object_type
self.assertEqual(exp_value, rcv_value,
msg.format(exp_value, rcv_value))
@ -784,7 +784,7 @@ class TestRequestMessage(TestCase):
operation = contents.Operation(enums.Operation.REGISTER)
object_type = attr.ObjectType(enums.ObjectType.TEMPLATE)
object_type = enums.ObjectType.TEMPLATE
tmpl_attr = objects.TemplateAttribute()
attributes = []
@ -833,7 +833,7 @@ class TestRequestMessage(TestCase):
request_payload = payloads.RegisterRequestPayload(
object_type=object_type,
template_attribute=tmpl_attr,
secret=template)
managed_object=template)
batch_item = messages.RequestBatchItem(operation=operation,
request_payload=request_payload)
request_message = messages.RequestMessage(request_header=req_header,
@ -1891,12 +1891,12 @@ class TestResponseMessage(TestCase):
unique_identifier = response_payload.unique_identifier
msg = "Bad unique identifier type: expected {0}, received {1}"
self.assertIsInstance(unique_identifier, attr.UniqueIdentifier,
msg.format(attr.UniqueIdentifier,
self.assertIsInstance(unique_identifier, six.string_types,
msg.format(six.string_types,
type(unique_identifier)))
msg = "Bad unique identifier value: expected {0}, received {1}"
exp_value = '5c9b81ef-4ee5-42cd-ba2d-c002fdd0c7b3'
rcv_value = unique_identifier.value
rcv_value = unique_identifier
self.assertEqual(exp_value, rcv_value,
msg.format(exp_value, rcv_value))
@ -1914,7 +1914,7 @@ class TestResponseMessage(TestCase):
operation = contents.Operation(enums.Operation.REGISTER)
result_status = contents.ResultStatus(enums.ResultStatus.SUCCESS)
uuid = attr.UniqueIdentifier('5c9b81ef-4ee5-42cd-ba2d-c002fdd0c7b3')
uuid = '5c9b81ef-4ee5-42cd-ba2d-c002fdd0c7b3'
resp_pl = payloads.RegisterResponsePayload(unique_identifier=uuid)
batch_item = messages.ResponseBatchItem(operation=operation,
result_status=result_status,

View File

@ -1591,8 +1591,8 @@ class TestProxyKmipClient(testtools.TestCase):
result = results.RegisterResult(
contents.ResultStatus(enums.ResultStatus.SUCCESS),
uuid=attr.PublicKeyUniqueIdentifier(
'aaaaaaaa-1111-2222-3333-ffffffffffff'))
uuid='aaaaaaaa-1111-2222-3333-ffffffffffff'
)
with ProxyKmipClient() as client:
client.proxy.register.return_value = result

View File

@ -3357,7 +3357,7 @@ class TestKmipEngine(testtools.TestCase):
attribute_factory = factory.AttributeFactory()
# Build a SymmetricKey for registration.
object_type = attributes.ObjectType(enums.ObjectType.SYMMETRIC_KEY)
object_type = enums.ObjectType.SYMMETRIC_KEY
template_attribute = objects.TemplateAttribute(
attributes=[
attribute_factory.create_attribute(
@ -3408,7 +3408,7 @@ class TestKmipEngine(testtools.TestCase):
payload = payloads.RegisterRequestPayload(
object_type=object_type,
template_attribute=template_attribute,
secret=secret
managed_object=secret
)
response_payload = e._process_register(payload)
@ -3419,7 +3419,7 @@ class TestKmipEngine(testtools.TestCase):
"Processing operation: Register"
)
uid = response_payload.unique_identifier.value
uid = response_payload.unique_identifier
self.assertEqual('1', uid)
# Retrieve the stored object and verify all attributes were set
@ -3467,7 +3467,7 @@ class TestKmipEngine(testtools.TestCase):
e._data_session = e._data_store_session_factory()
e._logger = mock.MagicMock()
object_type = attributes.ObjectType(enums.ObjectType.SPLIT_KEY)
object_type = enums.ObjectType.SPLIT_KEY
payload = payloads.RegisterRequestPayload(object_type=object_type)
args = (payload, )
@ -3491,7 +3491,7 @@ class TestKmipEngine(testtools.TestCase):
e._data_session = e._data_store_session_factory()
e._logger = mock.MagicMock()
object_type = attributes.ObjectType(enums.ObjectType.SYMMETRIC_KEY)
object_type = enums.ObjectType.SYMMETRIC_KEY
payload = payloads.RegisterRequestPayload(object_type=object_type)
args = (payload, )
@ -8337,7 +8337,7 @@ class TestKmipEngine(testtools.TestCase):
attribute_factory = factory.AttributeFactory()
# Build a SymmetricKey for registration.
object_type = attributes.ObjectType(enums.ObjectType.SYMMETRIC_KEY)
object_type = enums.ObjectType.SYMMETRIC_KEY
template_attribute = objects.TemplateAttribute(
attributes=[
attribute_factory.create_attribute(
@ -8385,7 +8385,7 @@ class TestKmipEngine(testtools.TestCase):
payload = payloads.RegisterRequestPayload(
object_type=object_type,
template_attribute=template_attribute,
secret=secret
managed_object=secret
)
response_payload = e._process_register(payload)
@ -8396,7 +8396,7 @@ class TestKmipEngine(testtools.TestCase):
"Processing operation: Register"
)
uid = response_payload.unique_identifier.value
uid = response_payload.unique_identifier
self.assertEqual('1', uid)
e._logger.reset_mock()
@ -8479,7 +8479,7 @@ class TestKmipEngine(testtools.TestCase):
attribute_factory = factory.AttributeFactory()
# Build a SymmetricKey for registration.
object_type = attributes.ObjectType(enums.ObjectType.SYMMETRIC_KEY)
object_type = enums.ObjectType.SYMMETRIC_KEY
template_attribute = objects.TemplateAttribute(
attributes=[
attribute_factory.create_attribute(
@ -8527,7 +8527,7 @@ class TestKmipEngine(testtools.TestCase):
payload = payloads.RegisterRequestPayload(
object_type=object_type,
template_attribute=template_attribute,
secret=secret
managed_object=secret
)
response_payload = e._process_register(payload)
@ -8538,7 +8538,7 @@ class TestKmipEngine(testtools.TestCase):
"Processing operation: Register"
)
uuid = response_payload.unique_identifier.value
uuid = response_payload.unique_identifier
self.assertEqual('1', uuid)
e._logger.reset_mock()