PHP WebShell

Текущая директория: /usr/lib/python3/dist-packages/twisted/protocols/haproxy/test/__pycache__

Просмотр файла: test_v1parser.cpython-310.pyc

o

�bJ�@sRdZddlmZddlmZddlmZddlmZm	Z	m
Z
Gdd�dej�Zd	S)
z7
Test cases for L{twisted.protocols.haproxy.V1Parser}.
�)�address)�unittest�)�	_v1parser)�InvalidNetworkProtocol�InvalidProxyHeader�MissingAddressDatac@steZdZdZddd�Zddd�Zddd	�Zdd
d�Zddd
�Zddd�Z	ddd�Z
ddd�Zddd�Zddd�Z
dS)�
V1ParserTestsz?
    Test L{twisted.protocols.haproxy.V1Parser} behaviour.
    �returnNcC�|�ttjjd�dS)zT
        Test that an exception is raised when the PROXY header is missing.
        s	NOTPROXY N)�assertRaisesrr�V1Parser�parse��self�r�N/usr/lib/python3/dist-packages/twisted/protocols/haproxy/test/test_v1parser.py�test_missingPROXYHeaderValue�
�z*V1ParserTests.test_missingPROXYHeaderValuecCr)zX
        Test that an exception is raised when the proto is not TCP or UNKNOWN.
        sPROXY WUTPROTO N)rrrr
rrrrr�test_invalidNetworkProtocolrz)V1ParserTests.test_invalidNetworkProtocolcCr)zU
        Test that an exception is raised when the proto has no source data.
        sPROXY TCP4 N�rrrr
rrrrr�test_missingSourceData'rz$V1ParserTests.test_missingSourceDatacCr)zU
        Test that an exception is raised when the proto has no destination.
        sPROXY TCP4 127.0.0.1 8080 8888Nrrrrr�test_missingDestData1rz"V1ParserTests.test_missingDestDatacC�tj�d�}|�|jtj�t|jtj�sJ�t|jtj�s J�|�	|jj
d�|�	|jjd�|�	|jj
d�|�	|jjd�dS)zE
        Test that parsing is successful for a PROXY header.
        s(PROXY TCP4 127.0.0.1 127.0.0.1 8080 8888�	127.0.0.1��"N)rr
r�assertIsInstance�sourcer�IPv4Address�
isinstance�destination�assertEqual�host�port�r�inforrr�test_fullParsingSuccess;��z%V1ParserTests.test_fullParsingSuccesscCr)zK
        Test that parsing is successful for an IPv6 PROXY header.
        sPROXY TCP6 ::1 ::1 8080 8888z::1rrN)rr
rrrr�IPv6Addressr r!r"r#r$r%rrr�test_fullParsingSuccess_IPv6Jr(z*V1ParserTests.test_fullParsingSuccess_IPv6cCs(tj�d�}|�|j�|�|j�dS)zM
        Test that parsing is successful for a UNKNOWN PROXY header.
        s$PROXY UNKNOWN anything could go hereN)rr
r�assertIsNonerr!r%rrr�test_fullParsingSuccess_UNKNOWNYs
�z-V1ParserTests.test_fullParsingSuccess_UNKNOWNcCs�t��}|�d�\}}|�|�|�|�|�d�\}}|�|�|�|�|�d�\}}|�|�|dus8J�|dus>J�|�|jtj�t|jtj�sOJ�t|j	tj�sXJ�|�
|jjd�|�
|jjd�|�
|j	jd�|�
|j	jd�dS)zE
        Test that parsing happens when fed a complete line.
        �PROXY TCP4 127.0.0.1 127.0.0.1 �	8080 8888s
Nrrr)
rr
�feed�assertFalserrrrr r!r"r#r$�r�parserr&�	remainingrrr�test_feedParsingcs$




zV1ParserTests.test_feedParsingcCs`t��}|�d�\}}|�|�|�|�|�d�\}}|�|�|�|�|�t|jd�dS)zN
        Test that parsing fails if no newline is found in 108 bytes.
        r-r.sd                                                                                                    N)rr
r/r0rrr1rrr�test_feedParsingTooLongzs



�z%V1ParserTests.test_feedParsingTooLongcCs<t��}|�d�\}}|�|�|�|d�|�|j�dS)zH
        Test that parsing leaves overflow bytes in the buffer.
        s:PROXY TCP4 127.0.0.1 127.0.0.1 8080 8888
HTTP/1.1 GET /
sHTTP/1.1 GET /
N)rr
r/�
assertTruer"r0�bufferr1rrr�test_feedParsingOverflow�s�
z&V1ParserTests.test_feedParsingOverflow)r
N)�__name__�
__module__�__qualname__�__doc__rrrrr'r*r,r4r5r8rrrrr	s













r	N)
r<�twisted.internetr�
twisted.trialr�r�_exceptionsrrr�TestCaser	rrrr�<module>s

Выполнить команду


Для локальной разработки. Не используйте в интернете!