AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/twisted/web/test/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /lib/python3/dist-packages/twisted/web/test/__pycache__/test_xmlrpc.cpython-310.pyc
o

�blw�@s|dZddlZddlmZmZddlmZddlmZm	Z	ddl
mZddlm
Z
mZmZmZddlmZdd	lmZmZdd
lmZddlmZmZddlmZdd
lmZmZmZm Z m!Z!ddl"m#Z#ddl$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*zed�Wne+y�dZ,YnwdZ,Gdd�dej-�Z.Gdd�de/�Z0Gdd�de1�Z2Gdd�de%�Z3Gdd�de%�Z4Gdd�de%�Z5Gdd �d e3�Z6Gd!d"�d"e!j7�Z8Gd#d$�d$e!j&�Z9Gd%d&�d&e!j&�Z:Gd'd(�d(ej-�Z;Gd)d*�d*e;�Z<Gd+d,�d,ej-�Z=Gd-d.�d.�Z>Gd/d0�d0e>ej-�Z?Gd1d2�d2e>ej-�Z@Gd3d4�d4e;�ZAGd5d6�d6e;�ZBGd7d8�d8ej-�ZCGd9d:�d:ej-�ZDGd;d<�d<ej-�ZEdS)=z6
Tests for  XML-RPC support in L{twisted.web.xmlrpc}.
�N)�BytesIO�StringIO)�skipIf)�defer�reactor)�ConnectionDone)�FilteringLogObserver�LogLevel�LogLevelFilterPredicate�globalLogPublisher)�failure)�nativeString�
networkString)�namedModule)�EventLoggingObserver�
MemoryReactor)�unittest)�client�http�server�static�xmlrpc)�DummyRequest)�XMLRPC�QueryFactory�addIntrospection�payloadTemplate�withRequest�	xmlrpclibztwisted.internet.sslTFc@�(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_async=�z:AsyncXMLRPCTests.setUp.<locals>.AsyncResource.xmlrpc_asyncN)�__name__�
__module__�__qualname__r+r$r(r$r*�
AsyncResource<sr0)
r�request�methodrrr�dumps�contentr�Deferredr)r�resource)r'r0r$r(r*�setUp3s�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)r6�renderr1�assertEqual�writtenr)�callbackr�loads�join�finished)r'�respr$r$r*�test_deferredResponseBs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.
        �	Simulatedr)rN)r6r:r1�processingFailedr�Failurerr)r=r;r<r@r&r$r$r*� test_interruptedDeferredResponsePs
z1AsyncXMLRPCTests.test_interruptedDeferredResponseN)r-r.r/�__doc__r7rBrFr$r$r$r*r .s
r c@�eZdZdS)�TestRuntimeErrorN�r-r.r/r$r$r$r*rI^�rIc@rH)�TestValueErrorNrJr$r$r$r*rLbrKrLc@s�eZdZdZdZdZdd�Zdd�Zgd�gd	�ge_d
d�Z	gd�ge	_d
d�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zde_edd��Zd d!�Zd"S)#�Test���*cC�|Sr%r$)r'�argr$r$r*�xmlrpc_echoor,zTest.xmlrpc_echocCs||S)z0
        This function add two numbers.
        r$)r'�a�br$r$r*�
xmlrpc_adds�zTest.xmlrpc_add��intrYrY��doubler[r[cCs||gS)zC
        This function puts the two arguments in an array.
        r$)r'�string�numr$r$r*�xmlrpc_pairrWzTest.xmlrpc_pair��arrayr\rYcCs
t�|�S)�Help for defer.)r�succeed�r'�xr$r$r*�xmlrpc_defer�s
zTest.xmlrpc_defercCst�t��Sr%)r�failrLr&r$r$r*�xmlrpc_deferFail��zTest.xmlrpc_deferFailcCst�r%)rIr&r$r$r*�xmlrpc_fail�r,zTest.xmlrpc_failcCst�dd�S)N��hello�r�Faultr&r$r$r*�xmlrpc_fault�rhzTest.xmlrpc_faultcCst�t�dd��S)N��hi)rrfrrmr&r$r$r*�xmlrpc_deferFault��zTest.xmlrpc_deferFaultcCsd}||krt�dd�S|S)z8
        Used to test that we can pass Unicode.
        �☃�
