Exemplo n.º 1
0
    def testAuthProcessInput(self):
        fd = MockFd(1)
        self.server._realauthfds = [1]
        MockClassMethod(Server, '_GrabPacket')
        MockClassMethod(Server, '_HandleAuthPacket')

        self.server._ProcessInput(fd)
        self.assertEqual([x[0] for x in self.server.called],
                ['_GrabPacket', '_HandleAuthPacket'])
        self.assertEqual(self.server.called[0][1][1], fd)
Exemplo n.º 2
0
 def testRunIgnoresPacketErrors(self):
     def RaisePacketError(self, fd):
         raise PacketError
     MockClassMethod(Server, '_ProcessInput', RaisePacketError)
     self.server.authfds = [MockFd()]
     MockPoll.results = [(0, select.POLLIN)]
     self.assertRaises(MockFinished, self.server.Run)
Exemplo n.º 3
0
 def testRunRunsProcessInput(self):
     MockClassMethod(Server, '_ProcessInput')
     self.server.authfds = fd = [MockFd()]
     MockPoll.results = [(0, select.POLLIN)]
     self.assertRaises(MockFinished, self.server.Run)
     self.assertEqual(self.server.called,
                      [('_ProcessInput', (fd[0], ), {})])
Exemplo n.º 4
0
 def testRunInitializes(self):
     MockClassMethod(Server, '_PrepareSockets')
     self.assertRaises(MockFinished, self.server.Run)
     self.assertEqual(self.server.called, [('_PrepareSockets', (), {})])
     self.failUnless(isinstance(self.server._fdmap, dict))
     self.failUnless(isinstance(self.server._poll, MockPoll))
Exemplo n.º 5
0
 def testProcessInput(self):
     MockClassMethod(Proxy, '_GrabPacket')
     MockClassMethod(Proxy, '_HandleProxyPacket')
     self.proxy._ProcessInput(self.proxy._proxyfd)
     self.assertEqual([x[0] for x in self.proxy.called],
             ['_GrabPacket', '_HandleProxyPacket'])
Exemplo n.º 6
0
 def testProcessInputNonProxyPort(self):
     fd = MockFd(fd=111)
     MockClassMethod(Server, '_ProcessInput')
     self.proxy._ProcessInput(fd)
     self.assertEqual(self.proxy.called,
             [('_ProcessInput', (fd,), {})])