Exemplo n.º 1
0
 def setUp(self):
     self.logger = get_test_logger()
     self.our_class = RemoteServerImpl(self)
     self.host = '127.0.0.1'
     self.port = 7001
     self.rpc_server = RpcServer(self.host, self.port, self.our_class)
     self.rpc_server_th = Thread(target=self.rpc_server.start)
     self.rpc_client = RpcClient(self.host, self.port)
     self.called_functions = []
Exemplo n.º 2
0
def main():
    options = docopt.docopt(__doc__)
    fuzzer = ClientFuzzer(name='UmapFuzzer', option_line=options['--kitty-options'])
    fuzzer.set_interface(WebInterface())

    target = ClientTarget(name='USBTarget')
    target.set_controller(get_controller(options))
    target.set_mutation_server_timeout(10)

    model = get_model(options)
    fuzzer.set_model(model)
    fuzzer.set_target(target)

    remote = RpcServer(host='localhost', port=26007, impl=fuzzer)
    remote.start()
Exemplo n.º 3
0
 def setUp(self):
     self.logger = get_test_logger()
     self.our_class = RemoteServerImpl(self)
     self.host = '127.0.0.1'
     self.port = 7001
     self.rpc_server = RpcServer(self.host, self.port, self.our_class)
     self.rpc_server_th = Thread(target=self.rpc_server.start)
     self.rpc_client = RpcClient(self.host, self.port)
     self.called_functions = []
Exemplo n.º 4
0
def main():
    options = docopt.docopt(__doc__)
    fuzzer = get_fuzzer(options)
    remote = RpcServer(host='localhost', port=26007, impl=fuzzer)
    remote.start()
Exemplo n.º 5
0
class RpcServerTestCase(unittest.TestCase):

    def setUp(self):
        self.logger = get_test_logger()
        self.our_class = RemoteServerImpl(self)
        self.host = '127.0.0.1'
        self.port = 7001
        self.rpc_server = RpcServer(self.host, self.port, self.our_class)
        self.rpc_server_th = Thread(target=self.rpc_server.start)
        self.rpc_client = RpcClient(self.host, self.port)
        self.called_functions = []

    def mark_called(self, func_name, **kwargs):
        self.called_functions.append((func_name, kwargs))

    def tearDown(self):
        if self.rpc_server.is_running():
            self.rpc_client.stop_remote_server()

    def start_server(self):
        self.rpc_server_th.start()
        time.sleep(0.001)

    def stop_server(self):
        self.rpc_client.stop_remote_server()
        time.sleep(0.001)

    def testStartStopServer(self):
        self.start_server()
        self.assertTrue(self.rpc_server.is_running())
        self.stop_server()
        self.assertFalse(self.rpc_server.is_running())

    def testCallFuncNoArgs(self):
        self.start_server()
        retval = self.rpc_client.func_without_args()
        self.assertEqual(retval, 1)
        self.stop_server()
        self.assertEqual(self.called_functions, [('func_without_args', {})])

    def testCallFuncWithArgs(self):
        self.start_server()
        retval = self.rpc_client.func_with_args(arg1=1, arg2=2)
        self.assertEqual(retval, 1)
        self.stop_server()
        self.assertEqual(self.called_functions, [('func_with_args', {u'arg1': 1, u'arg2': 2})])

    def testCallMultipleTimes(self):
        self.start_server()
        retval = self.rpc_client.func_with_args(arg1=1, arg2=2)
        self.assertEqual(retval, 1)
        retval = self.rpc_client.func_with_args(arg1=11, arg2=22)
        self.assertEqual(retval, 1)
        retval = self.rpc_client.func_with_args(arg1=111, arg2=222)
        self.assertEqual(retval, 1)
        retval = self.rpc_client.func_with_args(arg1=1111, arg2=2222)
        self.assertEqual(retval, 1)
        self.stop_server()
        self.assertEqual(self.called_functions, [
            ('func_with_args', {u'arg1': 1, u'arg2': 2}),
            ('func_with_args', {u'arg1': 11, u'arg2': 22}),
            ('func_with_args', {u'arg1': 111, u'arg2': 222}),
            ('func_with_args', {u'arg1': 1111, u'arg2': 2222}),
        ])

    def testCallWithString(self):
        self.start_server()
        retval = self.rpc_client.func_with_args(arg1='hello', arg2='world')
        self.assertEqual(retval, 1)
        self.stop_server()
        self.assertEqual(self.called_functions, [('func_with_args', {u'arg1': 'hello', u'arg2': 'world'})])

    def testCallWithDict(self):
        arg = {'k1': 'hello', 'k2': 1}
        self.start_server()
        retval = self.rpc_client.func_with_args(arg=arg)
        self.assertEqual(retval, 1)
        self.stop_server()
        self.assertEqual(self.called_functions, [('func_with_args', {u'arg': arg})])

    def testCallWithArr(self):
        arg = ['a string', 123]
        self.start_server()
        retval = self.rpc_client.func_with_args(arg=arg)
        self.assertEqual(retval, 1)
        self.stop_server()
        self.assertEqual(self.called_functions, [('func_with_args', {u'arg': arg})])

    def testCallWithNone(self):
        arg = None
        self.start_server()
        retval = self.rpc_client.func_with_args(arg=arg)
        self.assertEqual(retval, 1)
        self.stop_server()
        self.assertEqual(self.called_functions, [('func_with_args', {u'arg': arg})])

    def testCallNoRetVal(self):
        self.start_server()
        retval = self.rpc_client.func_with_no_retval()
        self.assertIsNone(retval)
        self.stop_server()
        self.assertEqual(self.called_functions, [('func_with_no_retval', {})])

    def testExceptionRaised(self):
        self.start_server()
        with self.assertRaises(Exception):
            self.rpc_client.raises_exception()
        self.stop_server()
        self.assertEqual(self.called_functions, [('raises_exception', {})])

    def testCallFunctionAfterException(self):
        self.start_server()
        with self.assertRaises(Exception):
            self.rpc_client.raises_exception()
        retval = self.rpc_client.func_with_args(arg1=1, arg2=2)
        self.assertEqual(retval, 1)
        self.stop_server()
        self.assertEqual(self.called_functions, [
            ('raises_exception', {}),
            ('func_with_args', {u'arg1': 1, u'arg2': 2}),
        ])
