Ë
    ojhw  ã                   óÊ  — d Z ddlZddlmZmZ ddlmZ ddlmZm	Z	 ddl
mZ ddlmZmZ ddlmZmZmZmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZ ddlmZmZmZm Z m!Z! ddl"m#Z# ddl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z* 	  ed«       dZ+ G d„ dejZ                  «      Z. G d„ de/«      Z0 G d„ de1«      Z2 G d„ de%«      Z3 G d„ de%«      Z4 G d„ de%«      Z5 G d„ d e3«      Z6 G d!„ d"e!jn                  «      Z8 G d#„ d$e!jL                  «      Z9 G d%„ d&e!jL                  «      Z: G d'„ d(ejZ                  «      Z; G d)„ d*e;«      Z< G d+„ d,ejZ                  «      Z= G d-„ d.«      Z> G d/„ d0e>ejZ                  «      Z? G d1„ d2e>ejZ                  «      Z@ G d3„ d4e;«      ZA G d5„ d6e;«      ZB G d7„ d8ejZ                  «      ZC G d9„ d:ejZ                  «      ZD G d;„ d<ejZ                  «      ZEy# e,$ r dZ+Y �Œaw xY w)=z6
Tests for  XML-RPC support in L{twisted.web.xmlrpc}.
é    N)ÚBytesIOÚStringIO)ÚskipIf)ÚdeferÚreactor)ÚConnectionDone)ÚEventLoggingObserverÚMemoryReactor)ÚFilteringLogObserverÚLogLevelÚLogLevelFilterPredicateÚglobalLogPublisher)Úfailure)ÚnativeStringÚnetworkString)ÚnamedModule)Úunittest)ÚclientÚhttpÚserverÚstaticÚxmlrpc)ÚDummyRequest)ÚXMLRPCÚQueryFactoryÚaddIntrospectionÚpayloadTemplateÚwithRequestÚ	xmlrpclibztwisted.internet.sslFTc                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)ÚAsyncXMLRPCTestsz5
    Tests for L{XMLRPC}'s support of Deferreds.
    c                 ó&  ‡— t        dg«      | _        d| j                  _        t        t        dt        j                  d«      fz  «      | j                  _        t        j                  «       xŠ| _
         G ˆfd„dt        «      } |«       | _        y )NÚ ÚPOSTÚasync© c                   ó   •— e Zd Zˆ fd„Zy)ú-AsyncXMLRPCTests.setUp.<locals>.AsyncResourcec                 ó   •— ‰S ©Nr&   )ÚselfÚresults    €ú>/usr/lib/python3/dist-packages/twisted/web/test/test_xmlrpc.pyÚxmlrpc_asyncz:AsyncXMLRPCTests.setUp.<locals>.AsyncResource.xmlrpc_async=   s   ø€ Ø�ó    N)Ú__name__Ú
__module__Ú__qualname__r.   ©r,   s   €r-   ÚAsyncResourcer(   <   s   ø„ õr/   r4   )r   ÚrequestÚmethodr   r   r   ÚdumpsÚcontentr   ÚDeferredr,   r   Úresource)r+   r4   r,   s     @r-   ÚsetUpzAsyncXMLRPCTests.setUp3   sp   ø€ Ü# R DÓ)ˆŒØ$ˆ�‰ÔÜ'Ü˜w¬	¯©¸Ó(;Ð<Ñ<ó 
ˆ�‰Ôô  %Ÿ~™~Ó/Ð/ˆ�”ö	œFô 	ñ &›ˆ�r/   c                 ó°  — | j                   j                  | j                  «       | j                  | j                  j                  g «       | j
                  j                  d«       t        j                  dj                  | j                  j                  «      «      }| j                  |d«       | j                  | j                  j                  d«       y)zž
        If an L{XMLRPC} C{xmlrpc_*} method returns a L{defer.Deferred}, the
        response to the request is the result of that L{defer.Deferred}.
        r,   r/   )r3   Né   N)r:   Úrenderr5   ÚassertEqualÚwrittenr,   Úcallbackr   ÚloadsÚjoinÚfinished)r+   Úresps     r-   Útest_deferredResponsez&AsyncXMLRPCTests.test_deferredResponseB   s’   € ð
 	�‰×Ñ˜TŸ\™\Ô*Ø×Ñ˜Ÿ™×-Ñ-¨rÔ2à�‰×Ñ˜XÔ&ä�‰˜sŸx™x¨¯©×(<Ñ(<Ó=Ó>ˆØ×Ñ˜Ð2Ô3Ø×Ñ˜Ÿ™×.Ñ.°Õ2r/   c                 óŠ  — | j                   j                  | j                  «       | j                  j                  t	        j
                  t        d«      «      «       | j                  j                  d«       | j                  | j                  j                  g «       | j                  | j                  j                  d«       y)a   
        While waiting for the L{Deferred} returned by an L{XMLRPC} C{xmlrpc_*}
        method to fire, the connection the request was issued over may close.
        If this happens, neither C{write} nor C{finish} is called on the
        request.
        Ú	Simulatedr,   r   N)r:   r>   r5   ÚprocessingFailedr   ÚFailurer   r,   rA   r?   r@   rD   ©r+   s    r-   Ú test_interruptedDeferredResponsez1AsyncXMLRPCTests.test_interruptedDeferredResponseP   s€   € ð 	�‰×Ñ˜TŸ\™\Ô*Ø�‰×%Ñ%¤g§o¡o´nÀ[Ó6QÓ&RÔSØ�‰×Ñ˜XÔ&Ø×Ñ˜Ÿ™×-Ñ-¨rÔ2Ø×Ñ˜Ÿ™×.Ñ.°Õ2r/   N)r0   r1   r2   Ú__doc__r;   rF   rL   r&   r/   r-   r!   r!   .   s   „ ñò(ò3ó3r/   r!   c                   ó   — e Zd Zy)ÚTestRuntimeErrorN©r0   r1   r2   r&   r/   r-   rO   rO   ^   ó   „ Ør/   rO   c                   ó   — e Zd Zy)ÚTestValueErrorNrP   r&   r/   r-   rS   rS   b   rQ   r/   rS   c                   ó¬   — e Zd ZdZdZdZd„ Zd„ Zg d¢g d¢ge_        d„ Z	g d	¢ge	_        d
„ Z
d„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zde_        ed„ «       Zd„ Zy)ÚTestéš  é   é*   c                 ó   — |S r*   r&   )r+   Úargs     r-   Úxmlrpc_echozTest.xmlrpc_echon   s   € Øˆ
r/   c                 ó   — ||z   S )z0
        This function add two numbers.
        r&   )r+   ÚaÚbs      r-   Ú
