Пример #1
0
 def test_stacking_override_target_address(self):
     """Stacked proxies can override their target own address without affecting their parent session"""
     self.session.setTargetAddress(self.address)
     ss = StackedSession(self.session)
     address2 = SockAddrInet("10.0.0.1", 90)
     ss.setTargetAddress(address2)
     self.assertEqual(ss.target_address, (address2, ))
     self.assertEqual(self.session.target_address, (self.address, ))
Пример #2
0
 def test_stacking_override_target_address(self):
     """Stacked proxies can override their target own address without affecting their parent session"""
     self.session.setTargetAddress(self.address)
     ss = StackedSession(self.session)
     address2 = SockAddrInet("10.0.0.1", 90)
     ss.setTargetAddress(address2)
     self.assertEqual(ss.target_address, (address2, ))
     self.assertEqual(self.session.target_address, (self.address, ))
Пример #3
0
    def proxyThread(self):
        self.log("Proxy started; name='%s'", self.__class__)
        self.notifyParent()

        self.log("Starting stacked proxy")

        client_streams = createStreamPair("client")
        server_streams = createStreamPair("server")
        session = StackedSession(self.session)
        session.client_stream = client_streams.upstream
        session.server_stream = server_streams.upstream
        session.session_id = "svc/stacked:1"
        session.proxy_event = threading.Event()

        self.stack(Z_STACK_PROXY_IN_SESSION, CopyingTestProxy, session, client_streams.downstream, server_streams.downstream)

        self.log("Waiting for stacked proxy to start up")
        session.proxy_event.wait()
        session.proxy_event.clear()

        client_streams.downstream.nonblocking = FALSE
        server_streams.downstream.nonblocking = FALSE

        self.log("Copying from client to server through stacked proxy")
        line = self.client_stream.read(1024)
        client_streams.downstream.write(line)
        output = server_streams.downstream.read(1024)
        self.server_stream.write(output)

        self.log("Copying from server to client through stacked proxy")
        line = self.server_stream.read(1024)
        server_streams.downstream.write(line)
        output = client_streams.downstream.read(1024)
        self.client_stream.write(output)

        self.log("Waiting for stacked proxy to finish")
        session.proxy_event.wait()
        session.proxy_event.clear()

        self.log("Closing downstream streams")

        self.notifyParent()
Пример #4
0
 def setUp(self):
     self.service = Service("testservice",
                            HttpProxy,
                            resolver_policy="test_resolver")
     self.address = SockAddrInet("127.0.0.1", 80)
     self.mastersession = MasterSession(self.service,
                                        client_stream=None,
                                        client_local=None,
                                        client_listen=DBSockAddr(
                                            self.address, ZD_PROTO_TCP),
                                        client_address=self.address,
                                        instance_id=1)
     self.session = StackedSession(self.mastersession)
Пример #5
0
 def test_stacking_inherit_target_address(self):
     """Stacked proxies should inherit the target address of their parent"""
     self.session.setTargetAddress(self.address)
     ss = StackedSession(self.session)
     self.assertEqual(ss.target_address, (self.address, ))