Ejemplo n.º 1
0
    def _test_read(self, stream, data):
        server_information = ServerInformation()
        server_information.read(stream)

        expected = data
        observed = server_information.data

        msg = "data decoding mismatch"
        msg += "; expected {0}, observed {1}".format(expected, observed)
        self.assertEqual(expected, observed, msg)
Ejemplo n.º 2
0
    def test_not_equal_on_equal_and_empty(self):
        """
        Test that the inequality operator returns False when comparing
        two ServerInformation objects with no internal data.
        """
        a = ServerInformation()
        b = ServerInformation()

        self.assertFalse(a != b)
        self.assertFalse(b != a)
Ejemplo n.º 3
0
    def _test_read(self, stream, data):
        server_information = ServerInformation()
        server_information.read(stream)

        expected = data
        observed = server_information.data

        msg = "data decoding mismatch"
        msg += "; expected {0}, observed {1}".format(expected, observed)
        self.assertEqual(expected, observed, msg)
Ejemplo n.º 4
0
    def test_equal_on_equal_and_empty(self):
        """
        Test that the equality operator returns True when comparing two
        ServerInformation objects with no internal data.
        """
        a = ServerInformation()
        b = ServerInformation()

        self.assertTrue(a == b)
        self.assertTrue(b == a)
Ejemplo n.º 5
0
    def test_not_equal_on_not_equal(self):
        """
        Test that the inequality operator returns True when comparing two
        ServerInformation objects with different sets of internal data.
        """
        a = ServerInformation()
        b = ServerInformation()

        a.data = self.data

        self.assertTrue(a != b)
        self.assertTrue(b != a)
Ejemplo n.º 6
0
    def test_not_equal_on_not_equal(self):
        """
        Test that the inequality operator returns True when comparing two
        ServerInformation objects with different sets of internal data.
        """
        a = ServerInformation()
        b = ServerInformation()

        a.data = self.data

        self.assertTrue(a != b)
        self.assertTrue(b != a)
Ejemplo n.º 7
0
    def test_not_equal_on_equal(self):
        """
        Test that the inequality operator returns False when comparing
        two ServerInformation objects with the same internal data.
        """
        a = ServerInformation()
        b = ServerInformation()

        a.data = self.data
        b.data = self.data

        self.assertFalse(a != b)
        self.assertFalse(b != a)
Ejemplo n.º 8
0
 def test_process_query_batch_item_with_results(self):
     self._test_process_query_batch_item(
         list(),
         list(),
         VendorIdentification(),
         ServerInformation(),
         list(),
         list())
Ejemplo n.º 9
0
    def read(self, istream, kmip_version=enums.KMIPVersion.KMIP_1_0):
        """
        Read the data encoding the QueryResponsePayload object and decode it
        into its constituent parts.

        Args:
            istream (Stream): A data stream containing encoded object data,
                supporting a read method; usually a BytearrayStream object.
            kmip_version (KMIPVersion): An enumeration defining the KMIP
                version with which the object will be decoded. Optional,
                defaults to KMIP 1.0.
        """
        super(QueryResponsePayload, self).read(istream,
                                               kmip_version=kmip_version)
        tstream = BytearrayStream(istream.read(self.length))

        while (self.is_tag_next(enums.Tags.OPERATION, tstream)):
            operation = Operation()
            operation.read(tstream, kmip_version=kmip_version)
            self.operations.append(operation)

        while (self.is_tag_next(enums.Tags.OBJECT_TYPE, tstream)):
            object_type = ObjectType()
            object_type.read(tstream, kmip_version=kmip_version)
            self.object_types.append(object_type)

        if self.is_tag_next(enums.Tags.VENDOR_IDENTIFICATION, tstream):
            self.vendor_identification = VendorIdentification()
            self.vendor_identification.read(tstream, kmip_version=kmip_version)

        if self.is_tag_next(enums.Tags.SERVER_INFORMATION, tstream):
            self.server_information = ServerInformation()
            self.server_information.read(tstream, kmip_version=kmip_version)

        while (self.is_tag_next(enums.Tags.APPLICATION_NAMESPACE, tstream)):
            application_namespace = ApplicationNamespace()
            application_namespace.read(tstream, kmip_version=kmip_version)
            self.application_namespaces.append(application_namespace)

        while (self.is_tag_next(enums.Tags.EXTENSION_INFORMATION, tstream)):
            extension_information = ExtensionInformation()
            extension_information.read(tstream, kmip_version=kmip_version)
            self.extension_information.append(extension_information)

        self.is_oversized(tstream)
        self.validate()
