Merge pull request #188 from OpenKMIP/feat/add-state-attribute

Adding support for the State attribute
This commit is contained in:
Peter Hamilton 2016-08-27 17:50:41 -04:00 committed by GitHub
commit 249fafb89b
3 changed files with 13 additions and 5 deletions

View File

@ -620,6 +620,12 @@ class CryptographicUsageMask(Integer):
value, Tags.CRYPTOGRAPHIC_USAGE_MASK) value, Tags.CRYPTOGRAPHIC_USAGE_MASK)
class State(Enumeration):
def __init__(self, value=None):
super(State, self).__init__(enums.State, value, Tags.STATE)
# 3.33 # 3.33
class ObjectGroup(TextString): class ObjectGroup(TextString):

View File

@ -66,7 +66,7 @@ class AttributeValueFactory(object):
elif name is enums.AttributeType.USAGE_LIMITS: elif name is enums.AttributeType.USAGE_LIMITS:
raise NotImplementedError() raise NotImplementedError()
elif name is enums.AttributeType.STATE: elif name is enums.AttributeType.STATE:
raise NotImplementedError() return attributes.State(value)
elif name is enums.AttributeType.INITIAL_DATE: elif name is enums.AttributeType.INITIAL_DATE:
return primitives.DateTime(value, enums.Tags.INITIAL_DATE) return primitives.DateTime(value, enums.Tags.INITIAL_DATE)
elif name is enums.AttributeType.ACTIVATION_DATE: elif name is enums.AttributeType.ACTIVATION_DATE:

View File

@ -228,10 +228,12 @@ class TestAttributeValueFactory(testtools.TestCase):
""" """
Test that a State attribute can be created. Test that a State attribute can be created.
""" """
kwargs = {'name': enums.AttributeType.STATE, state = self.factory.create_attribute_value(
'value': None} enums.AttributeType.STATE,
self.assertRaises( enums.State.ACTIVE
NotImplementedError, self.factory.create_attribute_value, **kwargs) )
self.assertIsInstance(state, attributes.State)
self.assertEqual(enums.State.ACTIVE, state.value)
def test_create_initial_date(self): def test_create_initial_date(self):
""" """