def testOrAnythingUnderTheMagicDirectoryToo(self): request = self.make_request('/app1/__/blah/blah/blah', Zope=True) task = Task(StubChannel(), request) try: task.process() except Response, response: self.assertEqual(response.code, 404)
def testDirectlyAccessingMagicDirectoryRaises404(self): request = self.make_request('/app1/__', Zope=True) task = Task(StubChannel(), request) try: task.process() except Response, response: self.assertEqual(response.code, 404)
def testSubdirStillMatches(self): request = self.make_request('/app1/foo/bar.html', Zope=True) task = Task(StubChannel(), request) try: task.process() except Response, response: self.assertEqual(response.code, 200)
def testAppNotThereRaises404(self): request = self.make_request('/not-there', Zope=True) task = Task(StubChannel(), request) try: task.process() except Response, response: self.assertEqual(response.code, 404)
def testBasic(self): request = self.make_request('/index.html', Zope=True) task = Task(StubChannel(), request) try: task.process() except Response, response: pass
def testNonRootAppWithNoMagicDirectoryRaises500(self): request = self.make_request('/app1', Zope=True) task = Task(StubChannel(), request) os.remove(self.convert_path('root/app1/__/app.py')) os.remove(self.convert_path('root/app1/__/app.pyc')) os.rmdir(self.convert_path('root/app1/__')) try: task.process() except Response, response: self.assertEqual(response.code, 500)
def testEtcPasswdCaughtByFindApp(self): request = self.make_request( '../../../../../../../../../../etc/master.passwd', Zope=True) task = Task(StubChannel(), request) expected = [ "HTTP/1.0 500 Internal Server Error", "Content-Length: 25", "Content-Type: text/plain", "", "Internal Server Error", "", "" ] expected = '\r\n'.join(expected) actual = task.channel.getvalue() self.assertEqual(expected, actual)
def DUMMY_TASK(): return Task(StubChannel(), request)