xmlrpc_addzTest.xmlrpc_addr   s   € ð �1‰uˆr/   ©Úintra   ra   ©Údoublerc   rc   c                 ó
   — ||gS )zC
        This function puts the two arguments in an array.
        r&   )r+   ÚstringÚnums      r-   Úxmlrpc_pairzTest.xmlrpc_pair~   s   € ð ˜ˆ}Ðr/   ©Úarrayre   ra   c                 ó,   — t        j                  |«      S )úHelp for defer.)r   Úsucceed©r+   Úxs     r-   Úxmlrpc_deferzTest.xmlrpc_defer‡   s   € ä�}‰}˜QÓÐr/   c                 ó<   — t        j                  t        «       «      S r*   )r   ÚfailrS   rK   s    r-   Úxmlrpc_deferFailzTest.xmlrpc_deferFail‹   s   € Ü�z‰zœ.Ó*Ó+Ð+r/   c                 ó   — t         ‚r*   )rO   rK   s    r-   Úxmlrpc_failzTest.xmlrpc_fail�   s   € ÜÐr/   c                 ó.   — t        j                  dd«      S )Né   Úhello©r   ÚFaultrK   s    r-   Úxmlrpc_faultzTest.xmlrpc_fault’   s   € Ü�|‰|˜B Ó(Ð(r/   c                 óT   — t        j                  t        j                  dd«      «      S )Né   Úhi)r   rq   r   ry   rK   s    r-   Úxmlrpc_deferFaultzTest.xmlrpc_deferFault•   s   € Ü�z‰zœ&Ÿ,™, r¨4Ó0Ó1Ð1r/   c                 ó@   — d}||k7  rt        j                  dd«      S |S )z8
        Used to test that we can pass Unicode.
        õ   â˜ƒé   zPayload not unicode snowmanrx   )r+   ÚpayloadÚsnowmans      r-   Úxmlrpc_snowmanzTest.xmlrpc_snowman˜   s(   € ð ˆØ�gÒÜ—<‘< Ð$AÓBÐBØˆr/   c                 ó   — dddg gddœS )Nr^   Úcrv   Úfoo©r]   ÚDr&   rK   s    r-   Úxmlrpc_complexzTest.xmlrpc_complex¡   s   € Ø˜3  BÐ'¨eÑ4Ð4r/   c                 ó   — ||   S r*   r&   )r+   ÚmapÚkeys      r-   Úxmlrpc_dictzTest.xmlrpc_dict¤   s   € Ø�3‰xˆr/   úHelp for dict.c                 ó&   — |j                   dz   |z   S )z©
        A method decorated with L{withRequest} which can be called by
        a test to verify that the request object really is passed as
        an argument.
        ú )r6   )r+   r5   Úothers      r-   Úxmlrpc_withRequestzTest.xmlrpc_withRequest©   s$   € ð �N‰Nð ñð ñ	ð	
r/   c                 óÂ   — 	 t        j                  | |«      S # t        j                  $ r3 |j	                  d«      r t        j
                  | j                  d«      ‚‚ w xY w)NÚSESSIONzSession non-existent/expired.)r   ÚlookupProcedurer   ÚNoSuchFunctionÚ
startswithry   ÚSESSION_EXPIRED)r+   ÚprocedurePaths     r-   r–   zTest.lookupProcedure¹   s_   € ð	Ü×)Ñ)¨$°Ó>Ð>øÜ×$Ñ$ò 	Ø×'Ñ'¨	Ô2Ü—l‘lØ×(Ñ(Ð*Ióð ð ð	ús
   ‚ ˜AAN)r0   r1   r2   ÚFAILUREÚ	NOT_FOUNDr™   r[   r_   Ú	signaturerg   ro   rr   rt   rz   r~   r„   rŠ   rŽ   Úhelpr   r“   r–   r&   r/   r-   rU   rU   f   sŠ   „ ð €GØ€IØ€Oòòò 	Ú&ð€JÔòò 8Ð8€KÔò ò,òò)ò2òò5òð (€KÔàñ
ó ð
ó	r/   rU   c                   ó   — e Zd ZdZd„ Zd„ Zy)ÚTestLookupProcedurez}
    This is a resource which customizes procedure lookup to be used by the tests
    of support for this customization.
    c                 ó   — |S r*   r&   rm   s     r-   ÚechozTestLookupProcedure.echoË   s   € Øˆr/   c                 ól   — |dk(  r| j                   S t        j                  | j                  d|› d�«      ‚)zs
        Lookup a procedure from a fixed set of choices, either I{echo} or
        I{system.listeMethods}.
        r¢   z
procedure z
 not found)r¢   r   r—   rœ   )r+   ÚprocedureNames     r-   r–   z#TestLookupProcedure.lookupProcedureÎ   s;   € ð
 ˜FÒ"Ø—9‘9ÐÜ×#Ñ#Ø�N‰N˜j¨¨°zÐBó
ð 	
r/   N)r0   r1   r2   rM   r¢   r–   r&   r/   r-   r    r    Å   s   „ ñò
ó	
r/   r    c                   ó   — e Zd ZdZd„ Zy)ÚTestListProceduresz‚
    This is a resource which customizes procedure enumeration to be used by the
    tests of support for this customization.
    c                 ó   — dgS )zW
        Return a list of a single method this resource will claim to support.
        r‡   r&   rK   s    r-   ÚlistProceduresz!TestListProcedures.listProceduresà   s   € ð ˆwˆr/   N)r0   r1   r2   rM   r¨   r&   r/   r-   r¦   r¦   Ú   s   „ ñó
r/   r¦   c                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)ÚTestAuthHeaderzU
    This is used to get the header info so that we can test
    authentication.
    c                 ó<   — t         j                  | «       d | _        y r*   )rU   Ú__init__r5   rK   s    r-   r¬   zTestAuthHeader.__init__í   s   € Ü�‰�dÔØˆ�r/   c                 ó<   — || _         t        j                  | |«      S r*   )r5   rU   r>   )r+   r5   s     r-   r>   zTestAuthHeader.renderñ   s   € ØˆŒÜ�{‰{˜4 Ó)Ð)r/   c                 ój   — | j                   j                  «       | j                   j                  «       fS r*   )r5   ÚgetUserÚgetPasswordrK   s    r-   Úxmlrpc_authinfozTestAuthHeader.xmlrpc_authinfoõ   s'   € Ø�|‰|×#Ñ#Ó% t§|¡|×'?Ñ'?Ó'AÐAÐAr/   N)r0   r1   r2   rM   r¬   r>   r±   r&   r/   r-   rª   rª   ç   s   „ ñò
ò*óBr/   rª   c                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)ÚTestQueryProtocolz_
    QueryProtocol for tests that saves headers received and sent,
    inside the factory.
    c                 óx   — | j                   | j                  _         t        j                  j	                  | «       y r*   )Ú	transportÚfactoryr   ÚQueryProtocolÚconnectionMaderK   s    r-   r¸   z TestQueryProtocol.connectionMadeÿ   s&   € Ø!%§¡ˆ�‰ÔÜ×Ñ×+Ñ+¨DÕ1r/   c                 óR   — || j                   j                  |j                  «       <   y r*   )r¶   ÚheadersÚlower©r+   r�   Úvals      r-   ÚhandleHeaderzTestQueryProtocol.handleHeader  s   € Ø,/ˆ�‰×Ñ˜SŸY™Y›[Ò)r/   c                 ó”   — || j                   j                  |j                  «       <   t        j                  j                  | ||«       y)zA
        Keep sent headers so we can inspect them later.
        N)r¶   Úsent_headersr»   r   r·   Ú