zPayload not unicode snowmanrl)r'�payload�snowmanr$r$r*�xmlrpc_snowman�szTest.xmlrpc_snowmancCsdddggdd�S)NrU�crj�foo�rT�Dr$r&r$r$r*�xmlrpc_complex�rrzTest.xmlrpc_complexcCs||Sr%r$)r'�map�keyr$r$r*�xmlrpc_dict��zTest.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.
        � )r2)r'r1�otherr$r$r*�xmlrpc_withRequest�s	���zTest.xmlrpc_withRequestcCs:zt�||�WStjy|�d�rt�|jd���w)N�SESSIONzSession non-existent/expired.)r�lookupProcedurer�NoSuchFunction�
startswithrm�SESSION_EXPIRED)r'�
procedurePathr$r$r*r��s
��zTest.lookupProcedureN)r-r.r/�FAILURE�	NOT_FOUNDr�rSrV�	signaturer^rergrirnrqrwr|r�helprr�r�r$r$r$r*rMfs.�	
rMc@s eZdZdZdd�Zdd�ZdS)�TestLookupProcedurez}
    This is a resource which customizes procedure lookup to be used by the tests
    of support for this customization.
    cCrQr%r$rcr$r$r*�echo�r,zTestLookupProcedure.echocCs$|dkr|jSt�|jd|�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�rr�r�)r'�
procedureNamer$r$r*r��s
�z#TestLookupProcedure.lookupProcedureN)r-r.r/rGr�r�r$r$r$r*r��sr�c@�eZdZdZdd�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.
        ryr$r&r$r$r*�listProcedures�sz!TestListProcedures.listProceduresN)r-r.r/rGr�r$r$r$r*r���r�c@r)	�TestAuthHeaderzU
    This is used to get the header info so that we can test
    authentication.
    cCst�|�d|_dSr%)rM�__init__r1r&r$r$r*r��s

zTestAuthHeader.__init__cCs||_t�||�Sr%)r1rMr:)r'r1r$r$r*r:�szTestAuthHeader.rendercCs|j��|j��fSr%)r1�getUser�getPasswordr&r$r$r*�xmlrpc_authinfo��zTestAuthHeader.xmlrpc_authinfoN)r-r.r/rGr�r:r�r$r$r$r*r��s
r�c@r)	�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'r~�valr$r$r*�handleHeaderr�zTestQueryProtocol.handleHeadercCs$||jj|��<tj�|||�dS)zA
        Keep sent headers so we can inspect them later.
        N)r��sent_headersr�rr��
sendHeaderr�r$r$r*r�szTestQueryProtocol.sendHeaderN)r-r.r/rGr�r�r�r$r$r$r*r��s
r�c@seZdZdZeZdd�ZdS)�TestQueryFactoryzE
    QueryFactory using L{TestQueryProtocol} for saving headers.
    cOs*i|_i|_tjj|g|�Ri|��dSr%)r�r�rrr�)r'�args�kwargsr$r$r*r�szTestQueryFactory.__init__N)r-r.r/rGr��protocolr�r$r$r$r*r�sr�c@r�)�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*�startedConnecting"�
z(TestQueryFactoryCancel.startedConnectingN)r-r.r/rGr�r$r$r$r*r�r�r�c@s�eZdZdd�Zdd�Zdd�Zd!dd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zeed�dd ��ZdS)"�XMLRPCTestscC�2tjdt�t��dd�|_|j��j|_g|_dS�Nr�	127.0.0.1��	interface)	r�	listenTCPr�SiterM�p�getHost�port�	factoriesr&r$r$r*r7's
zXMLRPCTests.setUpcCsg|_|j��Sr%)r�r��
stopListeningr&r$r$r*�tearDown,s
zXMLRPCTests.tearDowncOst|i|��}|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*�queryFactory0szXMLRPCTests.queryFactoryNcCs2t�td|j��}|dur|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/N�r�Proxyrr�r��r'r�r�r$r$r*�proxy9s�zXMLRPCTests.proxycCs�dddddidfdfddddgfdd	d
ddd
ggdd�fg}g}|D]\}}}|��j|g|�R�}|�|j|�|�|�q"tj|dd�S)N)�add)���)r)rTrT�dictrTr9�pair)rTr9)rvrsrs�complexr$rUrxrjryrzT��fireOnOneErrback�r��
callRemote�addCallbackr;r�r�DeferredList)r'�inputOutput�dl�methr��outp�dr$r$r*�test_resultsFs�	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.

        rvrscs4���jdjdd����jdjdd�dS)Nr�content-type�text/xml; charset=utf-8�content-lengths129)r;r�r�)�ingr&r$r*�check_server_headers_s�z6XMLRPCTests.test_headers.<locals>.check_server_headerscsL���jdjdd����jdjdd����jdjdd�dS)Nrs
