Uname:Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64

403WebShell
403Webshell
Server IP : 3.111.61.48  /  Your IP : 216.73.216.67
Web Server : Apache
System : Linux ip-10-0-5-176 6.8.0-1057-aws #60~22.04.1-Ubuntu SMP Wed May 27 08:16:59 UTC 2026 x86_64
User : ubuntu ( 1000)
PHP Version : 8.2.31
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.10/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.10/test/__pycache__/test_xmlrpc.cpython-310.pyc
o

�9j���@s8ddlZddlZddlZddlZddlZddlZddlmZddlmZ	ddl
ZddlZ
ddl
Z
ddlZ
ddlZddlZddlZddlZddlZddlmZddlmZddlmZddlmZddlmZmZmZzddlZWney{dZYnwdd	d
ddge	�d
�d
e d
�ddde	�!d�e	�!d�e	�!e�dddddd��d�gZ"Gdd�dej#�Z$Gdd�dej#�Z%Gdd�dej#�Z&Gdd �d ej#�Z'Gd!d"�d"ej#�Z(Gd#d$�d$ej#�Z)da*a+a,dRd%d&�Z-dSd'd(�Z.d)d*�Z/d+d,�Z0Gd-d.�d.ej#�Z1Gd/d0�d0e1�Z2Gd1d2�d2e1�Z3Gd3d4�d4e1�Z4Gd5d6�d6e1�Z5Gd7d8�d8e5�Z6Gd9d:�d:e5�Z7e�8edud;�Gd<d=�d=e1��Z9e�8edud;�Gd>d?�d?ej#��Z:Gd@dA�dAe1�Z;GdBdC�dCej#�Z<GdDdE�dEe
jj=�Z>GdFdG�dGej#�Z?ej@dTdIdJ��ZAGdKdL�dLej#�ZBGdMdN�dNej#�ZCdOdP�ZDeEdQk�r�e�F�dSdS)U�N)�mock)�support)�	os_helper)�
socket_helper)�threading_helper)�	ALWAYS_EQ�LARGEST�SMALLESTzfoo@bar.baz.spamgH�zns�@i�z.zyx.41�my dog has fleasFu	䀀怀耀z
regular value�20050210T11:41:23)	��r
�
��)�r����r
rrrr)�astring�afloat�anint�
ashortlong�anotherlist�abase64�b64bytes�b64bytearray�boolean�unicodeuukey䀀�	datetime1�	datetime2�	datetime3c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-S).�XMLRPCTestCasecCs.t�tf�}t�|�}|�t|dd�dS)Nr)�	xmlrpclib�dumps�alist�loads�assertEqual)�self�dump�load�r*�'/usr/lib/python3.10/test/test_xmlrpc.py�test_dump_load0s
zXMLRPCTestCase.test_dump_loadcCs6t�dddddd�}|�|t�d��t�|f�}tj|dd	�\}}|\}|�||�|�t|�tj�|�|�tj|d
d	�\}}|\}|�||�|�t|�tj�|�|�tj|dd�\}}|\}|�||�|�t|�tj�|�|�tj|d
d�\}}|\}|�||�|�t|�tj�|�|�dS)Nr
r
rrrrrT��use_builtin_typesF)�use_datetime�	�datetimer&r"�DateTimer#r%�assertIs�type�assertIsNone�r'�dt�s�result�m�newdtr*r*r+�test_dump_bare_datetime5s.


z&XMLRPCTestCase.test_dump_bare_datetimecCs�t�dddddd�}|�|t�d��t�|f�}tj|dd	�\}}|\}|�||�|�t|�tj�|�|�tj|d
d	�\}}|\}|�||�|�t|�tj�|�|�dS)Nrr
rrrrz00010210T11:41:23Tr-Fr0r6r*r*r+�test_datetime_before_1900Ws
z(XMLRPCTestCase.test_datetime_before_1900cCsRt��}t�tj|fdd��\\}}|�|jt�tj|fdd�}|�|t�dS)NT��methodresponse)r"r2r%r#�assertIsInstance�value�str)r'�d�new_d�dummyr8r*r*r+�test_bug_1164912is�zXMLRPCTestCase.test_bug_1164912cCsLGdd�dt�}|�}d|_d|_t�t�|f��\\}}|�||j�dS)Nc@seZdZdS)z-XMLRPCTestCase.test_newstyle_class.<locals>.TN)�__name__�
__module__�__qualname__r*r*r*r+�TtsrJ�d�Hello)�object�x�yr"r%r#r&�__dict__)r'rJ�t�t2rEr*r*r+�test_newstyle_classssz"XMLRPCTestCase.test_newstyle_classcCs|�ttjddf�dS)Nr
�c)�assertRaises�
OverflowErrorr"r#�r'r*r*r+�test_dump_big_long|�z!XMLRPCTestCase.test_dump_big_longcCs|�ttjddif�dS)N�rr
�r�rU�	TypeErrorr"r#rWr*r*r+�test_dump_bad_dictrYz!XMLRPCTestCase.test_dump_bad_dictcCs4gd�}ddd|g}|�|�|�ttj|f�dS)NrZr[��)�appendrUr]r"r#)r'�lrQr*r*r+�test_dump_recursive_seq�s
z&XMLRPCTestCase.test_dump_recursive_seqcCs2ddd�}d|d�}||d<|�ttj|f�dS)Nr)�1�2r[)�3rCrQr\�r'rCrQr*r*r+�test_dump_recursive_dict�s

z'XMLRPCTestCase.test_dump_recursive_dictcCs�tjdkr|�ttjtd�f�t�tjtjf�|�ttjtjdf�|�ttjtjdf�dd�}t�	�}|�
tj|�|�
tj|�|�t|j
tjd|�|�t|j
tjd|�dS)Ni����rcS�dS�Nr*�r8r*r*r+�dummy_write��z5XMLRPCTestCase.test_dump_big_int.<locals>.dummy_write)�sys�maxsizerUrVr"r#�int�MAXINT�MININT�
Marshaller�dump_int�r'rmr:r*r*r+�test_dump_big_int�s*

�

�

�

�

