%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python3/dist-packages/twisted/web/test/__pycache__/
Upload File :
Create Path :
Current File : //usr/lib/python3/dist-packages/twisted/web/test/__pycache__/test_vhost.cpython-312.pyc

�

Ϫ�f����dZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZdd	lmZdd
lmZmZmZGd�de�ZGd
�de�ZGd�de�Zy)z!
Tests for L{twisted.web.vhost}.
�)�
gatherResults)�TestCase)�	NOT_FOUND)�
NoResource)�Site)�Data)�_render)�DummyRequest)�NameVirtualHost�VHostMonsterResource�
_HostResourcec��eZdZdZd�Zy)�HostResourceTestsz%
    Tests for L{_HostResource}.
    c�&�tdd�}tdd�}tdd�}|jd|�|jd|�t�}t�}tdd�|_|jd|�t
ddg�}gd	�|_t|�|_	d
�|_
d|_|jd|�}|j|t�t
ddg�}|jd|�}|j|t�y)
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�httprc��y)NF�r��=/usr/lib/python3/dist-packages/twisted/web/test/test_vhost.py�<lambda>z1HostResourceTests.test_getChild.<locals>.<lambda>-s�rrN)r�putChildr
r�default�addHostr
�prepathr�site�isSecure�host�getChild�assertIsInstancer)�self�bazroot�bazuri�baztest�hr�root�request�steps        r�
test_getChildzHostResourceTests.test_getChilds����|�R�(���k�2�&���|�R�(�������)������(�
�_��� ���O�R�0������Z��)����0�1��7����D�z���(�������{�{�:�w�/�����d�D�)����0�1���}�}�V�W�-�����d�J�/rN��__name__�
__module__�__qualname__�__doc__r*rrrrrs���0rrc�:�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
y	)
�NameVirtualHostTestsz'
    Tests for L{NameVirtualHost}.
    c��t�}tdd�|_tdg�}|j	|j|�d�y)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 resultrrN)rrrr
�assertEqual�render�r"�virtualHostResourcer(s   r�test_renderWithoutHostz+NameVirtualHostTests.test_renderWithoutHost=sG��.�/��&*�+<�b�&A��#���u�%�����,�3�3�G�<�>O�Prc�|���t�}tdg��t|��}��fd�}|j|�|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�F���j�jt�y�N�r3�responseCoder��ignoredr(r"s ��r�
cbRenderedzHNameVirtualHostTests.test_renderWithoutHostNoDefault.<locals>.cbRenderedR�������W�1�1�9�=r)rr
r	�addCallback�r"r6�dr?r(s`   @r�test_renderWithoutHostNoDefaultz4NameVirtualHostTests.test_renderWithoutHostNoDefaultHs?���.�/����u�%���'��1��	>�	
�
�
�j�!��rc���t�}|jdtdd��tdg�}|jjdd�t
||�}�fd�}|j||�tdg�}|jjdd�t
||�}�fd�}|j||�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�\���jdj|j�d�y�NrrF�r3�join�writtenr=s  �rr?z<NameVirtualHostTests.test_renderWithHost.<locals>.cbRenderedes ������S�X�X�g�o�o�6�	�Brsexample.org:8000c�\���jdj|j�d�yrIrJ)r>�requestWithPortr"s  �rr?z<NameVirtualHostTests.test_renderWithHost.<locals>.cbRenderedos"������S�X�X�o�&=�&=�>�	�Jr)	rrrr
�requestHeaders�addRawHeaderr	rAr)r"r6r(rCr?rN�	dWithPorts`      r�test_renderWithHostz(NameVirtualHostTests.test_renderWithHostXs����.�/���#�#�N�D��B�4G�H���u�%�����+�+�G�^�D��'��1��	C�	
�
�
�j�'�*�'��u�-���&�&�3�3�G�=P�Q��/��A�	�	K�	���j�/�:��a��^�,�,rc�����t�}tdd�|_tdg���jjdd�t
|��}��fd�}|j|�|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 datarrrG�example.comc�\���jdj�j�d�y)NrrTrJr=s ��rr?zCNameVirtualHostTests.test_renderWithUnknownHost.<locals>.cbRendered�s ������S�X�X�g�o�o�6��Hr)rrrr
rOrPr	rArBs`   @r�test_renderWithUnknownHostz/NameVirtualHostTests.test_renderWithUnknownHostvsf���.�/��&*�?�B�&?��#���u�%�����+�+�G�^�D��'��1��	I�	
�
�
�j�!��rc����t�}tdg���jjdd�t	|��}��fd�}|j|�|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.
        rrGrUc�F���j�jt�yr:r;r=s ��rr?zLNameVirtualHostTests.test_renderWithUnknownHostNoDefault.<locals>.cbRendered�r@r)rr
rOrPr	rArBs`   @r�#test_renderWithUnknownHostNoDefaultz8NameVirtualHostTests.test_renderWithUnknownHostNoDefault�sU���.�/����u�%�����+�+�G�^�D��'��1��	>�	
�
�
�j�!��rc���K�t�}tdg�}|jjdd�t	||��d{���|jddj
|j��y7�0�w)zs
        L{NameVirtualHost.render} doesn't echo unescaped HTML when present in
        the I{Host} header.
        rrGs<b>example</b>.comNs<b>)rr
rOrPr	�assertNotInrKrLr5s   r�test_renderWithHTMLHostz,NameVirtualHostTests.test_renderWithHTMLHost�sg����
.�/����u�%�����+�+�G�5J�K��)�7�3�3�3��������'�/�/�!:�;�	4�s�AA7�A5�1A7c���t�}tdd�}d|_tdd�}|jd|�|jd|�t	g�}|j
j
dd�dg|_|j|jd|�t�|j|jdg�|j|jg�t	g�}|j
j
dd�dg|_|j|jd|�t�|j|jg�|j|jdg�y	)
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.orgrGrN)
rr�isLeafrr
rOrPrr!r rr3�postpath)r"r6�leafResource�normResourcer(s     rr*z"NameVirtualHostTests.test_getChild�s7��.�/���L�"�-��"����L�"�-���#�#�$7��F��#�#�$7��F��r�"�����+�+�G�5H�I��%������1�:�:�3��H�*�U�������3�%�0�����)�)�2�.��r�"�����+�+�G�5H�I��%������1�:�:�3��H�$�O�������"�-�����)�)�C�5�1rN)r,r-r.r/r7rDrRrWrZr]r*rrrr1r18s+���	Q�� -�<�$�"<�2rr1c��eZdZdZd�Zy)�VHostMonsterResourceTestsz,
    Tests for L{VHostMonsterResource}.
    c�X�t�}tg�}|j|jd|�t�|j|j
��tg�}|j|jd|�t�|j|j
��y)z�
        L{VHostMonsterResource.getChild} returns I{_HostResource} and modifies
        I{Request} with correct L{Request.isSecure}.
        rshttpsN)rr
r!r r
�assertFalser�
assertTrue)r"�vhmr(s   rr*z'VHostMonsterResourceTests.test_getChild�s���
#�$���r�"�����c�l�l�7�G�<�m�L�����)�)�+�,��r�"�����c�l�l�8�W�=�}�M�����(�(�*�+rNr+rrrrdrd�s���,rrdN)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.vhostrrr
rr1rdrrr�<module>rrsR���
1�+�&�+�#�#�*�2�R�R�!0��!0�HI2�8�I2�X,��,r

Zerion Mini Shell 1.0