def setUp(self): self.transport = StubTransport() self.session = session.SSHSession(conn=StubConnection(self.transport), remoteWindow=500, remoteMaxPacket=100) self.pp = session.SSHSessionProcessProtocol(self.session) self.pp.makeConnection(self.transport)
def setUp(self): RegistryUsingMixin.setUp(self) components.registerAdapter( StubSessionForStubAvatar, StubAvatar, session.ISession) self.session = session.SSHSession() self.session.avatar = StubAvatar() self.assertIsNone(self.session.session)
def setUp(self): """ Make an SSHSession object to test. Give the channel some window so that it's allowed to send packets. 500 and 100 are arbitrary values. """ self.session = session.SSHSession(remoteWindow=500, remoteMaxPacket=100, conn=StubConnection(), avatar=StubAvatar())
def test_init(self): """ SSHSession initializes its buffer (buf), client, and ISession adapter. The avatar should not need to be adaptable to an ISession immediately. """ s = session.SSHSession(avatar=object) # use object because it doesn't # have an adapter self.assertEquals(s.buf, '') self.assertIdentical(s.client, None) self.assertIdentical(s.session, None)
def getSSHSession(self, register_adapters=True): """ Return a new SSH session. """ return session.SSHSession( remoteWindow=500, remoteMaxPacket=100, conn=StubConnection(), avatar=StubAvatar(), )
def setUp(self): """ Make an SSHSession object to test. Give the channel some window so that it's allowed to send packets. 500 and 100 are arbitrary values. """ RegistryUsingMixin.setUp(self) components.registerAdapter( StubSessionForStubAvatar, StubAvatar, session.ISession) self.session = session.SSHSession( remoteWindow=500, remoteMaxPacket=100, conn=StubConnection(), avatar=StubAvatar())
def test_lookupSubsystemDoesNotNeedISession(self): """ Previously, if one only wanted to implement a subsystem, an ISession adapter wasn't needed because subsystems were looked up using the lookupSubsystem method on the avatar. """ s = session.SSHSession(avatar=SubsystemOnlyAvatar(), conn=StubConnection()) ret = s.request_subsystem(common.NS(b"subsystem") + b"data") self.assertTrue(ret) self.assertIsNotNone(s.client) self.assertIsNone(s.conn.closes.get(s)) s.eofReceived() self.assertTrue(s.conn.closes.get(s)) # these should not raise errors s.loseConnection() s.closed()
def test_sessionClose(self): """ Closing a session should notify an SFTP subsystem launched by that session. """ # make a session testSession = session.SSHSession(conn=FakeConn(), avatar=self.avatar) # start an SFTP subsystem on the session testSession.request_subsystem(common.NS(b'sftp')) sftpServer = testSession.client.transport.proto # intercept connectionLost so we can check that it's called self.interceptConnectionLost(sftpServer) # close session testSession.closeReceived() self.assertSFTPConnectionLost()
def setUp(self): self.session = session.SSHSession() self.session.avatar = StubAvatar() self.assertIdentical(self.session.session, None)
def setUp(self): self.session = session.SSHSession() self.session.avatar = StubAvatar() self.assertIsNone(self.session.session)