§
    Étºf.  ã                   óæ   — d Z ddlmZ ddlmZ ddlmZ  G d„ dej        ¦  «        Z G d„ d¦  «        Z	 G d	„ d
e	ej        ¦  «        Z
 G d„ de	ej        ¦  «        Z G d„ de	ej        ¦  «        ZdS )z)
Tests L{twisted.web.client} helper APIs
é    )Úurlparse)Úunittest)Úclientc                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚURLJoinTestsz'
    Tests for L{client._urljoin}.
    c                 óü   — |                       t          j        dd¦  «        d¦  «         |                       t          j        dd¦  «        d¦  «         |                       t          j        dd¦  «        d¦  «         dS )z´
        L{client._urljoin} does not include a fragment identifier in the
        resulting URL if neither the base nor the new path include a fragment
        identifier.
        ó   http://foo.com/baró   /quuxs   http://foo.com/quuxs   http://foo.com/bar#s   /quux#N©ÚassertEqualr   Ú_urljoin©Úselfs    ú^/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/web/test/test_webclient.pyÚtest_noFragmentszURLJoinTests.test_noFragments   s“   € ð 	×ÒÝŒOÐ1°8Ñ<Ô<Ð>Tñ	
ô 	
ð 	
ð 	×ÒÝŒOÐ2°HÑ=Ô=Ð?Uñ	
ô 	
ð 	
ð 	×ÒÝŒOÐ1°9Ñ=Ô=Ð?Uñ	
ô 	
ð 	
ð 	
ð 	
ó    c                 óü   — |                       t          j        dd¦  «        d¦  «         |                       t          j        dd¦  «        d¦  «         |                       t          j        dd¦  «        d¦  «         dS )a  
        L{client._urljoin} preserves the fragment identifier from either the
        new path or the base URL respectively, as specified in the HTTP 1.1 bis
        draft.

        @see: U{https://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-22#section-7.1.2}
        s   http://foo.com/bar#fragr
   s   http://foo.com/quux#fragr	   s   /quux#frag2s   http://foo.com/quux#frag2Nr   r   s    r   Útest_preserveFragmentsz#URLJoinTests.test_preserveFragments$   s“   € ð 	×ÒÝŒOÐ6¸ÑAÔAØ'ñ	
ô 	
ð 	
ð 	×ÒÝŒOÐ1°>ÑBÔBØ(ñ	
ô 	
ð 	
ð 	×ÒÝŒOÐ6¸ÑGÔGØ(ñ	
ô 	
ð 	
ð 	
ð 	
r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   © r   r   r   r      s<   € € € € € ðð ð
ð 
ð 
ð 
ð 
ð 
ð 
ð 
r   r   c                   óv   — e Zd ZdZd„ Z	 dd„Zd„ Zd„ Zd„ Zd„ Z	d	„ Z
d
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ ZdS )ÚURITestsa  
    Abstract tests for L{twisted.web.client.URI}.

    Subclass this and L{unittest.TestCase}. Then provide a value for
    C{host} and C{uriHost}.

    @ivar host: A host specification for use in tests, must be L{bytes}.

    @ivar uriHost: The host specification in URI form, must be a L{bytes}. In
        most cases this is identical with C{host}. IPv6 address literals are an
        exception, according to RFC 3986 section 3.2.2, as they need to be
        enclosed in brackets. In this case this variable is different.
    c                 ó  — |                       | j        t          ¦  «         |                       | j        t          ¦  «         |                       |t          ¦  «         |                      d|¦  «         |                     d| j        ¦  «        S )a±  
        Replace the string "HOST" in C{template} with this test's host.

        Byte strings Python between (and including) versions 3.0 and 3.4
        cannot be formatted using C{%} or C{format} so this does a simple
        replace.

        @type template: L{bytes}
        @param template: A string containing "HOST".

        @rtype: L{bytes}
        @return: A string where "HOST" has been replaced by C{self.host}.
        s   HOST)ÚassertIsInstanceÚhostÚbytesÚuriHostÚassertInÚreplace)r   Útemplates     r   ÚmakeURIStringzURITests.makeURIStringI   sv   € ð 	×Ò˜dœi­Ñ/Ô/Ð/Ø×Ò˜dœl­EÑ2Ô2Ð2Ø×Ò˜h­Ñ.Ô.Ð.Ø�Š�g˜xÑ(Ô(Ð(Ø×Ò ¨¬Ñ6Ô6Ð6r   r   c
                 ó¢   — |                       ||||||||	f|j        |j        |j        |j        |j        |j        |j        |j        f¦  «         dS )aU  
        Assert that all of a L{client.URI}'s components match the expected
        values.

        @param uri: U{client.URI} instance whose attributes will be checked
            for equality.

        @type scheme: L{bytes}
        @param scheme: URI scheme specifier.

        @type netloc: L{bytes}
        @param netloc: Network location component.

        @type host: L{bytes}
        @param host: Host name.

        @type port: L{int}
        @param port: Port number.

        @type path: L{bytes}
        @param path: Hierarchical path.

        @type params: L{bytes}
        @param params: Parameters for last path segment, defaults to C{b''}.

        @type query: L{bytes}
        @param query: Query string, defaults to C{b''}.

        @type fragment: L{bytes}
        @param fragment: Fragment identifier, defaults to C{b''}.
        N)	r   ÚschemeÚnetlocr   ÚportÚpathÚparamsÚqueryÚfragment)
