mirror of
https://github.com/OpenKMIP/PyKMIP.git
synced 2025-04-08 19:25:06 +02:00
Adding OperationPolicyName
This change adds the OperationPolicyName attribute, extending support to the AttributeValueFactory. Test cases are included for the creation process for both the factory and the individual attribute.
This commit is contained in:
parent
b99bf8cbf4
commit
3918c320fd
kmip
core
tests/core
@ -259,6 +259,14 @@ class CertificateType(Enumeration):
|
||||
Tags.CERTIFICATE_TYPE)
|
||||
|
||||
|
||||
# 3.18
|
||||
class OperationPolicyName(TextString):
|
||||
|
||||
def __init__(self, value=None):
|
||||
super(OperationPolicyName, self).__init__(
|
||||
value, Tags.OPERATION_POLICY_NAME)
|
||||
|
||||
|
||||
# 3.19
|
||||
class CryptographicUsageMask(Integer):
|
||||
|
||||
|
@ -25,6 +25,7 @@ from kmip.core.attributes import Name
|
||||
from kmip.core.attributes import ObjectGroup
|
||||
from kmip.core.attributes import UniqueIdentifier
|
||||
from kmip.core.attributes import ObjectType
|
||||
from kmip.core.attributes import OperationPolicyName
|
||||
|
||||
from kmip.core import utils
|
||||
|
||||
@ -185,7 +186,7 @@ class AttributeValueFactory(object):
|
||||
raise NotImplementedError()
|
||||
|
||||
def _create_operation_policy_name(self, name):
|
||||
raise NotImplementedError()
|
||||
return OperationPolicyName(name)
|
||||
|
||||
def _create_cryptographic_usage_mask(self, flags):
|
||||
mask = None
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
from testtools import TestCase
|
||||
|
||||
from kmip.core.enums import AttributeType
|
||||
from kmip.core.attributes import OperationPolicyName
|
||||
from kmip.core.factories.attribute_values import AttributeValueFactory
|
||||
|
||||
|
||||
@ -26,3 +28,32 @@ class TestAttributeValueFactory(TestCase):
|
||||
|
||||
def tearDown(self):
|
||||
super(TestAttributeValueFactory, self).tearDown()
|
||||
|
||||
# TODO (peter-hamilton) Consider even further modularity
|
||||
def _test_operation_policy_name(self, opn, value):
|
||||
msg = "expected {0}, received {1}".format(OperationPolicyName, opn)
|
||||
self.assertIsInstance(opn, OperationPolicyName, msg)
|
||||
|
||||
msg = "expected {0}, received {1}".format(value, opn.value)
|
||||
self.assertEqual(value, opn.value, msg)
|
||||
|
||||
def _test_create_attribute_value_operation_policy_name(self, value):
|
||||
opn = self.factory.create_attribute_value(
|
||||
AttributeType.OPERATION_POLICY_NAME, value)
|
||||
self._test_operation_policy_name(opn, value)
|
||||
|
||||
def _test_create_operation_policy_name(self, value):
|
||||
opn = self.factory._create_operation_policy_name(value)
|
||||
self._test_operation_policy_name(opn, value)
|
||||
|
||||
def test_create_attribute_value_operation_policy_name(self):
|
||||
self._test_create_attribute_value_operation_policy_name('test')
|
||||
|
||||
def test_create_attribute_value_operation_policy_name_on_none(self):
|
||||
self._test_create_attribute_value_operation_policy_name(None)
|
||||
|
||||
def test_create_operation_policy_name(self):
|
||||
self._test_create_operation_policy_name('test')
|
||||
|
||||
def test_create_operation_policy_name_on_none(self):
|
||||
self._test_create_operation_policy_name(None)
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
from testtools import TestCase
|
||||
|
||||
from kmip.core.attributes import OperationPolicyName
|
||||
|
||||
from kmip.core.utils import BytearrayStream
|
||||
|
||||
|
||||
@ -60,3 +62,24 @@ class TestName(TestCase):
|
||||
|
||||
def test_maximum_read(self):
|
||||
self.skip('Not implemented')
|
||||
|
||||
|
||||
class TestOperationPolicyName(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestOperationPolicyName, self).setUp()
|
||||
|
||||
def tearDown(self):
|
||||
super(TestOperationPolicyName, self).tearDown()
|
||||
|
||||
def _test_operation_policy_name(self, value):
|
||||
opn = OperationPolicyName(value)
|
||||
|
||||
msg = "expected {0}, received {1}".format(value, opn.value)
|
||||
self.assertEqual(value, opn.value, msg)
|
||||
|
||||
def test_operation_policy_name(self):
|
||||
self._test_operation_policy_name('test')
|
||||
|
||||
def test_operation_policy_name_on_none(self):
|
||||
self._test_operation_policy_name(None)
|
||||
|
Loading…
x
Reference in New Issue
Block a user