HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/web/test/__pycache__/test_xmlrpc.cpython-38.pyc
U


W[^v�@s�dZddlmZmZddlmZmZmZddlm	Z	ddl
Z
ddlmZddl
mZddlmZmZmZdd	lmZmZmZdd
l
mZmZmZmZddlmZmZddlmZdd
lm Z ddl!m"Z"ddl#m$Z$m%Z%ddl&m'Z'ddl(m)Z)m*Z*m+Z+m,Z,ze"d�Wne-k
�r"dZ.YnXdZ.Gdd�dej/�Z0Gdd�de1�Z2Gdd�de3�Z4Gdd�de�Z5Gdd�de�Z6Gdd�de�Z7Gd d!�d!e5�Z8Gd"d#�d#ej9�Z:Gd$d%�d%ej�Z;Gd&d'�d'ej�Z<Gd(d)�d)ej/�Z=Gd*d+�d+e=�Z>Gd,d-�d-ej/�Z?Gd.d/�d/�Z@Gd0d1�d1e@ej/�ZAGd2d3�d3e@ej/�ZBGd4d5�d5e=�ZCGd6d7�d7e=�ZDGd8d9�d9ej/�ZEGd:d;�d;ej/�ZFGd<d=�d=ej/�ZGdS)>z6
Tests for  XML-RPC support in L{twisted.web.xmlrpc}.
�)�division�absolute_import)�nativeString�
networkString�NativeStringIO)�BytesION)�unittest)�xmlrpc)�XMLRPC�payloadTemplate�addIntrospection)�
_QueryFactory�withRequest�	xmlrpclib)�server�client�http�static)�reactor�defer)�ConnectionDone)�failure)�namedModule)�
MemoryReactor�EventLoggingObserver)�DummyRequest)�globalLogPublisher�FilteringLogObserver�LogLevelFilterPredicate�LogLevelztwisted.internet.sslzOpenSSL not presentc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�AsyncXMLRPCTestsz5
    Tests for L{XMLRPC}'s support of Deferreds.
    cs\tdg�|_d|j_ttdt�d�f�|j_t�	��|_
G�fdd�dt�}|�|_dS)N��POST�async�cseZdZ�fdd�ZdS)z-AsyncXMLRPCTests.setUp.<locals>.AsyncResourcecs�S�Nr$��self��resultr$�>/usr/lib/python3/dist-packages/twisted/web/test/test_xmlrpc.py�xmlrpc_async1sz:AsyncXMLRPCTests.setUp.<locals>.AsyncResource.xmlrpc_asyncN)�__name__�
__module__�__qualname__r+r$r(r$r*�
AsyncResource0sr/)
r�request�methodrrr�dumps�contentrZDeferredr)r
�resource)r'r/r$r(r*�setUp)s�zAsyncXMLRPCTests.setUpcCs^|j�|j�|�|jjg�|j�d�t�d�	|jj��}|�|d�|�|jj
d�dS)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(N�N)r4�renderr0�assertEqual�writtenr)�callbackr�loads�join�finished)r'Zrespr$r$r*�test_deferredResponse7sz&AsyncXMLRPCTests.test_deferredResponsecCsT|j�|j�|j�t�td���|j�d�|�	|jj
g�|�	|jjd�dS)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.
        Z	Simulatedr)rN)r4r8r0ZprocessingFailedr�Failurerr)r;r9r:r>r&r$r$r*� test_interruptedDeferredResponseFs�z1AsyncXMLRPCTests.test_interruptedDeferredResponseN)r,r-r.�__doc__r5r?rAr$r$r$r*r %sr c@seZdZdS)�TestRuntimeErrorN�r,r-r.r$r$r$r*rCVsrCc@seZdZdS)�TestValueErrorNrDr$r$r$r*rE[srEc@s�eZdZdZdZdZdd�Zdd�Zdddgd	d	d	gge_d
d�Z	dd
dgge	_dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zde_edd ��Zd!d"�Zd#S)$�Test���*cCs|Sr%r$)r'�argr$r$r*�xmlrpc_echoiszTest.xmlrpc_echocCs||S)z0
        This function add two numbers.
        r$)r'�a�br$r$r*�
