__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.10: ~ $
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

"""
Test L{twisted.web.pages}
"""

from typing import cast

from twisted.trial.unittest import SynchronousTestCase
from twisted.web.http_headers import Headers
from twisted.web.iweb import IRequest
from twisted.web.pages import errorPage, forbidden, notFound
from twisted.web.resource import IResource
from twisted.web.test.requesthelper import DummyRequest


def _render(resource: IResource) -> DummyRequest:
    """
    Render a response using the given resource.

    @param resource: The resource to use to handle the request.

    @returns: The request that the resource handled,
    """
    request = DummyRequest([b""])
    # The cast is necessary because DummyRequest isn't annotated
    # as an IRequest, and this can't be trivially done. See
    # https://github.com/twisted/twisted/issues/11719
    resource.render(cast(IRequest, request))
    return request


class ErrorPageTests(SynchronousTestCase):
    """
    Test L{twisted.web.pages._ErrorPage} and its public aliases L{errorPage},
    L{notFound} and L{forbidden}.
    """

    maxDiff = None

    def assertResponse(self, request: DummyRequest, code: int, body: bytes) -> None:
        self.assertEqual(request.responseCode, code)
        self.assertEqual(
            request.responseHeaders,
            Headers({b"content-type": [b"text/html; charset=utf-8"]}),
        )
        self.assertEqual(
            # Decode to str because unittest somehow still doesn't diff bytes
            # without truncating them in 2022.
            b"".join(request.written).decode("latin-1"),
            body.decode("latin-1"),
        )

    def test_escapesHTML(self) -> None:
        """
        The I{brief} and I{detail} parameters are HTML-escaped on render.
        """
        self.assertResponse(
            _render(errorPage(400, "A & B", "<script>alert('oops!')")),
            400,
            (
                b"<!DOCTYPE html>\n"
                b"<html><head><title>400 - A &amp; B</title></head>"
                b"<body><h1>A &amp; B</h1><p>&lt;script&gt;alert('oops!')"
                b"</p></body></html>"
            ),
        )

    def test_getChild(self) -> None:
        """
        The C{getChild} method of the resource returned by L{errorPage} returns
        the L{_ErrorPage} it is called on.
        """
        page = errorPage(404, "foo", "bar")
        self.assertIs(
            page.getChild(b"name", cast(IRequest, DummyRequest([b""]))),
            page,
        )

    def test_notFoundDefaults(self) -> None:
        """
        The default arguments to L{twisted.web.pages.notFound} produce
        a reasonable error page.
        """
        self.assertResponse(
            _render(notFound()),
            404,
            (
                b"<!DOCTYPE html>\n"
                b"<html><head><title>404 - No Such Resource</title></head>"
                b"<body><h1>No Such Resource</h1>"
                b"<p>Sorry. No luck finding that resource.</p>"
                b"</body></html>"
            ),
        )

    def test_forbiddenDefaults(self) -> None:
        """
        The default arguments to L{twisted.web.pages.forbidden} produce
        a reasonable error page.
        """
        self.assertResponse(
            _render(forbidden()),
            403,
            (
                b"<!DOCTYPE html>\n"
                b"<html><head><title>403 - Forbidden Resource</title></head>"
                b"<body><h1>Forbidden Resource</h1>"
                b"<p>Sorry, resource is forbidden.</p>"
                b"</body></html>"
            ),
        )

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
__init__.py File 107 B 0644
_util.py File 3.26 KB 0644
injectionhelpers.py File 5.46 KB 0644
requesthelper.py File 15.07 KB 0644
test_agent.py File 119.75 KB 0644
test_cgi.py File 14.76 KB 0644
test_client.py File 1.52 KB 0644
test_distrib.py File 17.58 KB 0644
test_domhelpers.py File 11.18 KB 0644
test_error.py File 16.37 KB 0644
test_flatten.py File 25.67 KB 0644
test_html.py File 1.21 KB 0644
test_http.py File 153.63 KB 0644
test_http2.py File 105.17 KB 0644
test_http_headers.py File 24.38 KB 0644
test_httpauth.py File 23.23 KB 0644
test_newclient.py File 106.8 KB 0644
test_pages.py File 3.56 KB 0644
test_proxy.py File 19.57 KB 0644
test_resource.py File 10.37 KB 0644
test_script.py File 3.91 KB 0644
test_soap.py File 3.04 KB 0644
test_stan.py File 7.08 KB 0644
test_static.py File 66.6 KB 0644
test_tap.py File 11.86 KB 0644
test_template.py File 28.38 KB 0644
test_util.py File 14.76 KB 0644
test_vhost.py File 7.49 KB 0644
test_web.py File 67.52 KB 0644
test_web__responses.py File 837 B 0644
test_webclient.py File 11.52 KB 0644
test_wsgi.py File 73.83 KB 0644
test_xml.py File 42.28 KB 0644
test_xmlrpc.py File 29.85 KB 0644
Filemanager