Ë
    #ïàjŒ  ã                   óÖ  — d Z ddlZddlZddlZddlZddlZddlmZm	Z	 ddl
Z
ddlZddlZddlmZ dZdZdZdZdZej*                  j,                  eefddœej.                  j0                  eefej.                  j2                  d	œiZe	d
„ «       Ze
j8                  d„ «       Ze
j8                  d„ «       Ze
j8                  d„ «       Ze
j8                  d„ «       Z  G d„ d«      Z!d„ Z"d„ Z#d„ Z$y)zAPytest fixtures and other helpers for doing testing by end-users.é    N)ÚclosingÚcontextmanager)Úwebtestz0.0.0.0z::é   )Ú	bind_addrÚwsgi_app)r   Úgatewayc              #   ó$  K  — t         |    j                  «       }|j                  d«      d   }t        t        fD ]  }	 ||f} | dd|i|¤Ž} n d_        t        j                  |j                  ¬«      }|j                  «        |j                  s"t        j                  d«       |j                  sŒ"	 ||f–— |j                  «        |j                  «        y# t
        $ r Y Œ­w xY w# |j                  «        |j                  «        w xY w­w)z/Set up and tear down a Cheroot server instance.r   éÿÿÿÿr   )Útargetgš™™™™™¹?N© )ÚconfigÚcopyÚpopÚANY_INTERFACE_IPV6ÚANY_INTERFACE_IPV4ÚOSErrorÚshutdown_timeoutÚ	threadingÚThreadÚ
safe_startÚstartÚreadyÚtimeÚsleepÚstopÚjoin)Úserver_factoryÚconfÚ	bind_portÚ	interfaceÚactual_bind_addrÚ
httpserverÚserver_threads          ú>/srv/dav/.venv/lib/python3.12/site-packages/cheroot/testing.pyÚcheroot_serverr&   &   s  è ø€ ô �.Ñ!×&Ñ&Ó(€DØ—‘˜Ó% bÑ)€Iä'Ô);Ð;ò 
ˆ	ð		Ø )¨9Ð5ÐÙ'ñ Ø*ðàñˆJñ ð
ð #$€JÔô ×$Ñ$¨J×,AÑ,AÔB€MØ×ÑÔØ×ÒÜ�
‰
�3Œð ×ÓðØ˜ZÐ'Ò'à�‰ÔØ×ÑÕøô% ò 	Ùð	ûð" 	�‰ÔØ×ÑÕüsA   ‚;D¾CÁA'DÂ5C+ Â;!DÃ	C(Ã%DÃ'C(Ã(DÃ+"DÄDc               #   óŽ   K  — t        t        j                  j                  «      5 \  } }| |f–— ddd«       y# 1 sw Y   yxY w­w)ztSet up and tear down a Cheroot WSGI server instance.

    This emits a tuple of a thread and a server instance.
    N)r&   ÚcherootÚwsgiÚServer©r$   Úsrvs     r%   Úthread_and_wsgi_serverr-   H   s@   è ø€ ô 