sendHeaderr¼   s      r-   rÁ   zTestQueryProtocol.sendHeader  s6   € ð 25ˆ�‰×!Ñ! #§)¡)£+Ñ.Ü×Ñ×'Ñ'¨¨c°3Õ7r/   N)r0   r1   r2   rM   r¸   r¾   rÁ   r&   r/   r-   r³   r³   ù   s   „ ñò
2ò0ó8r/   r³   c                   ó   — e Zd ZdZeZd„ Zy)ÚTestQueryFactoryzE
    QueryFactory using L{TestQueryProtocol} for saving headers.
    c                 óf   — i | _         i | _        t        j                  j                  | g|¢­i |¤Ž y r*   )rº   rÀ   r   r   r¬   )r+   ÚargsÚkwargss      r-   r¬   zTestQueryFactory.__init__  s/   € ØˆŒØˆÔÜ×Ñ×$Ñ$ TÐ;¨DÒ;°FÓ;r/   N)r0   r1   r2   rM   r³   Úprotocolr¬   r&   r/   r-   rÃ   rÃ     s   „ ñð !€Hó<r/   rÃ   c                   ó   — e Zd ZdZd„ Zy)ÚTestQueryFactoryCancelz{
    QueryFactory that saves a reference to the
    L{twisted.internet.interfaces.IConnector} to test connection lost.
    c                 ó   — || _         y r*   )Ú	connector)r+   rË   s     r-   ÚstartedConnectingz(TestQueryFactoryCancel.startedConnecting!  s	   € Ø"ˆ�r/   N)r0   r1   r2   rM   rÌ   r&   r/   r-   rÉ   rÉ     s   „ ñó
#r/   rÉ   c                   ó€   — e Zd Zd„ Zd„ Zd„ Zdd„Zd„ Zd„ Zd„ Z	d	„ Z
d
„ Zd„ Zd„ Zd„ Zd„ Zd„ Z eed«      d„ «       Zy)ÚXMLRPCTestsc                 óÔ   — t        j                  dt        j                  t	        «       «      d¬«      | _        | j
                  j                  «       j                  | _        g | _        y ©Nr   ú	127.0.0.1©Ú	interface)	r   Ú	listenTCPr   ÚSiterU   ÚpÚgetHostÚportÚ	factoriesrK   s    r-   r;   zXMLRPCTests.setUp&  sB   € Ü×"Ñ" 1¤f§k¡k´$³&Ó&9À[ÔQˆŒØ—F‘F—N‘NÓ$×)Ñ)ˆŒ	Øˆ�r/   c                 óD   — g | _         | j                  j                  «       S r*   )rÙ   rÖ   ÚstopListeningrK   s    r-   ÚtearDownzXMLRPCTests.tearDown+  s   € ØˆŒØ�v‰v×#Ñ#Ó%Ð%r/   c                 óR   — t        |i |¤Ž}| j                  j                  |«       |S )zw
        Specific queryFactory for proxy that uses our custom
        L{TestQueryFactory}, and save factories.
        )rÃ   rÙ   Úappend)r+   rÅ   rÆ   r¶   s       r-   ÚqueryFactoryzXMLRPCTests.queryFactory/  s*   € ô
 # DÐ3¨FÑ3ˆØ�‰×Ñ˜gÔ&Øˆr/   Nc                 ó”   — t        j                  t        d| j                  z  «      «      }|€| j                  |_        |S ||_        |S )z¾
        Return a new xmlrpc.Proxy for the test site created in
        setUp(), using the given factory as the queryFactory, or
        self.queryFactory if no factory is provided.
        úhttp://127.0.0.1:%d/©r   ÚProxyr   rØ   rß   ©r+   r¶   rÖ   s      r-   ÚproxyzXMLRPCTests.proxy8  sH   € ô �L‰LœÐ'=ÀÇ	Á	Ñ'IÓJÓKˆØˆ?Ø!×.Ñ.ˆAŒNð ˆð %ˆAŒNØˆr/   c                 ó"  — dddddidfdfddddgfdd	d
dddg gddœfg}g }|D ]T  \  }}} | j                  «       j                  |g|¢­Ž }|j                  | j                  |«       |j	                  |«       ŒV t        j                  |d¬«      S )N)Úadd)é   é   é   )r   )r]   r]   Údictr]   r=   Úpair)r]   r=   )rƒ   r€   r€   Úcomplexr&   r^   r†   rv   r‡   rˆ   T©ÚfireOnOneErrback©rå   Ú
callRemoteÚaddCallbackr?   rÞ   r   ÚDeferredList)r+   ÚinputOutputÚdlÚmethrÅ   ÚoutpÚds          r-   Útest_resultszXMLRPCTests.test_resultsE  s¸   € àØ"Ø�s˜A�h �_ aÐ(Ø�X  Q˜xÐ(Ø-Ø˜ 3¨¨R°Ð"4¸5ÑAÐBð
ˆð ˆØ +ò 	ÑˆD�$˜Ø'�—
‘
“×'Ñ'¨Ð4¨tÒ4ˆAØ�M‰M˜$×*Ñ*¨DÔ1Ø�I‰I�a�Lð	ô ×!Ñ! "°tÔ<Ð<r/   c                 ó    ‡ — ‰ j                  «       j                  dd«      }ˆ fd„}ˆ fd„}|j                  |«       |j                  |«       |S )zƒ
        Verify that headers sent from the client side and the ones we
        get back from the server side are correct.

        rƒ   r€   c                 ó¶   •— ‰j                  ‰j                  d   j                  d   d«       ‰j                  ‰j                  d   j                  d   d«       y )Nr   ó   content-typeó   text/xml; charset=utf-8ó   content-lengths   129)r?   rÙ   rº   )Úingr+   s    €r-   Úcheck_server_headersz6XMLRPCTests.test_headers.<locals>.check_server_headers^  sR   ø€ Ø×ÑØ—‘˜qÑ!×)Ñ)¨/Ñ:Ð<Vôð ×Ñ˜TŸ^™^¨AÑ.×6Ñ6Ð7HÑIÈ6ÕRr/   c                 ó  •— ‰j                  ‰j                  d   j                  d   d«       ‰j                  ‰j                  d   j                  d   d«       ‰j                  ‰j                  d   j                  d   d«       y )Nr   s
   user-agents   Twisted/XMLRPClibrü   rý   rþ   s   155)r?   rÙ   rÀ   )Úignr+   s    €r-   Úcheck_client_headersz6XMLRPCTests.test_headers.<locals>.check_client_headersd  s}   ø€ Ø×ÑØ—‘˜qÑ!×.Ñ.¨}Ñ=Ð?Sôð ×ÑØ—‘˜qÑ!×.Ñ.¨Ñ?Ø*ôð ×Ñ˜TŸ^™^¨AÑ.×;Ñ;Ð<MÑNÐPVÕWr/   ©rå   rñ   rò   )r+   rø   r   r  s   `   r-   Útest_headerszXMLRPCTests.test_headersV  sJ   ø€ ð �J‰J‹L×#Ñ# I¨xÓ8ˆô	Sô	Xð 	
�‰Ð*Ô+Ø	�‰Ð*Ô+Øˆr/   c                 óü  ‡ ‡‡— t        «       Št        ‰t        t        j                  ¬«      g«      Št        j                  ‰«       ‰ j                  ˆfd„«       g }dD ]k  \  }}‰ j                  «       j                  |«      }‰ j                  |t        j                  «      }|j                  |fˆ fd„	«       |j                  |«       Œm t        j                   |d¬«      }ˆˆ fd„}|j                  |«       |S )zø
        Verify that for each way a method exposed via XML-RPC can fail, the
        correct 'Content-type' header is set in the response and that the
        client-side Deferred is errbacked with an appropriate C{Fault}
        instance.
        ©ÚdefaultLogLevelc                  ó.   •— t        j                  ‰ «      S r*   ©r   ÚremoveObserver©Úfiltereds   €r-   ú<lambda>z)XMLRPCTests.test_errors.<locals>.<lambda>~  ó   ø€ Ô 2× AÑ AÀ(Ó K€ r/   ))rV   rq   )rV   Ú	deferFail)rv   Úfault)rW   ÚnoSuchMethod)r|   Ú
deferFault)rX   ÚSESSION_TESTc                 ó<   •— ‰j                  | j                  |«      S r*   )r?   Ú	faultCode)ÚexcÚcoder+   s     €r-   r  z)XMLRPCTests.test_errors.<locals>.<lambda>Š  s   ø€ °×1AÑ1AÀ#Ç-Á-ÐQUÓ1V€ r/   Trî   c                 ó¾  •— ‰j                   D ]!  }‰j                  |j                  d   d«       Œ# ‰j                  dt	        ‰«      «       ‰d   d   j
                  }‰d   d   j
                  }t        |t        «      r‰j                  |t        «       n,‰j                  |t        «       ‰j                  |t        «       ‰j                  t        t        «       y )Nrü   rý   rè   r   Úlog_failurer=   )rÙ   r?   rº   ÚassertEqualsÚlenÚvalueÚ
isinstancerS   ÚassertIsInstancerO   ÚflushLoggedErrors)r  r¶   Úf1Úf2ÚlogObserverr+   s       €€r-   Úcbz#XMLRPCTests.test_errors.<locals>.cbŽ  s¿   ø€ ØŸ>™>ò �Ø× Ñ Ø—O‘O OÑ4Ð6Põðð ×Ñ˜a¤ [Ó!1Ô2Ø˜Q‘ Ñ.×4Ñ4ˆBØ˜Q‘ Ñ.×4Ñ4ˆBä˜"œnÔ-Ø×%Ñ% bÔ*:Õ;à×%Ñ% bÔ*:Ô;Ø×%Ñ% b¬.Ô9à×"Ñ"Ô#3´^ÕDr/   )r	   r   r   r   Úcriticalr   ÚaddObserverÚ
addCleanuprå   rñ   ÚassertFailurer   ry   rò   rÞ   r   ró   )r+   rõ   r  Ú
methodNamerø   r$  r  r#  s   `     @@r-   Útest_errorszXMLRPCTests.test_errorsr  sØ   ú€ ô +Ó,ˆÜ'ØÔ1Ä(×BSÑBSÔTÐUó
ˆô 	×&Ñ& xÔ0Ø�‰ÓKÔLØˆð!
ò 	ÑˆD�*ð —
‘
“×'Ñ'¨
Ó3ˆAØ×"Ñ" 1¤f§l¡lÓ3ˆAØ�M‰M¨4ÔVÔWØ�I‰I�a�Lð	ô ×Ñ˜r°DÔ9ˆõ	Eð" 	
�‰�bÔØˆr/   c                 óv  ‡— ˆfd„Š| j                  ‰«      j                  ddd«      }| j                  ‰j                  j                  j
                  d«       |j                  «        | j                  ‰j                  j                  j
                  d«       | j                  |t        j                  «      }|S )z‚
        A deferred from the Proxy can be cancelled, disconnecting
        the L{twisted.internet.interfaces.IConnector}.
        c                  ó<   •— t        | i |¤Ž‰_        ‰j                  S r*   )rÉ   Úf)rÅ   Úkwr¶   s     €r-   r¶   z(XMLRPCTests.test_cancel.<locals>.factory¨  s   ø€ Ü.°Ð;¸Ñ;ˆGŒIØ—9‘9Ðr/   rç   rè   ré   Údisconnected)rå   rñ   ÚassertNotEqualr-  rË   ÚstateÚcancelr?   r(  r   ÚCancelledError)r+   rø   r¶   s     @r-   Útest_cancelzXMLRPCTests.test_cancel¢  s�   ø€ ô	ð �J‰J�wÓ×*Ñ*¨5°!°QÓ7ˆØ×Ñ˜GŸI™I×/Ñ/×5Ñ5°~ÔFØ	�‰Œ