Ejemplo n.º 10
0
    def _test_str(self, data):
        server_information = ServerInformation()
        server_information.data = data
        str_repr = str(server_information)

        expected = len(str(data))
        observed = len(str_repr)

        msg = "expected {0}, observed {1}".format(expected, observed)
        self.assertEqual(expected, observed, msg)

        # TODO (peter-hamilton) This should be binary_type. Fix involves
        # TODO (peter-hamilton) refining BytearrayStream implementation.
        expected = string_types
        observed = str_repr

        msg = "expected {0}, observed {1}".format(expected, observed)
        self.assertIsInstance(observed, expected, msg)
Ejemplo n.º 11
0
    def _test_str(self, data):
        server_information = ServerInformation()
        server_information.data = data
        str_repr = str(server_information)

        expected = len(str(data))
        observed = len(str_repr)

        msg = "expected {0}, observed {1}".format(expected, observed)
        self.assertEqual(expected, observed, msg)

        # TODO (peter-hamilton) This should be binary_type. Fix involves
        # TODO (peter-hamilton) refining BytearrayStream implementation.
        expected = string_types
        observed = str_repr

        msg = "expected {0}, observed {1}".format(expected, observed)
        self.assertIsInstance(observed, expected, msg)
Ejemplo n.º 12
0
    def test_not_equal_on_type_mismatch(self):
        """
        Test that the inequality operator returns True when comparing a
        ServerInformation object to a non-ServerInformation object.
        """
        a = ServerInformation()
        b = "invalid"

        self.assertTrue(a != b)
Ejemplo n.º 13
0
    def _test_write(self, stream_expected, data):
        stream_observed = BytearrayStream()
        server_information = ServerInformation()

        if data is not None:
            server_information.data = data

        server_information.write(stream_observed)

        length_expected = len(stream_expected)
        length_observed = len(stream_observed)

        msg = "encoding lengths not equal"
        msg += "; expected {0}, observed {1}".format(length_expected,
                                                     length_observed)
        self.assertEqual(length_expected, length_observed, msg)

        msg = "encoding mismatch"
        msg += ";\nexpected:\n{0}\nobserved:\n{1}".format(
            stream_expected, stream_observed)
        self.assertEqual(stream_expected, stream_observed, msg)
Ejemplo n.º 14
0
    def _test_write(self, stream_expected, data):
        stream_observed = BytearrayStream()
        server_information = ServerInformation()

        if data is not None:
            server_information.data = data

        server_information.write(stream_observed)

        length_expected = len(stream_expected)
        length_observed = len(stream_observed)

        msg = "encoding lengths not equal"
        msg += "; expected {0}, observed {1}".format(
            length_expected, length_observed)
        self.assertEqual(length_expected, length_observed, msg)

        msg = "encoding mismatch"
        msg += ";\nexpected:\n{0}\nobserved:\n{1}".format(
            stream_expected, stream_observed)
        self.assertEqual(stream_expected, stream_observed, msg)
Ejemplo n.º 15
0
    def test_equal_on_equal(self):
        """
        Test that the equality operator returns True when comparing two
        ServerInformation objects with the same internal data.
        """
        a = ServerInformation()
        b = ServerInformation()

        a.data = self.data
        b.data = self.data

        self.assertTrue(a == b)
        self.assertTrue(b == a)
Ejemplo n.º 16
0
    def test_repr(self):
        """
        Test that the representation of a ServerInformation object is
        formatted properly and can be used by eval to create a new
        ServerInformation object.
        """
        server_information = ServerInformation()

        expected = "ServerInformation()"
        observed = repr(server_information)

        msg = "expected {0}, observed {1}".format(expected, observed)
        self.assertEqual(expected, observed, msg)

        expected = server_information
        observed = eval(observed)

        msg = "expected {0}, observed {1}".format(expected, observed)
        self.assertEqual(expected, observed, msg)