�z XMLRPCTestCase.test_dump_big_intcCs�t�td�f�t�ttj�ttj�f�t�ttjd�ttjd�f�dd�}t��}|�tj|�|�tj|�|�tjd|�|�tjd|�dS)Nri�*cSrjrkr*rlr*r*r+rm�rnz4XMLRPCTestCase.test_dump_double.<locals>.dummy_write)r"r#�floatrrrsrt�dump_doublervr*r*r+�test_dump_double�s��zXMLRPCTestCase.test_dump_doublecCsTtdg}tdgf}tj|dd�}|�|t�|�dd�|�ttj|f�dS)NT)�
allow_noner)r$r"r#r&r%rUr])r'rA�arg1�strgr*r*r+�test_dump_none�s
�zXMLRPCTestCase.test_dump_nonecCs�ddi}tj|fdd�}d|}|�t�|�dd|�|�dd�}|�t�|�dd|�tj|fddd	�}|�t�|�dd|�|�dd�}|�t�|�dd|�d
}tj|fd|d�}|�t�|�dd|�|�t�|�d|�dS)
Nukey€¤u
value€¤�iso-8859-15��encodingz,<?xml version='1.0' encoding='iso-8859-15'?>r�xmlcharrefreplaceT)r�r?umethod€¤)r��
methodnamer)r"r#r&r%�encode)r'rAr~r�r*r*r+�test_dump_encoding�s(�
�
�z!XMLRPCTestCase.test_dump_encodingcCs�d}|�|t�|��tttjfD]K}||�}t�|f�}tj|dd�\}}|\}|�||�|�t|�t�|�	|�tj|dd�\}}|\}|�||�|�t|�tj�|�	|�qdS)NrTr-F)
r&r"�Binary�bytes�	bytearrayr#r%r3r4r5)r'�sample�type_rAr8r9r:�newvaluer*r*r+�test_dump_bytes�s 
�zXMLRPCTestCase.test_dump_bytescCsFtj}d}|�|tj|�d}|�|tj|�d}|�|tj|�dS)Nz6<params><param><value><spam/></value></param></params>zT<params><param><value><array><value><spam/></value></array></value></param></params>z�<params><param><value><struct><member><name>a</name><value><spam/></value></member><member><name>b</name><value><spam/></value></member></struct></value></param></params>)r"�
ResponseErrorrUr%)r'r��datar*r*r+�test_loads_unsupported�sz%XMLRPCTestCase.test_loads_unsupportedcKsRd|}tj|fi|��\}}|\}|�||�|�t|�t|��|�|�dS)Nz1<params><param><value>%s</value></param></params>)r"r%r&r3r4r5)r'r8rA�kwargsr(r9r:r�r*r*r+�check_loads�szXMLRPCTestCase.check_loadsc
Cs�|j}|dd�|dd�|dd�|dd�|dd�|d	d�|d
d�|dd
�|dt�d��|dddd�|dt�d��|dt�dddddd�dd�|dddg�|dddd��dS)N�stringz<string>string</string>u4<string>𝔘𝔫𝔦𝔠𝔬𝔡𝔢 string</string>u#𝔘𝔫𝔦𝔠𝔬𝔡𝔢 stringz<int>2056183947</int>i��zz<int>-2056183947</int>iuq�z<i4>2056183947</i4>z<double>46093.78125</double>g���@z<boolean>0</boolean>Fz%<base64>AGJ5dGUgc3RyaW5n/w==</base64>s
byte string�Tr-z6<dateTime.iso8601>20050210T11:41:23</dateTime.iso8601>rr
r
rrrrzR<array><data><value><int>1</int></value><value><int>2</int></value></data></array>rz�<struct><member><name>b</name><value><int>2</int></value></member><member><name>a</name><value><int>1</int></value></member></struct>)�a�b)r�r"r�r2r1�r'�checkr*r*r+�test_load_standard_types�s8







������z'XMLRPCTestCase.test_load_standard_typescCs`|j}|dd�|dd�|dd�|dd�|dd�|d	d
�|dd�|d
t�d��dS)Nz<nil/>z	<ex:nil/>z<i1>205</i1>��z<i2>20561</i2>iQPz<i8>9876543210</i8>l�`	z-<biginteger>98765432100123456789</biginteger>l5�?�4*UUz<float>93.78125</float>grW@z.<bigdecimal>9876543210.0123456789</bigdecimal>z9876543210.0123456789)r��decimal�Decimalr�r*r*r+�test_load_extension_typess




�
�z(XMLRPCTestCase.test_load_extension_typesc	Cs�|j}d}t�|��Sd|d}|�t��|d|�d�d�Wd�n1s*wY|�t��|d|�d�d�Wd�n1sHwYWd�dSWd�dS1s`wYdS)Ni�rdrz<int>z</int>z<biginteger>z
</biginteger>)r�r�adjust_int_max_str_digitsrU�
ValueError)r'r��	maxdigitsr8r*r*r+�test_limit_int"s���"�zXMLRPCTestCase.test_limit_intcCs(tj��}|�|�d�ddgif�dS)Nz
user@host.tldzhost.tld)�
AuthorizationzBasic dXNlcg==)�xmlrpc�client�	Transportr&�
get_host_info)r'�transpr*r*r+�test_get_host_info,s
��z!XMLRPCTestCase.test_get_host_infocCs|zddl}Wntyd}Ynwd}ztj�d���WdSty/|�|d�YdSty=|�	|�YdSw)NrFTzhttps://localhost:9999z&xmlrpc client's error with SSL support)
�ssl�ImportErrorr�r��ServerProxy�bad_function�NotImplementedError�assertFalse�OSError�
assertTrue)r'r��has_sslr*r*r+�test_ssl_presence3s��z XMLRPCTestCase.test_ssl_presencecs�Gdd�dtjj�}�fdd�}tj�tjdf|��|��j�tj	|d�}|�
�|�|j�dj�j
�}t�|��}|�|��d�|�|��d�Wd�dS1sWwYdS)	Nc@s$eZdZdZdZdd�Zdd�ZdS)z@XMLRPCTestCase.test_keepalive_disconnect.<locals>.RequestHandler�HTTP/1.1FcSs�t|j�d��}|j�|�|jrd|_dStjddd�}|�	�}|�
tjj
�|�dt|��|��|j�|�d|_d|_dS)N�Content-LengthT)r`r>F)rq�headers�get�rfile�read�handled�close_connectionr"r#r��
send_response�http�
HTTPStatus�OK�send_header�len�end_headers�wfile�write)r'�length�responser*r*r+�do_POSTFs
zHXMLRPCTestCase.test_keepalive_disconnect.<locals>.RequestHandler.do_POSTcWrjrkr*)r'�format�argsr*r*r+�log_messageU�zLXMLRPCTestCase.test_keepalive_disconnect.<locals>.RequestHandler.log_messageN)rGrHrI�protocol_versionr�r�r�r*r*r*r+�RequestHandlerBs
r�cs$�j�td��������dS�Nr)�socket�
settimeoutry�handle_requestr*��serverr*r+�
run_serverYsz<XMLRPCTestCase.test_keepalive_disconnect.<locals>.run_serverr)�targetz
http://{}:{}/r`)r�r��BaseHTTPRequestHandler�
HTTPServerr�HOST�
addCleanup�server_close�	threading�Thread�start�joinr��server_addressr"r�r&�method)r'r�r��thread�url�pr*r�r+�test_keepalive_disconnectAs"�z(XMLRPCTestCase.test_keepalive_disconnectN)rGrHrIr,r<r=rFrSrXr^rcrhrwr{rr�r�r�r�r�r�r�r�r�r�r*r*r*r+r!.s."
	

r!c@sLeZdZGdd�de�Zdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dS)�SimpleXMLRPCDispatcherTestCasec@seZdZdZdS)z*SimpleXMLRPCDispatcherTestCase.DispatchExczSRaised inside the dispatched functions when checking for
        chained exceptionsN)rGrHrI�__doc__r*r*r*r+�DispatchExcj�r�cs�d}�fdd�}tj��}|�|����j��}|�d|�Wd�n1s)wY��|jj	|f���
|jj���
|jj�dS)z$Calls explicitly registered functionrZcs
��|��rk)r�)�paramsrWr*r+�dispatched_funcu�
zQSimpleXMLRPCDispatcherTestCase.test_call_registered_func.<locals>.dispatched_funcr�N)
r�r��SimpleXMLRPCDispatcher�register_functionrUr��	_dispatchr&�	exceptionr�r5�	__cause__�__context__)r'�
exp_paramsr��
dispatcher�exc_ctxr*rWr+�test_call_registered_funcns

�z8SimpleXMLRPCDispatcherTestCase.test_call_registered_funccCs�d}Gdd�d�}tj��}|�|��|�|j��}|�d|�Wd�n1s+wY|�|jj	|f�|�
|jj�|�
|jj�dS)z3Calls a registered instance attribute as a functionrZc@�eZdZdd�ZdS)zOSimpleXMLRPCDispatcherTestCase.test_call_instance_func.<locals>.DispatchedClasscWs
t�|��rk�r�r�)r'r�r*r*r+r��r�z_SimpleXMLRPCDispatcherTestCase.test_call_instance_func.<locals>.DispatchedClass.dispatched_funcN)rGrHrIr�r*r*r*r+�DispatchedClass��r�r�N�
r�r�r��register_instancerUr�r�r&r�r�r5r�r�)r'r�r�r�r�r*r*r+�test_call_instance_func�s
�z6SimpleXMLRPCDispatcherTestCase.test_call_instance_funccCs�d}d}Gdd�d�}tj��}|�|��|�|j��}|�||�Wd�n1s-wY|�|jj	||f�|�
|jj�|�
|jj�dS)z4Calls the registered instance's `_dispatch` functionr�rZc@r�)zLSimpleXMLRPCDispatcherTestCase.test_call_dispatch_func.<locals>.TestInstancecSst�||��rkr�)r'r�r�r*r*r+r��s�zVSimpleXMLRPCDispatcherTestCase.test_call_dispatch_func.<locals>.TestInstance._dispatchN)rGrHrIr�r*r*r*r+�TestInstance�r�r�Nr�)r'�
exp_methodr�r�r�r�r*r*r+�test_call_dispatch_func�s
�z6SimpleXMLRPCDispatcherTestCase.test_call_dispatch_funccCsVtj��}|jddd�|�td��|�dd�Wd�dS1s$wYdS)z2Calls explicitly registered function which is NoneNr���name��param)r�r�r�r��assertRaisesRegex�	Exceptionr��r'r�r*r*r+�test_registered_func_is_none�s

"�z;SimpleXMLRPCDispatcherTestCase.test_registered_func_is_nonecCsTtj��}|�t��|�td��|�dd�Wd�dS1s#wYdS)z>Attempts to call nonexistent function on a registered instancer�rN)r�r�r�r�rMrrr�rr*r*r+�test_instance_has_no_func�s

"�z8SimpleXMLRPCDispatcherTestCase.test_instance_has_no_funccCsHtj��}|�td��|�dd�Wd�dS1swYdS)z2Calls a function that the dispatcher cannot locater�rN)r�r�r�rrr�rr*r*r+�test_cannot_locate_func�s
"�z6SimpleXMLRPCDispatcherTestCase.test_cannot_locate_funcN)rGrHrIrr�r�r�r�rrrr*r*r*r+r�isr�c@r�)�HelperTestCasecCs:|�t�d�d�|�t�d�d�|�t�d�d�dS)Nza&bza&amp;bza<bza&lt;bza>bza&gt;b)r&r"�escaperWr*r*r+�test_escape�szHelperTestCase.test_escapeN)rGrHrIr
r*r*r*r+r�r�rc@�$eZdZdd�Zdd�Zdd�ZdS)�
FaultTestCasecCs4t�dd�}|�t|�d�|�t|�t|��dS)Nrx�
Test Faultz<Fault 42: 'Test Fault'>)r"�Faultr&�reprrB)r'�fr*r*r+�	test_repr�szFaultTestCase.test_reprcCsjt�dd�}t�|f�}t�|�\\}}|�|ddd��|�|d�t���|�}|�tjtj|�dS)Nrxr
)�	faultCode�faultString)r"rr#r%r&rtrU)r'rr8�newfr:r*r*r+�test_dump_fault�szFaultTestCase.test_dump_faultcCs,|�ttjjtd�|�tj�td��dS�N�__add�title)rU�AttributeErrorr�r��resolve_dotted_attributerBr�rWr*r*r+�test_dotted_attribute�s
�z#FaultTestCase.test_dotted_attributeN)rGrHrIrrrr*r*r*r+r�s
rc@sLeZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dS)�DateTimeTestCasecCslt�d��'}t�gd��}||_t��}t��}|�t	|�t�
d|��Wd�dS1s/wYdS)Nztime.localtime)	i���r��1r��r�%Y%m%dT%H:%M:%S)r�patch�time�struct_time�return_value�	localtimer"r2r&rB�strftime)r'�localtime_mock�time_structr'rQr*r*r+�test_default�s�

�"�zDateTimeTestCase.test_defaultc	Cs0d}t�|�}|�t|�t�dt�|���dS�Ngl]�ޮ��Ar")r"r2r&rBr$r(r'rgr*r*r+�	test_time�s


�zDateTimeTestCase.test_timecCs"d}t�|�}|�t|�d�dS)N)	����	r�&�2r`�rz20070609T10:38:50)r"r2r&rBrgr*r*r+�test_time_tuple�s
z DateTimeTestCase.test_time_tuplecCs0t�d�}t�|�}|�t|�t�d|��dSr,)r$r'r"r2r&rBr(rgr*r*r+�test_time_struct�s

