Merge pull request from OpenKMIP/bug/fix-factory-support-for-object-type

Updating the attribute value factory to support ObjectType values
This commit is contained in:
Peter Hamilton 2016-12-06 14:41:09 -05:00 committed by GitHub
commit 7ee336ad56
2 changed files with 19 additions and 3 deletions
kmip
core/factories
tests/unit/core/factories

View File

@ -28,7 +28,7 @@ class AttributeValueFactory(object):
elif name is enums.AttributeType.NAME:
return self._create_name(value)
elif name is enums.AttributeType.OBJECT_TYPE:
return attributes.ObjectType()
return attributes.ObjectType(value)
elif name is enums.AttributeType.CRYPTOGRAPHIC_ALGORITHM:
return attributes.CryptographicAlgorithm(value)
elif name is enums.AttributeType.CRYPTOGRAPHIC_LENGTH:

View File

@ -49,9 +49,25 @@ class TestAttributeValueFactory(testtools.TestCase):
def test_create_object_type(self):
"""
Test that an ObjectType attribute can be created.
Test that an empty ObjectType attribute can be created.
"""
self.skip('')
object_type = self.factory.create_attribute_value(
enums.AttributeType.OBJECT_TYPE,
None
)
self.assertIsInstance(object_type, attributes.ObjectType)
self.assertEqual(None, object_type.value)
def test_create_object_type_with_value(self):
"""
Test that an ObjectType attribute can be created with a custom value.
"""
object_type = self.factory.create_attribute_value(
enums.AttributeType.OBJECT_TYPE,
enums.ObjectType.SYMMETRIC_KEY
)
self.assertIsInstance(object_type, attributes.ObjectType)
self.assertEqual(enums.ObjectType.SYMMETRIC_KEY, object_type.value)
def test_create_cryptographic_algorithm(self):
"""