Ejemplo n.º 17
0
    def read(self, istream):
        """
        Read the data encoding the QueryResponsePayload object and decode it
        into its constituent parts.

        Args:
            istream (Stream): A data stream containing encoded object data,
                supporting a read method; usually a BytearrayStream object.
        """
        super(QueryResponsePayload, self).read(istream)
        tstream = BytearrayStream(istream.read(self.length))

        while(self.is_tag_next(Tags.OPERATION, tstream)):
            operation = Operation()
            operation.read(tstream)
            self.operations.append(operation)

        while(self.is_tag_next(Tags.OBJECT_TYPE, tstream)):
            object_type = ObjectType()
            object_type.read(tstream)
            self.object_types.append(object_type)

        if self.is_tag_next(Tags.VENDOR_IDENTIFICATION, tstream):
            self.vendor_identification = VendorIdentification()
            self.vendor_identification.read(tstream)

        if self.is_tag_next(Tags.SERVER_INFORMATION, tstream):
            self.server_information = ServerInformation()
            self.server_information.read(tstream)

        while(self.is_tag_next(Tags.APPLICATION_NAMESPACE, tstream)):
            application_namespace = ApplicationNamespace()
            application_namespace.read(tstream)
            self.application_namespaces.append(application_namespace)

        while(self.is_tag_next(Tags.EXTENSION_INFORMATION, tstream)):
            extension_information = ExtensionInformation()
            extension_information.read(tstream)
            self.extension_information.append(extension_information)

        self.is_oversized(tstream)
        self.validate()