z!DateTimeTestCase.test_time_structcCs2t�dddddd�}t�|�}|�t|�d�dS)Nr.rr
r[r_r`z20070102T03:04:05)r1r"r2r&rBrgr*r*r+�test_datetime_datetime�s
z'DateTimeTestCase.test_datetime_datetimecCs>t�dddddd�}t�|�}dt|�}|�t|�|�dS)Nr.rr
r[r_r`z%<DateTime '20070102T03:04:05' at %#x>)r1r"r2�idr&r)r'rCrQ�valr*r*r+r�s
zDateTimeTestCase.test_reprc
CsVd}t��}|�|�t�t�dddddd��}|�||�t�|�}|�||�dS)Nz 20070908T07:11:13  r.r0�rr�
)r"r2�decoder1r&�	_datetime)r'rC�t1�trefrRr*r*r+�test_decodes

zDateTimeTestCase.test_decodecCs^tj��}t�|���}|�||k�|�||k�|tjdd�}|�||k�|�||k�|�d�}|�||k�|�||k�t�|���}|�||k�|�||k�|�d�}|��}|�	|dk�|�||k�|�	|t
|�k�|�||k�|�t��|t
d�kWd�n1s�wY|�t��||kWd�n1s�wY|�t��|t
|�kWd�n1s�wY|�t��||kWd�n1s�wY|�|tk�|�	|tk�|�|tk�|�	|tk�|�|tk�|�	|tk�|�	|tk�|�|tk�|�	|tk�|�|tk�dS)Nr_)�secondsr"�asciii�)r1�nowr"r2�	timetupler��	timedeltar(r�r�r�rUr]ryrrr	)r'rB�dtime�then�dstr�
dtime_then�dbytes�dtupler*r*r+�test_comparison
sR


�
��
�z DateTimeTestCase.test_comparisonN)rGrHrIr+r-r4r5r6rr?rKr*r*r*r+r�s

rc@r)�BinaryTestCasecCst��}|�t|�d�dS)N��r"r�r&rB)r'rQr*r*r+r+CszBinaryTestCase.test_defaultcCs(d}t�|�}|�t|�t|d��dS�Nsabc123��zlatin-1rNrgr*r*r+�test_stringGs
zBinaryTestCase.test_stringcCsZd}t�|�}t��}|�|�|�t|�t|d��t�|�}|�t|�t|d��dSrO)�base64�encodebytesr"r�r;r&rB�_binary)r'rC�der=rRr*r*r+r?Ls


zBinaryTestCase.test_decodeN)rGrHrIr+rPr?r*r*r*r+rL<srLc
Cs\Gdd�d�}Gdd�dtjj�}|stjj}|d||ddd�}z�z[|��|j��\aadttfa	|�
�|��|��|�
t�|�
d	d
�d�|j
dd
��}|j
dd�dd��}|�}	|j|	dd�|��|dkr{|��|d8}|dksoWn	ty�YnwW|j��da|��dSW|j��da|��dS|j��da|��w)Nc@s*eZdZdd�Zdd�ZGdd�d�ZdS)z&http_server.<locals>.TestInstanceClasscS�||Srkr*�r'rNrOr*r*r+�div^�z*http_server.<locals>.TestInstanceClass.divcS�|dkrdSdS�NrW�This is the div functionr*�r'r�r*r*r+�_methodHelpa��z2http_server.<locals>.TestInstanceClass._methodHelpc@seZdZedd��ZdS)z.http_server.<locals>.TestInstanceClass.FixturecS�dS)N�42r*r*r*r*r+�getDatafr�z6http_server.<locals>.TestInstanceClass.Fixture.getDataN)rGrHrI�staticmethodrar*r*r*r+�FixtureesrcN)rGrHrIrWr]rcr*r*r*r+�TestInstanceClass]srdc@r�)z#http_server.<locals>.MyXMLRPCServercS� |j��\}}|�d�||fS�NT�r��accept�setblocking�r'r8�portr*r*r+�get_requestk�
z/http_server.<locals>.MyXMLRPCServer.get_requestN�rGrHrIrlr*r*r*r+�MyXMLRPCServerjr�ro��	localhostrF)r��logRequests�bind_and_activate�http://%s:%dcS�|Srkr*)rNr*r*r+�<lambda>��zhttp_server.<locals>.<lambda>�têštcSr_��This is my functionTr*r*r*r*r+�my_function�sz http_server.<locals>.my_function�addr�cS�||Srkr*�rNrOr*r*r+�_�szhttp_server.<locals>._T)�allow_dotted_namesrr)r�r��SimpleXMLRPCServer�SimpleXMLRPCRequestHandler�server_bindr��getsockname�ADDR�PORT�URL�server_activate� register_introspection_functions�register_multicall_functionsr��powr��setr��TimeoutError�close)
�evt�numrequests�requestHandlerr�rdro�servr{r�testInstancer*r*r+�http_server\sV
�



����
�

�
r�cCs�Gdd�d�}dd�}Gdd�dtjj�}|stjj}Gdd�d|�}Gd	d
�d
�}|d|ddd
�}|j�d�|��z�zi|j��\aa	dtt	fa
|��gd�}	|	D]}
|�|
tj�
��}|��|��|�|
fdd�d�qU|�|	d��t�|�|	d��dd�d�|�d|��|��|dkr�|��|d8}|dks�Wn	ty�YnwW|j��da	|��dSW|j��da	|��dS|j��da	|��w)Nc@seZdZdd�Zdd�ZdS)z,http_multi_server.<locals>.TestInstanceClasscSrUrkr*rVr*r*r+rW�rXz0http_multi_server.<locals>.TestInstanceClass.divcSrYrZr*r\r*r*r+r]�r^z8http_multi_server.<locals>.TestInstanceClass._methodHelpN)rGrHrIrWr]r*r*r*r+rd�srdcSr_ryr*r*r*r*r+r{�r�z&http_multi_server.<locals>.my_functionc@r�)z)http_multi_server.<locals>.MyXMLRPCServercSrerfrgrjr*r*r+rl�rmz5http_multi_server.<locals>.MyXMLRPCServer.get_requestNrnr*r*r*r+ro�r�roc@seZdZgZdS)z+http_multi_server.<locals>.MyRequestHandlerN)rGrHrI�	rpc_pathsr*r*r*r+�MyRequestHandler�r�r�c@seZdZddd�ZdS)z+http_multi_server.<locals>.BrokenDispatcherNcSstd��)Nzbroken dispatcher)�RuntimeError)r'r��dispatch_method�pathr*r*r+�_marshaled_dispatch�rXz?http_multi_server.<locals>.BrokenDispatcher._marshaled_dispatch�NN)rGrHrIr�r*r*r*r+�BrokenDispatcher�sr�rpF)rrrsr[rt)
�/foo�/foo/bar�/foo?k=v�	/foo#frag�
/foo?k=v#fragrM�/�/RPC2�?k=v�#fragcSrurkr*)r�r*r*r+rv�rwz#http_multi_server.<locals>.<lambda>�testrrcSr}rkr*r~r*r*r+rv�sr|�
/is/broken)r�r��MultiPathXMLRPCServerr�r�r�r�r�r�r�r�r��add_dispatcherr�r�r�r��get_dispatcherr�r�r�r�r�)r�r�r�rdr{ror�r�r��pathsr�rCr*r*r+�http_multi_server�sZ�����
�

�
r�cCsbz|jdks|jdurWdS|j�d�}Wn
ty"t|�}Ynw|r-d|��vr/dSdSdS)z�Returns True if the given ProtocolError is the product of a server-side
       exception caused by the 'temporarily unavailable' response sometimes
       given by operations on non-blocking sockets.rNT�X-exceptionztemporarily unavailable)�errcoder�r�rrB�lower)�e�exc_messr*r*r+�is_unavailable_exception�s��r�cs|sdd�S�fdd�}|S)NcSrurkr*)�funcr*r*r+rv�rwz)make_request_and_skipIf.<locals>.<lambda>cs�fdd�}|S)Nc