œŸ™×+Ñ+Ó	,ð !Ñ0D°ÀØ˜SÐ Ò ÷!÷ !ñ !üó   ‚$A¦
9°	A¹A¾Ac               #   óŽ   K  — t        t        j                  j                  «      5 \  } }| |f–— ddd«       y# 1 sw Y   yxY w­w)ztSet up and tear down a Cheroot HTTP server instance.

    This emits a tuple of a thread and a server instance.
    N)r&   r(   ÚserverÚ
HTTPServerr+   s     r%   Úthread_and_native_serverr2   R   s@   è ø€ ô 
œŸ™×1Ñ1Ó	2ð !Ñ6J°}ÀcØ˜SÐ Ò ÷!÷ !ñ !ür.   c                 ó   — | \  }}|S )z4Set up and tear down a Cheroot WSGI server instance.r   )r-   Ú_server_threadr,   s      r%   Úwsgi_serverr5   \   s   € ð 1Ñ€N�CØ€Jó    c                 ó   — | \  }}|S )z4Set up and tear down a Cheroot HTTP server instance.r   )r2   r4   r,   s      r%   Únative_serverr8   c   s   € ð 3Ñ€N�CØ€Jr6   c                   ó.   — e Zd Zd„ Zd„ Z	 	 	 	 dd„Zd„ Zy)Ú_TestClientc                 óŒ   — t        |j                  «      \  | _        | _        | _        || _        | j                  «       | _        y )N)Ú_get_conn_datar   Ú
_interfaceÚ_hostÚ_portÚserver_instanceÚget_connectionÚ_http_connection)Úselfr0   s     r%   Ú__init__z_TestClient.__init__k   s=   € Ü2@Ø×Ñó3
Ñ/ˆŒ˜œ T¤Zð  &ˆÔØ $× 3Ñ 3Ó 5ˆÕr6   c                 óÜ   — | j                   › d| j                  › �}| j                  j                  €t        j
                  j                  nt        j
                  j                  } ||«      S )Nú:)r=   r?   r@   Ússl_adapterÚhttpÚclientÚHTTPConnectionÚHTTPSConnection)rC   ÚnameÚconn_clss      r%   rA   z_TestClient.get_connectionr   s\   € Ø—/‘/Ð" ! D§J¡J <Ð0ˆð ×#Ñ#×/Ñ/Ð7ô �K‰K×&Ò&ä—‘×,Ñ,ð 	ñ
 ˜‹~Ðr6   Nc           	      ó~   — t        j                  |||| j                  | j                  |xs | j                  |¬«      S )N)ÚmethodÚheadersÚhostÚportÚ	http_connÚprotocol)r   ÚopenURLr>   r?   rB   )rC   ÚurirO   rP   rS   rT   s         r%   Úrequestz_TestClient.request{   s=   € ô �‰ØØØØ—‘Ø—‘ØÒ8 4×#8Ñ#8Øô
ð 	
r6   c                 ó   ‡ ‡— ˆˆ fd„}|S )Nc                 óN   •— ‰j                  «       } ‰j                  | fd|i|¤ŽS )NrO   )ÚupperrW   )rV   ÚkwargsÚhttp_methodÚ	attr_namerC   s      €€r%   Ú_wrapperz)_TestClient.__getattr__.<locals>._wrapperŽ   s*   ø€ Ø#Ÿ/™/Ó+ˆKØ�4—<‘< ÑB¨KÐB¸6ÑBÐBr6   r   )rC   r]   r^   s   `` r%   Ú__getattr__z_TestClient.__getattr__�   s   ù€ õ	Cð ˆr6   )ÚGETNNzHTTP/1.1)Ú__name__Ú
__module__Ú__qualname__rD   rA   rW   r_   r   r6   r%   r:   r:   j   s$   „ ò6òð ØØØó
ó$r6   r:   c                 ó  — 	 t        t        j                  t        j                  ¬«      «      5 }|j                  | df«       d d d «       y# 1 sw Y   yxY w# t        $ r(}|j
                  t
        j                  k7  r‚ Y d }~yd }~ww xY w)N)Úfamilyr   TF)r   ÚsocketÚAF_INET6Úbindr   ÚerrnoÚEADDRNOTAVAIL)r!   ÚsockÚsock_errs      r%   Ú_probe_ipv6_sockrm   •   sx   € ðÜ”V—]‘]¬&¯/©/Ô:Ó;ð 	&¸tØ�I‰I�y !�nÔ%÷	&ð ÷	&ð ûô	 ò Ø�>‰>œU×0Ñ0Ò0Øó 1ð
 ûðús4   ‚-A ¯AÁA ÁAÁA ÁA Á	B	Á!BÂB	c                 ó˜   — t        | t        «      r| \  }}n| d}}t        j                  |«      }d|v rt	        |«      sd}d|v r|}|||fS )Nr   rF   z	127.0.0.1)Ú
isinstanceÚtupler   r!   rm   )r   rQ   rR   r!   s       r%   r<   r<   ¤   s\   € Ü�)œUÔ#Ø‰
ˆ‰dà ˆdˆä×!Ñ! $Ó'€Ià
ˆiÑÔ 0°Ô ;Øˆ	Ø�$‰;ØˆDà�d˜DÐ Ð r6   c                 ó   — t        | «      S )z5Create and return a test client for the given server.)r:   )r0   s    r%   Úget_server_clientrr   ´   s   € ä�vÓÐr6   )%Ú__doc__ri   Úhttp.clientrH   rf   r   r   Ú
contextlibr   r   ÚpytestÚcheroot.serverr(   Úcheroot.wsgiÚcheroot.testr   ÚEPHEMERAL_PORTÚNO_INTERFACEr   r   ÚSUCCESSFUL_SUBPROCESS_EXITr)   r*   r0   r1   ÚGatewayr   r&   Úfixturer-   r2   r5   r8   r:   rm   r<   rr   r   r6   r%   ú<module>r      s$  ðÙ Gã Û Û Û Û ß .ã ã Û Ý  ð €Ø€ØÐ ØÐ ð  Ð ð ‡L�L×ÑØ" NÐ3Øñð ‡N�N×ÑØ" NÐ3Ø—>‘>×)Ñ)ñ ð	
€ð ñó ððB ‡�ñ!ó ð!ð ‡�ñ!ó ð!ð ‡�ñó ðð ‡�ñó ð÷(ñ (òVò!ó r6   