xmlrpc_addmszTest.xmlrpc_add�int�doublecCs||gS)zC
        This function puts the two arguments in an array.
        r$)r'�stringZnumr$r$r*�xmlrpc_pairwszTest.xmlrpc_pair�arrayrQcCs
t�|�S)�Help for defer.)rZsucceed�r'�xr$r$r*�xmlrpc_defer�szTest.xmlrpc_defercCst�t��Sr%)r�failrEr&r$r$r*�xmlrpc_deferFail�szTest.xmlrpc_deferFailcCst�dSr%)rCr&r$r$r*�xmlrpc_fail�szTest.xmlrpc_failcCst�dd�S)N��hello�r	�Faultr&r$r$r*�xmlrpc_fault�szTest.xmlrpc_faultcCst�t�dd��S)N��hi)rrXr	r^r&r$r$r*�xmlrpc_deferFault�szTest.xmlrpc_deferFaultcCsd}||krt�dd�S|S)z8
        Used to test that we can pass Unicode.
        �☃�
zPayload not unicode snowmanr])r'Zpayload�snowmanr$r$r*�xmlrpc_snowman�szTest.xmlrpc_snowmancCsdddggdd�S)NrM�cr[�foo�rL�Dr$r&r$r$r*�xmlrpc_complex�szTest.xmlrpc_complexcCs||Sr%r$)r'�map�keyr$r$r*�xmlrpc_dict�szTest.xmlrpc_dict�Help for dict.cCs|jd|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.
        � )r1)r'r0�otherr$r$r*�xmlrpc_withRequest�s	���zTest.xmlrpc_withRequestcCsFzt�||�WStjk