sRz	t�t���Wntjtfy#}zt|�s�WYd}~nd}~wwt����rk)	r"r�r�r{�
ProtocolErrorr�r��unittest�SkipTest)r'r���reasonr*r+�make_request_and_skip�s���
zImake_request_and_skipIf.<locals>.decorator.<locals>.make_request_and_skipr*)r�r�r�r*r+�	decorator�sz*make_request_and_skipIf.<locals>.decoratorr*)�	conditionr�r�r*r�r+�make_request_and_skipIf�s	r�c@s,eZdZdZdZee�Zdd�Zdd�Z	dS)�BaseServerTestCaseNrcCs`dtjj_t��|_|j|j|jf}tj	|j
|d�}|��|�|j
�|j��|j��dS)NT�r�r�)r�r�r��_send_traceback_headerr��Eventr��
request_countr�r��
threadFuncr�r�r��wait�clear�r'�	serv_argsr�r*r*r+�setUp
s


zBaseServerTestCase.setUpcCs|j��dtjj_dS�NF)r�r�r�r�r�r�rWr*r*r+�tearDowns
zBaseServerTestCase.tearDown)
rGrHrIr�r�rbr�r�r�r�r*r*r*r+r�sr�c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	e
ejj
dkd�dd��Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%S)&�SimpleServerTestCasecCs�zt�t�}|�|�dd�d�WdStjtfy@}zt|�s5|�d|t	|dd�f�WYd}~dSWYd}~dSd}~ww)Nr/r9���%s
%sr�rM)
r"r�r�r&r�r�r�r��fail�getattr�r'r�r�r*r*r+�test_simple1!s
(���z!SimpleServerTestCase.test_simple1cCs�d}d}zt�t�}|�|�||�||�WdStjtfyF}zt|�s;|�d|t	|dd�f�WYd}~dSWYd}~dSd}~ww)NuPŷtuhơnr�r�rM)
r"r�r�r&r|r�r�r�r�r��r'�start_string�
end_stringr�r�r*r*r+�
test_nonascii+s

�(���z"SimpleServerTestCase.test_nonasciicCs�d}d}ztjtdd�}|�|�||�||�WdStjtjfyI}zt|�s>|�	d|t
|dd�f�WYd}~dSWYd}~dSd}~ww)N�€�¤r�r�r�r�rM�r"r�r�r&r|r�r��errorr�r�r�r�r*r*r+�test_client_encoding8s
�(���z)SimpleServerTestCase.test_client_encodingcCs�ztjtdd�}|�|�d�d�WdStjtjfyB}zt|�s7|�	d|t
|dd�f�WYd}~dSWYd}~dSd}~ww)NrAr�rxr�r�rM)r"r�r�r&�têštr�r�r�r�r�r�r�r*r*r+�test_nonascii_methodnameFs(���z-SimpleServerTestCase.test_nonascii_methodnamecCsht�tj�tt���}|�dd�|��}Wd�n1swY|�	|j
d�|�	|jd�dS)N�POSTz/this-is-not-validi�z	Not Found)�
contextlib�closingr�r��HTTPConnectionr�r��request�getresponser&�statusr�)r'�connr�r*r*r+�test_404Ps
�zSimpleServerTestCase.test_404cCs�tgd��}zt�t�}|j��}|�t|�|�WdStjtfyI}zt	|�s>|�
d|t|dd�f�WYd}~dSWYd}~dSd}~ww)N)
r�rWr{r|rxzsystem.listMethodszsystem.methodHelpzsystem.methodSignaturezsystem.multicallrcr�r�rM)r�r"r�r��system�listMethodsr&r�r�r�r�r�)r'�expected_methodsr��methr�r*r*r+�test_introspection1Zs

(���z(SimpleServerTestCase.test_introspection1cC�zt�t�}|j�d�}|�|d�WdStjtfyB}zt|�s7|�	d|t
|dd�f�WYd}~dSWYd}~dSd}~ww)NrWr[r�r�rM�r"r�r�r��
methodHelpr&r�r�r�r�r�)r'r��divhelpr�r*r*r+�test_introspection2js
(���z(SimpleServerTestCase.test_introspection2r
z)Docstrings are omitted with -O2 and abovecCr�)Nr{rzr�r�rMr�)r'r��
myfunctionr�r*r*r+�test_introspection3vs
(���z(SimpleServerTestCase.test_introspection3cCr�)NrWzsignatures not supportedr�r�rM)r"r�r�r��methodSignaturer&r�r�r�r�r�)r'r��divsigr�r*r*r+�test_introspection4�s
(���z(SimpleServerTestCase.test_introspection4cCs�z7t�t�}t�|�}|�dd�|�dd�|�dd�|�\}}}|�|d�|�|d�|�|d�WdStjt	fye}zt
|�sZ|�d	|t|d
d�f�WYd}~dSWYd}~dSd}~ww)Nr
r[r/r9�rxr`r�r�r�rM)
r"r�r��	MultiCallr|r�rWr&r�r�r�r�r�)r'r��	multicall�
add_result�
pow_result�
div_resultr�r*r*r+�test_multicall�s 

