예제 #1
0
 def decode_tcp_transport_response( self, session_list, transport_id, response_transport_packets ):
     packet_data = self.decrypt_transport_response_packets(session_list, transport_id, response_transport_packets)
     if packet_data is None:
         return None  # no response
     response_packet = self.decode_packet(transport_id, packet_data, tPacket)
     log.info('Received response:')
     pprint(tPacket, response_packet)
     response = self.decode_packet(transport_id, response_packet.payload, tServerPacket)
     pprint(tServerPacket, response)
     return response
 def run_unsubscribe_notification( self ):
     url = self.load_url_from_file()
     notification = ClientNotification(
         iface=url.iface,
         path=url.path,
         command_id='unsubscribe',
         params=url.iface.get_request_params_type('unsubscribe')(),
         )
     pprint(tClientPacket, notification.to_data())
     server = Server.from_public_key(self.services.remoting, url.public_key)
     response = yield from (asyncio.wait_for(server.send_notification(notification), timeout=0.5))
     self.assertEqual(None, response)
 def run_get_request( self ):
     url = self.load_url_from_file()
     request = Request(
         iface=url.iface,
         path=url.path,
         command_id='get',
         request_id='test-001',
         params=url.iface.get_request_params_type('get')(),
         )
     pprint(tClientPacket, request.to_data())
     server = Server.from_public_key(self.services.remoting, url.public_key)
     response = yield from (asyncio.wait_for(server.execute_request(request), timeout=0.5))
     self.assertIsInstance(response, Response)
     self.assertEqual('get', response.command_id)
     self.assertEqual('test-001', response.request_id)
예제 #4
0
    def test_simple_request( self ):
        request_data = tRequest(
            iface='test_iface',
            path=[TestModule.name, TestObject.class_name, '1'],
            command_id='echo',
            params=test_iface.get_request_params_type('echo')(test_param='hello'),
            request_id='001',
            )
        pprint(tClientPacket, request_data)
        request = RequestBase.from_data(None, Peer(PhonyChannel()), self.iface_registry, request_data)

        response = self.server.process_request(request)

        pprint(tServerPacket, response.to_data())
        self.assertEqual('hello to you too', response.result.test_result)
예제 #5
0
 def make_tcp_transport_notification( self, session_list, transport_id, obj_id, command_id, **kw ):
     request = tClientNotification(
         iface='test_iface',
         path=[TestModule.name, TestObject.class_name, obj_id],
         command_id=command_id,
         params=test_iface.get_request_params_type(command_id)(**kw),
         )
     log.info('Sending client notification:')
     pprint(tClientPacket, request)
     request_packet = tPacket(
         aux_info=tAuxInfo(requirements=[], type_modules=[], modules=[], routes=[], resources=[]),
         payload=self.encode_packet(transport_id, request, tClientPacket))
     request_packet_data = self.encode_packet(transport_id, request_packet, tPacket)
     transport_request = tTransportPacket(
         transport_id=transport_id,
         data=self.encrypt_packet(session_list, transport_id, request_packet_data))
     return transport_request
예제 #6
0
def test_yacc( fpaths ):
    type_registry_registry = builtin_type_registry_registry()
    for fpath in fpaths:
        print('%s:' % fpath)
        dir, fname = os.path.split(fpath)
        module_name = os.path.splitext(fname)[0]
        with open(fpath) as f:
            input = f.read()
        print('parsing:')
        used_modules, typedefs, type_registry = parse_type_module(
            make_meta_type_registry(), type_registry_registry, fpath, input, debug=True)
        print('used modules:', used_modules)
        print('typedefs:', typedefs)
        for name, t in type_registry.items():
            print('type %s: %s' % (name, t))
        if typedefs:
            pprint(TList(tTypeDef), typedefs)
        type_registry_registry.register(module_name, type_registry)