r@|�d�r:t�|jd��n�YnXdS)NZSESSIONzSession non-existent/expired.)r
�lookupProcedurer	�NoSuchFunction�
startswithr^�SESSION_EXPIRED)r'Z
procedurePathr$r$r*rs�s
�zTest.lookupProcedureN)r,r-r.�FAILURE�	NOT_FOUNDrvrKrNZ	signaturerRrWrYrZr_rbrfrkrn�helprrrrsr$r$r$r*rF`s,�	

rFc@s eZdZdZdd�Zdd�ZdS)�TestLookupProcedurez}
    This is a resource which customizes procedure lookup to be used by the tests
    of support for this customization.
    cCs|Sr%r$rUr$r$r*�echo�szTestLookupProcedure.echocCs&|dkr|jSt�|jd|f��dS)zs
        Lookup a procedure from a fixed set of choices, either I{echo} or
        I{system.listeMethods}.
        r{zprocedure %s not foundN)r{r	rtrx)r'Z
procedureNamer$r$r*rs�s�z#TestLookupProcedure.lookupProcedureN)r,r-r.rBr{rsr$r$r$r*rz�srzc@seZdZdZdd�ZdS)�TestListProceduresz�
    This is a resource which customizes procedure enumeration to be used by the
    tests of support for this customization.
    cCsdgS)zW
        Return a list of a single method this resource will claim to support.
        rhr$r&r$r$r*�listProcedures�sz!TestListProcedures.listProceduresN)r,r-r.rBr}r$r$r$r*r|�sr|c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�TestAuthHeaderzU
    This is used to get the header info so that we can test
    authentication.
    cCst�|�d|_dSr%)rF�__init__r0r&r$r$r*r�s
zTestAuthHeader.__init__cCs||_t�||�Sr%)r0rFr8)r'r0r$r$r*r8�szTestAuthHeader.rendercCs|j��|j��fSr%)r0ZgetUserZgetPasswordr&r$r$r*�xmlrpc_authinfo�szTestAuthHeader.xmlrpc_authinfoN)r,r-r.rBrr8r�r$r$r$r*r~�sr~c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�TestQueryProtocolz_
    QueryProtocol for tests that saves headers received and sent,
    inside the factory.
    cCs|j|j_tj�|�dSr%)�	transport�factoryr	�
QueryProtocol�connectionMader&r$r$r*r��s
z TestQueryProtocol.connectionMadecCs||jj|��<dSr%)r��headers�lower�r'rm�valr$r$r*�handleHeader�szTestQueryProtocol.handleHeadercCs$||jj|��<tj�|||�dS)zA
        Keep sent headers so we can inspect them later.
        N)r��sent_headersr�r	r��
sendHeaderr�r$r$r*r��szTestQueryProtocol.sendHeaderN)r,r-r.rBr�r�r�r$r$r$r*r��sr�c@seZdZdZeZdd�ZdS)�TestQueryFactoryzE
    QueryFactory using L{TestQueryProtocol} for saving headers.
    cOs$i|_i|_tjj|f|�|�dSr%)r�r�r	r
r)r'�args�kwargsr$r$r*rszTestQueryFactory.__init__N)r,r-r.rBr�Zprotocolrr$r$r$r*r�sr�c@seZdZdZdd�ZdS)�TestQueryFactoryCancelz{
    QueryFactory that saves a reference to the
    L{twisted.internet.interfaces.IConnector} to test connection lost.
    cCs
||_dSr%)�	connector)r'r�r$r$r*�startedConnectingsz(TestQueryFactoryCancel.startedConnectingN)r,r-r.rBr�r$r$r$r*r�sr�c@s�eZdZdd�Zdd�Zdd�Zd dd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zee_dS)!�XMLRPCTestscCs2tjdt�t��dd�|_|j��j|_g|_dS�Nr�	127.0.0.1�Z	interface)	r�	listenTCPr�SiterF�p�getHost�port�	factoriesr&r$r$r*r5s
�zXMLRPCTests.setUpcCsg|_|j��Sr%)r�r��
stopListeningr&r$r$r*�tearDown#szXMLRPCTests.tearDowncOst||�}|j�|�|S)zw
        Specific queryFactory for proxy that uses our custom
        L{TestQueryFactory}, and save factories.
        )r�r��append)r'r�r�r�r$r$r*�queryFactory's
zXMLRPCTests.queryFactoryNcCs0t�td|j��}|dkr&|j|_n||_|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/N�r	�Proxyrr�r��r'r�r�r$r$r*�proxy0s

zXMLRPCTests.proxycCs�dddddidfdfddddgfdd	d
ddd
ggdd�fg}g}|D]6\}}}|��j|f|��}|�|j|�|�|�qDtj|dd�S)N)�add)���)r)rLrL�dictrLr7�pair)rLr7)rercrc�complexr$rMrgr[rhriT�ZfireOnOneErrback�r��
callRemote�addCallbackr9r�r�DeferredList)r'ZinputOutput�dl�methr�Zoutp�dr$r$r*�test_results=s�zXMLRPCTests.test_resultscs@����dd�}�fdd�}�fdd�}|�|�|�|�|S)z�
        Verify that headers sent from the client side and the ones we
        get back from the server side are correct.

        rerccs4���jdjdd����jdjdd�dS)Nr�content-type�text/xml; charset=utf-8�content-lengths129)r9r�r�)Zingr&r$r*�check_server_headersVs��z6XMLRPCTests.test_headers.<locals>.check_server_headerscsL���jdjdd����jdjdd����jdjdd�dS)Nrs
user-agentsTwisted/XMLRPClibr�r�r�s155)r9r�r�)�ignr&r$r*�check_client_headers]s���z6XMLRPCTests.test_headers.<locals>.check_client_headers�r�r�r�)r'r�r�r�r$r&r*�test_headersNs


zXMLRPCTests.test_headerscs�t��t�ttjd�g��t������fdd��g}dD]D\}}����	|�}��
|tj�}|�
|f�fdd�	�|�|�q>tj|dd�}��fdd	�}|�
|�|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.
        �ZdefaultLogLevelcs
t���Sr%�rZremoveObserverr$��filteredr$r*�<lambda>yr6z)XMLRPCTests.test_errors.<locals>.<lambda>))rGrX)rG�	deferFail)r[�fault)rHZnoSuchMethod)r`�
deferFault)rIZSESSION_TESTcs��|j|�Sr%)r9Z	faultCode)�exc�coder&r$r*r��sTr�cs��jD]}��|jdd�q��dt����ddj}�ddj}t|t�rb��|t	�n��|t	���|t���
t	t�dS)Nr�r�r�r�log_failurer7)r�r9r��assertEquals�len�value�
isinstancerE�assertIsInstancerC�flushLoggedErrors)r�r��f1�f2��logObserverr'r$r*�cb�s
�
z#XMLRPCTests.test_errors.<locals>.cb)rrrr�criticalr�addObserver�
addCleanupr�r��
assertFailurer	r^r�r�rr�)r'r�r�Z
methodNamer�r�r$�r�r�r'r*�test_errorsls"�

zXMLRPCTests.test_errorscs^�fdd��|����ddd�}|��jjjd�|��|��jjjd�|�|t	j
�}|S)z�
        A deferred from the Proxy can be cancelled, disconnecting
        the L{twisted.internet.interfaces.IConnector}.
        cst||��_�jSr%)r��f)r��kw�r�r$r*r��sz(XMLRPCTests.test_cancel.<locals>.factoryr�r�r��disconnected)r�r�ZassertNotEqualr�r��stateZcancelr9r�rZCancelledError�r'r�r$r�r*�test_cancel�szXMLRPCTests.test_cancelcs<t�t�}|�dtd�jf��}�fdd�}|�|�|S)zN
        A classic GET on the xml server should return a NOT_ALLOWED.
        sGETr�cs��|jtj�dSr%)r9r�rZNOT_ALLOWED)Zresponser&r$r*�
checkResponse�sz0XMLRPCTests.test_errorGet.<locals>.checkResponse)r�Agentrr0rr�r�)r'�agentr�r�r$r&r*�
test_errorGet�s


zXMLRPCTests.test_errorGetcsVt�t�}|jtd�jf�dt�td��d�}|�tj	��fdd�}|�|�|S)zL
        Test that an invalid XML input returns an L{xmlrpc.Fault}.
        r�sPOSTsfoo)Zurir1ZbodyProducercs��tjtj|�dSr%)ZassertRaisesr	r^rr<r(r&r$r*r��sz,XMLRPCTests.test_errorXMLContent.<locals>.cb)
rr�rr0rr�ZFileBodyProducerrr�ZreadBody)r'r�r�r�r$r&r*�test_errorXMLContent�s
�
z XMLRPCTests.test_errorXMLContentcCs*t��}|���d|�}|�|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{)rZDateTimer�r�r�r9)r'Zwhenr�r$r$r*�test_datetimeRoundtrip�sz"XMLRPCTests.test_datetimeRoundtripcs�t��t�ttjd�g��t������fdd������	dd�}dd�}��
td|���|t
�}��fd	d
�}|�|�|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�cs
t���Sr%r�r$r�r$r*r��r6z6XMLRPCTests.test_doubleEncodingError.<locals>.<lambda>r{r!c_std��dS)NzCannot encode anything at all!)�RuntimeError)r�r�r$r$r*�	fakeDumps�sz7XMLRPCTests.test_doubleEncodingError.<locals>.fakeDumpsr2cs@��dt������ddjt���t��t��d�dS)Nr7rr�)r�r�r�r�r�r9r�)�ignoredr�r$r*�cbFailed�s�z6XMLRPCTests.test_doubleEncodingError.<locals>.cbFailed)rrrrr�rr�r�r�r�Zpatchrr��	Exceptionr�)r'r�r�r�r$r�r*�test_doubleEncodingError�s�

z$XMLRPCTests.test_doubleEncodingErrorcs&����dd�}�fdd�}|�|�S)zV
        The connection to the web server is closed when the request is done.
        r{r!cs(�j\}��|jj���|jj�dSr%)r�ZassertFalser�Z	connectedZ