Ø×Ñ˜Ÿ™×,Ñ,×2Ñ2°NÔCØ×Ñ˜q¤%×"6Ñ"6Ó7ˆØˆr/   c                 ó¸   ‡ — t        j                  t        «      }|j                  dt	        d‰ j
                  fz  «      «      }ˆ fd„}|j                  |«       |S )zN
        A classic GET on the xml server should return a NOT_ALLOWED.
        s   GETrá   c                 óZ   •— ‰j                  | j                  t        j                  «       y r*   )r?   r  r   ÚNOT_ALLOWED)Úresponser+   s    €r-   ÚcheckResponsez0XMLRPCTests.test_errorGet.<locals>.checkResponseº  s   ø€ Ø×Ñ˜XŸ]™]¬D×,<Ñ,<Õ=r/   )r   ÚAgentr   r5   r   rØ   rò   )r+   Úagentrø   r9  s   `   r-   Útest_errorGetzXMLRPCTests.test_errorGet³  sL   ø€ ô —‘œWÓ%ˆØ�M‰M˜&¤-Ð0FÈ$Ï)É)ÈÑ0UÓ"VÓWˆô	>ð 	
�‰�mÔ$Øˆr/   c           	      ó2  ‡ — t        j                  t        «      }|j                  t	        d‰ j
                  fz  «      dt        j                  t        d«      «      ¬«      }|j                  t         j                  «       ˆ fd„}|j                  |«       |S )zL
        Test that an invalid XML input returns an L{xmlrpc.Fault}.
        rá   s   POSTs   foo)Úurir6   ÚbodyProducerc                 ód   •— ‰j                  t        j                  t        j                  | «       y r*   )ÚassertRaisesr   ry   r   rB   )r,   r+   s    €r-   r$  z,XMLRPCTests.test_errorXMLContent.<locals>.cbÌ  s   ø€ Ø×ÑœfŸl™l¬I¯O©O¸VÕDr/   )
r   r:  r   r5   r   rØ   ÚFileBodyProducerr   rò   ÚreadBody)r+   r;  rø   r$  s   `   r-   Útest_errorXMLContentz XMLRPCTests.test_errorXMLContentÀ  sz   ø€ ô —‘œWÓ%ˆØ�M‰MÜÐ4¸¿	¹	°|ÑCÓDØÜ×0Ñ0´¸³ÓAð ó 
ˆð
 	
