def TODO_test_clientDataSent(self): reactor = object() wrappedFac = FakeFactory() bobEndpoint = FakeEndpoint() endpoint = endpoints.BOBI2PClientEndpoint(reactor, bobEndpoint, '') endpoint.connect(wrappedFac) bobEndpoint.proto.transport.clear() wrappedFac.proto.transport.write('xxxxx') self.assertEqual(bobEndpoint.proto.transport.value(), 'xxxxx')
def TODO_test_noProtocolFromWrappedFactory(self): wrappedFac = FakeFactory(returnNoProtocol=True) mreactor = proto_helpers.MemoryReactor() fac, proto = self.makeProto(mreactor, wrappedFac, None, '') fac.tunnelNick = 'spam' # Shortcut to end of BOB protocol proto.receiver.currentRule = 'State_start' proto._parser._setupInterp() proto.dataReceived('OK HTTP 418\n') self.assert_(self.aborted) # TODO: Check the Deferred chain return self.assertFailure(fac.deferred, defer.CancelledError)
def test_streamAcceptIncoming(self): mreactor = proto_helpers.MemoryReactor() wrappedFactory = FakeFactory() session = Mock() listeningPort = Mock() fac, proto = self.makeProto(wrappedFactory, session, listeningPort) # Shortcut to end of SAM stream accept protocol proto.receiver.currentRule = 'State_readData' proto._parser._setupInterp() proto.dataReceived('%s FROM_PORT=34444 TO_PORT=0\n' % TEST_B64) listeningPort.removeAccept.assert_called_with(proto.receiver) self.assertEqual(wrappedFactory.proto, proto.receiver.wrappedProto)
def test_streamConnectionEstablished(self): mreactor = proto_helpers.MemoryReactor() wrappedFactory = FakeFactory() session = Mock() fac, proto = self.makeProto(wrappedFactory, session, 'spam.i2p', 'foo') # Shortcut to end of SAM stream connect protocol proto.receiver.currentRule = 'State_connect' proto._parser._setupInterp() proto.dataReceived('STREAM STATUS RESULT=OK\n') session.addStream.assert_called_with(proto.receiver) streamProto = self.successResultOf(fac.deferred) self.assertEqual(proto.receiver.wrappedProto, streamProto)
def test_buildProtocol(self): wrappedFac = FakeFactory() fac = BOBClientFactoryWrapper(wrappedFac, None, None, '', True) fac.setDest('spam.i2p') proto = fac.buildProtocol(None) self.assertEqual(proto.wrappedProto.factory, wrappedFac)
def test_buildProtocol(self): wrappedFac = FakeFactory() fac = BOBServerFactoryWrapper(wrappedFac, None, None, '', True) proto = fac.buildProtocol(None) self.assertEqual(proto.wrappedProto.factory, wrappedFac)