Adding various date attribute values

This commit is contained in:
Tim Kelsey 2015-07-01 15:43:41 +01:00
parent f22b3f9c60
commit 6bd311701c
2 changed files with 68 additions and 9 deletions

View File

@ -14,6 +14,9 @@
# under the License. # under the License.
from kmip.core.enums import AttributeType from kmip.core.enums import AttributeType
from kmip.core.enums import Tags
from kmip.core.primitives import DateTime
from kmip.core.attributes import ApplicationSpecificInformation from kmip.core.attributes import ApplicationSpecificInformation
from kmip.core.attributes import ContactInformation from kmip.core.attributes import ContactInformation
@ -234,34 +237,34 @@ class AttributeValueFactory(object):
raise NotImplementedError() raise NotImplementedError()
def _create_initial_date(self, date): def _create_initial_date(self, date):
raise NotImplementedError() return DateTime(value=date, tag=Tags.INITIAL_DATE)
def _create_activation_date(self, date): def _create_activation_date(self, date):
raise NotImplementedError() return DateTime(value=date, tag=Tags.ACTIVATION_DATE)
def _create_process_start_date(self, date): def _create_process_start_date(self, date):
raise NotImplementedError() return DateTime(value=date, tag=Tags.PROCESS_START_DATE)
def _create_protect_stop_date(self, date): def _create_protect_stop_date(self, date):
raise NotImplementedError() return DateTime(value=date, tag=Tags.PROTECT_STOP_DATE)
def _create_deactivation_date(self, date): def _create_deactivation_date(self, date):
raise NotImplementedError() return DateTime(value=date, tag=Tags.DEACTIVATION_DATE)
def _create_destroy_date(self, date): def _create_destroy_date(self, date):
raise NotImplementedError() return DateTime(value=date, tag=Tags.DESTROY_DATE)
def _create_compromise_occurrence_date(self, date): def _create_compromise_occurrence_date(self, date):
raise NotImplementedError() return DateTime(value=date, tag=Tags.COMPROMISE_OCCURRENCE_DATE)
def _create_compromise_date(self, date): def _create_compromise_date(self, date):
raise NotImplementedError() return DateTime(value=date, tag=Tags.COMPROMISE_DATE)
def _create_revocation_reason(self, reason): def _create_revocation_reason(self, reason):
raise NotImplementedError() raise NotImplementedError()
def _create_archive_date(self, date): def _create_archive_date(self, date):
raise NotImplementedError() return DateTime(value=date, tag=Tags.ARCHIVE_DATE)
def _create_object_group(self, group): def _create_object_group(self, group):
if group is not None and not isinstance(group, str): if group is not None and not isinstance(group, str):

View File

@ -20,11 +20,14 @@ from kmip.core.enums import BlockCipherMode
from kmip.core.enums import HashingAlgorithm from kmip.core.enums import HashingAlgorithm
from kmip.core.enums import PaddingMethod from kmip.core.enums import PaddingMethod
from kmip.core.enums import KeyRoleType from kmip.core.enums import KeyRoleType
from kmip.core.enums import Tags
from kmip.core import attributes from kmip.core import attributes
from kmip.core.attributes import CryptographicParameters from kmip.core.attributes import CryptographicParameters
from kmip.core.attributes import OperationPolicyName from kmip.core.attributes import OperationPolicyName
from kmip.core.primitives import DateTime
from kmip.core.factories.attribute_values import AttributeValueFactory from kmip.core.factories.attribute_values import AttributeValueFactory
@ -132,3 +135,56 @@ class TestAttributeValueFactory(TestCase):
# noqa - E128 continuation line under-indented for visual indent # noqa - E128 continuation line under-indented for visual indent
self._test_cryptograpic_parameters(cp, None, None, None, self._test_cryptograpic_parameters(cp, None, None, None,
attributes.HashingAlgorithm(HashingAlgorithm.SHA_512)) # noqa attributes.HashingAlgorithm(HashingAlgorithm.SHA_512)) # noqa
def _test_date_value(self, date, value, tag):
msg = "expected {0}, received {1}"
self.assertIsInstance(date, DateTime, msg.format(
DateTime, date.__class__))
self.assertEqual(date.value, value, msg.format(value, date.value))
self.assertEqual(date.tag, tag, msg.format(tag, date.tag))
def test_create_initial_date(self):
date = self.factory.create_attribute_value(
AttributeType.INITIAL_DATE, 0)
self._test_date_value(date, 0, Tags.INITIAL_DATE)
def test_create_activation_date(self):
date = self.factory.create_attribute_value(
AttributeType.ACTIVATION_DATE, 0)
self._test_date_value(date, 0, Tags.ACTIVATION_DATE)
def test_create_process_start_date(self):
date = self.factory.create_attribute_value(
AttributeType.PROCESS_START_DATE, 0)
self._test_date_value(date, 0, Tags.PROCESS_START_DATE)
def test_create_protect_stop_date(self):
date = self.factory.create_attribute_value(
AttributeType.PROTECT_STOP_DATE, 0)
self._test_date_value(date, 0, Tags.PROTECT_STOP_DATE)
def test_create_deactivation_date(self):
date = self.factory.create_attribute_value(
AttributeType.DEACTIVATION_DATE, 0)
self._test_date_value(date, 0, Tags.DEACTIVATION_DATE)
def test_create_destroy_date(self):
date = self.factory.create_attribute_value(
AttributeType.DESTROY_DATE, 0)
self._test_date_value(date, 0, Tags.DESTROY_DATE)
def test_create_compromise_occurance_date(self):
date = self.factory.create_attribute_value(
AttributeType.COMPROMISE_OCCURRENCE_DATE, 0)
self._test_date_value(date, 0, Tags.COMPROMISE_OCCURRENCE_DATE)
def test_create_compromise_date(self):
date = self.factory.create_attribute_value(
AttributeType.COMPROMISE_DATE, 0)
self._test_date_value(date, 0, Tags.COMPROMISE_DATE)
def test_create_archive_date(self):
date = self.factory.create_attribute_value(
AttributeType.ARCHIVE_DATE, 0)
self._test_date_value(date, 0, Tags.ARCHIVE_DATE)