(���z#SimpleServerTestCase.test_multicallcCs�z*t�t�}t�|�}|��|�}|�|jddd�|�|jddd�WdStjtfyX}zt	|�sM|�
d|t|dd�f�WYd}~dSWYd}~dSd}~ww)	Nrrrrz@<class 'Exception'>:method "this_is_not_exists" is not supportedr�r�rM)r"r�r�r��this_is_not_existsr&�resultsr�r�r�r�r�)r'r�r�r9r�r*r*r+�test_non_existing_multicall�s


�(���z0SimpleServerTestCase.test_non_existing_multicallcCs4|�ttjjtd�|�tj�td��|��dSr)rUrr�r�rrBr�r�rWr*r*r+r�s

�z*SimpleServerTestCase.test_dotted_attributecCs,t�dttf�}|j��}|�|d�dS)N�http://%s:%d/RPC2r`)r"r�r�r�rcrar&)r'r�r�r*r*r+�test_allow_dotted_names_true�s
z1SimpleServerTestCase.test_allow_dotted_names_truecCs*t�dttf�}|�|�dd�d�dS)Nr�r��éuaé)r"r�r�r�r&r|�r'r�r*r*r+�test_unicode_host�sz&SimpleServerTestCase.test_unicode_hostcCsXt�t�ttf���}|�dt�dt�d��d��Wd�dS1s%wYdS)Nz@POST /RPC2 HTTP/1.0
Content-Length: 100

bye HTTP/1.1
Host: �:z2
Accept-Encoding: identity
Content-Length: 0

rA)r�r�r��create_connectionr�r��sendr�)r'r�r*r*r+�test_partial_post�s���"�z&SimpleServerTestCase.test_partial_postcCs^t�t��}|�dd�|�|d�jd�Wd�n1swY|�|d�jd�dS)Nr
r[�	transportr�)r"r�r�r|�assertNotEqual�_connectionr&rr*r*r+�test_context_manager�s���z)SimpleServerTestCase.test_context_managercCsfzt�t��}|�dd�Wd�n1swYWn
tjy'Ynw|�|d�jd�dS)Nr
r�rr�)r"r�r�r|rr&r	rr*r*r+�!test_context_manager_method_error�s����z6SimpleServerTestCase.test_context_manager_method_errorN)rGrHrIr�r�r�r�r�r�r�r�ro�flags�optimizer�r�r�r�rr�rrr
rr*r*r*r+r� s*



�



r�c@s"eZdZeddd��Zdd�ZdS)�SimpleServerEncodingTestCaseNcCst|||d�dS)Nr�)r�)r�r�r�r�r*r*r+r��sz'SimpleServerEncodingTestCase.threadFunccCs�d}d}zt�t�}|�|�||�||�WdStjtjfyG}zt|�s<|�	d|t
|dd�f�WYd}~dSWYd}~dSd}~ww)Nr�r�r�r�rMr�r�r*r*r+�test_server_encoding�s

�(���z1SimpleServerEncodingTestCase.test_server_encodingr�)rGrHrIrbr�rr*r*r*r+r�src@speZdZee�ZdZdd�Zdd�Zdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zdd�Zdd�Zdd�ZdS)�MultiPathServerTestCaser
cC�:t�td�}|�|�dd�d�|�tj|jdd�dS)Nr�r/r9r�)r"r�r�r&r�rUrr|�r'r�r*r*r+�
test_path1��z"MultiPathServerTestCase.test_path1cCr)Nr�r/r9�)r"r�r�r&r|rUrr�rr*r*r+�
test_path2rz"MultiPathServerTestCase.test_path2cC�&t�td�}|�tj|jdd�dS)Nr�r/r9�r"r�r�rUrr|rr*r*r+�
test_path3�z"MultiPathServerTestCase.test_path3cCr)Nz/invalidr/r9rrr*r*r+�test_invalid_pathrz)MultiPathServerTestCase.test_invalid_pathcC�"t�td�}|�|��d�dS)Nr��r"r�r�r&r�rr*r*r+�test_path_query_fragment�z0MultiPathServerTestCase.test_path_query_fragmentcCr)Nr�rrr*r*r+�test_path_fragmentrz*MultiPathServerTestCase.test_path_fragmentcCr)Nr�rrr*r*r+�test_path_queryrz'MultiPathServerTestCase.test_path_querycCst�t�}|�|��d�dS)Nr�rrr*r*r+�test_empty_paths
z'MultiPathServerTestCase.test_empty_pathcCr)Nr�rrr*r*r+�test_root_path rz&MultiPathServerTestCase.test_root_pathcCr)Nr�rrr*r*r+�test_empty_path_query$rz-MultiPathServerTestCase.test_empty_path_querycCr)Nr�rrr*r*r+�test_empty_path_fragment(rz0MultiPathServerTestCase.test_empty_path_fragmentN)rGrHrIrbr�r�r�rrrrrr r!r"r#r$r%r*r*r*r+r�src@s,eZdZGdd�dejj�ZeZdd�ZdS)�BaseKeepaliveServerTestCasec@s,eZdZejjZdZgZdd�Z	dd�Z
dS)z*BaseKeepaliveServerTestCase.RequestHandlerr�cCs(|j�g�t|j�d|_|j�|�Sr�)�
myRequestsrar��reqidx�parentClass�handlerWr*r*r+r*6sz1BaseKeepaliveServerTestCase.RequestHandler.handlecCs$|j�|�}|j|j�|j�|Srk)r)�handle_one_requestr'r(ra�raw_requestline)r'r9r*r*r+r+:sz=BaseKeepaliveServerTestCase.RequestHandler.handle_one_requestN)rGrHrIr�r�r�r)r�r'r*r+r*r*r*r+r�2sr�cCsg|j_t�|�Srk)r�r'r�r�rWr*r*r+r�@s
z!BaseKeepaliveServerTestCase.setUpN)	rGrHrIr�r�r�r�r�r�r*r*r*r+r&/s
r&c@r�)�KeepaliveServerTestCase1cCs�t�t�}|�|�dd�d�|�|�dd�d�|�|�dd�d�|d��|�t|jj�d�|�t|jjd�d�dS)Nr/r9r�r�rrr
�	r"r�r�r&r�r�r�r'�assertGreaterEqualrr*r*r+�test_twoHs

z!KeepaliveServerTestCase1.test_twoN)rGrHrIr0r*r*r*r+r-Gr�r-c@� eZdZdZdd�Zdd�ZdS)�KeepaliveServerTestCase2r
cCs�t�t�}|�|�dd�d�|�|�dd�d�|�|�dd�d�|d��|�|�dd�d�|�|�dd�d�|�|�dd�d�|d��|�t|jj�d�|�t|jjd�d�|�t|jjd�d�dS)Nr/r9r�r�r
r���r.rr*r*r+�
test_close^s