assertTruer�)r�r�r&r$r*�responseDone�szBXMLRPCTests.test_closeConnectionAfterRequest.<locals>.responseDoner�)r'r�r�r$r&r*� test_closeConnectionAfterRequest�sz,XMLRPCTests.test_closeConnectionAfterRequestcCs:t�}tjdd|d�}|�d�|�|jddd�dS)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.
        shttp://127.0.0.1:69g@�ZconnectTimeoutr�
someMethodrr�N)rr	r�r�r9Z
tcpClients�r'rr�r$r$r*�test_tcpTimeouts�
zXMLRPCTests.test_tcpTimeoutcCs:t�}tjdd|d�}|�d�|�|jddd�dS)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.
        shttps://127.0.0.1:69g@r�r�r�N)rr	r�r�r9Z
sslClientsr�r$r$r*�test_sslTimeouts�
zXMLRPCTests.test_sslTimeout)N)r,r-r.r5r�r�r�r�r�r�r�r�r�r�r�r�r�r��sslSkip�skipr$r$r$r*r�s 	

+
&
r�c@seZdZdZddd�ZdS)�XMLRPCProxyWithoutSlashTestsz3
    Test with proxy that doesn't add a slash.
    NcCs0t�td|j��}|dkr&|j|_n||_|S)N�http://127.0.0.1:%dr�r�r$r$r*r�"s

z"XMLRPCProxyWithoutSlashTests.proxy)N)r,r-r.rBr�r$r$r$r*r�sr�c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)� XMLRPCPublicLookupProcedureTestszr
    Tests for L{XMLRPC}'s support of subclasses which override
    C{lookupProcedure} and C{listProcedures}.
    cCsNtjdt�|�dd�|_|�|jj�|j��j|_t	�
td|j��|_dS)Nrr�r�r�)
rr�rr�r�r�r�r�r�r	r�rr�)r'r4r$r$r*�createServer2s��z-XMLRPCPublicLookupProcedureTests.createServercCs0|�t��d}|j�d|�}|�|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.
        r\r{)r�rzr�r�r�r9)r'Zwhatr�r$r$r*�test_lookupProcedure;s
z5XMLRPCPublicLookupProcedureTests.test_lookupProcedurecCs,|�t��|j�dd�}|�|tj�}|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.
        Zxxxxr\)r�rzr�r�r�r	r^r�r$r$r*r�Gsz,XMLRPCPublicLookupProcedureTests.test_errorscs>t�}t|���|��j�d�}�fdd�}|�|�|S)z�
        A subclass of L{XMLRPC} can override C{listProcedures} to define
        Overriding listProcedures should prevent introspection from being
        broken.
        �system.listMethodscs��d|�dS)Nrh)ZassertIn)Z
proceduresr&r$r*�listed]szAXMLRPCPublicLookupProcedureTests.test_listMethods.<locals>.listed)r|rr�r�r�r�)r'r4r�r�r$r&r*�test_listMethodsSs

z1XMLRPCPublicLookupProcedureTests.test_listMethodsN)r,r-r.rBr�r�r�r�r$r$r$r*r�,s
	r�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�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.
    cCsd|jdi}tjdt�tf|��dd�|_|�|jj�|j�	�j
|_
tjt
d|j
f�f|�|_dS)zO
        Create a new XML-RPC server with C{allowNone} set to C{True}.
        Trr�r�r�N)�flagNamerr�rr�rFr�r�r�r�r�r	r�rr�)r'r�r$r$r*r5vs
