2
0
mirror of https://github.com/openkmip/pykmip synced 2025-12-21 02:33:33 +00:00

Update utilities to remove use of TemplateAttribute subclasses

This change updates the TemplateAttribute conversion utilities to
remove use of various TemplateAttribute subclasses. This reflects
the usage updates added for CreateKeyPair support. All related
unit tests have been updated to reflect this change.
This commit is contained in:
Peter Hamilton
2019-03-18 11:56:25 -04:00
committed by Peter Hamilton
parent 71d508019a
commit 1c85295d89
2 changed files with 28 additions and 17 deletions

View File

@@ -2979,11 +2979,11 @@ def convert_template_attribute_to_attributes(value):
raise TypeError("Input must be a TemplateAttribute structure.")
tag = enums.Tags.ATTRIBUTES
if isinstance(value, CommonTemplateAttribute):
if value.tag == enums.Tags.COMMON_TEMPLATE_ATTRIBUTE:
tag = enums.Tags.COMMON_ATTRIBUTES
elif isinstance(value, PrivateKeyTemplateAttribute):
elif value.tag == enums.Tags.PRIVATE_KEY_TEMPLATE_ATTRIBUTE:
tag = enums.Tags.PRIVATE_KEY_ATTRIBUTES
elif isinstance(value, PublicKeyTemplateAttribute):
elif value.tag == enums.Tags.PUBLIC_KEY_TEMPLATE_ATTRIBUTE:
tag = enums.Tags.PUBLIC_KEY_ATTRIBUTES
attribute_values = []
@@ -3014,14 +3014,18 @@ def convert_attributes_to_template_attribute(value):
)
)
template_tag = enums.Tags.TEMPLATE_ATTRIBUTE
if value.tag == enums.Tags.COMMON_ATTRIBUTES:
return CommonTemplateAttribute(attributes=attribute_structures)
template_tag = enums.Tags.COMMON_TEMPLATE_ATTRIBUTE
elif value.tag == enums.Tags.PRIVATE_KEY_ATTRIBUTES:
return PrivateKeyTemplateAttribute(attributes=attribute_structures)
template_tag = enums.Tags.PRIVATE_KEY_TEMPLATE_ATTRIBUTE
elif value.tag == enums.Tags.PUBLIC_KEY_ATTRIBUTES:
return PublicKeyTemplateAttribute(attributes=attribute_structures)
else:
return TemplateAttribute(attributes=attribute_structures)
template_tag = enums.Tags.PUBLIC_KEY_TEMPLATE_ATTRIBUTE
return TemplateAttribute(
attributes=attribute_structures,
tag=template_tag
)
# 2.1.9