HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python3.6/site-packages/supervisor/tests/__pycache__/test_http.cpython-36.opt-1.pyc
3

�k�`Jc�@s�ddlZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZddlm
Z
ddlmZddlmZdd	lmZdd
lmZddlmZddlmZGd
d�d�ZGdd�deej�ZGdd�deej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd�dej�ZGdd �d ej�Zd!Z Gd"d#�d#ej�Z!Gd$d%�d%ej�Z"Gd&d'�d'ej�Z#Gd(d)�d)ej�Z$Gd*d+�d+�Z%Gd,d-�d-�Z&d.d/�Z'e(d0k�r�ej)d/d1�dS)2�N)�as_bytes)�	as_string)�sha1)�DummySupervisor)�PopulatedDummySupervisor)�DummyRPCInterfaceFactory)�DummyPConfig)�DummyOptions)�DummyRequest)�DummyLogger)�NOT_DONE_YETc@seZdZdd�Zdd�ZdS)�HandlerTestscCs|j�|�S)N)�_getTargetClass)�self�supervisord�r�/usr/lib/python3.6/test_http.py�_makeOneszHandlerTests._makeOnecCs:Gdd�d�}t�}|j|�}|j|j||j��d�dS)Nc@seZdZdd�ZdS)z,HandlerTests.test_match.<locals>.FakeRequestcSs
||_dS)N)�uri)rrrrr�__init__sz5HandlerTests.test_match.<locals>.FakeRequest.__init__N)�__name__�
__module__�__qualname__rrrrr�FakeRequestsrT)rr�assertEqual�match�path)rr�
supervisor�handlerrrr�
test_matchs
zHandlerTests.test_matchN)rrrrrrrrrr
sr
c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�LogtailHandlerTestscCsddlm}|S)Nr)�logtail_handler)�supervisor.httpr!)rr!rrrr$sz#LogtailHandlerTests._getTargetClasscCsXt�}t|ddddd�}t|d|�}|j|�}tdddd�}|j|�|j|jd�dS)NZprocess1z
/bin/process1�z/tmp/process1.log)Zpriority�stdout_logfilez/logtail/process1i�)r	rrrr
�handle_requestr�_error)r�options�pconfigrr�requestrrr�'test_handle_request_stdout_logfile_none(s


z;LogtailHandlerTests.test_handle_request_stdout_logfile_nonecCsTt�}t|ddd�}t|d|�}|j|�}tdddd�}|j|�|j|jd�dS)N�fooz
it/is/missingz/logtail/fooi�)r	rrrr
r%rr&)rr'r(rrr)rrr�*test_handle_request_stdout_logfile_missing2s

z>LogtailHandlerTests.test_handle_request_stdout_logfile_missingc	
Cs�tj���}|j}t�}t|dd|d�}t|d|�}|j|�}tdddd�}|j|�|j	|j
d�ddlm}|j	|j
d|jtj|�tj��|j	|j
dd�|j	|j
d	d
�|j	t|j�d�|j	|jd�WdQRXdS)
Nr+)r$z/logtail/foor)�	http_datez
Last-ModifiedzContent-Typeztext/plain;charset=utf-8zX-Accel-Buffering�nor#T)�tempfile�NamedTemporaryFile�namer	rrrr
r%rr&�supervisor.medusar-�headers�build_http_date�os�stat�ST_MTIME�len�	producers�_done)	r�f�tr'r(rrr)r-rrr�test_handle_request;s 


z'LogtailHandlerTests.test_handle_requestN)rrrrr*r,r=rrrrr #s
	r c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�MainLogTailHandlerTestscCsddlm}|S)Nr)�mainlogtail_handler)r"r?)rr?rrrrNsz'MainLogTailHandlerTests._getTargetClasscCs:t�}|j|�}tdddd�}|j|�|j|jd�dS)Nz/mainlogtaili�)rrr
r%rr&)rrrr)rrrr*Rs


z?MainLogTailHandlerTests.test_handle_request_stdout_logfile_nonecCsBt�}d|j_tdddd�}|j|�}|j|�|j|jd�dS)Nz
/not/therez/mainlogtaili�)rr'�logfiler
rr%rr&)rrr)rrrrr,Ys

zBMainLogTailHandlerTests.test_handle_request_stdout_logfile_missingcCs�t�}tj���}|j}||j_|j|�}tdddd�}|j|�|j	|j
d�ddlm}|j	|j
d|jtj|�tj��|j	|j
dd�|j	t|j�d�|j	|jd�WdQRXdS)	Nz/mainlogtailr)r-z
Last-ModifiedzContent-Typeztext/plain;charset=utf-8r#T)rr/r0r1r'r@rr
r%rr&r2r-r3r4r5r6r7r8r9r:)rrr;r<rr)r-rrrr=as


z+MainLogTailHandlerTests.test_handle_requestN)rrrrr*r,r=rrrrr>Msr>c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�TailFProducerTestscCsddlm}|S)Nr)�tail_f_producer)r"rB)rrBrrrrssz"TailFProducerTests._getTargetClasscCs|j�|||�S)N)r)rr)�filename�headrrrrwszTailFProducerTests._makeOnecCs�tdddd�}ddlm}tj�}|jdd�|j�|j||jd�}|j	�}|j
|dd�|jtdd��|j�|j	�}|j
|dd�|j	�}|j
||j�|j
d�|j�|j	�}|j
|d�dS)	Nz/logtail/foor)�http�a�P�w�dz==> File truncated <==
)r
rrEr/r0�write�flushrr1�morerrr�truncate)rr)rEr;�producer�resultrrr�test_handle_morezs$
z#TailFProducerTests.test_handle_morecCsrtdddd�}tj��B}|jtdd��|j�|j||jd�}|jj	�|j
�}WdQRX|j||j
��dS)Nz/logtail/foo�arG)r
r/r0rJrrKrr1�file�closerLr)rr)r;rNrOrrr�test_handle_more_fd_closed�s

z-TailFProducerTests.test_handle_more_fd_closedcCs�tdddd�}tj�}|jtdd��|j�|j||jd�}|j�}|j	|dd�|j
�t|jd�}z&|jtdd��|j
�|j�}Wdtj
|j�X|j	|dd�dS)Nz/logtail/foorQrGrF�wb�b)r
r/r0rJrrKrr1rLrrS�openr5�unlink)rr)r;rNrO�f2rrr�&test_handle_more_follow_file_recreated�sz9TailFProducerTests.test_handle_more_follow_file_recreatedc!Cs�tdddd�}tj�}t|d��}|jdd�WdQRXz|j||jd�}Wdtj|j�X|j	�}|j
|dd�t|d��}|jtdd��WdQRXz|j	�}|j
|dd�Wdtj|j�XdS)Nz/logtail/foorUrFrGrV)r
r/�mktemprWrJrr1r5rXrLrr)rr)rCr;rNrOrrr�!test_handle_more_follow_file_gone�sz4TailFProducerTests.test_handle_more_follow_file_goneN)	rrrrrrPrTrZr\rrrrrArs
rAc@sNeZdZdd�Zddd�Zdd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dS)�DeferringChunkedProducerTestscCsddlm}|S)Nr)�deferring_chunked_producer)r"r^)rr^rrrr�sz-DeferringChunkedProducerTests._getTargetClassNcCs|j�||�S)N)r)rrN�footersrrrr�sz&DeferringChunkedProducerTests._makeOnecCs&tt�}|j|�}|j|j�t�dS)N)�
DummyProducerrrrrL)r�wrappedrNrrr�test_more_not_done_yet�s
z4DeferringChunkedProducerTests.test_more_not_done_yetcCs&td�}|j|�}|j|j�d�dS)Nshellos
5
hello
)r`rrrL)rrarNrrr�test_more_string�s
z.DeferringChunkedProducerTests.test_more_stringcCs,t�}|j|ddgd�}|j|j�d�dS)NrFrV)r_s0
a
b

)r`rrrL)rrarNrrr�test_more_nodata�sz.DeferringChunkedProducerTests.test_more_nodatacCs.td�}|j|ddgd�}|j|j�d�dS)N�rFrV)r_s0
a
b

)r`rrrL)rrarNrrr�test_more_nodata_footers�sz6DeferringChunkedProducerTests.test_more_nodata_footerscCs&td�}|j|�}|j|j�d�dS)Nres0

)r`rrrL)rrarNrrr�test_more_nodata_nofooters�s
z8DeferringChunkedProducerTests.test_more_nodata_nofooterscCs|jd�}|j|j�d�dS)Nre)rrrL)rrNrrr�test_more_noproducer�s
z2DeferringChunkedProducerTests.test_more_noproducer)N)rrrrrrbrcrdrfrgrhrrrrr]�s
r]c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�DeferringCompositeProducerTestscCsddlm}|S)Nr)�deferring_composite_producer)r"rj)rrjrrrr�sz/DeferringCompositeProducerTests._getTargetClasscCs|j�|�S)N)r)rr9rrrr�sz(DeferringCompositeProducerTests._makeOnecCs(tt�}|j|g�}|j|j�t�dS)N)r`rrrrL)rrarNrrrrb�sz6DeferringCompositeProducerTests.test_more_not_done_yetcCsRtd�}td�}|j||g�}|j|j�d�|j|j�d�|j|j�d�dS)N�helloZgoodbyere)r`rrrL)rZwrapped1Zwrapped2rNrrrrc�sz0DeferringCompositeProducerTests.test_more_stringcCs&t�}|j|g�}|j|j�d�dS)Nre)r`rrrL)rrarNrrrrd�sz0DeferringCompositeProducerTests.test_more_nodataN)rrrrrrbrcrdrrrrri�s
ric@s6eZdZdd�Zddd�Zdd�Zd	d
�Zdd�Zd
S)�DeferringGlobbingProducerTestscCsddlm}|S)Nr)�deferring_globbing_producer)r"rm)rrmrrrr�sz.DeferringGlobbingProducerTests._getTargetClassr#�cCs|j�||�S)N)r)rrN�buffer_sizerrrrsz'DeferringGlobbingProducerTests._makeOnecCs&tt�}|j|�}|j|j�t�dS)N)r`rrrrL)rrarNrrrrbs
z5DeferringGlobbingProducerTests.test_more_not_done_yetcCsXtddd�}|j|dd�}|j|j�d�tddd�}|j|dd�}|j|j�d�dS)	NrkZthereZguyr#)roshello�2s
hellothereguy)r`rrrL)rrarNrrrrc	sz/DeferringGlobbingProducerTests.test_more_stringcCs$t�}|j|�}|j|j�d�dS)Nre)r`rrrL)rrarNrrrrds
z/DeferringGlobbingProducerTests.test_more_nodataN�)rq)rrrrrrbrcrdrrrrrl�s

	rlc@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�DeferringHookedProducerTestscCsddlm}|S)Nr)�deferring_hooked_producer)r"rs)rrsrrrrsz,DeferringHookedProducerTests._getTargetClasscCs|j�||�S)N)r)rrNZfunctionrrrrsz%DeferringHookedProducerTests._makeOnecCs(tt�}|j|d�}|j|j�t�dS)N)r`rrrrL)rrarNrrrrbsz3DeferringHookedProducerTests.test_more_not_done_yetcsZtd�}g��fdd�}|j||�}|j|j�d�|j�g�|j�|j�dg�dS)Nrkcs�j|�dS)N)�append)�bytes)�Lrr�callback'sz?DeferringHookedProducerTests.test_more_string.<locals>.callback�)r`rrrL)rrarwrNr)rvrrc$sz-DeferringHookedProducerTests.test_more_stringcsDt�}g��fdd�}|j||�}|j|j�d�|j�dg�dS)Ncs�j|�dS)N)rt)ru)rvrrrw2sz?DeferringHookedProducerTests.test_more_nodata.<locals>.callbackrer)r`rrrL)rrarwrNr)rvrrd/sz-DeferringHookedProducerTests.test_more_nodatacCs |jdd�}|j|j�d�dS)Nre)rrrL)rrNrrrrh8sz1DeferringHookedProducerTests.test_more_noproducerN)	rrrrrrbrcrdrhrrrrrrs	rrc@szeZdZdd�Zdddddffdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�DeferringHttpRequestTestscCsddlm}|S)Nr)�deferring_http_request)r"rz)rrzrrrr=sz)DeferringHttpRequestTests._getTargetClassNzGET / HTTP/1.0ZGET�/z1.0cCs|j�||||||�S)N)r)r�channelZreqZcommandr�version�headerrrrrAs	z"DeferringHttpRequestTests._makeOnecCsGdd�d�}|�S)Nc@s eZdZdZdd�Zdd�ZdS)z7DeferringHttpRequestTests._makeChannel.<locals>.ChannelFcSs