Ejemplo n.º 18
0
class QueryResponsePayload(Struct):
    """
    A response payload for the Query operation.

    The payload contains different sets of responses that the KMIP server
    provides in response to the initial Query request. See Section 4.25 of the
    KMIP 1.1 specification for more information.

    Attributes:
        operations: A list of Operations supported by the server.
        object_types: A list of ObjectTypes supported by the server.
        vendor_identification: A string identifying the server vendor.
        server_information: A structure containing vendor-specific fields and
            substructures.
        application_namespaces: A list of application namespaces supported by
            the server.
        extension_information: A list of ExtensionInformation objects detailing
            Objects supported by the server with ItemTag values in the
            Extensions range.
    """
    def __init__(self, operations=None, object_types=None,
                 vendor_identification=None, server_information=None,
                 application_namespaces=None, extension_information=None):
        """
        Construct a QueryResponsePayload object.

        Args:
            operations (list): A list of Operations supported by the server.
            object_types (list): A list of ObjectTypes supported by the server.
            vendor_identification (VendorIdentification): A string identifying
                the server vendor.
            server_information (ServerInformation): A structure containing
                vendor-specific fields and substructures.
            application_namespaces (list): A list of application namespaces
                supported by the server.
            extension_information (list): A list of ExtensionInformation
                objects detailing Objects supported by the server with ItemTag
                values in the Extensions range.
        """
        super(QueryResponsePayload, self).__init__(Tags.RESPONSE_PAYLOAD)

        if operations is None:
            self.operations = list()
        else:
            self.operations = operations

        if object_types is None:
            self.object_types = list()
        else:
            self.object_types = object_types

        self.vendor_identification = vendor_identification
        self.server_information = server_information

        if application_namespaces is None:
            self.application_namespaces = list()
        else:
            self.application_namespaces = application_namespaces

        if extension_information is None:
            self.extension_information = list()
        else:
            self.extension_information = extension_information

        self.validate()

    def read(self, istream):
        """
        Read the data encoding the QueryResponsePayload object and decode it
        into its constituent parts.

        Args:
            istream (Stream): A data stream containing encoded object data,
                supporting a read method; usually a BytearrayStream object.
        """
        super(QueryResponsePayload, self).read(istream)
        tstream = BytearrayStream(istream.read(self.length))

        while(self.is_tag_next(Tags.OPERATION, tstream)):
            operation = Operation()
            operation.read(tstream)
            self.operations.append(operation)

        while(self.is_tag_next(Tags.OBJECT_TYPE, tstream)):
            object_type = ObjectType()
            object_type.read(tstream)
            self.object_types.append(object_type)

        if self.is_tag_next(Tags.VENDOR_IDENTIFICATION, tstream):
            self.vendor_identification = VendorIdentification()
            self.vendor_identification.read(tstream)

        if self.is_tag_next(Tags.SERVER_INFORMATION, tstream):
            self.server_information = ServerInformation()
            self.server_information.read(tstream)

        while(self.is_tag_next(Tags.APPLICATION_NAMESPACE, tstream)):
            application_namespace = ApplicationNamespace()
            application_namespace.read(tstream)
            self.application_namespaces.append(application_namespace)

        while(self.is_tag_next(Tags.EXTENSION_INFORMATION, tstream)):
            extension_information = ExtensionInformation()
            extension_information.read(tstream)
            self.extension_information.append(extension_information)

        self.is_oversized(tstream)
        self.validate()

    def write(self, ostream):
        """
        Write the data encoding the QueryResponsePayload object to a stream.

        Args:
            ostream (Stream): A data stream in which to encode object data,
                supporting a write method; usually a BytearrayStream object.
        """
        tstream = BytearrayStream()

        for operation in self.operations:
            operation.write(tstream)

        for object_type in self.object_types:
            object_type.write(tstream)

        if self.vendor_identification is not None:
            self.vendor_identification.write(tstream)

        if self.server_information is not None:
            self.server_information.write(tstream)

        for application_namespace in self.application_namespaces:
            application_namespace.write(tstream)

        for extension_information in self.extension_information:
            extension_information.write(tstream)

        self.length = tstream.length()
        super(QueryResponsePayload, self).write(ostream)
        ostream.write(tstream.buffer)

    def validate(self):
        """
        Error check the attributes of the QueryRequestPayload object.
        """
        self.__validate()

    def __validate(self):
        # TODO (peter-hamilton) Add separate validate_list function for this
        if isinstance(self.operations, list):
            for i in xrange(len(self.operations)):
                operation = self.operations[i]
                if not isinstance(operation, Operation):
                    msg = "invalid operation ({0} in list)".format(i)
                    msg += "; expected {0}, received {1}".format(
                        Operation, operation)
                    raise TypeError(msg)
        else:
            msg = "invalid operations list"
            msg += "; expected {0}, received {1}".format(
                list, self.operations)
            raise TypeError(msg)

        if isinstance(self.object_types, list):
            for i in xrange(len(self.object_types)):
                object_type = self.object_types[i]
                if not isinstance(object_type, ObjectType):
                    msg = "invalid object type ({0} in list)".format(i)
                    msg += "; expected {0}, received {1}".format(
                        ObjectType, object_type)
                    raise TypeError(msg)
        else:
            msg = "invalid object types list"
            msg += "; expected {0}, received {1}".format(
                list, self.object_types)
            raise TypeError(msg)

        if self.vendor_identification is not None:
            if not isinstance(self.vendor_identification,
                              VendorIdentification):
                msg = "invalid vendor identification"
                msg += "; expected {0}, received {1}".format(
                    VendorIdentification, self.vendor_identification)
                raise TypeError(msg)

        if self.server_information is not None:
            if not isinstance(self.server_information, ServerInformation):
                msg = "invalid server information"
                msg += "; expected {0}, received {1}".format(
                    ServerInformation, self.server_information)
                raise TypeError(msg)

        if isinstance(self.application_namespaces, list):
            for i in xrange(len(self.application_namespaces)):
                application_namespace = self.application_namespaces[i]
                if not isinstance(application_namespace, ApplicationNamespace):
                    msg = "invalid application namespace ({0} in list)".format(
                        i)
                    msg += "; expected {0}, received {1}".format(
                        ApplicationNamespace, application_namespace)
                    raise TypeError(msg)
        else:
            msg = "invalid application namespaces list"
            msg += "; expected {0}, received {1}".format(
                list, self.application_namespaces)
            raise TypeError(msg)

        if isinstance(self.extension_information, list):
            for i in xrange(len(self.extension_information)):
                extension_information = self.extension_information[i]
                if not isinstance(extension_information, ExtensionInformation):
                    msg = "invalid extension information ({0} in list)".format(
                        i)
                    msg += "; expected {0}, received {1}".format(
                        ExtensionInformation, extension_information)
                    raise TypeError(msg)
        else:
            msg = "invalid extension information list"
            msg += "; expected {0}, received {1}".format(
                list, self.extension_information)
            raise TypeError(msg)
