def _test_read(self, stream, extension_name, extension_tag,
                   extension_type):
        extension_information = ExtensionInformation()
        extension_information.read(stream)

        if extension_name is None:
            extension_name = ExtensionName()

        msg = "extension name encoding mismatch"
        msg += "; expected {0}, observed {1}".format(
            extension_name, extension_information.extension_name)
        self.assertEqual(extension_name, extension_information.extension_name,
                         msg)

        msg = "extension tag encoding mismatch"
        msg += "; expected {0}, observed {1}".format(
            extension_tag, extension_information.extension_tag)
        self.assertEqual(extension_tag, extension_information.extension_tag,
                         msg)

        msg = "extension type encoding mismatch"
        msg += "; expected {0}, observed {1}".format(
            extension_type, extension_information.extension_type)
        self.assertEqual(extension_type, extension_information.extension_type,
                         msg)
    def _test_read(self, stream, extension_name, extension_tag,
                   extension_type):
        extension_information = ExtensionInformation()
        extension_information.read(stream)

        if extension_name is None:
            extension_name = ExtensionName()

        msg = "extension name encoding mismatch"
        msg += "; expected {0}, observed {1}".format(
            extension_name,
            extension_information.extension_name)
        self.assertEqual(
            extension_name,
            extension_information.extension_name, msg)

        msg = "extension tag encoding mismatch"
        msg += "; expected {0}, observed {1}".format(
            extension_tag,
            extension_information.extension_tag)
        self.assertEqual(
            extension_tag,
            extension_information.extension_tag, msg)

        msg = "extension type encoding mismatch"
        msg += "; expected {0}, observed {1}".format(
            extension_type,
            extension_information.extension_type)
        self.assertEqual(
            extension_type,
            extension_information.extension_type, msg)
Beispiel #3
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()
Beispiel #4
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()