z#KeepaliveServerTestCase2.test_closecCs`t�t�}|�|�dd�d�|d���|�|�dd�d�|d��|�t|jj�d�dS)Nr/r9r�rr�r
)	r"r�r�r&r�r�r�r�r'rr*r*r+�test_transportqs

z'KeepaliveServerTestCase2.test_transportN)rGrHrIr�r4r5r*r*r*r+r2Zsr2z
requires gzipc@sVeZdZGdd�dejj�ZeZGdd�dej	�Z	dd�Z
dd�Zd	d
�Zdd�Z
d
S)�GzipServerTestCasec@s eZdZejjZdZdd�ZdS)z!GzipServerTestCase.RequestHandlerr�cCst|jd�|j_|j�|�S)N�content-length)rqr��	__class__�content_lengthr)r�rWr*r*r+r��sz)GzipServerTestCase.RequestHandler.do_POSTN)	rGrHrIr�r�r�r)r�r�r*r*r*r+r��sr�c@r1)zGzipServerTestCase.TransportFcCs t|�dd��|_tj�||�S)Nr7r)rq�	getheader�response_lengthr"r��parse_response)r'r�r*r*r+r<�sz+GzipServerTestCase.Transport.parse_responsecCs"|jr	|�dd�tj�|||�S)NzContent-Encoding�gzip)�	fake_gzip�	putheaderr"r��send_content)r'�
connection�bodyr*r*r+r@�sz)GzipServerTestCase.Transport.send_contentN)rGrHrIr>r<r@r*r*r*r+r��sr�cCst�|�dSrk)r�r�rWr*r*r+r��szGzipServerTestCase.setUpcCsv|��}d|_tjt|d�}|�|�dd�d�|jj}d|_|�|�dd�d�|jj}|�	||k�|d��dS�N�rr/r9r�rr�)
r��encode_thresholdr"r�r�r&r�r�r9r�)r'rQr�r�r�r*r*r+�test_gzip_request�sz$GzipServerTestCase.test_gzip_requestcCst|��}d|_d|_tjt|d�}|�tjt�	d��}|�|�
dd�Wd�n1s.wY|d��dS)NTrDz\b400\br/r9r�)r�rEr>r"r�r�rr��re�compiler�)r'rQr��cmr*r*r+�test_bad_gzip_request�s��z(GzipServerTestCase.test_bad_gzip_requestcCs�|��}tjt|d�}|jj}d|j_|�|�dd�d�|j}d|j_|�|�dd�d�|d��|j}||j_|�	||k�dSrC)
r�r"r�r�r�rEr&r�r;r�)r'rQr��oldr�r�r*r*r+�test_gzip_response�s
z%GzipServerTestCase.test_gzip_responseN)rGrHrIr�r�r�r�r�r"r�r�rFrJrLr*r*r*r+r6|s
r6c@r�)�GzipUtilTestCasecCs�d}d|}t�|�}t�|�}|�t|�|�d|d}t�|�}|�td��
t�|�Wd�n1s9wYtj|dd�dS)Ni@�rz#max gzipped payload length exceededr)�
max_decode)r"�gzip_encode�gzip_decoder&r�rr�)r'�max_gzip_decoder��encoded�decodedr*r*r+�test_gzip_decode_limit�s


��z'GzipUtilTestCase.test_gzip_decode_limitN)rGrHrIrUr*r*r*r+rM�srMcsleZdZGdd�dejj�ZeZgd�Z�fdd�Z	dd�Z
dd	�Zd
d�Zdd
�Z
dd�Zdd�Z�ZS)�HeadersServerTestCasecs eZdZdZ�fdd�Z�ZS)z$HeadersServerTestCase.RequestHandlerNcs|j|j_t���Srk)r�r8�test_headers�superr�rW�r8r*r+r��s

z,HeadersServerTestCase.RequestHandler.do_POST)rGrHrIrWr��
__classcell__r*r*rYr+r��sr�)�HostzAccept-EncodingzContent-Typez
User-Agentr�csd|j_t���Srk)r�rWrXr�rWrYr*r+r��s
zHeadersServerTestCase.setUpcCsRt|jt|����}|�t|���|�|��D]
\}}|�|�|�|�qdSrk)�sorted�standard_headers�list�keys�assertListEqual�itemsr&r�)r'r��
additional�
expected_keys�keyrAr*r*r+�assertContainsAdditionalHeaders�s
�z5HeadersServerTestCase.assertContainsAdditionalHeaderscCs@tjtdgd�}|�|�dd�d�|jj}|�|ddi�dS)N��X-Test�foo�r�r/r9r�rgrh�r"r�r�r&r�r�rWre�r'r�r�r*r*r+�test_header�sz!HeadersServerTestCase.test_headercCsDtjtddgd�}|�|�dd�d�|jj}|�|ddd	��dS)
Nrf)�
X-Test-Second�barrir/r9r�rhrn)rgrmrjrkr*r*r+�test_header_many�s�
�z&HeadersServerTestCase.test_header_manycCs:tjtgd�}|�|�dd�d�|jj}|�|i�dS)Nrir/r9r�rjrkr*r*r+�test_header_empty�sz'HeadersServerTestCase.test_header_emptycCs>tjtdd�}|�|�dd�d�|jj}|�|ddi�dS)N)rfrir/r9r�rgrhrjrkr*r*r+�test_header_tuplesz'HeadersServerTestCase.test_header_tuplecCsFtjtddi��d�}|�|�dd�d�|jj}|�|ddi�dS)Nrgrhrir/r9r�)	r"r�r�rar&r�r�rWrerkr*r*r+�test_header_items	sz'HeadersServerTestCase.test_header_items)rGrHrIr�r�r�r�r�r]r�rerlrorprqrrrZr*r*rYr+rV�s	rVc@r)�ServerProxyTestCasecCstj�|�d|_dS)Nzhttp://fake.localhost)r��TestCaser�r�rWr*r*r+r�s
zServerProxyTestCase.setUpcCs"t�|j�}|�|d��d�dS)Nr�)r"r�r�r&rr*r*r+r4szServerProxyTestCase.test_closecCs,t��}tj|j|d�}|�|d�|�dS)NrDr)r"r�r�r�r&)r'rQr�r*r*r+r5sz"ServerProxyTestCase.test_transportN)rGrHrIr�r4r5r*r*r*r+rssrscseZdZd�fdd�	Z�ZS)�FailingMessageClassNcs"|��}|dkr
dSt��||�S)Nr7zI am broken)r�rXr�)r'rd�failobjrYr*r+r�&szFailingMessageClass.getrk)rGrHrIr�rZr*r*rYr+ru%sruc@s4eZdZdd�Zdd�Zdd�Zdd�Zd	d
�ZdS)�FailingServerTestCasecCsNt��|_|jdf}tjt|d�}|��|�|j�|j��|j�	�dS)Nrr�)
r�r�r�r�r�r�r�r�r�r�r�r*r*r+r�.s