r   Úurir&   r'   r   r(   r)   r*   r+   r,   s
             r   ÚassertURIEqualszURITests.assertURIEquals]   sh   € ðD 	×ÒØ�V˜T 4¨¨v°u¸hÐGà”
Ø”
Ø”Ø”Ø”Ø”
Ø”	Ø”ð	ñ	
ô 	
ð 	
ð 	
ð 	
r   c                 óÔ  — t           j                             |                      d¦  «        ¦  «        }|                      d|j        ¦  «         t           j                             |                      d¦  «        ¦  «        }|                      d|j        ¦  «         t           j                             |                      d¦  «        ¦  «        }|                      d|j        ¦  «         dS )z„
        L{client.URI.fromBytes} by default assumes port 80 for the I{http}
        scheme and 443 for the I{https} scheme.
        ó   http://HOSTéP   s   http://HOST:ó   https://HOSTi»  N©r   ÚURIÚ	fromBytesr$   r   r(   ©r   r-   s     r   Útest_parseDefaultPortzURITests.test_parseDefaultPort�   s»   € õ
 Œj×"Ò" 4×#5Ò#5°nÑ#EÔ#EÑFÔFˆØ×Ò˜˜SœXÑ&Ô&Ð&åŒj×"Ò" 4×#5Ò#5°oÑ#FÔ#FÑGÔGˆØ×Ò˜˜SœXÑ&Ô&Ð&ÝŒj×"Ò" 4×#5Ò#5°oÑ#FÔ#FÑGÔGˆØ×Ò˜˜cœhÑ'Ô'Ð'Ð'Ð'r   c                 óB  — t           j                             |                      d¦  «        d¬¦  «        }|                      d|j        ¦  «         t           j                             |                      d¦  «        d¬¦  «        }|                      d|j        ¦  «         dS )z‚
        L{client.URI.fromBytes} accepts a C{defaultPort} parameter that
        overrides the normal default port logic.
        r0   é  )ÚdefaultPortr2   Nr3   r6   s     r   Útest_parseCustomDefaultPortz$URITests.test_parseCustomDefaultPortš   s”   € õ
 Œj×"Ò" 4×#5Ò#5°nÑ#EÔ#EÐSWÐ"ÑXÔXˆØ×Ò˜˜sœxÑ(Ô(Ð(ÝŒj×"Ò"Ø×Ò˜Ñ/Ô/¸Tð #ñ 
