Пример #1
0
    def _integration_test_process(self, request, expected):
        """
        Semi-integration test of the Request processing;
         includes the encode/decode of messages and operation specific
         Payloads.

        WF is mocked on the socket level:
         - request blob data are supplied to socket in two chunks:
             -- Request tag/type/length;
             -- Request Message data.
         - data sent by socket are restored from the mock-calls and compared
           with expected data (excluding the TimeStamp data -- TODO).
        """

        socket = mock.MagicMock()
        socket.recv = mock.MagicMock(side_effect=[request[:8], request[8:]])

        socket.sendall = mock.MagicMock()

        factory = KMIPProtocolFactory()
        protocol = factory.getProtocol(socket)

        handler = KMIPImpl()
        processor = Processor(handler)

        processor.process(protocol, protocol)

        (args, kwargs) = socket.sendall.call_args
        to_cmp = self._setTimeStamp(args[0], expected)
        self.assertEqual(expected, to_cmp, "Unexpected error")
Пример #2
0
    def __init__(self,
                 host=None,
                 port=None,
                 keyfile=None,
                 certfile=None,
                 cert_reqs=None,
                 ssl_version=None,
                 ca_certs=None,
                 do_handshake_on_connect=None,
                 suppress_ragged_eofs=None):
        warnings.simplefilter("always")
        warnings.warn((
            "Please use the newer KmipServer located in kmip.services.server. "
            "This version of the server will be deprecated in the future."),
                      PendingDeprecationWarning)
        warnings.simplefilter("default")

        self.logger = logging.getLogger(__name__)

        self._set_variables(host, port, keyfile, certfile, cert_reqs,
                            ssl_version, ca_certs, do_handshake_on_connect,
                            suppress_ragged_eofs)

        handler = KMIPImpl()
        self._processor = Processor(handler)

        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        self.socket.bind((self.host, self.port))
Пример #3
0
    def test_init(self):
        """
        Test that a Kmip Server Processor can be created without errors.
        """

        handler = KMIPImpl()
        Processor(handler)