user-agentsTwisted/XMLRPClibr�r�r�s155)r;r�r�)�ignr&r$r*�check_client_headerses��z6XMLRPCTests.test_headers.<locals>.check_client_headers�r�r�r�)r'r�r�r�r$r&r*�test_headersWs


zXMLRPCTests.test_headerscs�t��t�ttjd�g��t������fdd��g}dD]"\}}����	|�}��
|tj�}|�
|f�fdd�	�|�|�qtj|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.
        ��defaultLogLevelc�
t���Sr%�r�removeObserverr$��filteredr$r*�<lambda>�
z)XMLRPCTests.test_errors.<locals>.<lambda>))rNrf)rN�	deferFail)rj�fault)rO�noSuchMethod)ro�
deferFault)rP�SESSION_TESTcs��|j|�Sr%)r;�	faultCode)�exc�coder&r$r*r��sTr�cs��jD]}��|jdd�q��dt����ddj}�ddj}t|t�r1��|t	�n��|t	���|t���
t	t�dS)Nr�r�r�r�log_failurer9)r�r;r��assertEquals�len�value�
isinstancerL�assertIsInstancerI�flushLoggedErrors)r�r��f1�f2��logObserverr'r$r*�cb�s

�
z#XMLRPCTests.test_errors.<locals>.cb)rrr
r	�criticalr�addObserver�
addCleanupr�r��
assertFailurerrmr�r�rr�)r'r�r��
methodNamer�r�r$�r�r�r'r*�test_errorsss �

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|i|���_�jSr%)r��f)r��kw�r�r$r*r��sz(XMLRPCTests.test_cancel.<locals>.factoryr�r�r��disconnected)r�r��assertNotEqualrr��state�cancelr;rr�CancelledError�r'r�r$rr*�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%)r;r�r�NOT_ALLOWED)�responser&r$r*�
checkResponse�r�z0XMLRPCTests.test_errorGet.<locals>.checkResponse)r�Agentrr1rr�r�)r'�agentr�rr$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)�urir2�bodyProducercs��tjtj|�dSr%)�assertRaisesrrmrr>r(r&r$r*r��sz,XMLRPCTests.test_errorXMLContent.<locals>.cb)
rrrr1rr��FileBodyProducerrr��readBody)r'rr�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�)r�DateTimer�r�r�r;)r'�whenr�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�cr�r%r�r$r�r$r*r��r�z6XMLRPCTests.test_doubleEncodingError.<locals>.<lambda>r�r!c_std��)NzCannot encode anything at all!)�RuntimeError)r�r�r$r$r*�	fakeDumps�r�z7XMLRPCTests.test_doubleEncodingError.<locals>.fakeDumpsr3cs@��dt������ddjt���t��t��d�dS)Nr9rr�)r�r�r�r�rr;r�)�ignoredr�r$r*�cbFailed�sz6XMLRPCTests.test_doubleEncodingError.<locals>.cbFailed)rrr
r	r�rr�rr�r��patchrr�	Exceptionr�)r'r�rr!r$rr*�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��assertFalser��	connected�
assertTruer)r r�r&r$r*�responseDoneszBXMLRPCTests.test_closeConnectionAfterRequest.<locals>.responseDoner�)r'r�r(r$r&r*� test_closeConnectionAfterRequests
z,XMLRPCTests.test_closeConnectionAfterRequestcC�: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@��connectTimeoutr�
someMethodrr�N)rrr�r�r;�
tcpClients�r'rr�r$r$r*�test_tcpTimeouts�
zXMLRPCTests.test_tcpTimeoutzOpenSSL not presentcCr*)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)rrr�r�r;�
sslClientsr/r$r$r*�test_sslTimeouts�
zXMLRPCTests.test_sslTimeoutr%)r-r.r/r7r�r�r�r�r�rrrrrr$r)r0r�sslSkipr3r$r$r$r*r�&s"
	