���zSerializationConfigMixin.setUpcCs$|j�d|j�}|�|j|j�|S)zY
        C{self.value} can be round-tripped over an XMLRPC method call/response.
        r�r�r�r�r�r9r�r$r$r*�test_roundtripValue�sz,SerializationConfigMixin.test_roundtripValuecCs,|j�dd|ji�}|�|jd|ji�|S)zz
        A C{dict} which contains C{self.value} can be round-tripped over an
        XMLRPC method call/response.
        rrLrr�r$r$r*�test_roundtripNestedValue�sz2SerializationConfigMixin.test_roundtripNestedValueN)r,r-r.rBr5rrr$r$r$r*r�gs
	r�c@seZdZdZdZdZdS)�XMLRPCAllowNoneTestszF
    Tests for passing L{None} when the C{allowNone} flag is set.
    �	allowNoneN)r,r-r.rBrr�r$r$r$r*r�src@s(eZdZdZdZe�dddddd�Zd	S)
�XMLRPCUseDateTimeTestszd
    Tests for passing a C{datetime.datetime} instance when the C{useDateTime}
    flag is set.
    ZuseDateTimei�r[�r��-�;N)r,r-r.rBr�datetimer�r$r$r$r*r�src@s@eZdZdZdZdZdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dS)�XMLRPCAuthenticatedTestsz]
    Test with authenticated proxy. We run this with the same input/output as
    above.
    susernamesasecretcCs2tjdt�t��dd�|_|j��j|_g|_dSr�)	rr�rr�r~r�r�r�r�r&r$r$r*r5�s
�zXMLRPCAuthenticatedTests.setUpcCsNdt|j�t|j�|jf}t�t|��}|�d�}|�|j	|j|jg�|S)Nzhttp://%s:%s@127.0.0.1:%d/�authinfo)
r�user�passwordr�r	r�rr�r�r9)r'Zurlr�r�r$r$r*�test_authInfoInURL�s�
z+XMLRPCAuthenticatedTests.test_authInfoInURLcCsBt�td|jf�|j|j�}|�d�}|�|j|j|jg�|S)Nr�r�	r	r�rr�r
rr�r�r9�r'r�r�r$r$r*�test_explicitAuthInfo�s��
z.XMLRPCAuthenticatedTests.test_explicitAuthInfocCsH|jd}t�td|jf�|j|�}|�d�}|�|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)	rr	r�rr�r
r�r�r9)r'ZlongPasswordr�r�r$r$r*�test_longPassword�s
��
z*XMLRPCAuthenticatedTests.test_longPasswordcCsBt�td|jf�|j|j�}|�d�}|�|j|j|jg�|S)Nzhttp://wrong:info@127.0.0.1:%d/rrrr$r$r*�test_explicitAuthInfoOverride�s��
z6XMLRPCAuthenticatedTests.test_explicitAuthInfoOverrideN)r,r-r.rBr
rr5rrrrr$r$r$r*r�s	rc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�XMLRPCIntrospectionTestscCs>t�}t|�tjdt�|�dd�|_|j��j|_g|_	dSr�)
rFrrr�rr�r�r�r�r�)r'r	r$r$r*r5�s
zXMLRPCIntrospectionTests.setUpcs(�fdd�}����d�}|�|�|S)Ncs6|����|ddddddddd	d
ddd
ddg�dS)Nr�r�rr�r�r�r{rXr�r�rer��system.methodHelp�system.methodSignaturer)�sortr9)Zmethsr&r$r*�	cbMethods�s"��z<XMLRPCIntrospectionTests.test_listMethods.<locals>.cbMethodsr�r�)r'rr�r$r&r*r��s

z)XMLRPCIntrospectionTests.test_listMethodscCsRdddg}g}|D]0\}}|���d|�}|�|j|�|�|�qtj|dd�S)N)rrT)rXr!)r�rorTr�r��r'ZinputOutputsr�r�Zexpectedr�r$r$r*�test_methodHelp�s�z(XMLRPCIntrospectionTests.test_methodHelpcCsrdddddgdddggfddddggfg}g}|D]0\}}|���d|�}|�|j|�|�|�q2tj|d	d
�S)N)rr!r�rOrPr�rSrQrTr�r�rr$r$r*�test_methodSignatures
��z-XMLRPCIntrospectionTests.test_methodSignatureN)r,r-r.r5r�rrr$r$r$r*r�s
rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�XMLRPCClientErrorHandlingTestsz3
    Test error handling on the xmlrpc client.
    cCs4t�dd�|_d|j_tjdt�|j�dd�|_dS)Ns*This text is not a valid XML-RPC response.s