Ejemplo n.º 19
0
class QueryResponsePayload(Struct):
    """
    A response payload for the Query operation.

    The payload contains different sets of responses that the KMIP server
    provides in response to the initial Query request. See Section 4.25 of the
    KMIP 1.1 specification for more information.

    Attributes:
        operations: A list of Operations supported by the server.
        object_types: A list of ObjectTypes supported by the server.
        vendor_identification: A string identifying the server vendor.
        server_information: A structure containing vendor-specific fields and
            substructures.
        application_namespaces: A list of application namespaces supported by
            the server.
        extension_information: A list of ExtensionInformation objects detailing
            Objects supported by the server with ItemTag values in the
            Extensions range.
    """
    def __init__(self,
                 operations=None,
                 object_types=None,
                 vendor_identification=None,
                 server_information=None,
                 application_namespaces=None,
                 extension_information=None):
        """
        Construct a QueryResponsePayload object.

        Args:
            operations (list): A list of Operations supported by the server.
            object_types (list): A list of ObjectTypes supported by the server.
            vendor_identification (VendorIdentification): A string identifying
                the server vendor.
            server_information (ServerInformation): A structure containing
                vendor-specific fields and substructures.
            application_namespaces (list): A list of application namespaces
                supported by the server.
            extension_information (list): A list of ExtensionInformation
                objects detailing Objects supported by the server with ItemTag
                values in the Extensions range.
        """
        super(QueryResponsePayload, self).__init__(Tags.RESPONSE_PAYLOAD)

        if operations is None:
            self.operations = list()
        else:
            self.operations = operations

        if object_types is None:
            self.object_types = list()
        else:
            self.object_types = object_types

        self.vendor_identification = vendor_identification
        self.server_information = server_information

        if application_namespaces is None:
            self.application_namespaces = list()
        else:
            self.application_namespaces = application_namespaces

        if extension_information is None:
            self.extension_information = list()
        else:
            self.extension_information = extension_information

        self.validate()

    def read(self, istream):
        """
        Read the data encoding the QueryResponsePayload object and decode it
        into its constituent parts.

        Args:
            istream (Stream): A data stream containing encoded object data,
                supporting a read method; usually a BytearrayStream object.
        """
        super(QueryResponsePayload, self).read(istream)
        tstream = BytearrayStream(istream.read(self.length))

        while (self.is_tag_next(Tags.OPERATION, tstream)):
            operation = Operation()
            operation.read(tstream)
            self.operations.append(operation)

        while (self.is_tag_next(Tags.OBJECT_TYPE, tstream)):
            object_type = ObjectType()
            object_type.read(tstream)
            self.object_types.append(object_type)

        if self.is_tag_next(Tags.VENDOR_IDENTIFICATION, tstream):
            self.vendor_identification = VendorIdentification()
            self.vendor_identification.read(tstream)

        if self.is_tag_next(Tags.SERVER_INFORMATION, tstream):
            self.server_information = ServerInformation()
            self.server_information.read(tstream)

        while (self.is_tag_next(Tags.APPLICATION_NAMESPACE, tstream)):
            application_namespace = ApplicationNamespace()
            application_namespace.read(tstream)
            self.application_namespaces.append(application_namespace)

        while (self.is_tag_next(Tags.EXTENSION_INFORMATION, tstream)):
            extension_information = ExtensionInformation()
            extension_information.read(tstream)
            self.extension_information.append(extension_information)

        self.is_oversized(tstream)
        self.validate()

    def write(self, ostream):
        """
        Write the data encoding the QueryResponsePayload object to a stream.

        Args:
            ostream (Stream): A data stream in which to encode object data,
                supporting a write method; usually a BytearrayStream object.
        """
        tstream = BytearrayStream()

        for operation in self.operations:
            operation.write(tstream)

        for object_type in self.object_types:
            object_type.write(tstream)

        if self.vendor_identification is not None:
            self.vendor_identification.write(tstream)

        if self.server_information is not None:
            self.server_information.write(tstream)

        for application_namespace in self.application_namespaces:
            application_namespace.write(tstream)

        for extension_information in self.extension_information:
            extension_information.write(tstream)

        self.length = tstream.length()
        super(QueryResponsePayload, self).write(ostream)
        ostream.write(tstream.buffer)

    def validate(self):
        """
        Error check the attributes of the QueryRequestPayload object.
        """
        self.__validate()

    def __validate(self):
        # TODO (peter-hamilton) Add separate validate_list function for this
        if isinstance(self.operations, list):
            for i in xrange(len(self.operations)):
                operation = self.operations[i]
                if not isinstance(operation, Operation):
                    msg = "invalid operation ({0} in list)".format(i)
                    msg += "; expected {0}, received {1}".format(
                        Operation, operation)
                    raise TypeError(msg)
        else:
            msg = "invalid operations list"
            msg += "; expected {0}, received {1}".format(list, self.operations)
            raise TypeError(msg)

        if isinstance(self.object_types, list):
            for i in xrange(len(self.object_types)):
                object_type = self.object_types[i]
                if not isinstance(object_type, ObjectType):
                    msg = "invalid object type ({0} in list)".format(i)
                    msg += "; expected {0}, received {1}".format(
                        ObjectType, object_type)
                    raise TypeError(msg)
        else:
            msg = "invalid object types list"
            msg += "; expected {0}, received {1}".format(
                list, self.object_types)
            raise TypeError(msg)

        if self.vendor_identification is not None:
            if not isinstance(self.vendor_identification,
                              VendorIdentification):
                msg = "invalid vendor identification"
                msg += "; expected {0}, received {1}".format(
                    VendorIdentification, self.vendor_identification)
                raise TypeError(msg)

        if self.server_information is not None:
            if not isinstance(self.server_information, ServerInformation):
                msg = "invalid server information"
                msg += "; expected {0}, received {1}".format(
                    ServerInformation, self.server_information)
                raise TypeError(msg)

        if isinstance(self.application_namespaces, list):
            for i in xrange(len(self.application_namespaces)):
                application_namespace = self.application_namespaces[i]
                if not isinstance(application_namespace, ApplicationNamespace):
                    msg = "invalid application namespace ({0} in list)".format(
                        i)
                    msg += "; expected {0}, received {1}".format(
                        ApplicationNamespace, application_namespace)
                    raise TypeError(msg)
        else:
            msg = "invalid application namespaces list"
            msg += "; expected {0}, received {1}".format(
                list, self.application_namespaces)
            raise TypeError(msg)

        if isinstance(self.extension_information, list):
            for i in xrange(len(self.extension_information)):
                extension_information = self.extension_information[i]
                if not isinstance(extension_information, ExtensionInformation):
                    msg = "invalid extension information ({0} in list)".format(
                        i)
                    msg += "; expected {0}, received {1}".format(
                        ExtensionInformation, extension_information)
                    raise TypeError(msg)
        else:
            msg = "invalid extension information list"
            msg += "; expected {0}, received {1}".format(
                list, self.extension_information)
            raise TypeError(msg)