ô 
ˆð 	×Ò˜˜sœxÑ(Ô(Ð(Ð(Ð(r   c                 óÊ  — t           j                             |                      d¦  «        ¦  «        }|                      d|j        ¦  «         |                      | j        |j        ¦  «         |                      | j        dz   |j        ¦  «         t           j                             |                      d¦  «        ¦  «        }|                      | j        |j        ¦  «         dS )zj
        Parsing a I{URI} splits the network location component into I{host} and
        I{port}.
        s   http://HOST:5144r9   s   :5144s   http://HOST N)	r   r4   r5   r$   r   r(   r   r    r'   r6   s     r   Útest_netlocHostPortzURITests.test_netlocHostPort¦   s¾   € õ
 Œj×"Ò" 4×#5Ò#5Ð6IÑ#JÔ#JÑKÔKˆØ×Ò˜˜sœxÑ(Ô(Ð(Ø×Ò˜œ C¤HÑ-Ô-Ð-Ø×Ò˜œ¨Ñ0°#´*Ñ=Ô=Ð=õ Œj×"Ò" 4×#5Ò#5°oÑ#FÔ#FÑGÔGˆØ×Ò˜œ s¤zÑ2Ô2Ð2Ð2Ð2r   c                 ó  — |                       d¦  «        }t          j                             |¦  «        }|                      |d| j        | j        dd¬¦  «         |                      ||                     ¦   «         ¦  «         dS )z/
        Parse the path from a I{URI}.
        s   http://HOST/foo/baró   httpr1   ó   /foo/bar©r&   r'   r   r(   r)   N©	r$   r   r4   r5   r.   r    r   r   ÚtoBytes©r   r-   Úparseds      r   Ú	test_pathzURITests.test_path´   sˆ   € ð × Ò Ð!7Ñ8Ô8ˆÝ”×%Ò% cÑ*Ô*ˆØ×ÒØØØ”<Ø”ØØð 	ñ 	
ô 	
ð 	
ð 	×Ò˜˜fŸnšnÑ.Ô.Ñ/Ô/Ð/Ð/Ð/r   c                 ó  — |                       d¦  «        }t          j                             |¦  «        }|                      |d| j        | j        dd¬¦  «         |                      ||                     ¦   «         ¦  «         dS )zL
        The path of a I{URI} that has no path is the empty string.
        r0   r?   r1   r   rA   NrB   rD   s      r   Útest_noPathzURITests.test_noPathÄ   s‡   € ð × Ò  Ñ0Ô0ˆÝ”×%Ò% cÑ*Ô*ˆØ×ÒØØØ”<Ø”ØØð 	ñ 	
ô 	
ð 	
ð 	×Ò˜˜fŸnšnÑ.Ô.Ñ/Ô/Ð/Ð/Ð/r   c                 ó´   — |                       d¦  «        }|                      t          j                             |¦  «        d| j        | j        dd¬¦  «         dS )zE
        The path of a I{URI} with an empty path is C{b'/'}.
        ó   http://HOST/r?   r1   ó   /rA   N)r$   r.   r   r4   r5   r    r   r6   s     r   Útest_emptyPathzURITests.test_emptyPathÔ   sd   € ð × Ò  Ñ1Ô1ˆØ×ÒÝŒJ× Ò  Ñ%Ô%ØØ”<Ø”ØØð 	ñ 	
ô 	
ð 	
ð 	
ð 	
r   c           	      ó
  — |                       d¦  «        }t          j                             |¦  «        }|                      |d| j        | j        ddd¬¦  «         |                      ||                     ¦   «         ¦  «         dS )z8
        Parse I{URI} parameters from a I{URI}.
        s   http://HOST/foo/bar;paramr?   r1   r@   ó   param)r&   r'   r   r(   r)   r*   NrB   rD   s      r   Ú
test_paramzURITests.test_paramâ   s‹   € ð × Ò Ð!=Ñ>Ô>ˆÝ”×%Ò% cÑ*Ô*ˆØ×ÒØØØ”<Ø”ØØØð 	ñ 	
ô 	
ð 	
ð 	×Ò˜˜fŸnšnÑ.Ô.Ñ/Ô/Ð/Ð/Ð/r   c           
      ó  — |                       d¦  «        }t          j                             |¦  «        }|                      |d| j        | j        dddd¬¦  «         |                      ||                     ¦   «         ¦  «         dS )	z7
        Parse the query string from a I{URI}.
        s!   http://HOST/foo/bar;param?a=1&b=2r?   r1   r@   rN   ó   a=1&b=2)r&   r'   r   r(   r)   r*   r+   NrB   rD   s      r   Ú