text/plainTrr�r�)	rZDatar4ZisLeafrr�rr�r�r&r$r$r*r5s��z$XMLRPCClientErrorHandlingTests.setUpcCs
|j��Sr%)r�r�r&r$r$r*r� sz'XMLRPCClientErrorHandlingTests.tearDowncCs.t�td|j��jf��}|�|�d�t�S)zj
        Test that calling the xmlrpc client on a static http server raises
        an exception.
        r�r�)r	r�rr�r�r�r��
ValueError)r'r�r$r$r*�test_erroneousResponse#s�z5XMLRPCClientErrorHandlingTests.test_erroneousResponseN)r,r-r.rBr5r�r r$r$r$r*rs	rc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�QueryFactoryParseResponseTestsz?
    Test the behaviour of L{_QueryFactory.parseResponse}.
    c	Cs<tdddddddd�|_t�d�|_d|_t�t��|_	dS)Nr"Fr$)�pathZhostr1r
rrr�)r!zinvalid xml)
r
r�rr2�goodContents�badContentsrr@r�reasonr&r$r$r*r53s�z$QueryFactoryParseResponseTests.setUpcCs,|jj}|�|jj|j�|j�|j�|S)z�
        We can safely call L{_QueryFactory.clientConnectionLost} as a callback
        of L{_QueryFactory.parseResponse}.
        )r��deferredr��clientConnectionLostr%�
parseResponser#r�r$r$r*� test_parseResponseCallbackSafetyBsz?QueryFactoryParseResponseTests.test_parseResponseCallbackSafetycCs,|jj}|�|jj|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$r�r$r$r*�test_parseResponseErrbackSafetyPsz>QueryFactoryParseResponseTests.test_parseResponseErrbackSafetycCs,|jj}|�|jj|j�|j�dd�|S)z
        We can safely call L{_QueryFactory.clientConnectionLost} as an errback
        of L{_QueryFactory.badStatus}.
        Zstatus�message)r�r&r*r'r%Z	badStatusr�r$r$r*�test_badStatusErrbackSafety^sz:QueryFactoryParseResponseTests.test_badStatusErrbackSafetycCs$d}|jj}|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'r3r�r$r$r*�test_parseResponseWithoutDataksz<QueryFactoryParseResponseTests.test_parseResponseWithoutDataN)	r,r-r.rBr5r)r+r-r/r$r$r$r*r!.s
r!c@seZdZdd�Zdd�ZdS)�XMLRPCWithRequestTestscCst�|_dSr%)rFr4r&r$r$r*r5�szXMLRPCWithRequestTests.setUpcsLtd�}d|_tt�dd��|_�fdd�}|���||�}�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")rhrcs t�|jd�}��|d�dS)Nr))zPOST fooN)rr<r:r9)�nr0�datar&r$r*�valid�sz6XMLRPCWithRequestTests.test_withRequest.<locals>.valid)
rr1rrr2r3ZnotifyFinishr�r4Zrender_POST)r'r0r3r�r$r&r*�test_withRequest�s�z'XMLRPCWithRequestTests.test_withRequestN)r,r-r.r5r4r$r$r$r*r0~sr0)HrBZ
__future__rrZtwisted.python.compatrrr�iorr
Z
twisted.trialrZtwisted.webr	Ztwisted.web.xmlrpcr
rrr
rrrrrrZtwisted.internetrrZtwisted.internet.errorrZtwisted.pythonrZtwisted.python.reflectrZtwisted.test.proto_helpersrrZtwisted.web.test.test_webrZtwisted.loggerrrrr�ImportErrorr�ZTestCaser r�rCrrErFrzr|r~r�r�r�r�r�r�r�r�rrrrrr!r0r$r$r$r*�<module>sX
1[

;0	65P