d|_dS)NT)�closed)rrrr�close_when_doneQszGDeferringHttpRequestTests._makeChannel.<locals>.Channel.close_when_donecSs
||_dS)N)rN)rrNrrr�push_with_producerSszJDeferringHttpRequestTests._makeChannel.<locals>.Channel.push_with_producerN)rrrrr�r�rrrr�ChannelOsr�r)rr�rrr�_makeChannelNsz&DeferringHttpRequestTests._makeChannelcCs.|j�}|j|dd�}|j�|j|j�dS)Nz1.0)r|r})r�r�done�
assertTruer)rr|�instrrr�test_done_http_10_nokeepaliveWsz7DeferringHttpRequestTests.test_done_http_10_nokeepalivecCs2|j�}|j|ddgd�}|j�|j|j�dS)Nz1.0zConnection: Keep-Alive)r|r}r~)r�rr�r�r)rr|r�rrr�-test_done_http_10_keepalive_no_content_length]s
zGDeferringHttpRequestTests.test_done_http_10_keepalive_no_content_lengthcCsL|j�}|j|ddgd�}d|jd<|j�|j|dd�|j|j�dS)Nz1.0zConnection: Keep-Alive)r|r}r~r#zContent-LengthZ
Connectionz
Keep-Alive)r�r�
reply_headersr�r�assertFalser)rr|r�rrr�.test_done_http_10_keepalive_and_content_lengthhs

