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__rrrrTrsr8dZHello)objectxyrrrr__dict__)rr8tt2r2rrrtest_newstyle_classqs z"XMLRPCTestCase.test_newstyle_classcCs|ttjddfdS)Nrc) assertRaises OverflowErrorrrrrrrtest_dump_big_longzsz!XMLRPCTestCase.test_dump_big_longcCs|ttjddifdS)NrrrrB TypeErrorrrrDrrrtest_dump_bad_dict}sz!XMLRPCTestCase.test_dump_bad_dictcCs4gd}ddd|g}|||ttj|fdS)NrFrG)appendrBrIrr)rlr>rrrtest_dump_recursive_seqs  z&XMLRPCTestCase.test_dump_recursive_seqcCs2ddd}d|d}||d<|ttj|fdS)Nr)12rG)3r1r>rHrr1r>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) sysmaxsizerBrCrrintMAXINTMININT MarshallerZdump_intrrXr*rrrtest_dump_big_ints*          z XMLRPCTestCase.test_dump_big_intcCsttdftttjttjftttjdttjdfdd}t}|tj||tj||tjd||tjd|dS)NrU*cSsdSrVrrWrrrrXsz4XMLRPCTestCase.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)rrrrrrBrI)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)rir.u method€¤)ri methodnamer)rrrrencode)rr/rerkrrrtest_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 ResponseErrorrBr)rrudatarrrtest_loads_unsupportedsz%XMLRPCTestCase.test_loads_unsupportedcKsRd|}tj|fi|\}}|\}||||t|t|||dS)Nz1%s)rrrr$r%r&)rr(r/kwargsrr)r*rsrrr 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)ryrrnr#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)rydecimalZDecimalr}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)rLr-F)r[headersgetZrfilereadhandledZclose_connectionrrrlZ send_responsehttpZ HTTPStatusZOKZ send_headerlenZ end_headersZwfilewrite)rlengthresponserrrdo_POST:s  zHXMLRPCTestCase.test_keepalive_disconnect..RequestHandler.do_POSTcWsdSrVr)rformatargsrrr log_messageIszLXMLRPCTestCase.test_keepalive_disconnect..RequestHandler.log_messageN)r5r6r7protocol_versionrrrrrrrRequestHandler6srcs$jtddSNr)socket settimeoutrbhandle_requestrserverrr run_serverMsz.run_serverr)targetz http://{}:{}/rL)rrZBaseHTTPRequestHandlerZ HTTPServerrZHOST addCleanup server_close threadingThreadstartjoinrZserver_addressrrrmethod)rrrthreadurlprrrtest_keepalive_disconnect5s      z(XMLRPCTestCase.test_keepalive_disconnectN)r5r6r7rr+r,r3r@rErJrOrTr`rcrfrmrtrwryrrrrrrrrrr,s*"   rc@sLeZdZGdddeZddZddZddZd d Zd d Z d dZ dS)SimpleXMLRPCDispatcherTestCasec@s eZdZdS)z*SimpleXMLRPCDispatcherTestCase.DispatchExcNr4rrrr DispatchExc^srcsd}fdd}tj}||j}|d|Wdn1sR0Y|jj |f |jj  |jj dS)NrFcs|dSrV)r)paramsrDrrdispatched_funciszQSimpleXMLRPCDispatcherTestCase.test_call_registered_func..dispatched_funcr) rrSimpleXMLRPCDispatcherregister_functionrBr _dispatchr exceptionrr& __cause__ __context__)r exp_paramsr dispatcherexc_ctxrrDrtest_call_registered_funcbs   *z8SimpleXMLRPCDispatcherTestCase.test_call_registered_funccCsd}Gddd}tj}||||j}|d|Wdn1sV0Y||jj |f| |jj | |jj dS)NrFc@seZdZddZdS)zOSimpleXMLRPCDispatcherTestCase.test_call_instance_func..DispatchedClasscWst|dSrVrr)rrrrrr|sz_SimpleXMLRPCDispatcherTestCase.test_call_instance_func..DispatchedClass.dispatched_funcN)r5r6r7rrrrrDispatchedClass{srr rrrregister_instancerBrrrrrr&rr)rrrrrrrrtest_call_instance_functs  *z6SimpleXMLRPCDispatcherTestCase.test_call_instance_funccCsd}d}Gddd}tj}||||j}|||Wdn1sZ0Y||jj ||f| |jj | |jj dS)NrrFc@seZdZddZdS)zLSimpleXMLRPCDispatcherTestCase.test_call_dispatch_func..TestInstancecSst||dSrVr)rrrrrrrszVSimpleXMLRPCDispatcherTestCase.test_call_dispatch_func..TestInstance._dispatchN)r5r6r7rrrrr TestInstancesrr)rZ exp_methodrrrrrrrtest_call_dispatch_funcs  *z6SimpleXMLRPCDispatcherTestCase.test_call_dispatch_funccCsTtj}|jddd|td|ddWdn1sF0YdS)NrnameZparam)rrrrassertRaisesRegex Exceptionrrrrrrtest_registered_func_is_nones z;SimpleXMLRPCDispatcherTestCase.test_registered_func_is_nonecCsRtj}|t|td|ddWdn1sD0YdSNrr)rrrrr:rrrrrrrtest_instance_has_no_funcs  z8SimpleXMLRPCDispatcherTestCase.test_instance_has_no_funccCsFtj}|td|ddWdn1s80YdSr)rrrrrrrrrrtest_cannot_locate_funcs z6SimpleXMLRPCDispatcherTestCase.test_cannot_locate_funcN) r5r6r7rrrrrrrrrrrrr]src@seZdZddZdS)HelperTestCasecCs:|tdd|tdd|tdddS)Nza&bza&bzabza>b)rrescaperDrrr test_escapeszHelperTestCase.test_escapeN)r5r6r7rrrrrrsrc@s$eZdZddZddZddZdS) FaultTestCasecCs4tdd}|t|d|t|t|dS)Nra Test Faultz)rFaultrreprr0)rfrrr test_reprs zFaultTestCase.test_reprcCsjtdd}t|f}t|\\}}||ddd||dt|}|tjtj|dS)Nrar) faultCode faultString)rrrrrr^rB)rrr(Znewfr*rrrtest_dump_faults   zFaultTestCase.test_dump_faultcCs,|ttjjtd|tjtddSNZ__addtitle)rBAttributeErrorrrresolve_dotted_attributer0rrDrrrtest_dotted_attributes z#FaultTestCase.test_dotted_attributeN)r5r6r7rrrrrrrrs 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#rr0rrrrSrrr test_times   zDateTimeTestCase.test_timecCs"d}t|}|t|ddS)N)  r &2rLrz20070609T10:38:50)rr#rr0rSrrrtest_time_tuples z DateTimeTestCase.test_time_tuplecCs0td}t|}|t|td|dSr)rrrr#rr0rrSrrrtest_time_structs  z!DateTimeTestCase.test_time_structcCs2tdddddd}t|}|t|ddS)NrrrrGrKrLz20070102T03:04:05)r"rr#rr0rSrrrtest_datetime_datetimes z'DateTimeTestCase.test_datetime_datetimecCs>tdddddd}t|}dt|}|t||dS)NrrrrGrKrLz%)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)NrK)Zsecondsrasciii)r"nowrr#Z timetuplerZ timedeltarrlrrprBrIrbrrr)rrZdtimeZthenZdstrZ dtime_thenZdbytesZdtuplerrrtest_comparisonsJ    , ( , (z DateTimeTestCase.test_comparisonN) r5r6r7rrrrrrrrrrrrrs  rc@s$eZdZddZddZddZdS)BinaryTestCasecCst}|t|ddS)Nrrnrr0)rr>rrrr7szBinaryTestCase.test_defaultcCs(d}t|}|t|t|ddSNs abc123zlatin-1rrSrrr test_string;s zBinaryTestCase.test_stringcCsZd}t|}t}|||t|t|dt|}|t|t|ddSr)base64Z encodebytesrrnrrr0Z_binary)rr1derr?rrrr@s   zBinaryTestCase.test_decodeN)r5r6r7rrrrrrrr0src 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||SrVrrr;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)r5r6r7 staticmethodrrrrrFixtureYsrN)r5r6r7r rrrrrrTestInstanceClassQsrc@seZdZddZdS)z#http_server..MyXMLRPCServercSs |j\}}|d||fSNTraccept setblockingrr(portrrr get_request_s z/http_server..MyXMLRPCServer.get_requestNr5r6r7rrrrrMyXMLRPCServer^sr localhostrF)ri logRequestsbind_and_activate http://%s:%dcSs|SrVr)r;rrrxzhttp_server..têštcSsdSrrrrrr my_functionysz http_server..my_functionaddrcSs||SrVrr;r<rrr_}szhttp_server.._T)Zallow_dotted_namesrr)rrSimpleXMLRPCServerSimpleXMLRPCRequestHandler server_bindr getsocknameADDRPORTURLserver_activate register_introspection_functionsregister_multicall_functionsrpowrsetrtimeoutclose) evt numrequestsrequestHandlerrirrservr'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||SrVrr rrrr sz0http_multi_server..TestInstanceClass.divcSs|dkr dSdSr rrrrrrsz8http_multi_server..TestInstanceClass._methodHelpN)r5r6r7r rrrrrrsrcSsdSrrrrrrr'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)r5r6r7Z rpc_pathsrrrrMyRequestHandlersr>c@seZdZdddZdS)z+http_multi_server..BrokenDispatcherNcSs tddS)Nzbroken dispatcher) RuntimeError)rrvZdispatch_methodpathrrr_marshaled_dispatchsz?http_multi_server..BrokenDispatcher._marshaled_dispatch)NN)r5r6r7rArrrrBrokenDispatchersrBrF)r!r"rGr#) /foo/foo/bar/foo?k=v /foo#frag /foo?k=v#fragr//RPC2?k=v#fragcSs|SrVr)rrrrr$r%z#http_multi_server..testrrcSs||SrVrr)rrrr$r%r( /is/broken)rrZMultiPathXMLRPCServerr,rrr-r.r/r0r1r2Zadd_dispatcherrr3r4rZget_dispatcherr5r6rr7r8) r9r:r;rr'rr>rBr<pathsr@r1rrrhttp_multi_serversJ     rOcCs^z*|jdks|jdurWdS|jd}WntyDt|}Yn0|rZd|vrZdSdS)NrT X-exceptionztemporarily unavailable)Zerrcoderrrr0lower)eZexc_messrrris_unavailable_exceptions rScs|s ddSfdd}|S)NcSs|SrVr)funcrrrr$r%z)make_request_and_skipIf..csfdd}|S)Nc sVzttWn4tjtfyF}zt|s2WYd}~n d}~00tdSrV) rrr1r' ProtocolErrorrrSunittestZSkipTest)rrRreasonrrmake_request_and_skips zImake_request_and_skipIf..decorator..make_request_and_skipr)rTrYrWrr decorators z*make_request_and_skipIf..decoratorr)Z conditionrXrZrrWrmake_request_and_skipIfs r[c@s,eZdZdZdZeeZddZddZ dS)BaseServerTestCaseNrcCs`dtjj_t|_|j|j|jf}tj |j |d}| | |j |j|jdS)NTrr)rrr+_send_traceback_headerrEventr9 request_countr;r threadFuncrrrwaitclearrZ serv_argsrrrrsetUps    zBaseServerTestCase.setUpcCs|jdtjj_dSNF)r9rbrrr+r^rDrrrtearDown s zBaseServerTestCase.tearDown) r5r6r7r;r`rr=rarergrrrrr\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) rrr1rr5rUrrSfailgetattrrrrRrrr test_simple1s  z!SimpleServerTestCase.test_simple1c Csd}d}z&tt}||||||WnLtjtfyz}z.t|sf|d|t |ddfWYd}~n d}~00dS)NuPŷtuhơnrjrr) rrr1rr(rUrrSrkrlrZ start_stringZ end_stringrrRrrr test_nonasciis z"SimpleServerTestCase.test_nonasciic Csd}d}z*tjtdd}||||||WnNtjtjfy}z.t|sl| d|t |ddfWYd}~n d}~00dS)N€¤rgrhrjrr rrr1rr(rUrerrorrSrkrlrorrrtest_client_encoding,sz)SimpleServerTestCase.test_client_encodingc Csxz$tjtdd}||ddWnNtjtjfyr}z.t|s^| d|t |ddfWYd}~n d}~00dS)Nrrhrarjrr) rrr1rttêštrUrrtrSrkrlrmrrrtest_nonascii_methodname:s z-SimpleServerTestCase.test_nonascii_methodnamecCshttjtt$}|dd|}Wdn1s>0Y| |j d| |j ddS)NZPOSTz/this-is-not-validiz Not Found) contextlibclosingrrZHTTPConnectionr/r0ZrequestZ getresponserstatusrX)rconnrrrrtest_404Ds  &zSimpleServerTestCase.test_404c Cstgd}z(tt}|j}|t||WnLtjtfy}z.t |sl| d|t |ddfWYd}~n d}~00dS)N) r5r r'r(r&zsystem.listMethodszsystem.methodHelpzsystem.methodSignaturezsystem.multicallrrjrr) r6rrr1systemZ listMethodsrrUrrSrkrl)rZexpected_methodsrmethrRrrrtest_introspection1Ns   z(SimpleServerTestCase.test_introspection1c Csxz&tt}|jd}||dWnLtjtfyr}z.t|s^| d|t |ddfWYd}~n d}~00dS)Nr rrjrr rrr1r|Z methodHelprrUrrSrkrl)rrZdivhelprRrrrtest_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'zThis is my functionrjrrr)rrZ myfunctionrRrrrtest_introspection3js  z(SimpleServerTestCase.test_introspection3c Csxz&tt}|jd}||dWnLtjtfyr}z.t|s^| d|t |ddfWYd}~n d}~00dS)Nr zsignatures not supportedrjrr) rrr1r|ZmethodSignaturerrUrrSrkrl)rrZdivsigrRrrrtest_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) NrrGrrrarLrirjrr) rrr1 MultiCallr(r5r rrUrrSrkrl)rr multicall add_resultZ pow_resultZ div_resultrRrrrtest_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 supportedrjrr) rrr1rZthis_is_not_existsrresultsrUrrSrkrl)rrrr)rRrrrtest_non_existing_multicalls  z0SimpleServerTestCase.test_non_existing_multicallcCs4|ttjjtd|tjtd|dSr)rBrrrrr0rrnrDrrrrs  z*SimpleServerTestCase.test_dotted_attributecCs,tdttf}|j}||ddS)Nhttp://%s:%d/RPC2r)rrr/r0rrr)rrrvrrrtest_allow_dotted_names_trues z1SimpleServerTestCase.test_allow_dotted_names_truecCs*tdttf}||ddddS)Nrr{éuaé)rrr/r0rr(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)rwrxrcreate_connectionr/r0sendrl)rrzrrrtest_partial_postsz&SimpleServerTestCase.test_partial_postcCs^tt.}|dd||djdWdn1s>0Y||djddS)NrrG transportNN)rrr1r(ZassertNotEqual _connectionrrrrrtest_context_managers   " z)SimpleServerTestCase.test_context_managercCsfz:tt}|ddWdn1s.0YWntjyNYn0||djddS)Nrr{rr)rrr1r(rrrrrrr!test_context_manager_method_errors . z6SimpleServerTestCase.test_context_manager_method_errorN)r5r6r7rnrprurvr{r~rr[rYflagsoptimizerrrrrrrrrrrrrrrhs(         rhc@s"eZdZedddZddZdS)SimpleServerEncodingTestCaseNcCst|||ddS)Nrg)r=)r9r:r;rirrrrasz'SimpleServerEncodingTestCase.threadFuncc Csd}d}z&tt}||||||WnNtjtjfy|}z.t|sh| d|t |ddfWYd}~n d}~00dS)Nrqrrrjrrrsrorrrtest_server_encodings z1SimpleServerEncodingTestCase.test_server_encoding)NN)r5r6r7rrarrrrrrs rc@speZdZeeZdZddZddZddZ dd Z d d Z d d Z ddZ ddZddZddZddZdS)MultiPathServerTestCasercCs:ttd}||ddd|tj|jdddS)NrCrrri)rrr1rr5rBrr(rrrrr test_path1sz"MultiPathServerTestCase.test_path1cCs:ttd}||ddd|tj|jdddS)NrDrr)rrr1rr(rBrr5rrrr test_path2sz"MultiPathServerTestCase.test_path2cCs&ttd}|tj|jdddS)NrMrrrrr1rBrr(rrrr test_path3sz"MultiPathServerTestCase.test_path3cCs&ttd}|tj|jdddS)Nz/invalidrrrrrrrtest_invalid_pathsz)MultiPathServerTestCase.test_invalid_pathcCs"ttd}||ddS)NrGrrr1rrLrrrrtest_path_query_fragmentsz0MultiPathServerTestCase.test_path_query_fragmentcCs"ttd}||ddS)NrFrrrrrtest_path_fragmentsz*MultiPathServerTestCase.test_path_fragmentcCs"ttd}||ddS)NrErrrrrtest_path_query sz'MultiPathServerTestCase.test_path_querycCstt}||ddS)NrIrrrrrtest_empty_paths z'MultiPathServerTestCase.test_empty_pathcCs"ttd}||ddS)NrHrrrrrtest_root_pathsz&MultiPathServerTestCase.test_root_pathcCs"ttd}||ddS)NrJrrrrrtest_empty_path_querysz-MultiPathServerTestCase.test_empty_path_querycCs"ttd}||ddS)NrKrrrrrtest_empty_path_fragmentsz0MultiPathServerTestCase.test_empty_path_fragmentN)r5r6r7rrOrar`rrrrrrrrrrrrrrrrsrc@s,eZdZGdddejjZeZddZdS)BaseKeepaliveServerTestCasec@s,eZdZejjZdZgZddZ ddZ dS)z*BaseKeepaliveServerTestCase.RequestHandlerrcCs(|jgt|jd|_|j|Sr) myRequestsrMrreqidx parentClasshandlerDrrrr*s z1BaseKeepaliveServerTestCase.RequestHandler.handlecCs$|j|}|j|j|j|SrV)rhandle_one_requestrrrMZraw_requestline)rr)rrrr.s z=BaseKeepaliveServerTestCase.RequestHandler.handle_one_requestN) r5r6r7rrr,rrrrrrrrrr&s rcCsg|j_t|SrV)rrr\rerDrrrre4sz!BaseKeepaliveServerTestCase.setUpN) r5r6r7rrr,rr;rerrrrr#s rc@seZdZddZdS)KeepaliveServerTestCase1cCstt}||ddd||ddd||ddd|d|t|jjd|t|jjdddS)Nrrrir8rrr rrr1rr5rrrZassertGreaterEqualrrrrtest_two<s  z!KeepaliveServerTestCase1.test_twoN)r5r6r7rrrrrr;src@s eZdZdZddZddZdS)KeepaliveServerTestCase2rcCstt}||ddd||ddd||ddd|d||ddd||ddd||ddd|d|t|jjd|t|jjdd|t|jjdddS)Nrrrir8rrrrrrr test_closeRs   z#KeepaliveServerTestCase2.test_closecCs`tt}||ddd|d||ddd|d|t|jjddS)Nrrrirr8r) rrr1rr5r8rrrrrrrtest_transportes    z'KeepaliveServerTestCase2.test_transportN)r5r6r7r`rrrrrrrNsrz 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)r[r __class__content_lengthrrrDrrrrxsz)GzipServerTestCase.RequestHandler.do_POSTN) r5r6r7rrr,rrrrrrrrtsrc@s eZdZdZddZddZdS)zGzipServerTestCase.TransportFcCs t|dd|_tj||S)Nrr)r[Z 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)r5r6r7rrrrrrrr~srcCst|dSrV)r\rerDrrrreszGzipServerTestCase.setUpcCsv|}d|_tjt|d}||ddd|jj}d|_||ddd|jj}| ||k|ddSNrrrrirr8) rencode_thresholdrrr1rr5rrr)rr>rr{r|rrrtest_gzip_requestsz$GzipServerTestCase.test_gzip_requestcCst|}d|_d|_tjt|d}|tjt d}|| ddWdn1s\0Y|ddS)NTrz\b400\brrr8) rrrrrr1rrUrecompiler5)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) rrrr1r;rrr5rr)rr>roldr{r|rrrtest_gzip_responses z%GzipServerTestCase.test_gzip_responseN)r5r6r7rrr,rr;rrrerrrrrrrrps   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_decodervencodedZdecodedrrrtest_gzip_decode_limits    (z'GzipUtilTestCase.test_gzip_decode_limitN)r5r6r7rrrrrrsrcsleZdZGdddejjZeZgdZfddZ ddZ dd Z d d Z d d Z ddZddZZS)HeadersServerTestCasecs eZdZdZfddZZS)z$HeadersServerTestCase.RequestHandlerNcs|j|j_tSrV)rr test_headerssuperrrDrrrrs z,HeadersServerTestCase.RequestHandler.do_POST)r5r6r7rr __classcell__rrrrrsr)ZHostzAccept-Encodingz Content-Typez User-Agentrcsd|j_tSrV)rrrrerDrrrreszHeadersServerTestCase.setUpcCsRt|jt|}|t|||D]\}}||||q2dSrV)sortedstandard_headerslistkeysZassertListEqualitemsrr)rr additionalZ expected_keyskeyr/rrrassertContainsAdditionalHeaderssz5HeadersServerTestCase.assertContainsAdditionalHeaderscCs@tjtdgd}||ddd|jj}||ddidS)NX-Testfoorrrrirrrrr1rr5rrrrrrrrr test_headersz!HeadersServerTestCase.test_headercCsDtjtddgd}||ddd|jj}||ddd dS) Nr) X-Test-Secondbarrrrrirr)rrrrrrrtest_header_manys z&HeadersServerTestCase.test_header_manycCs:tjtgd}||ddd|jj}||idS)Nrrrrirrrrrtest_header_emptysz'HeadersServerTestCase.test_header_emptycCs>tjtdd}||ddd|jj}||ddidS)N)rrrrrirrrrrrrtest_header_tuplesz'HeadersServerTestCase.test_header_tuplecCsFtjtddid}||ddd|jj}||ddidS)Nrrrrrri) rrr1rrr5rrrrrrrtest_header_itemssz'HeadersServerTestCase.test_header_items)r5r6r7rrr,rr;rrerrrrrrrrrrrrs  rc@s$eZdZddZddZddZdS)ServerProxyTestCasecCstj|d|_dS)Nzhttp://fake.localhost)rVTestCasererrDrrrres zServerProxyTestCase.setUpcCs"t|j}||dddS)Nr8)rrrrrrrrr s zServerProxyTestCase.test_closecCs,t}tj|j|d}||d|dS)Nrr)rrrrr)rr>rrrrrsz"ServerProxyTestCase.test_transportN)r5r6r7rerrrrrrrsrcseZdZdfdd ZZS)FailingMessageClassNcs"|}|dkrdSt||S)Nrz I am broken)rQrr)rrZfailobjrrrrszFailingMessageClass.get)N)r5r6r7rrrrrrrsrc@s4eZdZddZddZddZddZd d Zd S) FailingServerTestCasecCsNt|_|jdf}tjt|d}|||j|j|j dS)Nrr]) rr_r9rr=rrrrbrcrdrrrre"s    zFailingServerTestCase.setUpcCs*|jdtjj_tjj}|tjj _ dSrf) r9rbrrr+r^rr HTTPMessager, MessageClass)rZ default_classrrrrg.s  zFailingServerTestCase.tearDownc Cstjjj}||ddtjj_z"tt}||dddWnLtj t fy}z.t |sz| d|t |ddfWYd}~n d}~00dS) NFTrrrirjrr)rrr+r^rrrr1r5rUrrSrkrl)rZflagvalrrRrrr test_basic7s    z FailingServerTestCase.test_basicc Csttjj_ztt}|ddWnhtj t fy}zJt |sxt |drx| |jddu| |jdduWYd}~nd}~00|ddS)NrrrrP X-tracebackProtocolError not raised)rrrr,rrrr1r5rUrrShasattrrrrrkrmrrrtest_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'rPrr)rrrr,rr+r^rrr1r5rUrrSrrrrrrk)rrrRZ expected_errrrrtest_fail_with_infoYs   ,z)FailingServerTestCase.test_fail_with_infoN)r5r6r7rergrrrrrrrr!s   rutf-8ccs:tj}tjt|dt_ztjVW|t_n|t_0dS)Nrh)rYstdoutio TextIOWrapperBytesIO)riZ orig_stdoutrrrcaptured_stdoutos  rc@s,eZdZddZddZddZddZd S) CGIHandlerTestCasecCstj|_dSrV)rrCGIXMLRPCRequestHandlercgirDrrrre}szCGIHandlerTestCase.setUpcCs d|_dSrV)rrDrrrrgszCGIHandlerTestCase.tearDownc Cst}d|d<t|jjd}|jWdn1s@0Y|d|}|d}d |dd}| |d | |d Wdn1s0YdS) NGETZREQUEST_METHODrhrr rrKZ400z Bad Request) rEnvironmentVarGuardrrrirseekrsplitrr)renvdata_outrrymessagerrr 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 rhrZCONTENT_LENGTH,zUseBuiltinTypesTestCase.test_use_builtin_types..foobarT)rdrir r)rr"rrrrrrrArrr$r%ro)rZexpected_bytesZ expected_dateZ marshaledrhandlerZmybytesZmydaterrDrtest_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)r5r6r7rrrrrrrrsrcCs t}tjtjg|RdSrV)rZthreading_setuprVZaddModuleCleanupZthreading_cleanup) thread_inforrr setUpModulesr__main__)NN)N)r)Er r"rrYrrVr xmlrpc.clientrrZ xmlrpc.serverrZ http.clientrZ http.serverrrrrrwrLrZ test.supportrrrrrrrnrpr#rrrrrrrrr/r0r1r=rOrSr[r\rhrrrrrZskipIfrrrrrrrcontextmanagerrrrrr5mainrrrrs       3W_  @ HH4"C>N D!