§
    Ètºfÿ  ã                   ó¢   — d Z ddlmZmZ ddlmZmZmZmZ	m
Z
mZ ddlmZ ddlmZ ddlmZ ddlmZ  G d	„ d
e¦  «        Z G d„ de¦  «        ZdS )z1
Tests for L{twisted.protocols.haproxy._parser}.
é    )ÚTypeÚUnion)ÚTCP4ServerEndpointÚTCP6ServerEndpointÚUNIXServerEndpointÚ_parseÚ_WrapperServerEndpointÚserverFromString)ÚMemoryReactor)ÚSynchronousTestCaseé   )ÚunparseEndpoint)ÚHAProxyWrappingFactoryc                   óR   — e Zd ZdZdeddfd„Zdd„Zdd„Zdd„Zdd	„Z	dd
„Z
dd„ZdS )ÚUnparseEndpointTestszg
    Tests to ensure that un-parsing an endpoint string round trips through
    escaping properly.
    ÚinputÚreturnNc                 óZ   — |                       t          t          |¦  «        Ž |¦  «         dS )aA  
        Check that the input unparses into the output, raising an assertion
        error if it doesn't.

        @param input: an input in endpoint-string-description format.  (To
            ensure determinism, keyword arguments should be in alphabetical
            order.)
        @type input: native L{str}
        N)ÚassertEqualr   ÚparseEndpoint)Úselfr   s     úi/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/protocols/haproxy/test/test_parser.pyÚcheckzUnparseEndpointTests.check   s-   € ð 	×Ò�­-¸Ñ*>Ô*>Ð?ÀÑGÔGÐGÐGÐGó    c                 ó0   — |                       d¦  «         dS )z%
        An individual word.
        ÚwordN©r   ©r   s    r   Útest_basicUnparsez&UnparseEndpointTests.test_basicUnparse)   s   € ð 	�
Š
�6ÑÔÐÐÐr   c                 ó0   — |                       d¦  «         dS )z%
        Multiple arguments.
        zone:twoNr   r   s    r   Útest_multipleArgumentsz+UnparseEndpointTests.test_multipleArguments/   s   € ð 	�
Š
�9ÑÔÐÐÐr   c                 ó0   — |                       d¦  «         dS )z$
        Keyword arguments.
        zaleph=one:bet=twoNr   r   s    r   Útest_keywordsz"UnparseEndpointTests.test_keywords5   s   € ð 	�
Š
Ð&Ñ'Ô'Ð'Ð'Ð'r   c                 ó0   — |                       d¦  «         dS )z
        Escaped ":".
        zhello\:colon\:worldNr   r   s    r   Útest_colonInArgumentz)UnparseEndpointTests.test_colonInArgument;   s   € ð 	�
Š
Ð*Ñ+Ô+Ð+Ð+Ð+r   c                 ó0   — |                       d¦  «         dS )z/
        Escaped ":" in keyword value.
        zhello=\:Nr   r   s    r   Útest_colonInKeywordValuez-UnparseEndpointTests.test_colonInKeywordValueA   ó   € ð 	�
Š
�;ÑÔÐÐÐr   c                 ó0   — |                       d¦  «         dS )z.
        Escaped ":" in keyword name.
        z\:=helloNr   r   s    r   Útest_colonInKeywordNamez,UnparseEndpointTests.test_colonInKeywordNameG   r(   r   ©r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústrr   r   r!   r#   r%   r'   r*   © r   r   r   r      s¾   € € € € € ðð ð

H˜3ð 
H 4ð 
Hð 
Hð 
Hð 
Hðð ð ð ðð ð ð ð(ð (ð (ð (ð,ð ,ð ,ð ,ð ð  ð  ð  ð ð  ð  ð  ð  ð  r   r   c                   ót   — e Zd ZdZdedeee         ee         ee	         f         de
fd„Zd
d„Zd
d„Zd
d	„ZdS )ÚHAProxyServerParserTestsz@
    Tests that the parser generates the correct endpoints.
    ÚdescriptionÚexpectedClassr   c                 ó  — t          ¦   «         }t          ||¦  «        }|                      |t          ¦  «         t	          |t          ¦  «        sJ ‚|                      |j        |¦  «         |                      |j        t          ¦  «         |S )a%  
        Test the C{haproxy} enpdoint prefix against one sub-endpoint type.

        @param description: A string endpoint description beginning with
            C{haproxy}.
        @type description: native L{str}

        @param expectedClass: the expected sub-endpoint class given the
            description.
        @type expectedClass: L{type}

        @return: the parsed endpoint
        @rtype: L{IStreamServerEndpoint}

        @raise twisted.trial.unittest.Failtest: if the parsed endpoint doesn't
            match expectations.
        )	r   r
   ÚassertIsInstancer	   Ú
isinstanceÚ_wrappedEndpointÚassertIsÚ_wrapperFactoryr   )r   r4   r5   ÚreactorÚendpoints        r   Ú	onePrefixz"HAProxyServerParserTests.onePrefixS   s€   € õ4  ‘/”/ˆÝ# G¨[Ñ9Ô9ˆØ×Ò˜hÕ(>Ñ?Ô?Ð?Ý˜(Õ$:Ñ;Ô;Ð;Ð;Ð;Ø×Ò˜hÔ7¸ÑGÔGÐGØ�Š�hÔ.Õ0FÑGÔGÐGØˆr   Nc                 ó<   — |                       dt          ¦  «         dS )zG
        Test if the parser generates a wrapped TCP4 endpoint.
        zhaproxy:tcp:8080N)r>   r   r   s    r   Ú	test_tcp4z"HAProxyServerParserTests.test_tcp4u   s    € ð 	�ŠÐ)Õ+=Ñ>Ô>Ð>Ð>Ð>r   c                 ó<   — |                       dt          ¦  «         dS )zG
        Test if the parser generates a wrapped TCP6 endpoint.
        zhaproxy:tcp6:8080N)r>   r   r   s    r   Ú	test_tcp6z"HAProxyServerParserTests.test_tcp6{   s    € ð 	�ŠÐ*Õ,>Ñ?Ô?Ð?Ð?Ð?r   c                 ó<   — |                       dt          ¦  «         dS )zG
        Test if the parser generates a wrapped UNIX endpoint.
        z haproxy:unix:address=/tmp/socketN)r>   r   r   s    r   Ú	test_unixz"HAProxyServerParserTests.test_unix�   s    € ð 	�ŠÐ9Õ;MÑNÔNÐNÐNÐNr   r+   )r,   r-   r.   r/   r0   r   r   r   r   r   r	   r>   r@   rB   rD   r1   r   r   r3   r3   N   sº   € € € € € ðð ð àð ð ØÐ#Ô$ØÐ#Ô$ØÐ#Ô$ð&ô
ð ð 
 ð ð  ð  ð  ðD?ð ?ð ?ð ?ð@ð @ð @ð @ðOð Oð Oð Oð Oð Or   r3   N)r/   Útypingr   r   Útwisted.internet.endpointsr   r   r   r   r   r	   r
   Útwisted.internet.testingr   Útwisted.trial.unittestr   ÚTestCaseÚ_parserr   Ú_wrapperr   r   r3   r1   r   r   ú<module>rL      s,  ððð ð Ð Ð Ð Ð Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð 3Ð 2Ð 2Ð 2Ð 2Ð 2Ø BÐ BÐ BÐ BÐ BÐ BØ %Ð %Ð %Ð %Ð %Ð %Ø -Ð -Ð -Ð -Ð -Ð -ð4 ð 4 ð 4 ð 4 ð 4 ˜8ñ 4 ô 4 ð 4 ðn7Oð 7Oð 7Oð 7Oð 7O˜xñ 7Oô 7Oð 7Oð 7Oð 7Or   