zHDeferringHttpRequestTests.test_done_http_10_keepalive_and_content_lengthcCs2|j�}|j|ddgd�}|j�|j|j�dS)Nz1.1zConnection: close)r|r}r~)r�rr�r�r)rr|r�rrr�"test_done_http_11_connection_closets
z<DeferringHttpRequestTests.test_done_http_11_connection_closecCs8|j�}|j|dd�}d|jd<|j�|j|j�dS)Nz1.1)r|r}Z
notchunkedzTransfer-Encoding)r�rr�r�r�r)rr|r�rrr�+test_done_http_11_unknown_transfer_encoding~s
zEDeferringHttpRequestTests.test_done_http_11_unknown_transfer_encodingcCs8|j�}|j|dd�}d|jd<|j�|j|j�dS)Nz1.1)r|r}ZchunkedzTransfer-Encoding)r�rr�r�r�r)rr|r�rrr�+test_done_http_11_chunked_transfer_encoding�s
zEDeferringHttpRequestTests.test_done_http_11_chunked_transfer_encodingcCsB|j�}|j|dd�}d|_|j�|jd|k�|j|j�dS)Nz1.1)r|r}TzTransfer-Encoding)r�r�use_chunkedr�r�r�r)rr|r�rrr�test_done_http_11_use_chunked�sz7DeferringHttpRequestTests.test_done_http_11_use_chunkedcCs4|j�}|j|dd�}d|_|j�|j|j�dS)Nz1.1)r|r}F)r�rr�r�r�r)rr|r�rrr�>test_done_http_11_wo_content_length_no_te_no_use_chunked_close�szXDeferringHttpRequestTests.test_done_http_11_wo_content_length_no_te_no_use_chunked_closecCs.|j�}|j|dd�}|j�|j|j�dS)N)r|r})r�rr�r�r)rr|r�rrr�test_done_http_09�sz+DeferringHttpRequestTests.test_done_http_09)rrrrrr�r�r�r�r�r�r�r�r�r�rrrrry<s"	



