/usr/share/pyshared/twisted/web2/test/test_fastcgi.py is in python-twisted-web2 8.1.0-3build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | from twisted.trial import unittest
from twisted.web2.channel import fastcgi
from twisted.python import util
class FCGI(unittest.TestCase):
def testPacketReceived(self):
'''
Test that a packet can be received, and that it will cause
'writePacket' to be called.
'''
record = fastcgi.Record(fastcgi.FCGI_GET_VALUES, 0, '')
req = fastcgi.FastCGIChannelRequest()
called = []
def writePacket(rec):
self.assertEquals(rec.__class__, fastcgi.Record)
called.append(rec)
req.writePacket = writePacket
req.packetReceived(record)
self.assertEquals(len(called), 1)
def testPacketWrongVersion(self):
'''
Test that a version other than version 1 will raise FastCGIError
'''
record = fastcgi.Record(fastcgi.FCGI_GET_VALUES, 0, '', version=2)
req = fastcgi.FastCGIChannelRequest()
self.failUnless(util.raises(fastcgi.FastCGIError, req.packetReceived, record))
def testPacketBadType(self):
'''
Test that an invalid packet type will raise FastCGIError
'''
record = fastcgi.Record(99999, 0, '')
req = fastcgi.FastCGIChannelRequest()
self.failUnless(util.raises(fastcgi.FastCGIError, req.packetReceived, record))
def testParseLongName(self):
'''
Test the code paths for parsing a name or value with >= 128 bytes. The
length prefixing is done differently in this case.
'''
self.assertEqual(
[('x'*128, 'y')],
list(fastcgi.parseNameValues(fastcgi.writeNameValue('x'*128, 'y'))))
def testParseLongValue(self):
'''
Test parsing a long value.
'''
self.assertEqual(
[('x', 'y'*128)],
list(fastcgi.parseNameValues(fastcgi.writeNameValue('x', 'y'*128))))
|