a ze@sddlZddlZddlZddlZddlZddlZddlmZddlmZ ddl Z ddl Z ddl Z ddlZ ddlZddlZddlZddlZddlZddlmZddlmZddlmZmZmZz ddlZWneydZYn0dddd d ge d d ed d d de de de edd dddddgZ Gdddej!Z"Gdddej!Z#Gdddej!Z$Gdddej!Z%Gdd d ej!Z&Gd!d"d"ej!Z'da(a)a*dPd#d$Z+dQd%d&Z,d'd(Z-d)d*Z.Gd+d,d,ej!Z/Gd-d.d.e/Z0Gd/d0d0e/Z1Gd1d2d2e/Z2Gd3d4d4e/Z3Gd5d6d6e3Z4Gd7d8d8e3Z5e6edud9Gd:d;d;e/Z7e6edud9Gdd?d?e/Z9Gd@dAdAej!Z:GdBdCdCe jj;ZdRdGdHZ?GdIdJdJej!Z@GdKdLdLej!ZAdMdNZBeCdOkreDdS)SN)mock)support) socket_helper) ALWAYS_EQLARGESTSMALLESTzfoo@bar.baz.spamgHzns@iz.zyx.41my dog has fleasFu 䀀怀耀z regular value20050210T11:41:23) r )rr r r rr)ZastringZafloatZanintZ ashortlongZ anotherlistZabase64Zb64bytesZ b64bytearrayZbooleanunicodeuukey䀀Z datetime1Z datetime2Z datetime3c@seZdZddZddZddZddZd d Zd d Zd dZ ddZ ddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+S),XMLRPCTestCasecCs.ttf}t|}|t|dddS)Nr) xmlrpclibdumpsalistloads assertEqual)selfdumploadrD/opt/bitninja-python-dojo/embedded/lib/python3.9/test/test_xmlrpc.pytest_dump_load.s  zXMLRPCTestCase.test_dump_loadcCs6tdddddd}||tdt|f}tj|dd \}}|\}||||t|tj||tj|d d \}}|\}||||t|tj||tj|dd \}}|\}||||t|tj||tj|d d \}}|\}||||t|tj||dS) Nr rr r rrr Tuse_builtin_typesF)Z use_datetime datetimerrDateTimerrassertIstype assertIsNonerZdtsresultmZnewdtrrrtest_dump_bare_datetime3s.        z&XMLRPCTestCase.test_dump_bare_datetimecCstdddddd}||tdt|f}tj|dd \}}|\}||||t|tj||tj|d d \}}|\}||||t|tj||dS) Nrrr r rrz00010210T11:41:23TrFr!r'rrrtest_datetime_before_1900Us    z(XMLRPCTestCase.test_datetime_before_1900cCsRt}ttj|fdd\\}}||jttj|fdd}||tdS)NTmethodresponse)rr#rrZassertIsInstancevaluestr)rdZnew_ddummyr(rrrtest_bug_1164912gs zXMLRPCTestCase.test_bug_1164912cCsLGdddt}|}d|_d|_tt|f\\}}|||jdS)Nc@s eZdZdS)z-XMLRPCTestCase.test_newstyle_class..TN)__name__ __module__ __qualname__rrrrTrsr7dZHello)objectxyrrrr__dict__)rr7tt2r2rrrtest_newstyle_classqs z"XMLRPCTestCase.test_newstyle_classcCs|ttjddfdS)Nrc) assertRaises OverflowErrorrrrrrrtest_dump_big_longzsz!XMLRPCTestCase.test_dump_big_longcCs|ttjddifdS)NrrrrA TypeErrorrrrCrrrtest_dump_bad_dict}sz!XMLRPCTestCase.test_dump_bad_dictcCs4gd}ddd|g}|||ttj|fdS)NrErF)appendrArHrr)rlr=rrrtest_dump_recursive_seqs  z&XMLRPCTestCase.test_dump_recursive_seqcCs2ddd}d|d}||d<|ttj|fdS)Nr)12rF)3r1r=rGrr1r=rrrtest_dump_recursive_dicts  z'XMLRPCTestCase.test_dump_recursive_dictcCstjdkr |ttjtdfttjtjf|ttjtjdf|ttjtjdfdd}t }| tj|| tj||t|j tjd||t|j tjd|dS)NircSsdSNrr(rrr dummy_writesz5XMLRPCTestCase.test_dump_big_int..dummy_write) sysmaxsizerArBrrintMAXINTMININT MarshallerZdump_intrrWr*rrrtest_dump_big_ints*          z XMLRPCTestCase.test_dump_big_intcCsttdftttjttjftttjdttjdfdd}t}|tj||tj||tjd||tjd|dS)NrT*cSsdSrUrrVrrrrWsz4XMLRPCTestCase.test_dump_double..dummy_write)rrfloatr[r\r]Z dump_doubler^rrrtest_dump_doubles  zXMLRPCTestCase.test_dump_doublecCsTtdg}tdgf}tj|dd}||t|dd|ttj|fdS)NT) allow_noner)rrrrrrArH)rr/Zarg1strgrrrtest_dump_nones  zXMLRPCTestCase.test_dump_nonecCsddi}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-15encodingz,rxmlcharrefreplaceT)rhr.u method€¤)rh methodnamer)rrrrencode)rr/rdrjrrrtest_dump_encodings(    z!XMLRPCTestCase.test_dump_encodingcCsd}||t|tttjfD]}||}t|f}tj|dd\}}|\}||||t|t| |tj|dd\}}|\}||||t|tj| |q"dS)Nr TrF) rrBinarybytes bytearrayrrr$r%r&)rsampletype_r/r(r)r*newvaluerrrtest_dump_bytess    zXMLRPCTestCase.test_dump_bytescCsFtj}d}||tj|d}||tj|d}||tj|dS)Nz6zTzab)r ResponseErrorrAr)rrtdatarrrtest_loads_unsupportedsz%XMLRPCTestCase.test_loads_unsupportedcKsRd|}tj|fi|\}}|\}||||t|t|||dS)Nz1%s)rrrr$r%r&)rr(r/kwargsrr)r*rrrrr check_loadss  zXMLRPCTestCase.check_loadsc Cs|j}|dd|dd|dd|dd|dd|d d|d d |d d |dtd|dddd|dtd|dtdddddddd|dddg|dddddS)Nstringzstringu4𝔘𝔫𝔦𝔠𝔬𝔡𝔢 stringu#𝔘𝔫𝔦𝔠𝔬𝔡𝔢 stringz2056183947izz-2056183947iuqz2056183947z46093.78125g@z0Fz%AGJ5dGUgc3RyaW5n/w==s byte stringTrz620050210T11:41:23r r rr r rrzR12rzb2a1)ab)rxrrmr#r"rcheckrrrtest_load_standard_typess8        z'XMLRPCTestCase.test_load_standard_typescCs`|j}|dd|dd|dd|dd|dd|d d |d d |d tddS)Nzz z 205z20561iQPz9876543210l` z-98765432100123456789l5?4*UUz93.78125grW@z.9876543210.0123456789z9876543210.0123456789)rxdecimalZDecimalr|rrrtest_load_extension_typess      z(XMLRPCTestCase.test_load_extension_typescCs(tj}||dddgifdS)Nz user@host.tldzhost.tld)Z AuthorizationzBasic dXNlcg==)xmlrpcclient TransportrZ get_host_info)rZtransprrrtest_get_host_info s   z!XMLRPCTestCase.test_get_host_infocCszz ddl}Wnty"d}Yn0d}ztjdWn8tyZ||dYntyt| |Yn0dS)NrFTzhttps://localhost:9999z&xmlrpc client's error with SSL support) ssl ImportErrorrr ServerProxyZ bad_functionNotImplementedError assertFalseOSError assertTrue)rrZhas_sslrrrtest_ssl_presence's     z XMLRPCTestCase.test_ssl_presencecsGdddtjj}fdd}tjtjdf||jtj |d}| ||j dj j }t|0}||d||dWdn1s0YdS) Nc@s$eZdZdZdZddZddZdS)z@XMLRPCTestCase.test_keepalive_disconnect..RequestHandlerHTTP/1.1FcSst|jd}|j||jr,d|_dStjddd}| }| t j j |dt|||j|d|_d|_dS)NContent-LengthT)rKr-F)rZheadersgetZrfilereadhandledZclose_connectionrrrkZ send_responsehttpZ HTTPStatusZOKZ send_headerlenZ end_headersZwfilewrite)rlengthresponserrrdo_POST:s  zHXMLRPCTestCase.test_keepalive_disconnect..RequestHandler.do_POSTcWsdSrUr)rformatargsrrr log_messageIszLXMLRPCTestCase.test_keepalive_disconnect..RequestHandler.log_messageN)r4r5r6protocol_versionrrrrrrrRequestHandler6srcs$jtddSNr)socket settimeoutrahandle_requestrserverrr run_serverMsz.run_serverr)targetz http://{}:{}/rK)rrZBaseHTTPRequestHandlerZ HTTPServerrZHOST addCleanup server_close threadingThreadstartjoinrZserver_addressrrrmethod)rrrthreadurlprrrtest_keepalive_disconnect5s      z(XMLRPCTestCase.test_keepalive_disconnectN)r4r5r6rr+r,r3r?rDrIrNrSr_rbrerlrsrvrxr~rrrrrrrrr,s*"   rc@sLeZdZGdddeZddZddZddZd d Zd d Z d dZ dS)SimpleXMLRPCDispatcherTestCasec@seZdZdZdS)z*SimpleXMLRPCDispatcherTestCase.DispatchExczSRaised inside the dispatched functions when checking for chained exceptionsN)r4r5r6__doc__rrrr DispatchExc^srcsd}fdd}tj}||j}|d|Wdn1sR0Y|jj |f |jj  |jj dS)z$Calls explicitly registered functionrEcs|dSrU)r)paramsrCrrdispatched_funciszQSimpleXMLRPCDispatcherTestCase.test_call_registered_func..dispatched_funcrN) rrSimpleXMLRPCDispatcherregister_functionrAr _dispatchr exceptionrr& __cause__ __context__)r exp_paramsr dispatcherexc_ctxrrCrtest_call_registered_funcbs   *z8SimpleXMLRPCDispatcherTestCase.test_call_registered_funccCsd}Gddd}tj}||||j}|d|Wdn1sV0Y||jj |f| |jj | |jj dS)z3Calls a registered instance attribute as a functionrEc@seZdZddZdS)zOSimpleXMLRPCDispatcherTestCase.test_call_instance_func..DispatchedClasscWst|dSrUrr)rrrrrr|sz_SimpleXMLRPCDispatcherTestCase.test_call_instance_func..DispatchedClass.dispatched_funcN)r4r5r6rrrrrDispatchedClass{srrN rrrregister_instancerArrrrrr&rr)rrrrrrrrtest_call_instance_functs  *z6SimpleXMLRPCDispatcherTestCase.test_call_instance_funccCsd}d}Gddd}tj}||||j}|||Wdn1sZ0Y||jj ||f| |jj | |jj dS)z4Calls the registered instance's `_dispatch` functionrrEc@seZdZddZdS)zLSimpleXMLRPCDispatcherTestCase.test_call_dispatch_func..TestInstancecSst||dSrUr)rrrrrrrszVSimpleXMLRPCDispatcherTestCase.test_call_dispatch_func..TestInstance._dispatchN)r4r5r6rrrrr TestInstancesrNr)rZ exp_methodrrrrrrrtest_call_dispatch_funcs  *z6SimpleXMLRPCDispatcherTestCase.test_call_dispatch_funccCsTtj}|jddd|td|ddWdn1sF0YdS)z2Calls explicitly registered function which is NoneNrnameZparam)rrrrassertRaisesRegex Exceptionrrrrrrtest_registered_func_is_nones z;SimpleXMLRPCDispatcherTestCase.test_registered_func_is_nonecCsRtj}|t|td|ddWdn1sD0YdS)z>Attempts to call nonexistent function on a registered instancerrN)rrrrr9rrrrrrrtest_instance_has_no_funcs  z8SimpleXMLRPCDispatcherTestCase.test_instance_has_no_funccCsFtj}|td|ddWdn1s80YdS)z2Calls a function that the dispatcher cannot locaterrN)rrrrrrrrrrtest_cannot_locate_funcs z6SimpleXMLRPCDispatcherTestCase.test_cannot_locate_funcN) r4r5r6rrrrrrrrrrrrr]src@seZdZddZdS)HelperTestCasecCs:|tdd|tdd|tdddS)Nza&bza&bzabza>b)rrescaperCrrr test_escapeszHelperTestCase.test_escapeN)r4r5r6rrrrrrsrc@s$eZdZddZddZddZdS) FaultTestCasecCs4tdd}|t|d|t|t|dS)Nr` Test Faultz)rFaultrreprr0)rfrrr test_reprs zFaultTestCase.test_reprcCsjtdd}t|f}t|\\}}||ddd||dt|}|tjtj|dS)Nr`r) faultCode faultString)rrrrrr]rA)rrr(Znewfr*rrrtest_dump_faults   zFaultTestCase.test_dump_faultcCs,|ttjjtd|tjtddSNZ__addtitle)rAAttributeErrorrrresolve_dotted_attributer0rrCrrrtest_dotted_attributes z#FaultTestCase.test_dotted_attributeN)r4r5r6rrrrrrrrs rc@sLeZdZddZddZddZddZd d Zd d Zd dZ ddZ dS)DateTimeTestCasecCsjtdL}tgd}||_t}t}|t |t d|Wdn1s\0YdS)Nztime.localtime) ir1rr%Y%m%dT%H:%M:%S) rZpatchtime struct_timeZ return_value localtimerr#rr0strftime)rZlocaltime_mockZ time_structrr=rrr test_defaults   zDateTimeTestCase.test_defaultc Cs0d}t|}|t|tdt|dSNgl]ޮAr)rr#rr0rrrrRrrr test_times   zDateTimeTestCase.test_timecCs"d}t|}|t|ddS)N)  r &2rKrz20070609T10:38:50)rr#rr0rRrrrtest_time_tuples z DateTimeTestCase.test_time_tuplecCs0td}t|}|t|td|dSr)rrrr#rr0rrRrrrtest_time_structs  z!DateTimeTestCase.test_time_structcCs2tdddddd}t|}|t|ddS)NrrrrFrJrKz20070102T03:04:05)r"rr#rr0rRrrrtest_datetime_datetimes z'DateTimeTestCase.test_datetime_datetimecCs>tdddddd}t|}dt|}|t||dS)NrrrrFrJrKz%)r"rr#idrr)rr1r=valrrrrs  zDateTimeTestCase.test_reprc CsVd}t}||ttdddddd}|||t|}|||dS)Nz 20070908T07:11:13 rrrr )rr#decoder"rZ _datetime)rr1t1Ztrefr>rrr test_decodes   zDateTimeTestCase.test_decodecCsftj}t|}|||k|||k|tjdd}|||k|||k|d}|||k|||kt|}|||k|||k|d}|}| |dk|||k| |t |k|||k| t |t dkWdn1s,0Y| t ||kWdn1s`0Y| t |t |kWdn1s0Y| t ||kWdn1s0Y||tk| |tk||tk| |tk||tk| |tk| |tk||tk| |tk||tkdS)NrJ)Zsecondsrasciii)r"nowrr#Z timetuplerZ timedeltarrkrrorArHrarrr)rrZdtimeZthenZdstrZ dtime_thenZdbytesZdtuplerrrtest_comparisonsJ    , ( , (z DateTimeTestCase.test_comparisonN) r4r5r6rrrrrrrrrrrrrs  rc@s$eZdZddZddZddZdS)BinaryTestCasecCst}|t|ddS)Nrrmrr0)rr=rrrr7szBinaryTestCase.test_defaultcCs(d}t|}|t|t|ddSNs abc123zlatin-1rrRrrr test_string;s zBinaryTestCase.test_stringcCsZd}t|}t}|||t|t|dt|}|t|t|ddSr)base64Z encodebytesrrmrrr0Z_binary)rr1derr>rrrr@s   zBinaryTestCase.test_decodeN)r4r5r6rrrrrrrr0src Cs@Gddd}Gdddtjj}|s.tjj}|d||ddd}zz||j\aadttfa | | | | t| d d d |j d d }|j dddd}|} |j| dd||dkr||d8}qWntjyYn0W|jda|n|jda|0dS)Nc@s*eZdZddZddZGdddZdS)z&http_server..TestInstanceClasscSs||SrUrrr:r;rrrdivRsz*http_server..TestInstanceClass.divcSs|dkr dSdSNr This is the div functionrrrrrr _methodHelpUsz2http_server..TestInstanceClass._methodHelpc@seZdZeddZdS)z.http_server..TestInstanceClass.FixturecSsdS)N42rrrrrgetDataZsz6http_server..TestInstanceClass.Fixture.getDataN)r4r5r6 staticmethodrrrrrFixtureYsrN)r4r5r6r rrrrrrTestInstanceClassQsrc@seZdZddZdS)z#http_server..MyXMLRPCServercSs |j\}}|d||fSNTraccept setblockingrr(portrrr get_request_s z/http_server..MyXMLRPCServer.get_requestNr4r5r6rrrrrMyXMLRPCServer^sr localhostrF)rh logRequestsbind_and_activate http://%s:%dcSs|SrUr)r:rrrxzhttp_server..têštcSsdSThis is my functionTrrrrr my_functionysz http_server..my_functionaddrcSs||SrUrr:r;rrr_}szhttp_server.._T)Zallow_dotted_namesrr)rrSimpleXMLRPCServerSimpleXMLRPCRequestHandler server_bindr getsocknameADDRPORTURLserver_activate register_introspection_functionsregister_multicall_functionsrpowrsetrtimeoutclose) evt numrequestsrequestHandlerrhrrservr(r+Z testInstancerrr http_serverPsF        r>c CsGddd}dd}Gdddtjj}|s6tjj}Gddd|}Gd d d }|d |d d d }|jd|zz|j\aa dtt fa | gd} | D]:} | | tj } | | | | fdddq|| dt|| dddd| d|||dkrJ||d8}q,WntjybYn0W|jda |n|jda |0dS)Nc@seZdZddZddZdS)z,http_multi_server..TestInstanceClasscSs||SrUrr rrrr sz0http_multi_server..TestInstanceClass.divcSs|dkr dSdSr rrrrrrsz8http_multi_server..TestInstanceClass._methodHelpN)r4r5r6r rrrrrrsrcSsdSr&rrrrrr(sz&http_multi_server..my_functionc@seZdZddZdS)z)http_multi_server..MyXMLRPCServercSs |j\}}|d||fSrrrrrrrs z5http_multi_server..MyXMLRPCServer.get_requestNrrrrrrsrc@seZdZgZdS)z+http_multi_server..MyRequestHandlerN)r4r5r6Z rpc_pathsrrrrMyRequestHandlersr?c@seZdZdddZdS)z+http_multi_server..BrokenDispatcherNcSs tddS)Nzbroken dispatcher) RuntimeError)rruZdispatch_methodpathrrr_marshaled_dispatchsz?http_multi_server..BrokenDispatcher._marshaled_dispatch)NN)r4r5r6rBrrrrBrokenDispatchersrCrF)r r!rFr") /foo/foo/bar/foo?k=v /foo#frag /foo?k=v#fragr//RPC2?k=v#fragcSs|SrUr)rrrrr#r$z#http_multi_server..testrrcSs||SrUrr*rrrr#r$r) /is/broken)rrZMultiPathXMLRPCServerr-rrr.r/r0r1r2r3Zadd_dispatcherrr4r5rZget_dispatcherr6r7rr8r9) r:r;r<rr(rr?rCr=pathsrAr1rrrhttp_multi_serversJ     rPcCs^z*|jdks|jdurWdS|jd}WntyDt|}Yn0|rZd|vrZdSdS)zReturns 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)Zerrcoderrrr0lower)eZexc_messrrris_unavailable_exceptions rTcs|s ddSfdd}|S)NcSs|SrUr)funcrrrr#r$z)make_request_and_skipIf..csfdd}|S)Nc sVzttWn4tjtfyF}zt|s2WYd}~n d}~00tdSrU) rrr2r( ProtocolErrorrrTunittestZSkipTest)rrSreasonrrmake_request_and_skips zImake_request_and_skipIf..decorator..make_request_and_skipr)rUrZrXrr decorators z*make_request_and_skipIf..decoratorr)Z conditionrYr[rrXrmake_request_and_skipIfs r\c@s,eZdZdZdZeeZddZddZ dS)BaseServerTestCaseNrcCs`dtjj_t|_|j|j|jf}tj |j |d}| | |j |j|jdS)NTrr)rrr,_send_traceback_headerrEventr: request_countr<r threadFuncrrrwaitclearrZ serv_argsrrrrsetUps    zBaseServerTestCase.setUpcCs|jdtjj_dSNF)r:rcrrr,r_rCrrrtearDown s zBaseServerTestCase.tearDown) r4r5r6r<rarr>rbrfrhrrrrr]s r]c@seZdZddZddZddZddZd d Zd d Zd dZ e e j j dkdddZddZddZddZddZddZddZdd Zd!d"Zd#d$Zd%S)&SimpleServerTestCasec Cstz"tt}||dddWnLtjtfyn}z.t|sZ|d|t |ddfWYd}~n d}~00dS)Nrr%s %srr) rrr2rr6rVrrTfailgetattrrrrSrrr test_simple1s  z!SimpleServerTestCase.test_simple1c Csd}d}z&tt}||||||WnLtjtfyz}z.t|sf|d|t |ddfWYd}~n d}~00dS)NuPŷtuhơnrkrr) rrr2rr)rVrrTrlrmrZ start_stringZ end_stringrrSrrr test_nonasciis z"SimpleServerTestCase.test_nonasciic Csd}d}z*tjtdd}||||||WnNtjtjfy}z.t|sl| d|t |ddfWYd}~n d}~00dS)N€¤rfrgrkrr rrr2rr)rVrerrorrTrlrmrprrrtest_client_encoding,sz)SimpleServerTestCase.test_client_encodingc Csxz$tjtdd}||ddWnNtjtjfyr}z.t|s^| d|t |ddfWYd}~n d}~00dS)Nrrgr`rkrr) rrr2rttêštrVrrurTrlrmrnrrrtest_nonascii_methodname:s z-SimpleServerTestCase.test_nonascii_methodnamecCshttjtt$}|dd|}Wdn1s>0Y| |j d| |j ddS)NZPOSTz/this-is-not-validiz Not Found) contextlibclosingrrZHTTPConnectionr0r1ZrequestZ getresponserstatusrY)rconnrrrrtest_404Ds  &zSimpleServerTestCase.test_404c Cstgd}z(tt}|j}|t||WnLtjtfy}z.t |sl| d|t |ddfWYd}~n d}~00dS)N) r6r r(r)r%zsystem.listMethodszsystem.methodHelpzsystem.methodSignaturezsystem.multicallrrkrr) r7rrr2systemZ listMethodsrrVrrTrlrm)rZexpected_methodsrmethrSrrrtest_introspection1Ns   z(SimpleServerTestCase.test_introspection1c Csxz&tt}|jd}||dWnLtjtfyr}z.t|s^| d|t |ddfWYd}~n d}~00dS)Nr r rkrr rrr2r}Z methodHelprrVrrTrlrm)rrZdivhelprSrrrtest_introspection2^s  z(SimpleServerTestCase.test_introspection2rz)Docstrings are omitted with -O2 and abovec Csxz&tt}|jd}||dWnLtjtfyr}z.t|s^| d|t |ddfWYd}~n d}~00dS)Nr(r'rkrrr)rrZ myfunctionrSrrrtest_introspection3js  z(SimpleServerTestCase.test_introspection3c Csxz&tt}|jd}||dWnLtjtfyr}z.t|s^| d|t |ddfWYd}~n d}~00dS)Nr zsignatures not supportedrkrr) rrr2r}ZmethodSignaturerrVrrTrlrm)rrZdivsigrSrrrtest_introspection4xs  z(SimpleServerTestCase.test_introspection4c Cszltt}t|}|dd|dd|dd|\}}}||d||d||dWnLtjt fy}z.t |s| d |t |d d fWYd}~n d}~00dS) NrrFrrr`rKrjrkrr) rrr2 MultiCallr)r6r rrVrrTrlrm)rr multicall add_resultZ pow_resultZ div_resultrSrrrtest_multicalls        z#SimpleServerTestCase.test_multicallc CszRtt}t|}||}||jddd||jdddWnLtjtfy}z.t |s| d|t |ddfWYd}~n d}~00dS) Nrrrrz@:method "this_is_not_exists" is not supportedrkrr) rrr2rZthis_is_not_existsrresultsrVrrTrlrm)rrrr)rSrrrtest_non_existing_multicalls  z0SimpleServerTestCase.test_non_existing_multicallcCs4|ttjjtd|tjtd|dSr)rArrrrr0rrorCrrrrs  z*SimpleServerTestCase.test_dotted_attributecCs,tdttf}|j}||ddS)Nhttp://%s:%d/RPC2r)rrr0r1rrr)rrrurrrtest_allow_dotted_names_trues z1SimpleServerTestCase.test_allow_dotted_names_truecCs*tdttf}||ddddS)Nrrzéuaé)rrr0r1rr)rrrrrtest_unicode_hostsz&SimpleServerTestCase.test_unicode_hostcCsVttttf.}|dtdtddWdn1sH0YdS)Nz@POST /RPC2 HTTP/1.0 Content-Length: 100 bye HTTP/1.1 Host: :z2 Accept-Encoding: identity Content-Length: 0 r)rxryrcreate_connectionr0r1sendrk)rr{rrrtest_partial_postsz&SimpleServerTestCase.test_partial_postcCs^tt.}|dd||djdWdn1s>0Y||djddS)NrrF transportNN)rrr2r)ZassertNotEqual _connectionrrrrrtest_context_managers   " z)SimpleServerTestCase.test_context_managercCsfz:tt}|ddWdn1s.0YWntjyNYn0||djddS)Nrrzrr)rrr2r)rrrrrrr!test_context_manager_method_errors . z6SimpleServerTestCase.test_context_manager_method_errorN)r4r5r6rorqrvrwr|rrr\rXflagsoptimizerrrrrrrrrrrrrrris(         ric@s"eZdZedddZddZdS)SimpleServerEncodingTestCaseNcCst|||ddS)Nrf)r>)r:r;r<rhrrrrbsz'SimpleServerEncodingTestCase.threadFuncc Csd}d}z&tt}||||||WnNtjtjfy|}z.t|sh| d|t |ddfWYd}~n d}~00dS)Nrrrsrkrrrtrprrrtest_server_encodings z1SimpleServerEncodingTestCase.test_server_encoding)NN)r4r5r6rrbrrrrrrs rc@speZdZeeZdZddZddZddZ dd Z d d Z d d Z ddZ ddZddZddZddZdS)MultiPathServerTestCasercCs:ttd}||ddd|tj|jdddS)NrDrrrj)rrr2rr6rArr)rrrrr test_path1sz"MultiPathServerTestCase.test_path1cCs:ttd}||ddd|tj|jdddS)NrErr)rrr2rr)rArr6rrrr test_path2sz"MultiPathServerTestCase.test_path2cCs&ttd}|tj|jdddS)NrNrrrrr2rArr)rrrr test_path3sz"MultiPathServerTestCase.test_path3cCs&ttd}|tj|jdddS)Nz/invalidrrrrrrrtest_invalid_pathsz)MultiPathServerTestCase.test_invalid_pathcCs"ttd}||ddS)NrHrrr2rrMrrrrtest_path_query_fragmentsz0MultiPathServerTestCase.test_path_query_fragmentcCs"ttd}||ddS)NrGrrrrrtest_path_fragmentsz*MultiPathServerTestCase.test_path_fragmentcCs"ttd}||ddS)NrFrrrrrtest_path_query sz'MultiPathServerTestCase.test_path_querycCstt}||ddS)NrJrrrrrtest_empty_paths z'MultiPathServerTestCase.test_empty_pathcCs"ttd}||ddS)NrIrrrrrtest_root_pathsz&MultiPathServerTestCase.test_root_pathcCs"ttd}||ddS)NrKrrrrrtest_empty_path_querysz-MultiPathServerTestCase.test_empty_path_querycCs"ttd}||ddS)NrLrrrrrtest_empty_path_fragmentsz0MultiPathServerTestCase.test_empty_path_fragmentN)r4r5r6rrPrbrarrrrrrrrrrrrrrrrsrc@s,eZdZGdddejjZeZddZdS)BaseKeepaliveServerTestCasec@s,eZdZejjZdZgZddZ ddZ dS)z*BaseKeepaliveServerTestCase.RequestHandlerrcCs(|jgt|jd|_|j|Sr) myRequestsrLrreqidx parentClasshandlerCrrrr*s z1BaseKeepaliveServerTestCase.RequestHandler.handlecCs$|j|}|j|j|j|SrU)rhandle_one_requestrrrLZraw_requestline)rr)rrrr.s z=BaseKeepaliveServerTestCase.RequestHandler.handle_one_requestN) r4r5r6rrr-rrrrrrrrrr&s rcCsg|j_t|SrU)rrr]rfrCrrrrf4sz!BaseKeepaliveServerTestCase.setUpN) r4r5r6rrr-rr<rfrrrrr#s rc@seZdZddZdS)KeepaliveServerTestCase1cCstt}||ddd||ddd||ddd|d|t|jjd|t|jjdddS)Nrrrjr9rrr rrr2rr6rrrZassertGreaterEqualrrrrtest_two<s  z!KeepaliveServerTestCase1.test_twoN)r4r5r6rrrrrr;src@s eZdZdZddZddZdS)KeepaliveServerTestCase2rcCstt}||ddd||ddd||ddd|d||ddd||ddd||ddd|d|t|jjd|t|jjdd|t|jjdddS)Nrrrjr9rrrrrrr test_closeRs   z#KeepaliveServerTestCase2.test_closecCs`tt}||ddd|d||ddd|d|t|jjddS)Nrrrjrr9r) rrr2rr6r9rrrrrrrtest_transportes    z'KeepaliveServerTestCase2.test_transportN)r4r5r6rarrrrrrrNsrz requires gzipc@sVeZdZGdddejjZeZGdddej Z ddZ ddZ d d Z d d Z d S)GzipServerTestCasec@s eZdZejjZdZddZdS)z!GzipServerTestCase.RequestHandlerrcCst|jd|j_|j|S)Ncontent-length)rZr __class__content_lengthrrrCrrrrxsz)GzipServerTestCase.RequestHandler.do_POSTN) r4r5r6rrr-rrrrrrrrtsrc@s eZdZdZddZddZdS)zGzipServerTestCase.TransportFcCs t|dd|_tj||S)Nrr)rZZ getheaderresponse_lengthrrparse_response)rrrrrrsz+GzipServerTestCase.Transport.parse_responsecCs"|jr|ddtj|||S)NzContent-Encodinggzip) fake_gzipZ putheaderrr send_content)r connectionbodyrrrrs z)GzipServerTestCase.Transport.send_contentN)r4r5r6rrrrrrrr~srcCst|dSrU)r]rfrCrrrrfszGzipServerTestCase.setUpcCsv|}d|_tjt|d}||ddd|jj}d|_||ddd|jj}| ||k|ddSNrrrrjrr9) rencode_thresholdrrr2rr6rrr)rr=rrzr{rrrtest_gzip_requestsz$GzipServerTestCase.test_gzip_requestcCst|}d|_d|_tjt|d}|tjt d}|| ddWdn1s\0Y|ddS)NTrz\b400\brrr9) rrrrrr2rrVrecompiler6)rr=rcmrrrtest_bad_gzip_requests*z(GzipServerTestCase.test_bad_gzip_requestcCs|}tjt|d}|jj}d|j_||ddd|j}d|j_||ddd|d|j}||j_| ||kdSr) rrrr2r<rrr6rr)rr=roldrzr{rrrtest_gzip_responses z%GzipServerTestCase.test_gzip_responseN)r4r5r6rrr-rr<rrrfrrrrrrrrps   rc@seZdZddZdS)GzipUtilTestCasecCsd}d|}t|}t|}|t||d|d}t|}|tdt|Wdn1sr0Ytj|dddS)Ni@rz#max gzipped payload length exceededr)Z max_decode)rZ gzip_encodeZ gzip_decoderrr ValueError)rZmax_gzip_decoderuencodedZdecodedrrrtest_gzip_decode_limits    (z'GzipUtilTestCase.test_gzip_decode_limitN)r4r5r6rrrrrrsrcsleZdZGdddejjZeZgdZfddZ ddZ dd Z d d Z d d Z ddZddZZS)HeadersServerTestCasecs eZdZdZfddZZS)z$HeadersServerTestCase.RequestHandlerNcs|j|j_tSrU)rr test_headerssuperrrCrrrrs z,HeadersServerTestCase.RequestHandler.do_POST)r4r5r6rr __classcell__rrrrrsr)ZHostzAccept-Encodingz Content-Typez User-Agentrcsd|j_tSrU)rrrrfrCrrrrfszHeadersServerTestCase.setUpcCsRt|jt|}|t|||D]\}}||||q2dSrU)sortedstandard_headerslistkeysZassertListEqualitemsrr)rr additionalZ expected_keyskeyr/rrrassertContainsAdditionalHeaderssz5HeadersServerTestCase.assertContainsAdditionalHeaderscCs@tjtdgd}||ddd|jj}||ddidS)NX-Testfoorrrrjrrrrr2rr6rrrrrrrrr test_headersz!HeadersServerTestCase.test_headercCsDtjtddgd}||ddd|jj}||ddd dS) Nr) X-Test-Secondbarrrrrjrr)rrrrrrrtest_header_manys z&HeadersServerTestCase.test_header_manycCs:tjtgd}||ddd|jj}||idS)Nrrrrjrrrrrtest_header_emptysz'HeadersServerTestCase.test_header_emptycCs>tjtdd}||ddd|jj}||ddidS)N)rrrrrjrrrrrrrtest_header_tuplesz'HeadersServerTestCase.test_header_tuplecCsFtjtddid}||ddd|jj}||ddidS)Nrrrrrrj) rrr2rrr6rrrrrrrtest_header_itemssz'HeadersServerTestCase.test_header_items)r4r5r6rrr-rr<rrfrrrrrrrrrrrrs  rc@s$eZdZddZddZddZdS)ServerProxyTestCasecCstj|d|_dS)Nzhttp://fake.localhost)rWTestCaserfrrCrrrrfs zServerProxyTestCase.setUpcCs"t|j}||dddS)Nr9)rrrrrrrrr s zServerProxyTestCase.test_closecCs,t}tj|j|d}||d|dS)Nrr)rrrrr)rr=rrrrrsz"ServerProxyTestCase.test_transportN)r4r5r6rfrrrrrrrsrcseZdZdfdd ZZS)FailingMessageClassNcs"|}|dkrdSt||S)Nrz I am broken)rRrr)rrZfailobjrrrrszFailingMessageClass.get)N)r4r5r6rrrrrrrsrc@s4eZdZddZddZddZddZd d Zd S) FailingServerTestCasecCsNt|_|jdf}tjt|d}|||j|j|j dS)Nrr^) rr`r:rr>rrrrcrdrerrrrf"s    zFailingServerTestCase.setUpcCs*|jdtjj_tjj}|tjj _ dSrg) r:rcrrr,r_rr HTTPMessager- MessageClass)rZ default_classrrrrh.s  zFailingServerTestCase.tearDownc Cstjjj}||ddtjj_z"tt}||dddWnLtj t fy}z.t |sz| d|t |ddfWYd}~n d}~00dS) NFTrrrjrkrr)rrr,r_rrrr2r6rVrrTrlrm)rZflagvalrrSrrr test_basic7s    z FailingServerTestCase.test_basicc Csttjj_ztt}|ddWnhtj t fy}zJt |sxt |drx| |jddu| |jdduWYd}~nd}~00|ddS)NrrrrQ X-tracebackProtocolError not raised)rrrr-rrrr2r6rVrrThasattrrrrrlrnrrrtest_fail_no_infoIs  ,z'FailingServerTestCase.test_fail_no_infoc Csttjj_dtjj_ztt }| ddWnjtj t fy}zLt |st|drd}||jd|||jdduWYd}~nd}~00|ddS) NTrrrz5invalid literal for int() with base 10: 'I am broken'rQrr)rrrr-rr,r_rrr2r6rVrrTrrrrrrl)rrrSZ expected_errrrrtest_fail_with_infoYs   ,z)FailingServerTestCase.test_fail_with_infoN)r4r5r6rfrhrrrrrrrr!s   rutf-8ccs:tj}tjt|dt_ztjVW|t_n|t_0dS)zhA variation on support.captured_stdout() which gives a text stream having a `buffer` attribute. rgN)rXstdoutio TextIOWrapperBytesIO)rhZ orig_stdoutrrrcaptured_stdoutos  rc@s,eZdZddZddZddZddZd S) CGIHandlerTestCasecCstj|_dSrU)rrCGIXMLRPCRequestHandlercgirCrrrrf}szCGIHandlerTestCase.setUpcCs d|_dSrU)rrCrrrrhszCGIHandlerTestCase.tearDownc Cst}d|d<t|jjd}|jWdn1s@0Y|d|}|d}d |dd}| |d | |d Wdn1s0YdS) NGETZREQUEST_METHODrgrr rrJZ400z Bad Request) rEnvironmentVarGuardrrrhrseekrsplitrr)renvdata_outrrzmessagerrr test_cgi_gets (   zCGIHandlerTestCase.test_cgi_getc Csd}t}t|jjdf}t>}|||dtt ||d<|j Wdn1sj0YWdn1s0YWdn1s0Y|d| }| t jt j|dd||dd}|ttd|dt |dS) Naw test_method foo bar rgrZCONTENT_LENGTH,zUseBuiltinTypesTestCase.test_use_builtin_types..foobarT)rcrhr r)rr"rrrrrrrBrrr$r%rn)rZexpected_bytesZ expected_dateZ marshaledrhandlerZmybytesZmydaterrCrtest_use_builtin_typess    z.UseBuiltinTypesTestCase.test_use_builtin_typescCstjjdd}||jdS)NTr)rrrrr )rrrrr*test_cgihandler_has_use_builtin_types_flagszBUseBuiltinTypesTestCase.test_cgihandler_has_use_builtin_types_flagcCs(tjjddd}|||jdS)NrTr)rrr,rrr rrrr,test_xmlrpcserver_has_use_builtin_types_flags zDUseBuiltinTypesTestCase.test_xmlrpcserver_has_use_builtin_types_flagN)r4r5r6rrrrrrrrsrcCs t}tjtjg|RdSrU)rZthreading_setuprWZaddModuleCleanupZthreading_cleanup) thread_inforrr setUpModulesr__main__)NN)N)r)Err"rrXrrWr xmlrpc.clientrrZ xmlrpc.serverrZ http.clientrZ http.serverrrrrrxrMrZ test.supportrrrrrrrmror#rrrrrrrrr0r1r2r>rPrTr\r]rirrrrrZskipIfrrrrrrrcontextmanagerrrrrr4mainrrrrs       3W_  @ HH4"C>N D!