ryc@sDeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dS)�DeferringHttpChannelTestscCsddlm}|S)Nr)�deferring_http_channel)r"r�)rr�rrrr�sz)DeferringHttpChannelTests._getTargetClasscCs|j�dddd�S)N)�serverZconnZaddr)r)rrrrr�sz"DeferringHttpChannelTests._makeOnecCs(|j�}|j|jd�|j|jd�dS)Nr)rr�delay�last_writable_check)rr|rrr�0test_defaults_delay_and_last_writable_check_time�szJDeferringHttpChannelTests.test_defaults_delay_and_last_writable_check_timecCs@|j�}d|_t|_td}|j|j|d��|j|jt�dS)N�r#)�now)rr��_NOWr�r��writabler)rr|�laterrrr�5test_writable_with_delay_is_False_if_elapsed_lt_delay�szODeferringHttpChannelTests.test_writable_with_delay_is_False_if_elapsed_lt_delaycCsB|j�}d|_t|_t|j}|j|j|d��|j|jt�dS)Nr�)r�)rr�r�r�r�r�r)rr|r�rrr�5test_writable_with_delay_is_False_if_elapsed_eq_delay�s
zODeferringHttpChannelTests.test_writable_with_delay_is_False_if_elapsed_eq_delaycCsF|j�}d|_t|_t|jd}|j|j|d��|j|j|�dS)Nr�g�������?)r�)rr�r�r�r�r�r)rr|r�rrr�4test_writable_with_delay_is_True_if_elapsed_gt_delay�szNDeferringHttpChannelTests.test_writable_with_delay_is_True_if_elapsed_gt_delaycCs@|j�}d|_t|_td}|j|j|d��|j|j|�dS)Nr�i)r�)rr�r�r�r�r�r)rr|r�rrr�>test_writable_with_delay_is_True_if_system_time_goes_backwards�szXDeferringHttpChannelTests.test_writable_with_delay_is_True_if_system_time_goes_backwardsN)
rrrrrr�r�r�r�r�rrrrr��sr�if��Wc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�"EncryptedDictionaryAuthorizedTestscCsddlm}|S)Nr)�encrypted_dictionary_authorizer)r"r�)rr�rrrr�sz2EncryptedDictionaryAuthorizedTests._getTargetClasscCs|j�|�S)N)r)r�dictrrrr�sz+EncryptedDictionaryAuthorizedTests._makeOnecCs|ji�}|j|jd��dS)Nr+�bar)r+r�)rr��	authorize)r�
authorizerrrr�test_authorize_baduser�s
z9EncryptedDictionaryAuthorizedTests.test_authorize_badusercCs"|jddi�}|j|jd��dS)Nr+�passwordr�)r+r�)rr�r�)rr�rrr�#test_authorize_gooduser_badpassword�szFEncryptedDictionaryAuthorizedTests.test_authorize_gooduser_badpasswordcCs"|jddi�}|j|jd��dS)Nr+r�)r+r�)rr�r�)rr�rrr�$test_authorize_gooduser_goodpassword�szGEncryptedDictionaryAuthorizedTests.test_authorize_gooduser_goodpasswordcCs"|jddi�}|j|jd��dS)Nr+�	pass:word)r+r�)rr�r�)rr�rrr�/test_authorize_gooduser_goodpassword_with_colon�szREncryptedDictionaryAuthorizedTests.test_authorize_gooduser_goodpassword_with_coloncCs6dttd��j�}|jd|i�}|j|jd��dS)Nz{SHA}r�r+r�)r+r�)rr�	hexdigestrr�r�)rr�r�rrr�'test_authorize_gooduser_badpassword_sha�szJEncryptedDictionaryAuthorizedTests.test_authorize_gooduser_badpassword_shacCs6dttd��j�}|jd|i�}|j|jd��dS)Nz{SHA}r�r+)r+r�)rrr�rr�r�)rr�r�rrr�(test_authorize_gooduser_goodpassword_shaszKEncryptedDictionaryAuthorizedTests.test_authorize_gooduser_goodpassword_shaN)rrrrrr�r�r�r�r�r�rrrrr��sr�c@s<eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
S)�SupervisorAuthHandlerTestscCsddlm}|S)Nr)�supervisor_auth_handler)r"r�)rr�rrrrsz*SupervisorAuthHandlerTests._getTargetClasscCs|j�||�S)N)r)rr�rrrrr
sz#SupervisorAuthHandlerTests._makeOnecCs0|jddid�}ddlm}|j|jj|�dS)NrQr#r)r�)rr"r�rr��	__class__)rrr�rrr�	test_ctor
s
z$SupervisorAuthHandlerTests.test_ctorcCs\tdddd�}tjtd��}dt|�g|_t�}|jddi|�}|j|�|j	|j
�dS)Nz/logtail/process1z
user:passwordzAuthorization: Basic %s�userr�)r
�base64�	b64encoderrr~�DummyHandlerrr%r��handled_request)rr)�encodedr�auth_handlerrrr�/test_handle_request_authorizes_good_credentialss
zJSupervisorAuthHandlerTests.test_handle_request_authorizes_good_credentialscCs\tdddd�}tjtd��}dt|�g|_t�}|jddi|�}|j|�|j	|j
�dS)Nz/logtail/process1zuser:pass:wordzAuthorization: Basic %sr�z	pass:word)r
r�r�rrr~r�rr%r�r�)rr)r�rr�rrr�7test_handle_request_authorizes_good_password_with_colons
zRSupervisorAuthHandlerTests.test_handle_request_authorizes_good_password_with_coloncCs\tdddd�}tjtd��}dt|�g|_t�}|jddi|�}|j|�|j	|j
�dS)Nz/logtail/process1zwrong:wrongzAuthorization: Basic %sr�r�)r
r�r�rrr~r�rr%r�r�)rr)r�rr�rrr�6test_handle_request_does_not_authorize_bad_credentials&s
zQSupervisorAuthHandlerTests.test_handle_request_does_not_authorize_bad_credentialsN)	rrrrrr�r�r�r�rrrrr�s	
r�c@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�LogWrapperTestscCsddlm}|S)Nr)�
LogWrapper)r"r�)rr�rrrr0szLogWrapperTests._getTargetClasscCs|j�|�S)N)r)r�loggerrrrr4szLogWrapperTests._makeOnecCsDt�}|j|�}|jd�|j}|jt|�d�|j|dd�dS)Nzfoo
r#rr+)rr�log�datarr8)rr��log_wrapperZlogdatarrr�'test_strips_trailing_newlines_from_msgs7s

