def request_exit_status(self, status): status, = struct.unpack('>L', status) if status == 0: unittest.fail('false exit status was 0') log.msg('finished false') self.conn.addResult() return 1
def request_exit_status(self, status): status, = struct.unpack(">L", status) if status == 0: unittest.fail("false exit status was 0") log.msg("finished false") self.conn.addResult() return 1
def closed(self): if self.status != 0: unittest.fail('err exit status was not 0: %i' % self.status) if self.testBuf != "hello\r\n": unittest.fail('err did not return hello: %s' % repr(self.testBuf)) unittest.assertEquals(self.localWindowLeft, 4) unittest.assert_(self.eofCalled) log.msg('finished err') self.conn.addResult() return 1
def closed(self): if self.status != 0: unittest.fail('echo exit status was not 0: %i' % self.status) unittest.assertEquals(self.testBuf, 'hello\r\n') unittest.assertEquals(self.testExtBuf, 'hello\r\n') unittest.assertEquals(self.localWindowLeft, 12) unittest.assert_(self.eofCalled) log.msg('finished max packet') self.conn.addResult() return 1
def global_tcpip_forward(self, data): host, port = forwarding.unpackGlobal_tcpip_forward(data) try: listener = reactor.listenTCP(port, forwarding.SSHListenForwardingFactory(self.conn, (host, port), forwarding.SSHListenServerForwardingChannel), interface = host) except: log.err() unittest.fail("something went wrong with remote->local forwarding") return 0 else: self.listeners[(host, port)] = listener return 1
def execute(self, args, p, preargs = ''): if runtime.platformType == 'win32': raise unittest.SkipTest, "can't run cmdline client on win32" port = self.server.getHost().port cmd1 = ('-p %i -l testuser ' '--known-hosts kh_test ' '--user-authentications publickey ' '--host-key-algorithms ssh-rsa ' '-a ' '-K direct ' '-i dsa_test ' '127.0.0.1') % port cmd2 = ('-p %i -l testuser ' '-K unix ' '-v ') % port + preargs + \ ' 127.0.0.1 ' + args cmds1 = cmd1.split() cmds2 = _makeArgs(cmd2.split()) o = options.ConchOptions() def _(host, *args): o['host'] = host o.parseArgs = _ o.parseOptions(cmds1) vhk = default.verifyHostKey conn = SSHTestConnectionForUnix(p, sys.executable, cmds2) uao = default.SSHUserAuthClient(o['user'], o, conn) d = connect.connect(o['host'], int(o['port']), o, vhk, uao) d.addErrback(lambda f: unittest.fail('Failure connecting to test server: %s' % f)) d.addCallback(lambda x : p.deferred) d.addCallback(lambda x : defer.maybeDeferred( conn.transport.transport.loseConnection)) return d
def openFailed(self, reason): unittest.fail('false open failed: %s' % reason)
def openFailed(self, reason): unittest.fail('echo open failed: %s' % reason)
def receiveUnimplemented(self, seqID): unittest.fail('got unimplemented: seqid %s' % seqID) self.expectedLoseConnection = 1 self.loseConnection()
def channelOpen(self, ignored): unittest.fail("opened unknown channel")
def _ebPtyReq(self, reason): unittest.fail('pty request failed: %s' % reason)
def ssh_USERAUTH_SUCCESS(self, packet): if not self.canSucceedPassword and self.canSucceedPublicKey: unittest.fail( 'got USERAUTH_SUCESS before password and publickey') userauth.SSHUserAuthClient.ssh_USERAUTH_SUCCESS(self, packet)
def dataReceived(self, data): unittest.fail('err channel got regular data: %s' % repr(data))
def openFailed(self, reason): unittest.fail('max packet open failed: %s' % reason)
def errReceived(self, dataType, data): unittest.fail('echo channel got extended data')
def _ebRequestFailed(self, reason): unittest.fail('err exec failed: %s' % reason)
def dataReceived(self, data): unittest.fail('got data when using false')
def _ebRequestFailed(self, reason): unittest.fail('max packet exec failed: %s' % reason)
def connectionLost(self, reason): if self.done: return if not hasattr(self,'expectedLoseConnection'): unittest.fail('unexpectedly lost connection %s\n%s' % (self, reason)) self.done = 1
def openFailed(self, reason): unittest.fail('shell open failed: %s' % reason)
def _cbRequestWorked(self, ignored): unittest.fail('fail exec succeeded')
def _ebShellOpen(self, reason): unittest.fail('shell request failed: %s' % reason)
def ssh_USERAUTH_SUCCESS(self, packet): if not self.canSucceedPassword and self.canSucceedPublicKey: unittest.fail('got USERAUTH_SUCESS before password and publickey') userauth.SSHUserAuthClient.ssh_USERAUTH_SUCCESS(self, packet)
def openFailed(self, reason): unittest.fail('subsystem open failed: %s' % reason)
def _cbRequestWorked(self, ignored): unittest.fail('opened non-crazy subsystem')
def _ebRealRequestFailed(self, reason): unittest.fail('opening crazy subsystem failed: %s' % reason)
def _ebFirstGlobal(self, reason): unittest.fail('first global request failed: %s' % reason)
def receiveError(self, reasonCode, desc): self.expectedLoseConnection = 1 if not self.allowedToError: unittest.fail('got disconnect for %s: reason %s, desc: %s' % (self, reasonCode, desc)) self.loseConnection()
def _ebSecondGlobal(self, reason): unittest.fail('second global request failed: %s' % reason)
def _cbThirdGlobal(self, ignored): unittest.fail('second global request succeeded')
def openFailed(self, reason): unittest.fail("err open failed: %s" % reason)