Exemplo n.º 1
0
 def checkKey(self, credentials):
     unittest.assertEquals(credentials.username, 'testuser',
                           'bad username')
     unittest.assertEquals(
         credentials.blob,
         keys.getPublicKeyString(data=publicDSA_openssh))
     return 1
Exemplo n.º 2
0
 def processEnded(self, reason):
     unittest.assertEquals(
         reason.value.exitCode, 0,
         'exit code was not 0: %s' % reason.value.exitCode)
     self.buf = self.buf.replace('\r\n', '\n')
     unittest.assertEquals(self.buf, 'goodbye\n')
     self.deferred.callback(None)
Exemplo n.º 3
0
 def verifyHostKey(self, key, fp):
     unittest.assertEquals(
         key,
         keys.Key.fromString(publicRSA_openssh).blob())
     unittest.assertEquals(
         fp, '3d:13:5f:cb:c9:79:8a:93:06:27:65:bc:3d:0b:8f:af')
     return defer.succeed(1)
Exemplo n.º 4
0
 def checkKey(self, credentials):
     unittest.assertEquals(credentials.username, 'testuser',
                           'bad username')
     unittest.assertEquals(
         credentials.blob,
         keys.Key.fromString(publicDSA_openssh).blob())
     return 1
Exemplo n.º 5
0
 def closed(self):
     log.msg('calling shell closed')
     if self.status != 0:
         log.msg('shell exit status was not 0: %i' % self.status)
     unittest.assertEquals(self.testBuf, 'testing the shell!\x00\r\n')
     unittest.assert_(self.eofCalled)
     log.msg('finished shell')
     self.conn.addResult()
Exemplo n.º 6
0
 def closed(self):
     log.msg("calling shell closed")
     if self.status != 0:
         log.msg("shell exit status was not 0: %i" % self.status)
     unittest.assertEquals(self.testBuf, "testing the shell!\x00\r\n")
     unittest.assert_(self.eofCalled)
     log.msg("finished shell")
     self.conn.addResult()
Exemplo n.º 7
0
 def closed(self):
     log.msg('calling shell closed')
     if self.status != 0:
         log.msg('shell exit status was not 0: %i' % self.status)
     unittest.assertEquals(self.testBuf, 'testing the shell!\x00\r\n')
     unittest.assert_(self.eofCalled)
     log.msg('finished shell')
     self.conn.addResult()
Exemplo n.º 8
0
 def closed(self):
     log.msg('closed cmd "%s"' % self.cmd)
     if self.cmd == 'echo hello':
         rwl = self.proto.session.remoteWindowLeft
         unittest.assertEquals(rwl, 4)
     elif self.cmd == 'eecho hello':
         rwl = self.proto.session.remoteWindowLeft
         unittest.assertEquals(rwl, 4)
     elif self.cmd == 'shell':
         unittest.assert_(self.eof)
Exemplo n.º 9
0
 def closed(self):
     log.msg('closed cmd "%s"' % self.cmd)
     if self.cmd == 'echo hello':
         rwl = self.proto.session.remoteWindowLeft
         unittest.assertEquals(rwl, 4)
     elif self.cmd == 'eecho hello':
         rwl = self.proto.session.remoteWindowLeft
         unittest.assertEquals(rwl, 4)
     elif self.cmd == 'shell':
         unittest.assert_(self.eof)
Exemplo n.º 10
0
 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
Exemplo n.º 11
0
 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
Exemplo n.º 12
0
 def receiveError(self, reasonCode, desc):
     self.expectedLoseConnection = 1
     # Some versions of OpenSSH (for example, OpenSSH_5.3p1) will
     # send a DISCONNECT_BY_APPLICATION error before closing the
     # connection.  Other, older versions (for example,
     # OpenSSH_5.1p1), won't.  So accept this particular error here,
     # but no others.
     unittest.assertEquals(
         reasonCode, transport.DISCONNECT_BY_APPLICATION,
         'got disconnect for %s: reason %s, desc: %s' % (
             self, reasonCode, desc))
     self.loseConnection()
