Example #1
0
    def test_tls_connect_disconnect(self):
        """Test with TLS or SSL endpoint.

        According to the deprecation note for the SSL client endpoint,
        the TLS endpoint is supported from Twistd 16.0.

        TODO add certificate verification (also will require some conditionals
        on various versions, including PyOpenSSL, service_identity. The CA used
        to generate the testing cert is in ``PKI_DIR/ca``
        """
        def escape_colon(path):
            # on windows we can't have \ as it serves as the escape character for :
            return path.replace('\\', '/').replace(':', '\\:')

        self.server_connection_string = (
            "ssl:port=0:certKey={pub}:privateKey={priv}:" +
            "interface=127.0.0.1").format(
                pub=escape_colon(os.path.join(PKI_DIR, '127.0.0.1.crt')),
                priv=escape_colon(os.path.join(PKI_DIR, '127.0.0.1.key')))
        self.client_connection_string_tpl = "ssl:host=127.0.0.1:port={port}"

        yield self.addWorker()

        # connect
        worker = yield self.connectWorker()

        # disconnect
        self.workerSideDisconnect(worker)

        # wait for the resulting detach
        yield worker.waitForDetach()
Example #2
0
    def test_tls_connect_disconnect(self):
        """Test with TLS or SSL endpoint.

        According to the deprecation note for the SSL client endpoint,
        the TLS endpoint is supported from Twistd 16.0.

        TODO add certificate verification (also will require some conditionals
        on various versions, including PyOpenSSL, service_identity. The CA used
        to generate the testing cert is in ``PKI_DIR/ca``
        """
        def escape_colon(path):
            # on windows we can't have \ as it serves as the escape character for :
            return path.replace('\\', '/').replace(':', '\\:')
        self.server_connection_string = (
            "ssl:port=0:certKey={pub}:privateKey={priv}:" +
            "interface=127.0.0.1").format(
                pub=escape_colon(os.path.join(PKI_DIR, '127.0.0.1.crt')),
                priv=escape_colon(os.path.join(PKI_DIR, '127.0.0.1.key')))
        self.client_connection_string_tpl = "ssl:host=127.0.0.1:port={port}"

        yield self.addWorker()

        # connect
        worker = yield self.connectWorker()

        # disconnect
        self.workerSideDisconnect(worker)

        # wait for the resulting detach
        yield worker.waitForDetach()
Example #3
0
    def test_connect_disconnect(self):
        """Test a single worker connecting and disconnecting."""
        yield self.addWorker()

        # connect
        worker = yield self.connectWorker()

        # disconnect
        self.workerSideDisconnect(worker)

        # wait for the resulting detach
        yield worker.waitForDetach()
Example #4
0
    def test_connect_disconnect(self):
        """Test a single worker connecting and disconnecting."""
        yield self.addWorker()

        # connect
        worker = yield self.connectWorker()

        # disconnect
        self.workerSideDisconnect(worker)

        # wait for the resulting detach
        yield worker.waitForDetach()
    def test_worker_info(self):
        yield self.addWorker()
        worker = yield self.connectWorker()
        props = self.buildworker.worker_status.info
        # check worker info passing
        self.assertEqual(props.getProperty("info"),
                         "here")
        # check worker info passing with UTF-8
        self.assertEqual(props.getProperty("os_release"),
                         b'\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88'.decode())
        self.assertEqual(props.getProperty(b'\xe3\x83\xaa\xe3\x83\xaa\xe3\x83\xbc\xe3\x82'
                                           b'\xb9\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88'.decode()),
                         b'\xe3\x83\x86\xe3\x82\xb9\xe3\x83\x88'.decode())
        self.assertEqual(props.getProperty("none"), None)
        self.assertEqual(props.getProperty("numcpus"), 1)

        self.workerSideDisconnect(worker)
        yield worker.waitForDetach()