def test_buildProtocolRespectsProtocol(self): """ buildProtocol() calls 'self.protocol()' to construct a protocol instance. """ calls = [] def makeProtocol(*args): calls.append(args) return transport.SSHServerTransport() factory = self.makeSSHFactory() factory.protocol = makeProtocol factory.buildProtocol(None) self.assertEquals([()], calls)
def test_buildProtocol(self): """ By default, buildProtocol() constructs an instance of SSHServerTransport. """ factory = self.makeSSHFactory() protocol = factory.buildProtocol(None) self.assertIsInstance(protocol, transport.SSHServerTransport)
def test_buildProtocolRespectsProtocol(self): """ buildProtocol() calls 'self.protocol()' to construct a protocol instance. """ calls = [] def makeProtocol(*args): calls.append(args) return transport.SSHServerTransport() factory = self.makeSSHFactory() factory.protocol = makeProtocol protocol = factory.buildProtocol(None) self.assertEquals([()], calls)
t.factory = self return t portal = portal.Portal(ExampleRealm()) passwdDB = checkers.InMemoryUsernamePasswordDatabaseDontUse() passwdDB.addUser('user', 'password') portal.registerChecker(passwdDB) portal.registerChecker(InMemoryPublicKeyChecker()) ExampleFactory.portal = portal if __name__ == '__main__': from twisted.conch.ssh import transport; from twisted.internet import stdio; factory = ExampleFactory(); setattr(factory, 'primes', ''); protocol = factory.buildProtocol('a'); stdio.StandardIO(protocol); reactor.run() # reactor.listenTCP(5022, ExampleFactory()) # from twisted.internet import stdio; # factory = ExampleFactory(); # stdio.StandardIO(factory); # runWithProtocol(ExampleFactory().buildProtocol()); # factory.doStart(); # factory.buildProtocol('127.0.0.1');
t.supportedKeyExchanges = ske t.factory = self return t portal = portal.Portal(ExampleRealm()) passwdDB = checkers.InMemoryUsernamePasswordDatabaseDontUse() passwdDB.addUser('user', 'password') portal.registerChecker(passwdDB) portal.registerChecker(InMemoryPublicKeyChecker()) ExampleFactory.portal = portal if __name__ == '__main__': from twisted.conch.ssh import transport from twisted.internet import stdio factory = ExampleFactory() setattr(factory, 'primes', '') protocol = factory.buildProtocol('a') stdio.StandardIO(protocol) reactor.run() # reactor.listenTCP(5022, ExampleFactory()) # from twisted.internet import stdio; # factory = ExampleFactory(); # stdio.StandardIO(factory); # runWithProtocol(ExampleFactory().buildProtocol()); # factory.doStart(); # factory.buildProtocol('127.0.0.1');