test_queryzURITests.test_queryó   sŽ   € ð × Ò Ð!EÑFÔFˆÝ”×%Ò% cÑ*Ô*ˆØ×ÒØØØ”<Ø”ØØØØð 	ñ 		
ô 		
ð 		
ð 	×Ò˜˜fŸnšnÑ.Ô.Ñ/Ô/Ð/Ð/Ð/r   c                 ó  — |                       d¦  «        }t          j                             |¦  «        }|                      |d| j        | j        ddddd¬¦	  «	         |                      ||                     ¦   «         ¦  «         d	S )
z>
        Parse the fragment identifier from a I{URI}.
        s&   http://HOST/foo/bar;param?a=1&b=2#fragr?   r1   r@   rN   rQ   s   frag)r&   r'   r   r(   r)   r*   r+   r,   NrB   rD   s      r   Útest_fragmentzURITests.test_fragment  s‘   € ð × Ò Ð!JÑKÔKˆÝ”×%Ò% cÑ*Ô*ˆØ×ÒØØØ”<Ø”ØØØØØð 	ñ 
	
ô 
	
ð 
	
ð 	×Ò˜˜fŸnšnÑ.Ô.Ñ/Ô/Ð/Ð/Ð/r   c                 ó    — t           j                             |                      d¦  «        ¦  «        }|                      d|j        ¦  «         dS )zn
        L{client.URI.originForm} produces an absolute I{URI} path including
        the I{URI} path.
        s   http://HOST/foos   /fooN©r   r4   r5   r$   r   Ú
originFormr6   s     r   Útest_originFormzURITests.test_originForm  sF   € õ
 Œj×"Ò" 4×#5Ò#5Ð6HÑ#IÔ#IÑJÔJˆØ×Ò˜ #¤.Ñ1Ô1Ð1Ð1Ð1r   c                 ó    — t           j                             |                      d¦  «        ¦  «        }|                      d|j        ¦  «         dS )z¸
        L{client.URI.originForm} produces an absolute I{URI} path including
        the I{URI} path, parameters and query string but excludes the fragment
        identifier.
        s   http://HOST/foo;param?a=1#frags   /foo;param?a=1NrV   r6   s     r   Útest_originFormComplexzURITests.test_originFormComplex   sN   € õ Œj×"Ò"Ø×ÒÐ@ÑAÔAñ
ô 
ˆð 	×ÒÐ*¨C¬NÑ;Ô;Ð;Ð;Ð;r   c                 ó    — t           j                             |                      d¦  «        ¦  «        }|                      d|j        ¦  «         dS )zp
        L{client.URI.originForm} produces a path of C{b'/'} when the I{URI}
        specifies no path.
        r0   rK   NrV   r6   s     r   Útest_originFormNoPathzURITests.test_originFormNoPath+  sE   € õ
 Œj×"Ò" 4×#5Ò#5°nÑ#EÔ#EÑFÔFˆØ×Ò˜˜sœ~Ñ.Ô.Ð.Ð.Ð.r   c                 ó    — t           j                             |                      d¦  «        ¦  «        }|                      d|j        ¦  «         dS )zv
        L{client.URI.originForm} produces a path of C{b'/'} when the I{URI}
        specifies an empty path.
        rJ   rK   NrV   r6   s     r   Útest_originFormEmptyPathz!URITests.test_originFormEmptyPath3  sE   € õ
 Œj×"Ò" 4×#5Ò#5°oÑ#FÔ#FÑGÔGˆØ×Ò˜˜sœ~Ñ.Ô.Ð.Ð.Ð.r   c                 óv  — |                       d¦  «        }|                     d¦  «        }t          |¦  «         t          j                             |¦  «        }|                      |j        t          ¦  «         |                      |j	        t          ¦  «         |                      |j
        t          ¦  «         dS )zÓ
        L{client.URI.fromBytes} parses the scheme, host, and path elements
        into L{bytes}, even when passed an URL which has previously been passed
        to L{urlparse} as a L{unicode} string.
        s   http://HOST/pathÚasciiN)r$   Údecoder   r   r4   r5   r   r&   r   r   r)   )r   Ú	goodInputÚbadInputr-   s       r   Ú test_externalUnicodeInterferencez)URITests.test_externalUnicodeInterference;  sœ   € ð ×&Ò&Ð':Ñ;Ô;ˆ	Ø×#Ò# GÑ,Ô,ˆÝ�ÑÔÐÝŒj×"Ò" 9Ñ-Ô-ˆØ×Ò˜cœj­%Ñ0Ô0Ð0Ø×Ò˜cœh­Ñ.Ô.Ð.Ø×Ò˜cœh­Ñ.Ô.Ð.Ð.Ð.r   N)r   r   r   )r   r   r   r   r$   r.   r7   r;   r=   rF   rH   rL   rO   rR   rT   rX   rZ   r\   r^   rd   r   r   r   r   r   :   s  € € € € € ðð ð7ð 7ð 7ð* VYð.