�‰”f—o‘oÔ&ô	Eð 	
�‰�bÔØˆr/   c                 ó¦   — t        j                  «       }| j                  «       j                  d|«      }|j	                  | j
                  |«       |S )zÈ
        If an L{xmlrpclib.DateTime} is passed as an argument to an XML-RPC
        call and then returned by the server unmodified, the result should
        be equal to the original object.
        r¢   )r   ÚDateTimerå   rñ   rò   r?   )r+   Úwhenrø   s      r-   Útest_datetimeRoundtripz"XMLRPCTests.test_datetimeRoundtripÒ  sC   € ô ×!Ñ!Ó#ˆØ�J‰J‹L×#Ñ# F¨DÓ1ˆØ	�‰�d×&Ñ&¨Ô-Øˆr/   c                 óŠ  ‡ ‡‡— t        «       Št        ‰t        t        j                  ¬«      g«      Št        j                  ‰«       ‰ j                  ˆfd„«       ‰ j                  «       j                  dd«      }d„ }‰ j                  t        d|«       ‰ j                  |t        «      }ˆˆ fd„}|j                  |«       |S )a.  
        If it is not possible to encode a response to the request (for example,
        because L{xmlrpclib.dumps} raises an exception when encoding a
        L{Fault}) the exception which prevents the response from being
        generated is logged and the request object is finished anyway.
        r  c                  ó.   •— t        j                  ‰ «      S r*   r
  r  s   €r-   r  z6XMLRPCTests.test_doubleEncodingError.<locals>.<lambda>é  r  r/   r¢   r#   c                  ó   — t        d«      ‚)NzCannot encode anything at all!)ÚRuntimeError)rÅ   rÆ   s     r-   Ú	fakeDumpsz7XMLRPCTests.test_doubleEncodingError.<locals>.fakeDumpsí  s   € ÜÐ?Ó@Ð@r/   r7   c                 óä   •— ‰j                  dt        ‰«      «       ‰j                  ‰d   d   j                  t        «       ‰j                  t        ‰j                  t        «      «      d«       y )Nr=   r   r  )r  r  r  r  rL  r?   r   )Úignoredr#  r+   s    €€r-   ÚcbFailedz6XMLRPCTests.test_doubleEncodingError.<locals>.cbFailed÷  sW   ø€ à×Ñ˜a¤ [Ó!1Ô2Ø×!Ñ! +¨a¡.°Ñ"?×"EÑ"EÄ|ÔTØ×ÑœS ×!7Ñ!7¼Ó!EÓFÈÕJr/   )r	   r   r   r   r%  r   r&  r'  rå   rñ   Úpatchr   r(  Ú	Exceptionrò   )r+   rø   rM  rP  r  r#  s   `   @@r-   Útest_doubleEncodingErrorz$XMLRPCTests.test_doubleEncodingErrorÝ  s¥   ú€ ô +Ó,ˆÜ'ØÔ1Ä(×BSÑBSÔTÐUó
ˆô 	×&Ñ& xÔ0Ø�‰ÓKÔLØ�J‰J‹L×#Ñ# F¨BÓ/ˆò	Að 	�
‰
”9˜g yÔ1ð
 ×Ñ˜q¤)Ó,ˆõ	Kð 	
�‰�hÔØˆr/   c                 óp   ‡ — ‰ j                  «       j                  dd«      }ˆ fd„}|j                  |«      S )zV
        The connection to the web server is closed when the request is done.
        r¢   r#   c                 ó¶   •— ‰j                   \  }‰j                  |j                  j                  «       ‰j	                  |j                  j
                  «       y r*   )rÙ   ÚassertFalserµ   Ú	connectedÚ
assertTruer/  )rO  r¶   r+   s     €r-   ÚresponseDonezBXMLRPCTests.test_closeConnectionAfterRequest.<locals>.responseDone  s@   ø€ ØŸ™‰IˆWØ×Ñ˜W×.Ñ.×8Ñ8Ô9Ø�O‰O˜G×-Ñ-×:Ñ:Õ;r/   r  )r+   rø   rY  s   `  r-   Ú test_closeConnectionAfterRequestz,XMLRPCTests.test_closeConnectionAfterRequest   s3   ø€ ð �J‰J‹L×#Ñ# F¨BÓ/ˆô	<ð
 �}‰}˜\Ó*Ð*r/   c                 ó®   — t        «       }t        j                  dd|¬«      }|j                  d«       | j	                  |j
                  d   d   d«       y)zÍ
        For I{HTTP} URIs, L{xmlrpc.Proxy.callRemote} passes the value it
        received for the C{connectTimeout} parameter as the C{timeout} argument
        to the underlying connectTCP call.
        s   http://127.0.0.1:69g       @©ÚconnectTimeoutr   Ú
someMethodr   ré   N)r
   r   rã   rñ   r?   Ú
tcpClients©r+   r   rå   s      r-   Útest_tcpTimeoutzXMLRPCTests.test_tcpTimeout  sP   € ô  “/ˆÜ—‘Ø"°3Àô
ˆð 	×Ñ˜Ô&Ø×Ñ˜×+Ñ+¨AÑ.¨qÑ1°3Õ7r/   zOpenSSL not presentc                 ó®   — t        «       }t        j                  dd|¬«      }|j                  d«       | j	                  |j
                  d   d   d«       y)zÎ
        For I{HTTPS} URIs, L{xmlrpc.Proxy.callRemote} passes the value it
        received for the C{connectTimeout} parameter as the C{timeout} argument
        to the underlying connectSSL call.
        s   https://127.0.0.1:69g      @r\  r^  r   é   N)r
   r   rã   rñ   r?   Ú
sslClientsr`  s      r-   Útest_sslTimeoutzXMLRPCTests.test_sslTimeout  sP   € ô  “/ˆÜ—‘Ø#°CÀô
ˆð 	×Ñ˜Ô&Ø×Ñ˜×+Ñ+¨AÑ.¨qÑ1°3Õ7r/   r*   )r0   r1   r2   r;   rÜ   rß   rå   rù   r  r*  r4  r<  rD  rH  rS  rZ  ra  r   ÚsslSkipre  r&   r/   r-   rÎ   rÎ   %  sf   „ òò
&òóò=ò"ò8.ò`ò"òò$	ò!òF+ò8ñ ˆGÐ*Ó+ñ8ó ,ñ8r/   rÎ   c                   ó   — e Zd ZdZdd„Zy)ÚXMLRPCProxyWithoutSlashTestsz3
    Test with proxy that doesn't add a slash.
    Nc                 ó”   — t        j                  t        d| j                  z  «      «      }|€| j                  |_        |S ||_        |S )Núhttp://127.0.0.1:%drâ   rä   s      r-   rå   z"XMLRPCProxyWithoutSlashTests.proxy.  sF   € Ü�L‰LœÐ'<¸t¿y¹yÑ'HÓIÓJˆØˆ?Ø!×.Ñ.ˆAŒNð ˆð %ˆAŒNØˆr/   r*   )r0   r1   r2   rM   rå   r&   r/   r-   rh  rh  )  s   „ ñôr/   rh  c                   ó(   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zy)Ú XMLRPCPublicLookupProcedureTestszr
    Tests for L{XMLRPC}'s support of subclasses which override
    C{lookupProcedure} and C{listProcedures}.
    c                 ó`  — t        j                  dt        j                  |«      d¬«      | _        | j                  | j                  j                  «       | j                  j                  «       j                  | _        t        j                  t        d| j                  z  «      «      | _        y )Nr   rÑ   rÒ   rj  )r   rÔ   r   rÕ   rÖ   r'  rÛ   r×   rØ   r   rã   r   rå   )r+   r:   s     r-   ÚcreateServerz-XMLRPCPublicLookupProcedureTests.createServer=  sn   € Ü×"Ñ" 1¤f§k¡k°(Ó&;À{ÔSˆŒØ�‰˜Ÿ™×,Ñ,Ô-Ø—F‘F—N‘NÓ$×)Ñ)ˆŒ	Ü—\‘\¤-Ð0EÈÏ	É	Ñ0QÓ"RÓSˆ�
r/   c                 ó¬   — | j                  t        «       «       d}| j                  j                  d|«      }|j	                  | j
                  |«       |S )z¢
        A subclass of L{XMLRPC} can override C{lookupProcedure} to find
        procedures that are not defined using a C{xmlrpc_}-prefixed method name.
        rw   r¢   )rn  r    rå   rñ   rò   r?   )r+   Úwhatrø   s      r-   Útest_lookupProcedurez5XMLRPCPublicLookupProcedureTests.test_lookupProcedureC  sJ   € ð
 	×ÑÔ-Ó/Ô0ØˆØ�J‰J×!Ñ! &¨$Ó/ˆØ	�‰�d×&Ñ&¨Ô-Øˆr/   c                 ó°   — | j                  t        «       «       | j                  j                  dd«      }| j	                  |t
        j                  «      }|S )zá
        A subclass of L{XMLRPC} can override C{lookupProcedure} to raise
        L{NoSuchFunction} to indicate that a requested method is not available
        to be called, signalling a fault to the XML-RPC client.
        Úxxxxrw   )rn  r    rå   rñ   r(  r   ry   ©r+   rø   s     r-   r*  z,XMLRPCPublicLookupProcedureTests.test_errorsN  sG   € ð 	×ÑÔ-Ó/Ô0Ø�J‰J×!Ñ! &¨'Ó2ˆØ×Ñ˜q¤&§,¡,Ó/ˆØˆr/   c                 ó¶   ‡ — t        «       }t        |«       ‰ j                  |«       ‰ j                  j	                  d«      }ˆ fd„}|j                  |«       |S )z¬
        A subclass of L{XMLRPC} can override C{listProcedures} to define
        Overriding listProcedures should prevent introspection from being
        broken.
        úsystem.listMethodsc                 ó*   •— ‰j                  d| «       y )Nr‡   )ÚassertIn)Ú
proceduresr+   s    €r-   ÚlistedzAXMLRPCPublicLookupProcedureTests.test_listMethods.<locals>.listedd  s   ø€ ð �M‰M˜% Õ,r/   )r¦   r   rn  rå   rñ   rò   )r+   r:   rø   rz  s   `   r-   Útest_listMethodsz1XMLRPCPublicLookupProcedureTests.test_listMethodsY  sP   ø€ ô &Ó'ˆÜ˜Ô"Ø×Ñ˜(Ô#Ø�J‰J×!Ñ!Ð"6Ó7ˆô	-ð 	
�‰�fÔØˆr/   N)r0   r1   r2   rM   rn  rq  r*  r{  r&   r/   r-   rl  rl  7  s   „ ñò
Tò	ò	ór/   rl  c                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)ÚSerializationConfigMixinas  
    Mixin which defines a couple tests which should pass when a particular flag
    is passed to L{XMLRPC}.

    These are not meant to be exhaustive serialization tests, since L{xmlrpclib}
    does all of the actual serialization work.  They are just meant to exercise
    a few codepaths to make sure we are calling into xmlrpclib correctly.

    @ivar flagName: A C{str} giving the name of the flag which must be passed to
        L{XMLRPC} to allow the tests to pass.  Subclasses should set this.

    @ivar value: A value which the specified flag will allow the serialization
        of.  Subclasses should set this.
    c           
      ó’  — | j                   di}t        j                  dt        j                  t        di |¤Ž«      d¬«      | _        | j                  | j                  j                  «       | j                  j                  «       j                  | _
        t        j                  t        d| j                  fz  «      fi |¤Ž| _        y)zO
        Create a new XML-RPC server with C{allowNone} set to C{True}.
        Tr   rÑ   rÒ   rá   Nr&   )ÚflagNamer   rÔ   r   rÕ   rU   rÖ   r'  rÛ   r×   rØ   r   rã   r   rå   )r+   rÆ   s     r-   r;   zSerializationConfigMixin.setUp~  s–   € ð —-‘- Ð&ˆÜ×"Ñ"ØŒv�{‰{œ4™> &™>Ó*°kô