zFailingServerTestCase.setUpcCs*|j��dtjj_tjj}|tjj	_
dSr�)r�r�r�r�r�r�r�r��HTTPMessager��MessageClass)r'�
default_classr*r*r+r�:s

zFailingServerTestCase.tearDowncCs�tjjj}|�|d�dtjj_zt�t�}|�|�dd�d�WdStj	t
fyP}zt|�sE|�d|t
|dd�f�WYd}~dSWYd}~dSd}~ww)	NFTr/r9r�r�r�rM)r�r�r�r�r&r"r�r�r�r�r�r�r�r�)r'�flagvalr�r�r*r*r+�
test_basicCs


(���z FailingServerTestCase.test_basicc
Cs�ttjj_z
t�t�}|�dd�WnCtj	t
fyU}z4t|�sCt|d�rJ|�
|j�d�du�|�
|j�d�du�WYd}~dSWYd}~dSWYd}~dSd}~ww|�d�dS)Nr/r9r�r��X-traceback�ProtocolError not raised)rur�r�r�ryr"r�r�r�r�r�r��hasattrr�r�r�r�r�r*r*r+�test_fail_no_infoUs

$���z'FailingServerTestCase.test_fail_no_infoc
Cs�ttjj_dtjj_z
t�t	�}|�
dd�WnDtjtfy[}z5t
|�sIt|d�rPd}|�|j�d�|�|�|j�d�du�WYd}~dSWYd}~dSWYd}~dSd}~ww|�d�dS)	NTr/r9r�z5invalid literal for int() with base 10: 'I am broken'r�r}r~)rur�r�r�ryr�r�r"r�r�r�r�r�r�rr&r�r�r�r�)r'r�r��expected_errr*r*r+�test_fail_with_infoes


$���z)FailingServerTestCase.test_fail_with_infoN)rGrHrIr�r�r|r�r�r*r*r*r+rw-s	rw�utf-8ccs:�tj}tjt��|d�t_z
tjVW|t_dS|t_w)zhA variation on support.captured_stdout() which gives a text stream
    having a `buffer` attribute.
    r�N)ro�stdout�io�
TextIOWrapper�BytesIO)r��orig_stdoutr*r*r+�captured_stdout{s�
r�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�CGIHandlerTestCasecCstj��|_dSrk)r�r��CGIXMLRPCRequestHandler�cgirWr*r*r+r���zCGIHandlerTestCase.setUpcCs
d|_dSrk)r�rWr*r*r+r��r�zCGIHandlerTestCase.tearDownc	Cs�t���O}d|d<t|jjd��
}|j��Wd�n1s wY|�d�|��}|��d}d�	|��dd��}|�
|d	�|�
|d
�Wd�dS1sVwYdS)N�GET�REQUEST_METHODr�rr� r
r_�400zBad Request)r�EnvironmentVarGuardr�r�r�r��seekr��splitr�r&)r'�env�data_outr*r��messager*r*r+�test_cgi_get�s
�
"�zCGIHandlerTestCase.test_cgi_getc
Csd}t���J}t|jjd��3}t���}|�|�|�d�t	t
|��|d<|j��Wd�n1s5wYWd�n1sDwYWd�n1sSwY|�d�|��}|�
tjtj|dd��||�d�d�}|�tt�d|��d��t
|��dS)	Naw<?xml version='1.0'?>
        <methodCall>
            <methodName>test_method</methodName>
            <params>
                <param>
                    <value><string>foo</string></value>
                </param>
                <param>
                    <value><string>bar</string></value>
                </param>
            </params>
        </methodCall>
        r�r�CONTENT_LENGTH�,z<?xmlzContent-Length: (\d+)r)rr�r�r�r�r�captured_stdinr�r�rBr�r�r�rUr"rr%�findr&rqrG�search�group)r'r�r�r��data_inr*�contentr*r*r+�test_cgi_xmlrpc_response�s2
��

���
�z+CGIHandlerTestCase.test_cgi_xmlrpc_responseN)rGrHrIr�r�r�r�r*r*r*r+r��s
r�c@r)�UseBuiltinTypesTestCasecs�g�_d}t�dddddd�}t�||fd�}�fd	d
�}tjjdddd�}|�|�|�|���	t
�j�d
��j\}}��	�j||g���t|�tj���t|�t
�dS)Nri�r`�����foobarcs�j�|�dSrk)�log�extend)r�rWr*r+r��r�z>UseBuiltinTypesTestCase.test_use_builtin_types.<locals>.foobarT)r|r�r.r
)r�r1r"r#r�r�r�r�r�r&r�r3r4r�)r'�expected_bytes�
expected_date�	marshaledr��handler�mybytes�mydater*rWr+�test_use_builtin_types�s�


z.UseBuiltinTypesTestCase.test_use_builtin_typescCstjjdd�}|�|j�dS)NTr-)r�r�r�r�r.)r'r�r*r*r+�*test_cgihandler_has_use_builtin_types_flag�szBUseBuiltinTypesTestCase.test_cgihandler_has_use_builtin_types_flagcCs(tjjddd�}|��|�|j�dS)NrpTr-)r�r�r�r�r�r.rr*r*r+�,test_xmlrpcserver_has_use_builtin_types_flag�s
�zDUseBuiltinTypesTestCase.test_xmlrpcserver_has_use_builtin_types_flagN)rGrHrIr�r�r�r*r*r*r+r��sr�cCs t��}tjtjg|�R�dSrk)r�threading_setupr��addModuleCleanup�threading_cleanup)�thread_infor*r*r+�setUpModule�sr��__main__r�rk)r�)GrQr1r�ror$r�r�
xmlrpc.clientr�r"�
xmlrpc.serverr��http.clientr��http.serverr�r�rGr�r�r�r�test.supportrrrrrr	r=r�r�r�r2r$rtr!r�rrrrLr�r�r�r�r�r�r�r�r�rrr&r-r2�skipIfr6rMrVrsrxrurw�contextmanagerr�r�r�r�rG�mainr*r*r*r+�<module>s�����=W_

@HH4"C>ND!
�

Youez - 2016 - github.com/yon3zu
LinuXploit