def test_invalid_message_during_streaming(tchannel_server): # test for invalid call request message hostport = 'localhost:%d' % tchannel_server.port tchannel = TChannel() connection = yield StreamConnection.outgoing( hostport=hostport, tchannel=tchannel, ) callrequest = CallRequestMessage( flags=FlagsType.fragment, args=[ 'endpoint2', 'a', 'a', ], headers={'as': 'raw'}, id=1, ) callreqcontinue = CallRequestContinueMessage( flags=FlagsType.fragment, args=[ 'a', ], id=1, ) resp_future = connection.send(callrequest) for _ in xrange(10): yield connection.write(callreqcontinue) # bypass the default checksum calculation # set a wrong checksum callreqcontinue.checksum = (ChecksumType.crc32c, 1) yield connection._write(callreqcontinue) with pytest.raises(ProtocolError) as e: resp = yield resp_future yield resp.get_header() yield resp.get_body() assert e.value.message == u"Checksum does not match!"
def test_invalid_message_during_streaming(mock_server): # test for invalid call request message tchannel = TChannel(name='test') connection = yield StreamConnection.outgoing( hostport=mock_server.hostport, tchannel=tchannel, ) callrequest = CallRequestMessage( flags=FlagsType.fragment, args=[ 'endpoint2', 'a', 'a', ], headers={'as': 'raw'}, id=1, ) callreqcontinue = CallRequestContinueMessage( flags=FlagsType.fragment, args=[ 'a', ], id=1, ) resp_future = connection.send(callrequest) for _ in xrange(10): yield connection.write(callreqcontinue) # bypass the default checksum calculation # set a wrong checksum callreqcontinue.checksum = (ChecksumType.crc32c, 1) yield connection._write(callreqcontinue) with pytest.raises(ProtocolError) as e: resp = yield resp_future yield resp.get_header() yield resp.get_body() assert e.value.message == u"Checksum does not match!"
def test_continue_message_error(mock_server): # test for invalid call request message tchannel = TChannel(name='test') connection = yield StreamConnection.outgoing( hostport=mock_server.hostport, tchannel=tchannel, ) callreqcontinue = CallRequestContinueMessage( flags=FlagsType.fragment, args=[ 'a', ], ) with pytest.raises(FatalProtocolError) as e: yield connection.send(callreqcontinue) assert 'missing call message after receiving continue message' in str(e)