ˆŒð 	�‰˜Ÿ™×,Ñ,Ô-Ø—F‘F—N‘NÓ$×)Ñ)ˆŒ	Ü—\‘\ÜÐ0°D·I±I°<Ñ?Ó@ñ
ØDJñ
ˆ�
r/   c                 óž   — | j                   j                  d| j                  «      }|j                  | j                  | j                  «       |S )zY
        C{self.value} can be round-tripped over an XMLRPC method call/response.
        r   ©rå   rñ   r  rò   r?   rt  s     r-   Útest_roundtripValuez,SerializationConfigMixin.test_roundtripValueŒ  s;   € ð �J‰J×!Ñ! '¨4¯:©:Ó6ˆØ	�‰�d×&Ñ&¨¯
©
Ô3Øˆr/   c                 ó¦   — | j                   j                  dd| j                  i«      }|j                  | j                  d| j                  i«       |S )zz
        A C{dict} which contains C{self.value} can be round-tripped over an
        XMLRPC method call/response.
        r   r]   r�  rt  s     r-   Útest_roundtripNestedValuez2SerializationConfigMixin.test_roundtripNestedValue”  sE   € ð
 �J‰J×!Ñ! '¨C°·±Ð+<Ó=ˆØ	�‰�d×&Ñ&¨¨d¯j©jÐ(9Ô:Øˆr/   N)r0   r1   r2   rM   r;   r‚  r„  r&   r/   r-   r}  r}  n  s   „ ñò
òór/   r}  c                   ó   — e Zd ZdZdZdZy)ÚXMLRPCAllowNoneTestszF
    Tests for passing L{None} when the C{allowNone} flag is set.
    Ú	allowNoneN)r0   r1   r2   rM   r  r  r&   r/   r-   r†  r†  ž  s   „ ñð €HØ�Er/   r†  c                   óB   — e Zd ZdZdZ ej
                  dddddd«      Zy	)
ÚXMLRPCUseDateTimeTestszd
    Tests for passing a C{datetime.datetime} instance when the C{useDateTime}
    flag is set.
    ÚuseDateTimeiÐ  rv   é   ré   é-   é;   N)r0   r1   r2   rM   r  Údatetimer  r&   r/   r-   r‰  r‰  §  s*   „ ñð
 €HØˆH×Ñ˜d B¨¨A¨r°2Ó6�Er/   r‰  c                   ó6   — e Zd ZdZdZdZd„ Zd„ Zd„ Zd„ Z	d„ Z
y	)
ÚXMLRPCAuthenticatedTestsz]
    Test with authenticated proxy. We run this with the same input/output as
    above.
    s   usernames   asecretc                 óÔ   — t        j                  dt        j                  t	        «       «      d¬«      | _        | j
                  j                  «       j                  | _        g | _        y rÐ   )	r   rÔ   r   rÕ   rª   rÖ   r×   rØ   rÙ   rK   s    r-   r;   zXMLRPCAuthenticatedTests.setUpº  sH   € Ü×"Ñ"ØŒv�{‰{œ>Ó+Ó,¸ô
ˆŒð —F‘F—N‘NÓ$×)Ñ)ˆŒ	Øˆ�r/   c                 ó8  — dt        | j                  «      t        | j                  «      | j                  fz  }t	        j
                  t        |«      «      }|j                  d«      }|j                  | j                  | j                  | j                  g«       |S )Nzhttp://%s:%s@127.0.0.1:%d/Úauthinfo)
r   ÚuserÚpasswordrØ   r   rã   r   rñ   rò   r?   )r+   ÚurlrÖ   rø   s       r-   Útest_authInfoInURLz+XMLRPCAuthenticatedTests.test_authInfoInURLÁ  sy   € Ø*Ü˜Ÿ™Ó#Ü˜Ÿ™Ó'Ø�I‰Ið.
ñ 
ˆô
 �L‰Lœ sÓ+Ó,ˆØ�L‰L˜Ó$ˆØ	�‰�d×&Ñ&¨¯©°D·M±MÐ(BÔCØˆr/   c                 ó  — t        j                  t        d| j                  fz  «      | j                  | j
                  «      }|j                  d«      }|j                  | j                  | j                  | j
                  g«       |S )Nrá   r“  ©	r   rã   r   rØ   r”  r•  rñ   rò   r?   ©r+   rÖ   rø   s      r-   Útest_explicitAuthInfoz.XMLRPCAuthenticatedTests.test_explicitAuthInfoÌ  sh   € Ü�L‰LÜÐ0°D·I±I°<Ñ?Ó@Ø�I‰IØ�M‰Mó