ð .
ð .
ð .
ð`(ð (ð (ð
)ð 
)ð 
)ð3ð 3ð 3ð0ð 0ð 0ð 0ð 0ð 0ð 
ð 
ð 
ð0ð 0ð 0ð"0ð 0ð 0ð$0ð 0ð 0ð&2ð 2ð 2ð	<ð 	<ð 	<ð/ð /ð /ð/ð /ð /ð/ð /ð /ð /ð /r   r   c                   ó   — e Zd ZdZdxZZdS )ÚURITestsForHostnamez>
    Tests for L{twisted.web.client.URI} with host names.
    s   example.comN©r   r   r   r   r    r   r   r   r   rf   rf   J  s$   € € € € € ðð ð $Ð#€Gˆdˆdˆdr   rf   c                   ó   — e Zd ZdZdxZZdS )ÚURITestsForIPv4zG
    Tests for L{twisted.web.client.URI} with IPv4 host addresses.
    s   192.168.1.67Nrg   r   r   r   ri   ri   R  s$   € € € € € ðð ð %Ð$€Gˆdˆdˆdr   ri   c                   ó    — e Zd ZdZdZdZd„ ZdS )ÚURITestsForIPv6z·
    Tests for L{twisted.web.client.URI} with IPv6 host addresses.

    IPv6 addresses must always be surrounded by square braces in URIs. No
    attempt is made to test without.
    s   fe80::20c:29ff:fea4:c60s   [fe80::20c:29ff:fea4:c60]c                 ó   — t           j                             d¦  «        }|                      |j        d¦  «         |                      |j        d¦  «         |                      |                     ¦   «         d¦  «         dS )z¶
        Brackets around IPv6 addresses are stripped in the host field. The host
        field is then exported with brackets in the output of
        L{client.URI.toBytes}.
        s   http://[::1]:80/index.htmls   ::1s   [::1]:80N)r   r4   r5   r   r   r'   rC   r6   s     r   Ú"test_hostBracketIPv6AddressLiteralz2URITestsForIPv6.test_hostBracketIPv6AddressLiterale  so   € õ Œj×"Ò"Ð#@ÑAÔAˆà×Ò˜œ 6Ñ*Ô*Ð*Ø×Ò˜œ [Ñ1Ô1Ð1Ø×Ò˜Ÿš™œÐ(EÑFÔFÐFÐFÐFr   N)r   r   r   r   r   r    rm   r   r   r   rk   rk   Z  s>   € € € € € ðð ð &€DØ*€Gð
Gð 
Gð 
Gð 
Gð 
Gr   rk   N)r   Úurllib.parser   Útwisted.trialr   Útwisted.webr   ÚTestCaser   r   rf   ri   rk   r   r   r   ú<module>rr      sG  ððð ð
 "Ð !Ð !Ð !Ð !Ð !à "Ð "Ð "Ð "Ð "Ð "Ø Ð Ð Ð Ð Ð ð(
ð (
ð (
ð (
ð (
�8Ô$ñ (
ô (
ð (
ðVM/ð M/ð M/ð M/ð M/ñ M/ô M/ð M/ð`$ð $ð $ð $ð $˜( HÔ$5ñ $ô $ð $ð%ð %ð %ð %ð %�h Ô 1ñ %ô %ð %ðGð Gð Gð Gð G�h Ô 1ñ Gô Gð Gð Gð Gr   