z7LogWrapperTests.test_strips_trailing_newlines_from_msgscCsJt�}|j|�}g}|j|_|jd�|jt|�d�|j|dd�dS)NzServer Errorr#r)rrrt�errorr�rr8)rr�r��errorsrrr�(test_logs_msgs_with_error_at_error_level?s

z8LogWrapperTests.test_logs_msgs_with_error_at_error_levelcCsJt�}|j|�}g}|j|_|jd�|jt|�d�|j|dd�dS)NzGET /r#r)rrrtZtracer�rr8)rr�r�Ztracesrrr�'test_logs_other_messages_at_trace_levelHs

z7LogWrapperTests.test_logs_other_messages_at_trace_levelN)rrrrrr�r�r�rrrrr�/s
	r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�TopLevelFunctionTestsc
Cs�t�}||_dtifg|_t�}ddlm}|||�}z:x4|D],\}}|j�|jd�}|dk	r>t	j
|�q>WWdddlm}	|	j
�X|S)NZdummyr)�make_http_serversrR)�
socket_map)r	Zserver_configsrZrpcinterface_factoriesrr"r�rS�getr5rXZasyncorer��clear)
rZsconfigsr'rr��servers�config�s�
socketfiler�rrr�_make_http_serversRs


z(TopLevelFunctionTests._make_http_serverscCsfddddddd�}y|j|g�|jd�Wn4tk
r`}z|j|jdd�WYdd}~XnXdS)	Ni��	localhostiGE�inet_http_server)�family�host�port�usernamer��sectionznothing raisedrz Cannot determine socket type 999)r�Zfail�
ValueErrorr�args)rr��excrrr�(test_make_http_servers_socket_type_errordsz>TopLevelFunctionTests.test_make_http_servers_socket_type_errorc	Cs�tj�}tjdddddd�}tj|dddddd�}|j||g�}|jt|�d	�|d
}|j|d
|�|d}ddd
ddg}|jdd�|jD�|�|d}|j|d
|�|d}|jdd�|jD�|�dS)Nr�iGEr�)r�r�r�r�r�r�i�r#�unix_http_server)r�rR�chmod�chownr�r�r�r�rzSupervisor XML-RPC HandlerzLogtail HTTP Request Handlerz!Main Logtail HTTP Request Handlerz&Supervisor Web UI HTTP Request HandlerzDefault HTTP Request HandlercSsg|]
}|j�qSr)�IDENT)�.0�xrrr�
<listcomp>�szGTopLevelFunctionTests.test_make_http_servers_noauth.<locals>.<listcomp>cSsg|]
}|j�qSr)r�)r�r�rrrr��s���r�)r�r�)	r/r[�socket�AF_INET�AF_UNIXr�rr8�handlers)	rr��inet�unixr�Zinetdatar�ZidentsZunixdatarrr�test_make_http_servers_noauthns*z3TopLevelFunctionTests.test_make_http_servers_noauthc	Cs�tj�}tjdddddd�}tj|ddddd	d
�}|j||g�}|jt|�d�dd
lm	}x2|D]*\}}x |j
D]}|jt||�|�qrWqbWdS)Nr�iHEr�r�r�)r�r�r�r�r�r�i�r#r�)r�rRr�r�r�r�r�r�r)r�r�r�)r�r�)
r/r[r�r�r�r�rr8r"r�r�r��
isinstance)	rr�r�r�r�r�r�r�rrrr�test_make_http_servers_withauth�sz5TopLevelFunctionTests.test_make_http_servers_withauthN)rrrr�r�r�r�rrrrr�Qs
r�c@seZdZdd�Zdd�ZdS)r�cCs
d|_dS)NF)r�)rrrrr�szDummyHandler.__init__cCs
d|_dS)NT)r�)rr)rrrr%�szDummyHandler.handle_requestN)rrrrr%rrrrr��sr�c@seZdZdd�Zdd�ZdS)r`cGst|�|_dS)N)�listr�)rr�rrrr�szDummyProducer.__init__cCs|jr|jjd�SdSdS)Nrre)r��pop)rrrrrL�szDummyProducer.moreN)rrrrrLrrrrr`�sr`cCstjtjt�S)N)�unittestZ
findTestCases�sys�modulesrrrrr�
test_suite�sr��__main__)ZdefaultTest)*r�r5r6r�r�r/r�Zsupervisor.compatrrrZsupervisor.tests.baserrrrr	r
rr"rr
ZTestCaser r>rAr]rirlrrryr�r�r�r�r�r�r�r`r�r�mainrrrr�<module>sJ*%K%%t1"*"H