Ejemplo n.º 20
0
    def setUp(self):
        super(TestQueryResponsePayload, self).setUp()

        self.operations = list()
        self.object_types = list()
        self.application_namespaces = list()
        self.extension_information = list()

        self.vendor_identification = VendorIdentification(
            "IBM test server, not-TKLM 2.0.1.1 KMIP 2.0.0.1")
        self.server_information = ServerInformation()

        self.operations.append(Operation(OperationEnum.CREATE))
        self.operations.append(Operation(OperationEnum.CREATE_KEY_PAIR))
        self.operations.append(Operation(OperationEnum.REGISTER))
        self.operations.append(Operation(OperationEnum.REKEY))
        self.operations.append(Operation(OperationEnum.CERTIFY))
        self.operations.append(Operation(OperationEnum.RECERTIFY))
        self.operations.append(Operation(OperationEnum.LOCATE))
        self.operations.append(Operation(OperationEnum.CHECK))
        self.operations.append(Operation(OperationEnum.GET))
        self.operations.append(Operation(OperationEnum.GET_ATTRIBUTES))
        self.operations.append(Operation(OperationEnum.GET_ATTRIBUTE_LIST))
        self.operations.append(Operation(OperationEnum.ADD_ATTRIBUTE))
        self.operations.append(Operation(OperationEnum.MODIFY_ATTRIBUTE))
        self.operations.append(Operation(OperationEnum.DELETE_ATTRIBUTE))
        self.operations.append(Operation(OperationEnum.OBTAIN_LEASE))
        self.operations.append(Operation(OperationEnum.GET_USAGE_ALLOCATION))
        self.operations.append(Operation(OperationEnum.ACTIVATE))
        self.operations.append(Operation(OperationEnum.REVOKE))
        self.operations.append(Operation(OperationEnum.DESTROY))
        self.operations.append(Operation(OperationEnum.ARCHIVE))
        self.operations.append(Operation(OperationEnum.RECOVER))
        self.operations.append(Operation(OperationEnum.QUERY))
        self.operations.append(Operation(OperationEnum.CANCEL))
        self.operations.append(Operation(OperationEnum.POLL))
        self.operations.append(Operation(OperationEnum.REKEY_KEY_PAIR))
        self.operations.append(Operation(OperationEnum.DISCOVER_VERSIONS))

        self.object_types.append(ObjectType(ObjectTypeEnum.CERTIFICATE))
        self.object_types.append(ObjectType(ObjectTypeEnum.SYMMETRIC_KEY))
        self.object_types.append(ObjectType(ObjectTypeEnum.PUBLIC_KEY))
        self.object_types.append(ObjectType(ObjectTypeEnum.PRIVATE_KEY))
        self.object_types.append(ObjectType(ObjectTypeEnum.TEMPLATE))
        self.object_types.append(ObjectType(ObjectTypeEnum.SECRET_DATA))

        self.extension_information.append(
            ExtensionInformation(
                extension_name=ExtensionName("ACME LOCATION")))
        self.extension_information.append(
            ExtensionInformation(
                extension_name=ExtensionName("ACME ZIP CODE")))

        self.encoding_a = utils.BytearrayStream(
            (b'\x42\x00\x7C\x01\x00\x00\x00\x00'))

        self.encoding_b = utils.BytearrayStream((
            b'\x42\x00\x7C\x01\x00\x00\x02\x40\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x01\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x02\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x03\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x04\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x06\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x07\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x08\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x09\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x0A\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x0B\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x0C\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x0D\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x0E\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x0F\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x10\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x11\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x12\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x13\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x14\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x15\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x16\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x18\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x19\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x1A\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x1D\x00\x00\x00\x00\x42\x00\x5C\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x1E\x00\x00\x00\x00\x42\x00\x57\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x01\x00\x00\x00\x00\x42\x00\x57\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x02\x00\x00\x00\x00\x42\x00\x57\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x03\x00\x00\x00\x00\x42\x00\x57\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x04\x00\x00\x00\x00\x42\x00\x57\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x06\x00\x00\x00\x00\x42\x00\x57\x05\x00\x00\x00\x04'
            b'\x00\x00\x00\x07\x00\x00\x00\x00\x42\x00\x9D\x07\x00\x00\x00\x2E'
            b'\x49\x42\x4D\x20\x74\x65\x73\x74\x20\x73\x65\x72\x76\x65\x72\x2C'
            b'\x20\x6E\x6F\x74\x2D\x54\x4B\x4C\x4D\x20\x32\x2E\x30\x2E\x31\x2E'
            b'\x31\x20\x4B\x4D\x49\x50\x20\x32\x2E\x30\x2E\x30\x2E\x31\x00\x00'
            b'\x42\x00\x88\x01\x00\x00\x00\x00'))

        self.encoding_c = utils.BytearrayStream((
            b'\x42\x00\x7C\x01\x00\x00\x00\x40\x42\x00\xA4\x01\x00\x00\x00\x18'
            b'\x42\x00\xA5\x07\x00\x00\x00\x0D\x41\x43\x4D\x45\x20\x4C\x4F\x43'
            b'\x41\x54\x49\x4F\x4E\x00\x00\x00\x42\x00\xA4\x01\x00\x00\x00\x18'
            b'\x42\x00\xA5\x07\x00\x00\x00\x0D\x41\x43\x4D\x45\x20\x5A\x49\x50'
            b'\x20\x43\x4F\x44\x45\x00\x00\x00'))
Ejemplo n.º 21
0
 def test_init(self):
     ServerInformation()