ˆð
 �L‰L˜Ó$ˆØ	�‰�d×&Ñ&¨¯©°D·M±MÐ(BÔCØˆr/   c                 ó  — | j                   dz  }t        j                  t        d| j                  fz  «      | j
                  |«      }|j                  d«      }|j                  | j                  | j
                  |g«       |S )zÔ
        C{QueryProtocol} uses the C{base64.b64encode} function to encode user
        name and password in the I{Authorization} header, so that it doesn't
        embed new lines when using long inputs.
        é(   rá   r“  )	r•  r   rã   r   rØ   r”  rñ   rò   r?   )r+   ÚlongPasswordrÖ   rø   s       r-   Útest_longPasswordz*XMLRPCAuthenticatedTests.test_longPasswordÖ  sp   € ð —}‘} rÑ)ˆÜ�L‰LÜÐ0°D·I±I°<Ñ?Ó@Ø�I‰IØó
ˆð
 �L‰L˜Ó$ˆØ	�‰�d×&Ñ&¨¯©°LÐ(AÔBØˆr/   c                 ó  — t        j                  t        d| j                  fz  «      | j                  | j
                  «      }|j                  d«      }|j                  | j                  | j                  | j
                  g«       |S )Nzhttp://wrong:info@127.0.0.1:%d/r“  r™  rš  s      r-   Útest_explicitAuthInfoOverridez6XMLRPCAuthenticatedTests.test_explicitAuthInfoOverrideæ  sh   € Ü�L‰LÜÐ;¸t¿y¹y¸lÑJÓKØ�I‰IØ�M‰Mó
ˆð
 �L‰L˜Ó$ˆØ	�‰�d×&Ñ&¨¯©°D·M±MÐ(BÔCØˆr/   N)r0   r1   r2   rM   r”  r•  r;   r—  r›  rŸ  r¡  r&   r/   r-   r�  r�  ±  s,   „ ñð
 €DØ€Hòò	òòó r/   r�  c                   ó$   — e Zd Zd„ Zd„ Zd„ Zd„ Zy)ÚXMLRPCIntrospectionTestsc                 óî   — t        «       }t        |«       t        j                  dt	        j
                  |«      d¬«      | _        | j                  j                  «       j                  | _        g | _	        y rÐ   )
rU   r   r   rÔ   r   rÕ   rÖ   r×   rØ   rÙ   )r+   r   s     r-   r;   zXMLRPCIntrospectionTests.setUpò  sO   € Ü“ˆÜ˜Ô Ü×"Ñ" 1¤f§k¡k°&Ó&9À[ÔQˆŒØ—F‘F—N‘NÓ$×)Ñ)ˆŒ	Øˆ�r/   c                 ór   ‡ — ˆ fd„}‰ j                  «       j                  d«      }|j                  |«       |S )Nc                 óN   •— | j                  «        ‰j                  | g d¢«       y )N)rç   rí   r   r  r  rë   r¢   rq   r  rì   rƒ   rv  úsystem.methodHelpúsystem.methodSignaturer   )Úsortr?   )Úmethsr+   s    €r-   Ú	cbMethodsz<XMLRPCIntrospectionTests.test_listMethods.<locals>.cbMethodsú  s"   ø€ Ø�J‰JŒLØ×ÑØòõr/   rv  r  )r+   r«  rø   s   `  r-   r{  z)XMLRPCIntrospectionTests.test_listMethodsù  s2   ø€ ô	ð. �J‰J‹L×#Ñ#Ð$8Ó9ˆØ	�‰�iÔ Øˆr/   c                 óê   — g d¢}g }|D ]R  \  }}| j                  «       j                  d|«      }|j                  | j                  |«       |j	                  |«       ŒT t        j                  |d¬«      S )N))r   rk   )rq   r#   )rë   r�   r§  Trî   rð   ©r+   ÚinputOutputsrõ   rö   Úexpectedrø   s         r-   Útest_methodHelpz(XMLRPCIntrospectionTests.test_methodHelp  sp   € ò
ˆð ˆØ*ò 	‰NˆD�(Ø—
‘
“×'Ñ'Ð(;¸TÓBˆAØ�M‰M˜$×*Ñ*¨HÔ5Ø�I‰I�a�Lð	ô ×!Ñ! "°tÔ<Ð<r/   c                 ó  — ddg d¢g d¢gfdg d¢gfg}g }|D ]R  \  }}| j                  «       j                  d|«      }|j                  | j                  |«       |j	                  |«       ŒT t        j                  |d¬	«      S )
N)r   r#   rç   r`   rb   rì   rh   r¨  Trî   rð   r­  s         r-   Útest_methodSignaturez-XMLRPCIntrospectionTests.test_methodSignature#  sŽ   € àØÒ*Ò,JÐKÐLØÒ0Ð1Ð2ð
ˆð ˆØ*ò 	‰NˆD�(Ø—
‘
“×'Ñ'Ð(@À$ÓGˆAØ�M‰M˜$×*Ñ*¨HÔ5Ø�I‰I�a�Lð	ô ×!Ñ! "°tÔ<Ð<r/   N)r0   r1   r2   r;   r{  r°  r²  r&   r/   r-   r£  r£  ñ  s   „ òòò8=ó=r/   r£  c                   ó"   — e Zd ZdZd„ Zd„ Zd„ Zy)ÚXMLRPCClientErrorHandlingTestsz3
    Test error handling on the xmlrpc client.
    c                 óÐ   — t        j                  dd«      | _        d| j                  _        t	        j
                  dt        j                  | j                  «      d¬«      | _        y )Ns*   This text is not a valid XML-RPC response.s
   text/plainTr   rÑ   rÒ   )	r   ÚDatar:   ÚisLeafr   rÔ   r   rÕ   rØ   rK   s    r-   r;   z$XMLRPCClientErrorHandlingTests.setUp7  sK   € ÜŸ™Ø9¸=ó
ˆŒð  $ˆ�‰Ôä×%Ñ%ØŒv�{‰{˜4Ÿ=™=Ó)°[ô
ˆ�	r/   c                 ó6   — | j                   j                  «       S r*   )rØ   rÛ   rK   s    r-   rÜ   z'XMLRPCClientErrorHandlingTests.tearDownA  s   € Ø�y‰y×&Ñ&Ó(Ð(r/   c                 óÔ   — t        j                  t        d| j                  j	                  «       j                  fz  «      «      }| j                  |j                  d«      t        «      S )zj
        Test that calling the xmlrpc client on a static http server raises
        an exception.
        rá   r^  )r   rã   r   rØ   r×   r(  rñ   Ú
ValueError)r+   rå   s     r-   Útest_erroneousResponsez5XMLRPCClientErrorHandlingTests.test_erroneousResponseD  sV   € ô
 —‘ÜÐ0°D·I±I×4EÑ4EÓ4G×4LÑ4LÐ3NÑNÓOó