0
#

r�c@seZdZdZddd�ZdS)�XMLRPCProxyWithoutSlashTestsz3
    Test with proxy that doesn't add a slash.
    NcCs2t�td|j��}|dur|j|_|S||_|S)N�http://127.0.0.1:%dr�r�r$r$r*r�0s�z"XMLRPCProxyWithoutSlashTests.proxyr%)r-r.r/rGr�r$r$r$r*r5+sr5c@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�r6)
rr�rr�r�rr�r�r�rr�rr�)r'r6r$r$r*�createServer?sz-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.
        rkr�)r8r�r�r�r�r;)r'�whatr�r$r$r*�test_lookupProcedureEs
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.
        �xxxxrk)r8r�r�r�rrrmr
r$r$r*rPs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)Nry)�assertIn)�
proceduresr&r$r*�listedfszAXMLRPCPublicLookupProcedureTests.test_listMethods.<locals>.listed)r�rr8r�r�r�)r'r6r�r?r$r&r*�test_listMethods[s

z1XMLRPCPublicLookupProcedureTests.test_listMethodsN)r-r.r/rGr8r:rr@r$r$r$r*r79sr7c@r)	�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.
    cCsl|jdi}tjdt�tdi|���dd�|_|�|jj�|j�	�j
|_
tjt
d|j
f�fi|��|_dS)zO
        Create a new XML-RPC server with C{allowNone} set to C{True}.
        Trr�r�r�Nr$)�flagNamerr�rr�rMr�rr�r�r�rr�rr�)r'r�r$r$r*r7�s
���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�r;r
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.
        rrTrCr
r$r$r*�test_roundtripNestedValue�sz2SerializationConfigMixin.test_roundtripNestedValueN)r-r.r/rGr7rDrEr$r$r$r*rAps
rAc@seZdZdZdZdZdS)�XMLRPCAllowNoneTestszF
    Tests for passing L{None} when the C{allowNone} flag is set.
    �	allowNoneN)r-r.r/rGrBr�r$r$r$r*rF�srFc@s(eZdZdZdZe�dddddd�Zd	S)
�XMLRPCUseDateTimeTestszd
    Tests for passing a C{datetime.datetime} instance when the C{useDateTime}
    flag is set.
    �useDateTimei�rj�r��-�;N)r-r.r/rGrB�datetimer�r$r$r$r*rH�srHc@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.
    susernamesasecretcCr�r�)	rr�rr�r�r�r�r�r�r&r$r$r*r7�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�rr�rr�r�r;)r'�urlr�r�r$r$r*�test_authInfoInURL�s�
z+XMLRPCAuthenticatedTests.test_authInfoInURLcC�Bt�td|jf�|j|j�}|�d�}|�|j|j|jg�|S)Nr�rO�	rr�rr�rPrQr�r�r;�r'r�r�r$r$r*�test_explicitAuthInfo���
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�rO)	rQrr�rr�rPr�r�r;)r'�longPasswordr�r�r$r$r*�test_longPassword�s
�
z*XMLRPCAuthenticatedTests.test_longPasswordcCrT)Nzhttp://wrong:info@127.0.0.1:%d/rOrUrVr$r$r*�test_explicitAuthInfoOverride�rXz6XMLRPCAuthenticatedTests.test_explicitAuthInfoOverrideN)r-r.r/rGrPrQr7rSrWr[r\r$r$r$r*rN�s
rNc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�XMLRPCIntrospectionTestscCs>t�}t|�tjdt�|�dd�|_|j��j|_g|_	dSr�)
rMrrr�rr�r�r�r�r�)r'rr$r$r*r7�s

