Exemplo n.º 1
0
    def test_client_dump_filter(self):
        """
        Test the installing of a dump filter into client endpoint
        """
        setup_logging()
        with NamedTemporaryFile(delete=DELETE_TMPFILE) as logf:
            client_filter = DumpFilter(handler={"filename": logf.name})
            self.clt_tun.install_filter(client_filter)

            self.client.send_message(self.message, self.on_response_received)
            self.wait(timeout=ASYNC_TIMEOUT)

            content = logf.read()
            for line in hex_dump(self.message).splitlines():
                self.assertIn(line, content.decode("utf-8"))

            self.clt_tun.uninstall_filter(client_filter)
Exemplo n.º 2
0
        def setUp(self):
            # super(WSTunnelServerDaemonTestCase, self).setUp()
            self.log_file, self.pid_file = setup_logging()

            with open(os.path.join(fixture, "wstunsrvd.yml")) as f:
                self.tun_conf = yaml.load(f.read())
            self.tun_conf["logging"]["handlers"]["file_handler"]["filename"] = self.log_file
            self.tun_conf["pid_file"] = self.pid_file
            self.tun_conf["listen"] = random_free_port()

            IOLoop.instance().start = lambda: 0
            IOLoop.instance().stop = lambda: 0

            self.daemon = WSTunnelServerDaemon(self.tun_conf)
            self.daemon.hush = lambda **kwargs: 0
Exemplo n.º 3
0
        def setUp(self):
            # super(WSTunnelServerDaemonTestCase, self).setUp()
            self.log_file, self.pid_file = setup_logging()

            with open(os.path.join(fixture, "wstunsrvd.yml")) as f:
                self.tun_conf = yaml.load(f.read())
            self.tun_conf["logging"]["handlers"]["file_handler"][
                "filename"] = self.log_file
            self.tun_conf["pid_file"] = self.pid_file
            self.tun_conf["listen"] = random_free_port()

            IOLoop.instance().start = lambda: 0
            IOLoop.instance().stop = lambda: 0

            self.daemon = WSTunnelServerDaemon(self.tun_conf)
            self.daemon.hush = lambda **kwargs: 0
Exemplo n.º 4
0
    def setUp(self):
        super(WSTunnelTestCase, self).setUp()
        self.log_file, self.pid_file = setup_logging()
        self.srv = EchoServer(port=0,
                              address="127.0.0.1")
        self.srv.start(1)
        self.srv_tun = WSTunnelServer(port=0,
                                      address=self.srv.address_list[0][0],
                                      proxies={"/test": self.srv.address_list[0]}, io_loop=self.io_loop)
        self.srv_tun.start()
        self.clt_tun = WSTunnelClient(proxies={0: "ws://localhost:{0}/test".format(self.srv_tun.port)},
                                      address=self.srv_tun.address,
                                      family=socket.AF_INET,
                                      io_loop=self.io_loop,
                                      ws_options={"validate_cert": False})
        self.clt_tun.start()

        self.message = "Hello World!".encode("utf-8")
        self.client = EchoClient(self.clt_tun.address_list[0])
Exemplo n.º 5
0
    def setUp(self):
        super(WSTunnelSSLTestCase, self).setUp()
        self.log_file, self.pid_file = setup_logging()
        self.srv = EchoServer(port=0, address="127.0.0.1")
        self.srv.start()
        self.srv_tun = WSTunnelServer(
            port=0,
            address=self.srv.address_list[0][0],
            proxies={"/test": self.srv.address_list[0]},
            ssl_options={
                "certfile": os.path.join(fixture, "localhost.pem"),
                "keyfile": os.path.join(fixture, "localhost.key"),
            })
        self.srv_tun.start()
        self.clt_tun = WSTunnelClient(
            proxies={0: "wss://localhost:{0}/test".format(self.srv_tun.port)},
            address=self.srv_tun.address,
            family=socket.AF_INET,
            ws_options={"validate_cert": False})
        self.clt_tun.start()

        self.message = "Hello World!".encode("utf-8")
        self.client = EchoClient(self.clt_tun.address_list[0])
Exemplo n.º 6
0
 def setUp(self):
     super(WSEndpointsTestCase, self).setUp()
     self.log_file, self.pid_file = setup_logging()
Exemplo n.º 7
0
        def setUp(self):
            self.log_file, self.pid_file = setup_logging()
            #open(self.log_file, 'w').close()

            self.daemon = Daemon(self.pid_file, workdir=fixture)
            self.daemon.hush = lambda **kwargs: 0
Exemplo n.º 8
0
        def setUp(self):
            self.log_file, self.pid_file = setup_logging()
            #open(self.log_file, 'w').close()

            self.daemon = Daemon(self.pid_file, workdir=fixture)
            self.daemon.hush = lambda **kwargs: 0