Beispiel #1
0
 def test_maximum_message_size_exceeded(self):
     parser = JsonRpcParser()
     parser.max_message_size = 100
     message = '{{ "{0}": "{1}" }}'.format('x' * 100, 'y' * 100)
     message = message.encode('ascii')
     exc = assert_raises(ParseError, parser.feed, message)
     assert exc.args[0] == errno.MESSAGE_TOO_LARGE
Beispiel #2
0
 def test_maximum_message_size_exceeded(self):
     parser = JsonRpcParser()
     parser.max_message_size = 100
     message = '{{ "{0}": "{1}" }}'.format('x' * 100, 'y' * 100)
     message = message.encode('ascii')
     exc = assert_raises(ParseError, parser.feed, message)
     assert exc.args[0] == errno.MESSAGE_TOO_LARGE
Beispiel #3
0
 def test_call_method_error(self):
     server = JsonRpcServer(echo_app)
     server.listen(('127.0.0.1', 0))
     addr = server.transport.getsockname()
     client = JsonRpcClient()
     client.connect(addr)
     exc = assert_raises(JsonRpcError, client.call_method, 'echo2')
     assert exc.args[0] == errno.INVALID_REQUEST
Beispiel #4
0
 def test_call_method_error(self):
     server = JsonRpcServer(echo_app)
     server.listen(('127.0.0.1', 0))
     addr = server.transport.getsockname()
     client = JsonRpcClient()
     client.connect(addr)
     exc = assert_raises(JsonRpcError, client.call_method, 'echo2')
     assert exc.args[0] == errno.INVALID_REQUEST
Beispiel #5
0
 def test_illegal_jsonrpc(self):
     m = b'{ "xxxx": "yyyy" }'
     parser = JsonRpcParser()
     exc = assert_raises(ParseError, parser.feed, m)
     assert exc.args[0] == errno.PARSE_ERROR
Beispiel #6
0
 def test_encoding_error(self):
     m = b'{ xxx\xff }'
     parser = JsonRpcParser()
     exc = assert_raises(ParseError, parser.feed, m)
     assert exc.args[0] == errno.PARSE_ERROR
Beispiel #7
0
 def test_framing_error(self):
     m = b'xxx'
     parser = JsonRpcParser()
     exc = assert_raises(ParseError, parser.feed, m)
     assert exc.args[0] == errno.FRAMING_ERROR
Beispiel #8
0
 def test_illegal_jsonrpc(self):
     m = b'{ "xxxx": "yyyy" }'
     parser = JsonRpcParser()
     exc = assert_raises(ParseError, parser.feed, m)
     assert exc.args[0] == errno.PARSE_ERROR
Beispiel #9
0
 def test_encoding_error(self):
     m = b'{ xxx\xff }'
     parser = JsonRpcParser()
     exc = assert_raises(ParseError, parser.feed, m)
     assert exc.args[0] == errno.PARSE_ERROR
Beispiel #10
0
 def test_framing_error(self):
     m = b'xxx'
     parser = JsonRpcParser()
     exc = assert_raises(ParseError, parser.feed, m)
     assert exc.args[0] == errno.FRAMING_ERROR
Beispiel #11
0
 def test_maximum_message_size_exceeded(self):
     parser = DBusParser()
     parser.max_message_size = 100
     m = b'l\1\0\1\0\1\0\0\1\0\0\0\0\0\0\0' + b'x' * 256
     exc = assert_raises(ParseError, parser.feed, m)
     assert exc.args[0] == errno.MESSAGE_TOO_LARGE
Beispiel #12
0
 def test_illegal_message(self):
     m = b'l\1\0\2\0\0\0\0\1\0\0\0\0\0\0\0'
     parser = DBusParser()
     exc = assert_raises(ParseError, parser.feed, m)
     assert exc.args[0] == errno.FRAMING_ERROR