Exemplo n.º 13
0
 def receiveError(self, reasonCode, desc):
     self.expectedLoseConnection = 1
     # Some versions of OpenSSH (for example, OpenSSH_5.3p1) will
     # send a DISCONNECT_BY_APPLICATION error before closing the
     # connection.  Other, older versions (for example,
     # OpenSSH_5.1p1), won't.  So accept this particular error here,
     # but no others.
     unittest.assertEquals(
         reasonCode, transport.DISCONNECT_BY_APPLICATION,
         'got disconnect for %s: reason %s, desc: %s' %
         (self, reasonCode, desc))
     self.loseConnection()
Exemplo n.º 14
0
        def _cbRealRequestWorked(self, ignored):
            d1 = self.conn.sendGlobalRequest('foo', 'bar', 1)
            d1.addErrback(self._ebFirstGlobal)

            d2 = self.conn.sendGlobalRequest('foo-2', 'bar2', 1)
            d2.addCallback(lambda x: unittest.assertEquals(x, 'data'))
            d2.addErrback(self._ebSecondGlobal)

            d3 = self.conn.sendGlobalRequest('bar', 'foo', 1)
            d3.addCallback(self._cbThirdGlobal)
            d3.addErrback(lambda x,s=self: log.msg('subsystem finished') or s.conn.addResult() or s.loseConnection())
Exemplo n.º 15
0
        def _cbRealRequestWorked(self, ignored):
            d1 = self.conn.sendGlobalRequest("foo", "bar", 1)
            d1.addErrback(self._ebFirstGlobal)

            d2 = self.conn.sendGlobalRequest("foo-2", "bar2", 1)
            d2.addCallback(lambda x: unittest.assertEquals(x, "data"))
            d2.addErrback(self._ebSecondGlobal)

            d3 = self.conn.sendGlobalRequest("bar", "foo", 1)
            d3.addCallback(self._cbThirdGlobal)
            d3.addErrback(lambda x, s=self: log.msg("subsystem finished") or s.conn.addResult() or s.loseConnection())
Exemplo n.º 16
0
        def _cbRealRequestWorked(self, ignored):
            d1 = self.conn.sendGlobalRequest('foo', 'bar', 1)
            d1.addErrback(self._ebFirstGlobal)

            d2 = self.conn.sendGlobalRequest('foo-2', 'bar2', 1)
            d2.addCallback(lambda x: unittest.assertEquals(x, 'data'))
            d2.addErrback(self._ebSecondGlobal)

            d3 = self.conn.sendGlobalRequest('bar', 'foo', 1)
            d3.addCallback(self._cbThirdGlobal)
            d3.addErrback(lambda x, s=self: log.msg('subsystem finished') or s.
                          conn.addResult() or s.loseConnection())
Exemplo n.º 17
0
 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
Exemplo n.º 18
0
 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
Exemplo n.º 19
0
 def verifyHostKey(self, key, fp):
     unittest.assertEquals(key, keys.Key.fromString(publicRSA_openssh).blob())
     unittest.assertEquals(fp,'3d:13:5f:cb:c9:79:8a:93:06:27:65:bc:3d:0b:8f:af')
     return defer.succeed(1)
Exemplo n.º 20
0
 def processEnded(self, reason):
     unittest.assertEquals(reason.value.exitCode, 0, 'exit code was not 0: %s' % reason.value.exitCode)
     self.buf = self.buf.replace('\r\n', '\n')
     unittest.assertEquals(self.buf, 'goodbye\n')
     self.deferred.callback(None)
Exemplo n.º 21
0
 def requestAvatar(self, avatarID, mind, *interfaces):
     unittest.assertEquals(avatarID, 'testuser')
     a = ConchTestAvatar()
     return interfaces[0], a, a.logout
Exemplo n.º 22
0
 def areDone(self, avatarId):
     unittest.assertEquals(avatarId, 'testuser')
     if len(self.successfulCredentials[avatarId]) < 2:
         return 0
     else:
         return 1
Exemplo n.º 23
0
 def global_foo(self, data):
     unittest.assertEquals(data, 'bar')
     return 1
