OXIESEC PANEL
- Current Dir:
/
/
usr
/
lib
/
python3
/
dist-packages
/
twisted
/
web
/
test
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
03/31/2022 06:22:39 AM
rwxr-xr-x
📄
__init__.py
108 bytes
09/08/2017 10:38:36 AM
rw-r--r--
📁
__pycache__
-
03/31/2022 06:22:40 AM
rwxr-xr-x
📄
_util.py
2.51 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
injectionhelpers.py
5.5 KB
03/22/2022 11:03:56 AM
rw-r--r--
📄
requesthelper.py
10.6 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_agent.py
113.19 KB
03/22/2022 11:03:56 AM
rw-r--r--
📄
test_cgi.py
13.29 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_client.py
1.34 KB
09/08/2017 10:38:35 AM
rw-r--r--
📄
test_distrib.py
16.02 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_domhelpers.py
10.84 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_error.py
15.83 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_flatten.py
17.83 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_html.py
1.23 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_http.py
122.6 KB
03/22/2022 11:03:56 AM
rw-r--r--
📄
test_http2.py
105.98 KB
03/22/2022 11:03:56 AM
rw-r--r--
📄
test_http_headers.py
19.91 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_httpauth.py
22.75 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_newclient.py
102.47 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_proxy.py
19.62 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_resource.py
8.02 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_script.py
3.7 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_stan.py
5.53 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_static.py
62.22 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_tap.py
10.34 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_template.py
24.99 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_util.py
12.29 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_vhost.py
7.22 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_web.py
55.24 KB
03/22/2022 11:03:56 AM
rw-r--r--
📄
test_web__responses.py
877 bytes
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_webclient.py
57.45 KB
03/22/2022 11:03:56 AM
rw-r--r--
📄
test_wsgi.py
73.06 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_xml.py
41.36 KB
09/08/2017 10:38:36 AM
rw-r--r--
📄
test_xmlrpc.py
28.24 KB
09/08/2017 10:38:36 AM
rw-r--r--
Editing: test_script.py
Close
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Tests for L{twisted.web.script}. """ import os from twisted.trial.unittest import TestCase from twisted.python.filepath import FilePath from twisted.web.http import NOT_FOUND from twisted.web.script import ResourceScriptDirectory, PythonScript from twisted.web.test._util import _render from twisted.web.test.requesthelper import DummyRequest class ResourceScriptDirectoryTests(TestCase): """ Tests for L{ResourceScriptDirectory}. """ def test_renderNotFound(self): """ L{ResourceScriptDirectory.render} sets the HTTP response code to I{NOT FOUND}. """ resource = ResourceScriptDirectory(self.mktemp()) request = DummyRequest([b'']) d = _render(resource, request) def cbRendered(ignored): self.assertEqual(request.responseCode, NOT_FOUND) d.addCallback(cbRendered) return d def test_notFoundChild(self): """ L{ResourceScriptDirectory.getChild} returns a resource which renders an response with the HTTP I{NOT FOUND} status code if the indicated child does not exist as an entry in the directory used to initialized the L{ResourceScriptDirectory}. """ path = self.mktemp() os.makedirs(path) resource = ResourceScriptDirectory(path) request = DummyRequest([b'foo']) child = resource.getChild("foo", request) d = _render(child, request) def cbRendered(ignored): self.assertEqual(request.responseCode, NOT_FOUND) d.addCallback(cbRendered) return d def test_render(self): """ L{ResourceScriptDirectory.getChild} returns a resource which renders a response with the HTTP 200 status code and the content of the rpy's C{request} global. """ tmp = FilePath(self.mktemp()) tmp.makedirs() tmp.child("test.rpy").setContent(b""" from twisted.web.resource import Resource class TestResource(Resource): isLeaf = True def render_GET(self, request): return b'ok' resource = TestResource()""") resource = ResourceScriptDirectory(tmp._asBytesPath()) request = DummyRequest([b'']) child = resource.getChild(b"test.rpy", request) d = _render(child, request) def cbRendered(ignored): self.assertEqual(b"".join(request.written), b"ok") d.addCallback(cbRendered) return d class PythonScriptTests(TestCase): """ Tests for L{PythonScript}. """ def test_notFoundRender(self): """ If the source file a L{PythonScript} is initialized with doesn't exist, L{PythonScript.render} sets the HTTP response code to I{NOT FOUND}. """ resource = PythonScript(self.mktemp(), None) request = DummyRequest([b'']) d = _render(resource, request) def cbRendered(ignored): self.assertEqual(request.responseCode, NOT_FOUND) d.addCallback(cbRendered) return d def test_renderException(self): """ L{ResourceScriptDirectory.getChild} returns a resource which renders a response with the HTTP 200 status code and the content of the rpy's C{request} global. """ tmp = FilePath(self.mktemp()) tmp.makedirs() child = tmp.child("test.epy") child.setContent(b'raise Exception("nooo")') resource = PythonScript(child._asBytesPath(), None) request = DummyRequest([b'']) d = _render(resource, request) def cbRendered(ignored): self.assertIn(b"nooo", b"".join(request.written)) d.addCallback(cbRendered) return d