zXMLRPCIntrospectionTests.setUpcs(�fdd�}����d�}|�|�|S)Ncs|����|gd��dS)N)r�r�rr�r�r�r�rfr�r�rvr<�system.methodHelp�system.methodSignaturer)�sortr;)�methsr&r$r*�	cbMethods�s
�z<XMLRPCIntrospectionTests.test_listMethods.<locals>.cbMethodsr<r�)r'rbr�r$r&r*r@�s
z)XMLRPCIntrospectionTests.test_listMethodscCsPgd�}g}|D]\}}|���d|�}|�|j|�|�|�qtj|dd�S)N))rra)rfr!)r�r�r^Tr�r��r'�inputOutputsr�r��expectedr�r$r$r*�test_methodHelpsz(XMLRPCIntrospectionTests.test_methodHelpcCslddgd�gd�gfdgd�gfg}g}|D]\}}|���d|�}|�|j|�|�|�qtj|dd	�S)
N)rr!r�rXrZr�r_r_Tr�r�rcr$r$r*�test_methodSignature%s�z-XMLRPCIntrospectionTests.test_methodSignatureN)r-r.r/r7r@rfrgr$r$r$r*r]�s
r]c@r)	�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�)	r�Datar6�isLeafrr�rr�r�r&r$r$r*r79s��z$XMLRPCClientErrorHandlingTests.setUpcCs
|j��Sr%)r�r�r&r$r$r*r�Cr�z'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-)rr�rr�r�rr��
ValueError)r'r�r$r$r*�test_erroneousResponseFs�z5XMLRPCClientErrorHandlingTests.test_erroneousResponseN)r-r.r/rGr7r�rlr$r$r$r*rh4s

rhc@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$)�path�hostr2rPrQrGr�)r!zinvalid xml)
rr�rr3�goodContents�badContentsrrEr�reasonr&r$r$r*r7Vs�
z$QueryFactoryParseResponseTests.setUpcC�,|jj}|�|jj|j�|j�|j�|S)z�
        We can safely call L{QueryFactory.clientConnectionLost} as a callback
        of L{QueryFactory.parseResponse}.
        )r��deferredr��clientConnectionLostrr�
parseResponserpr
r$r$r*� test_parseResponseCallbackSafetyj�z?QueryFactoryParseResponseTests.test_parseResponseCallbackSafetycCrs)z�
        We can safely call L{QueryFactory.clientConnectionLost} as an errback
        of L{QueryFactory.parseResponse}.
        )r�rt�
addErrbackrurrrvrqr
r$r$r*�test_parseResponseErrbackSafetywrxz>QueryFactoryParseResponseTests.test_parseResponseErrbackSafetycCs,|jj}|�|jj|j�|j�dd�|S)z}
        We can safely call L{QueryFactory.clientConnectionLost} as an errback
        of L{QueryFactory.badStatus}.
        �status�message)r�rtryrurr�	badStatusr
r$r$r*�test_badStatusErrbackSafety�rxz: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�rtrvr�
IndexError)r'r4r�r$r$r*�test_parseResponseWithoutData�sz<QueryFactoryParseResponseTests.test_parseResponseWithoutDataN)	r-r.r/rGr7rwrzr~r�r$r$r$r*rmQs


rmc@seZdZdd�Zdd�ZdS)�XMLRPCWithRequestTestscCst�|_dSr%)rMr6r&r$r$r*r7�rhzXMLRPCWithRequestTests.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")ryrcs t�|jd�}��|d�dS)Nr))zPOST fooN)rr>r<r;)�nr1�datar&r$r*�valid�sz6XMLRPCWithRequestTests.test_withRequest.<locals>.valid)
rr2rrr3r4�notifyFinishr�r6�render_POST)r'r1r�r�r$r&r*�test_withRequest�sz'XMLRPCWithRequestTests.test_withRequestN)r-r.r/r7r�r$r$r$r*r��sr�)FrGrM�iorrrr�twisted.internetrr�twisted.internet.errorr�twisted.loggerrr	r
r�twisted.pythonr�twisted.python.compatr
r�twisted.python.reflectr�twisted.test.proto_helpersrr�
twisted.trial�twisted.webrrrrr�twisted.web.test.test_webr�twisted.web.xmlrpcrrrrrr�ImportErrorr4�TestCaser rrIrkrLrMr�r�r�r�r�r�r�r�r5r7rArFrHrNr]rhrmr�r$r$r$r*�<module>sX 	�0`


70	
@AR

Anon7 - 2022
AnonSec Team