Exemplo n.º 6
0
class RpcServerTestCase(unittest.TestCase):
    def setUp(self):
        self.logger = get_test_logger()
        self.our_class = RemoteServerImpl(self)
        self.host = '127.0.0.1'
        self.port = 7001
        self.rpc_server = RpcServer(self.host, self.port, self.our_class)
        self.rpc_server_th = Thread(target=self.rpc_server.start)
        self.rpc_client = RpcClient(self.host, self.port)
        self.called_functions = []

    def mark_called(self, func_name, **kwargs):
        self.called_functions.append((func_name, kwargs))

    def tearDown(self):
        if self.rpc_server.is_running():
            self.rpc_client.stop_remote_server()

    def start_server(self):
        self.rpc_server_th.start()
        time.sleep(0.001)

    def stop_server(self):
        self.rpc_client.stop_remote_server()
        time.sleep(0.001)

    def testStartStopServer(self):
        self.start_server()
        self.assertTrue(self.rpc_server.is_running())
        self.stop_server()
        self.assertFalse(self.rpc_server.is_running())

    def testCallFuncNoArgs(self):
        self.start_server()
        retval = self.rpc_client.func_without_args()
        self.assertEqual(retval, 1)
        self.stop_server()
        self.assertEqual(self.called_functions, [('func_without_args', {})])

    def testCallFuncWithArgs(self):
        self.start_server()
        retval = self.rpc_client.func_with_args(arg1=1, arg2=2)
        self.assertEqual(retval, 1)
        self.stop_server()
        self.assertEqual(self.called_functions, [('func_with_args', {
            u'arg1': 1,
            u'arg2': 2
        })])

    def testCallMultipleTimes(self):
        self.start_server()
        retval = self.rpc_client.func_with_args(arg1=1, arg2=2)
        self.assertEqual(retval, 1)
        retval = self.rpc_client.func_with_args(arg1=11, arg2=22)
        self.assertEqual(retval, 1)
        retval = self.rpc_client.func_with_args(arg1=111, arg2=222)
        self.assertEqual(retval, 1)
        retval = self.rpc_client.func_with_args(arg1=1111, arg2=2222)
        self.assertEqual(retval, 1)
        self.stop_server()
        self.assertEqual(self.called_functions, [
            ('func_with_args', {
                u'arg1': 1,
                u'arg2': 2
            }),
            ('func_with_args', {
                u'arg1': 11,
                u'arg2': 22
            }),
            ('func_with_args', {
                u'arg1': 111,
                u'arg2': 222
            }),
            ('func_with_args', {
                u'arg1': 1111,
                u'arg2': 2222
            }),
        ])

    def testCallWithString(self):
        self.start_server()
        retval = self.rpc_client.func_with_args(arg1='hello', arg2='world')
        self.assertEqual(retval, 1)
        self.stop_server()
        self.assertEqual(self.called_functions, [('func_with_args', {
            u'arg1': 'hello',
            u'arg2': 'world'
        })])

    def testCallWithDict(self):
        arg = {'k1': 'hello', 'k2': 1}
        self.start_server()
        retval = self.rpc_client.func_with_args(arg=arg)
        self.assertEqual(retval, 1)
        self.stop_server()
        self.assertEqual(self.called_functions, [('func_with_args', {
            u'arg': arg
        })])

    def testCallWithArr(self):
        arg = ['a string', 123]
        self.start_server()
        retval = self.rpc_client.func_with_args(arg=arg)
        self.assertEqual(retval, 1)
        self.stop_server()
        self.assertEqual(self.called_functions, [('func_with_args', {
            u'arg': arg
        })])

    def testCallWithNone(self):
        arg = None
        self.start_server()
        retval = self.rpc_client.func_with_args(arg=arg)
        self.assertEqual(retval, 1)
        self.stop_server()
        self.assertEqual(self.called_functions, [('func_with_args', {
            u'arg': arg
        })])

    def testCallNoRetVal(self):
        self.start_server()
        retval = self.rpc_client.func_with_no_retval()
        self.assertIsNone(retval)
        self.stop_server()
        self.assertEqual(self.called_functions, [('func_with_no_retval', {})])

    def testExceptionRaised(self):
        self.start_server()
        with self.assertRaises(Exception):
            self.rpc_client.raises_exception()
        self.stop_server()
        self.assertEqual(self.called_functions, [('raises_exception', {})])

    def testCallFunctionAfterException(self):
        self.start_server()
        with self.assertRaises(Exception):
            self.rpc_client.raises_exception()
        retval = self.rpc_client.func_with_args(arg1=1, arg2=2)
        self.assertEqual(retval, 1)
        self.stop_server()
        self.assertEqual(self.called_functions, [
            ('raises_exception', {}),
            ('func_with_args', {
                u'arg1': 1,
                u'arg2': 2
            }),
        ])
Exemplo n.º 7
0
def main():
    options = docopt.docopt(__doc__)
    fuzzer = get_fuzzer(options)
    remote = RpcServer(host='localhost', port=26007, impl=fuzzer)
    remote.start()