Exemplo n.º 24
0
 def global_foo_2(self, data):
     unittest.assertEquals(data, "bar2")
     return 1, "data"
Exemplo n.º 25
0
 def checkKey(self, credentials):
     unittest.assertEquals(credentials.username, 'testuser', 'bad username')
     unittest.assertEquals(credentials.blob, keys.getPublicKeyString(data=publicDSA_openssh))
     return 1
Exemplo n.º 26
0
 def openShell(self, proto):
     log.msg('openning shell')
     unittest.assertEquals(self.ptyReq, True)
     self.proto = proto
     EchoTransport(proto)
     self.cmd = 'shell'
Exemplo n.º 27
0
 def requestAvatar(self, avatarID, mind, *interfaces):
     unittest.assertEquals(avatarID, 'testuser')
     a = ConchTestAvatar()
     return interfaces[0], a, a.logout
Exemplo n.º 28
0
 def getPty(self, term, windowSize, attrs):
     log.msg('pty req')
     unittest.assertEquals(term, 'conch-test-term')
     unittest.assertEquals(windowSize, (24, 80, 0, 0))
     self.ptyReq = True
Exemplo n.º 29
0
 def requestAvatarId(self, credentials):
     unittest.assertEquals(credentials.username, 'testuser',
                           'bad username')
     unittest.assertEquals(credentials.password, 'testpass',
                           'bad password')
     return defer.succeed(credentials.username)
Exemplo n.º 30
0
 def verifyHostKey(self, key, fp):
     unittest.assertEquals(key, keys.getPublicKeyString(data=publicRSA_openssh))
     unittest.assertEquals(fp, "3d:13:5f:cb:c9:79:8a:93:06:27:65:bc:3d:0b:8f:af")
     return defer.succeed(1)
Exemplo n.º 31
0
 def areDone(self, avatarId):
     unittest.assertEquals(avatarId, 'testuser')
     if len(self.successfulCredentials[avatarId]) < 2:
         return 0
     else:
         return 1
Exemplo n.º 32
0
 def global_foo(self, data):
     unittest.assertEquals(data, 'bar')
     return 1
Exemplo n.º 33
0
 def openShell(self, proto):
     log.msg('openning shell')
     unittest.assertEquals(self.ptyReq, True)
     self.proto = proto
     EchoTransport(proto)
     self.cmd = 'shell'
Exemplo n.º 34
0
 def global_foo_2(self, data):
     unittest.assertEquals(data, 'bar2')
     return 1, 'data'
Exemplo n.º 35
0
 def checkKey(self, credentials):
     unittest.assertEquals(credentials.username, 'testuser', 'bad username')
     unittest.assertEquals(credentials.blob, keys.Key.fromString(publicDSA_openssh).blob())
     return 1
Exemplo n.º 36
0
 def extReceived(self, dataType, data):
     unittest.assertEquals(dataType, connection.EXTENDED_DATA_STDERR)
     self.testExtBuf += data
Exemplo n.º 37
0
 def requestAvatarId(self, credentials):
     unittest.assertEquals(credentials.username, 'testuser', 'bad username')
     unittest.assertEquals(credentials.password, 'testpass', 'bad password')
     return defer.succeed(credentials.username)
Exemplo n.º 38
0
 def extReceived(self, dataType, data):
     unittest.assertEquals(dataType, connection.EXTENDED_DATA_STDERR)
     self.testExtBuf += data
Exemplo n.º 39
0
 def global_foo_2(self, data):
     unittest.assertEquals(data, 'bar2')
     return 1, 'data'
Exemplo n.º 40
0
 def getPty(self, term, windowSize, attrs):
     log.msg('pty req')
     unittest.assertEquals(term, 'conch-test-term')
     unittest.assertEquals(windowSize, (24, 80, 0, 0))
     self.ptyReq = True
Exemplo n.º 41
0
 def requestAvatarId(self, credentials):
     unittest.assertEquals(credentials.username, "testuser", "bad username")
     unittest.assertEquals(credentials.password, "testpass", "bad password")
     return defer.succeed(credentials.username)