ˆð ×!Ñ! %×"2Ñ"2°<Ó"@Ä*ÓMÐMr/   N)r0   r1   r2   rM   r;   rÜ   r»  r&   r/   r-   r´  r´  2  s   „ ñò
ò)óNr/   r´  c                   ó.   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zy)ÚQueryFactoryParseResponseTestsz>
    Test the behaviour of L{QueryFactory.parseResponse}.
    c           	      ó¸   — t        d d dd d dd¬«      | _        t        j                  d«      | _        d| _        t        j                  t        «       «      | _	        y )Nr$   Fr&   )ÚpathÚhostr6   r”  r•  r‡  rÅ   )r#   zinvalid xml)
r   rß   r   r7   ÚgoodContentsÚbadContentsr   rJ   r   ÚreasonrK   s    r-   r;   z$QueryFactoryParseResponseTests.setUpT  sV   € ô )ØØØØØØØô
ˆÔô &ŸO™O¨EÓ2ˆÔà(ˆÔô —o‘o¤nÓ&6Ó7ˆ�r/   c                 óÜ   — | j                   j                  }|j                  | j                   j                  | j                  «       | j                   j                  | j                  «       |S )z�
        We can safely call L{QueryFactory.clientConnectionLost} as a callback
        of L{QueryFactory.parseResponse}.
        )rß   Údeferredrò   ÚclientConnectionLostrÃ  ÚparseResponserÁ  rt  s     r-   Ú test_parseResponseCallbackSafetyz?QueryFactoryParseResponseTests.test_parseResponseCallbackSafetyh  sT   € ð
 ×Ñ×&Ñ&ˆð 	
�‰�d×'Ñ'×<Ñ<¸d¿k¹kÔJØ×Ñ×'Ñ'¨×(9Ñ(9Ô:Øˆr/   c                 óÜ   — | j                   j                  }|j                  | j                   j                  | j                  «       | j                   j                  | j                  «       |S )z�
        We can safely call L{QueryFactory.clientConnectionLost} as an errback
        of L{QueryFactory.parseResponse}.
        )rß   rÅ  Ú
addErrbackrÆ  rÃ  rÇ  rÂ  rt  s     r-   Útest_parseResponseErrbackSafetyz>QueryFactoryParseResponseTests.test_parseResponseErrbackSafetyu  sT   € ð
 ×Ñ×&Ñ&ˆð 	
�‰�T×&Ñ&×;Ñ;¸T¿[¹[ÔIØ×Ñ×'Ñ'¨×(8Ñ(8Ô9Øˆr/   c                 óÊ   — | j                   j                  }|j                  | j                   j                  | j                  «       | j                   j                  dd«       |S )z}
        We can safely call L{QueryFactory.clientConnectionLost} as an errback
        of L{QueryFactory.badStatus}.
        ÚstatusÚmessage)rß   rÅ  rÊ  rÆ  rÃ  Ú	badStatusrt  s     r-   Útest_badStatusErrbackSafetyz:QueryFactoryParseResponseTests.test_badStatusErrbackSafety‚  sP   € ð
 ×Ñ×&Ñ&ˆð 	
�‰�T×&Ñ&×;Ñ;¸T¿[¹[ÔIØ×Ñ×#Ñ# H¨iÔ8Øˆr/   c                 ó”   — d}| j                   j                  }| j                   j                  |«       | j                  |t        «      S )z¥
        Some server can send a response without any data:
        L{QueryFactory.parseResponse} should catch the error and call the
        result errback.
        zM
<methodResponse>
 <params>
  <param>
  </param>
 </params>
</methodResponse>)rß   rÅ  rÇ  r(  Ú
IndexError)r+   r8   rø   s      r-   Útest_parseResponseWithoutDataz<QueryFactoryParseResponseTests.test_parseResponseWithoutData�  sC   € ðˆð ×Ñ×&Ñ&ˆØ×Ñ×'Ñ'¨Ô0Ø×!Ñ! !¤ZÓ0Ð0r/   N)	r0   r1   r2   rM   r;   rÈ  rË  rÐ  rÓ  r&   r/   r-   r½  r½  O  s    „ ñò8ò(òòó1r/   r½  c                   ó   — e Zd Zd„ Zd„ Zy)ÚXMLRPCWithRequestTestsc                 ó"   — t        «       | _        y r*   )rU   r:   rK   s    r-   r;   zXMLRPCWithRequestTests.setUp¢  s   € Ü›ˆ�r/   c                 óô   ‡ — t        d«      }d|_        t        t        j                  dd«      «      |_        ˆ fd„}|j                  «       j                  ||«      }‰ j                  j                  |«       |S )z¯
        When an XML-RPC method is called and the implementation is
        decorated with L{withRequest}, the request object is passed as
        the first argument.
        z/RPC2r$   )r‡   r   c                 ón   •— t        j                  |j                  d   «      }‰j                  |d«       y )Nr   ))zPOST fooN)r   rB   r@   r?   )Únr5   Údatar+   s      €r-   Úvalidz6XMLRPCWithRequestTests.test_withRequest.<locals>.valid¯  s+   ø€ Ü—?‘? 7§?¡?°1Ñ#5Ó6ˆDØ×Ñ˜TÐ#8Õ9r/   )
r   r6   r   r   r7   r8   ÚnotifyFinishrò   r:   Úrender_POST)r+   r5   rÛ  rø   s   `   r-   Útest_withRequestz'XMLRPCWithRequestTests.test_withRequest¥  sf   ø€ ô ˜wÓ'ˆØˆŒÜ"¤9§?¡?°8¸]Ó#KÓLˆŒô	:ð × Ñ Ó"×.Ñ.¨u°gÓ>ˆØ�‰×!Ñ! 'Ô*Øˆr/   N)r0   r1   r2   r;   rÞ  r&   r/   r-   rÕ  rÕ  ¡  s   „ òór/   rÕ  )FrM   rŽ  Úior   r   r   r   Útwisted.internetr   r   Útwisted.internet.errorr   Útwisted.internet.testingr	   r
   Útwisted.loggerr   r   r   r   Útwisted.pythonr   Útwisted.python.compatr   r   Útwisted.python.reflectr   Útwisted.trialÚtwisted.webr   r   r   r   r   Útwisted.web.test.test_webr   Útwisted.web.xmlrpcr   r   r   r   r   r   rf  ÚImportErrorÚTestCaser!   rL  rO   rº  rS   rU   r    r¦   rª   r·   r³   rÃ   rÉ   rÎ   rh  rl  r}  r†  r‰  r�  r£  r´  r½  rÕ  r&   r/   r-   ú<module>rí     sÉ  ðñ
ó
 ß  Ý ç +Ý 1ß H÷ó õ #ß =Ý .Ý "ß <Õ <Ý 2÷÷ ðÙÐ&Ô'ð €Gô-3�x×(Ñ(ô -3ô`	�|ô 	ô	�Zô 	ô\ˆ6ô \ô~
˜&ô 
ô*
˜ô 
ôB�Tô Bô$8˜×,Ñ,ô 8ô*
<�v×*Ñ*ô 
<ô#˜V×0Ñ0ô #ôA8�(×#Ñ#ô A8ôH ;ô ô4 x×'8Ñ'8ô 4÷n-ñ -ô`Ð3°X×5FÑ5Fô ô7Ð5°x×7HÑ7Hô 7ô=˜{ô =ô@>=˜{ô >=ôBN X×%6Ñ%6ô Nô:O1 X×%6Ñ%6ô O1ôd˜X×.Ñ.õ øðs ò ØƒGðús   Á6G ÇG"Ç!G"