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/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/test/__pycache__/test_loopback.cpython-310.pyc
o

�b�7�@s�dZddlmZddlmZmZmZddlmZddl	m
Z
mZmZddl
mZddlmZmZddlmZGd	d
�d
ej�ZGdd�de�ZGd
d�d�ZGdd�deej�ZGdd�deej�ZGdd�deej�ZGdd�dej�ZdS)z.
Test case for L{twisted.protocols.loopback}.
�)�implementer)�defer�
interfaces�reactor)�Deferred)�IAddress�
IPullProducer�
IPushProducer)�Protocol)�basic�loopback)�unittestc@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�SimpleProtocolcCst��|_g|_g|_dS�N)rr�conn�lines�connLost��self�r�</usr/lib/python3/dist-packages/twisted/test/test_loopback.py�__init__s

zSimpleProtocol.__init__cCs|j�d�dSr)r�callbackrrrr�connectionMade�zSimpleProtocol.connectionMadecC�|j�|�dSr)r�append�r�linerrr�lineReceivedrzSimpleProtocol.lineReceivedcCrr)rr)r�reasonrrr�connectionLostrzSimpleProtocol.connectionLostN)�__name__�
__module__�__qualname__rrrr!rrrrrs
rc@�eZdZdZdd�ZdS)�DoomProtocolrcCsV|jd7_|jdkr|�d|jf�t�||�|jddkr)|j��dSdS)N��sHello %d����Hello 3)�i�sendLinerrr�	transport�loseConnectionrrrrr&s
�zDoomProtocol.lineReceivedN)r"r#r$r+rrrrrr&#�r&c@seZdZdd�Zdd�ZdS)�LoopbackTestCaseMixinc�Rt��t���fdd�}�j�|����fdd�}t��j���}|�|�|S)Ncs��d��j��dS)N�THIS IS LINE ONE!)r,r-r.��result��srr�	sendALine6s
z<LoopbackTestCaseMixin.testRegularFunction.<locals>.sendALinecs8���jdg���t�j�d���t�j�d�dS)Nr2r'��assertEqualr�lenr��ignored��cr6rrr�check<sz8LoopbackTestCaseMixin.testRegularFunction.<locals>.check)rr�addCallbackr�
maybeDeferred�loopbackFunc�rr7r?�drr=r�testRegularFunction2s
z)LoopbackTestCaseMixin.testRegularFunctioncr1)Ncs��d�dS)N�	DOOM LINE)r,r3r5rrr7Isz=LoopbackTestCaseMixin.testSneakyHiddenDoom.<locals>.sendALinecsL���jgd�����jgd����t�j�d���t�j�d�dS)N)�Hello 1�Hello 2r*)rFrGrHr*r'r8r;r=rrr?Ns
�z9LoopbackTestCaseMixin.testSneakyHiddenDoom.<locals>.check)r&rr@rrArBrCrr=r�testSneakyHiddenDoomEs
z*LoopbackTestCaseMixin.testSneakyHiddenDoomN)r"r#r$rErIrrrrr01sr0c@s�eZdZeej�Zdd�Zdd�Zdd�Z	dd�Z
d(d
d�Zdd
�Zdd�Z
dd�Zdd�Zd)dd�Zdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'S)*�LoopbackAsyncTestscCsDGdd�dt�}|�}|�}t�||�|�|j�|�|j�dS)z}
        Test that the client and server protocol both have makeConnection
        invoked on them by loopbackAsync.
        c@seZdZdZdd�ZdS)z<LoopbackAsyncTests.test_makeConnection.<locals>.TestProtocolNcS�
||_dSr)r-�rr-rrr�makeConnectiong�
zKLoopbackAsyncTests.test_makeConnection.<locals>.TestProtocol.makeConnection)r"r#r$r-rMrrrr�TestProtocoldr/rON)r
r�
loopbackAsync�assertIsNotNoner-)rrO�server�clientrrr�test_makeConnection^sz&LoopbackAsyncTests.test_makeConnectioncsjGdd�dt�}|r|�}t�}|_t�}nt�}|�}t�}|_t�||���fdd�}|�|�S)zJ
        Test one of the permutations of client/server host/peer.
        c@�eZdZdd�ZdS)z6LoopbackAsyncTests._hostpeertest.<locals>.TestProtocolcSst�||�|j�|�dSr)r
rM�onConnectionrrLrrrrMvszELoopbackAsyncTests._hostpeertest.<locals>.TestProtocol.makeConnectionN)r"r#r$rMrrrrrOu�rOcs t|���}��t�|��dSr)�getattr�
assertTruer�
providedBy)r-�host��getrrr�	connected�sz3LoopbackAsyncTests._hostpeertest.<locals>.connected)r
rrVrrPr@)rr]�
testServerrOrRrDrSr^rr\r�
_hostpeertestps
z LoopbackAsyncTests._hostpeertestcC�|�dd�S)z�
        Test that the server gets a transport with a properly functioning
        implementation of L{ITransport.getHost}.
        �getHostT�r`rrrr�test_serverHost��z"LoopbackAsyncTests.test_serverHostcCra)zG
        Like C{test_serverHost} but for L{ITransport.getPeer}
        �getPeerTrcrrrr�test_serverPeer��z"LoopbackAsyncTests.test_serverPeerrbcCra)z�
        Test that the client gets a transport with a properly functioning
        implementation of L{ITransport.getHost}.
        rbFrc)rr]rrr�test_clientHost�rez"LoopbackAsyncTests.test_clientHostcCra)zH
        Like C{test_clientHost} but for L{ITransport.getPeer}.
        rfFrcrrrr�test_clientPeer�rhz"LoopbackAsyncTests.test_clientPeercsjGdd�dt�}G�fdd�dt�}|r!|�}|�}t�}|_n|�}t�}|_|�}t�||�|S)z�
        Test one of the permutations of write/writeSequence client/server.

        @param write: The name of the method to test, C{"write"} or
            C{"writeSequence"}.
        c@r%)z9LoopbackAsyncTests._greetingtest.<locals>.GreeteeProtocol�cSs,|j|7_|jdkr|j�d�dSdS�N�bytes)�bytes�receivedr�rrnrrr�dataReceived�s
�zFLoopbackAsyncTests._greetingtest.<locals>.GreeteeProtocol.dataReceivedN�r"r#r$rnrqrrrr�GreeteeProtocol�r/rscseZdZ�fdd�ZdS)z9LoopbackAsyncTests._greetingtest.<locals>.GreeterProtocolcs,�dkr|j�d�dS|j�ddg�dS)N�writermsbytses)r-rt�
writeSequencer�rtrrr�szHLoopbackAsyncTests._greetingtest.<locals>.GreeterProtocol.connectionMadeN�r"r#r$rrrvrr�GreeterProtocol�srx)r
rrorrP)rrtr_rsrxrRrSrDrrvr�
_greetingtest�sz LoopbackAsyncTests._greetingtestcCra)z�
        Test that on a connection where the client speaks first, the server
        receives the bytes sent by the client.
        rtF�ryrrrr�test_clientGreeting�rez&LoopbackAsyncTests.test_clientGreetingcCra)zz
        Like C{test_clientGreeting}, but use C{writeSequence} instead of
        C{write} to issue the greeting.
        ruFrzrrrr�test_clientGreetingSequence�rez.LoopbackAsyncTests.test_clientGreetingSequencertcCra)z�
        Test that on a connection where the server speaks first, the client
        receives the bytes sent by the server.
        rtTrz)rrtrrr�test_serverGreeting�rez&LoopbackAsyncTests.test_serverGreetingcCra)zz
        Like C{test_serverGreeting}, but use C{writeSequence} instead of
        C{write} to issue the greeting.
        ruTrzrrrr�test_serverGreetingSequence�rez.LoopbackAsyncTests.test_serverGreetingSequencecshdd�tdd�D��G��fdd�dt�}G���fdd�dt�}|��|��t��_t�����jS)	NcSsg|]}d|f�qS)s%dr)�.0r+rrr�
<listcomp>�sz4LoopbackAsyncTests._producertest.<locals>.<listcomp>r�
cseZdZ��fdd�ZdS)z;LoopbackAsyncTests._producertest.<locals>.ProducingProtocolcs �t���|_|j�|j�dSr)�list�producer�startr-r��
producerClass�	toProducerrr�szJLoopbackAsyncTests._producertest.<locals>.ProducingProtocol.connectionMadeNrwrr�rr�ProducingProtocol�sr�cs eZdZdZ���fdd�ZdS)z;LoopbackAsyncTests._producertest.<locals>.ReceivingProtocolrkcs6|j|7_|jd���kr|j���f�dSdS)Nrk)rn�joinror�r�data�rSrRr�rrrq�s�zHLoopbackAsyncTests._producertest.<locals>.ReceivingProtocol.dataReceivedNrrrr�rr�ReceivingProtocol�sr�)�ranger
rrorrP)rr�r�r�r)rSr�rRr�r�
_producertest�sz LoopbackAsyncTests._producertestcs:tt�Gdd�d��}��|�}�fdd�}|�|�|S)zO
        Test a push producer registered against a loopback transport.
        c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)z:LoopbackAsyncTests.test_pushProducer.<locals>.PushProducerFcSrKr�r��rr�rrrrrNzCLoopbackAsyncTests.test_pushProducer.<locals>.PushProducer.__init__cSs
d|_dS�NT)�resumedrrrr�resumeProducingrNzJLoopbackAsyncTests.test_pushProducer.<locals>.PushProducer.resumeProducingcSs||_|�|d�|��dSr�)�consumer�registerProducer�_produceAndSchedule�rr�rrrr�
sz@LoopbackAsyncTests.test_pushProducer.<locals>.PushProducer.startcSs:|jr|j�|j�d��t�d|j�dS|j��dS�Nr)r�r�rt�popr�	callLaterr��unregisterProducerrrrrr�szNLoopbackAsyncTests.test_pushProducer.<locals>.PushProducer._produceAndScheduleN)r"r#r$r�rr�r�r�rrrr�PushProducersr�cs|\}}��|jjd�dS)Nz0Streaming producer should not have been resumed.)�assertFalser�r�)�resultsrSrRrrr�finisheds
�z6LoopbackAsyncTests.test_pushProducer.<locals>.finished)rr	r�r@)rr�rDr�rrr�test_pushProducer�s

z$LoopbackAsyncTests.test_pushProducercCs tt�Gdd�d��}|�|�S)zO
        Test a pull producer registered against a loopback transport.
        c@s$eZdZdd�Zdd�Zdd�ZdS)z:LoopbackAsyncTests.test_pullProducer.<locals>.PullProducercSrKrr�r�rrrr)rNzCLoopbackAsyncTests.test_pullProducer.<locals>.PullProducer.__init__cSs||_|j�|d�dS)NF)r�r�r�rrrr�,sz@LoopbackAsyncTests.test_pullProducer.<locals>.PullProducer.startcSs,|j�|j�d��|js|j��dSdSr�)r�rtr�r�r�rrrrr�0s�zJLoopbackAsyncTests.test_pullProducer.<locals>.PullProducer.resumeProducingN)r"r#r$rr�r�rrrr�PullProducer'sr�)rrr�)rr�rrr�test_pullProducer"s

z$LoopbackAsyncTests.test_pullProducercsTGdd�dt�}Gdd�dt�}|�}|��t��|�}��fdd�}|�|�|S)z�
        L{loopback.loopbackAsync} does not call a protocol's C{dataReceived}
        method while that protocol's transport's C{write} method is higher up
        on the stack.
        c@rU)z9LoopbackAsyncTests.test_writeNotReentrant.<locals>.ServercSs|j�d�dSrl)r-rtrprrrrq?rzFLoopbackAsyncTests.test_writeNotReentrant.<locals>.Server.dataReceivedN)r"r#r$rqrrrr�Server>rWr�c@s(eZdZdZdd�Zdd�Zdd�ZdS)	z9LoopbackAsyncTests.test_writeNotReentrant.<locals>.ClientFcSst�d|j�dSr�)rr��gorrrrrEszHLoopbackAsyncTests.test_writeNotReentrant.<locals>.Client.connectionMadecSs|j�d�d|_dS)N�fooT)r-rt�readyrrrrr�Hs
z<LoopbackAsyncTests.test_writeNotReentrant.<locals>.Client.gocSs|j|_|j��dSr)r��wasReadyr-r.rprrrrqLszFLoopbackAsyncTests.test_writeNotReentrant.<locals>.Client.dataReceivedN)r"r#r$r�rr�rqrrrr�ClientBs
r�cs���j�dSr)rYr�r;�rSrrr�
cbFinishedTrz=LoopbackAsyncTests.test_writeNotReentrant.<locals>.cbFinished)r
rrPr@)rr�r�rRrDr�rr�r�test_writeNotReentrant7s
z)LoopbackAsyncTests.test_writeNotReentrantcs�g��fdd�}t��t��t���|�}���g��j�d��j�d��j�d��j�d��j������fdd�}|�|�|S)	z�
        The callable passed as the value for the C{pumpPolicy} parameter to
        L{loopbackAsync} is called with a L{_LoopbackQueue} of pending bytes
        and a protocol to which they should be delivered.
        cs,g}|r
|�|���|s��||f�dSr)rr])�queue�targetrn)�	pumpCallsrr�dummyPolicybs
�z7LoopbackAsyncTests.test_pumpPolicy.<locals>.dummyPolicyr��bar�baz�quuxcs$����gd�f�ddgfg�dS)N)r�r�Nr�r�)r9r;�rSr�rrRrr�
cbCompletets�z6LoopbackAsyncTests.test_pumpPolicy.<locals>.cbComplete)r
rrPr9r-rtr.r@)rr�r�r�rr�r�test_pumpPolicyZs

z"LoopbackAsyncTests.test_pumpPolicycCsXg}t�}|j|_t��}|�d�|�d�|�d�t�||�|�|ddg�dS)z�
        L{identityPumpPolicy} is a pump policy which calls the target's
        C{dataReceived} method one for each string in the queue passed to it.
        r�r�N)r
rrqr�_LoopbackQueue�put�identityPumpPolicyr9�rrnrSr�rrr�test_identityPumpPolicys


z*LoopbackAsyncTests.test_identityPumpPolicycCsVg}t�}|j|_t��}|�d�|�d�|�d�t�||�|�|dg�dS)z�
        L{collapsingPumpPolicy} is a pump policy which calls the target's
        C{dataReceived} only once with all of the strings in the queue passed
        to it joined together.
        r�r�Nsfoobar)r
rrqrr�r��collapsingPumpPolicyr9r�rrr�test_collapsingPumpPolicy�s


z,LoopbackAsyncTests.test_collapsingPumpPolicyN)rbrv)r"r#r$�staticmethodrrPrBrTr`rdrgrirjryr{r|r}r~r�r�r�r�r�r�r�rrrrrJ[s(

#
'#%rJc@seZdZeej�ZdS)�LoopbackTCPTestsN)r"r#r$r�r�loopbackTCPrBrrrrr��sr�c@s.eZdZeej�Ze�e	d�durdZ
dSdS)�LoopbackUNIXTestsNz-Current reactor does not support UNIX sockets)r"r#r$r�r�loopbackUNIXrBr�IReactorUNIXr�skiprrrrr��s

�r�c@s0eZdZdZGdd�de�Zdd�Zdd�ZdS)	�LoopbackRelayTestz>
    Test for L{twisted.protocols.loopback.LoopbackRelay}
    c@seZdZdZdZdd�ZdS)zLoopbackRelayTest.ReceiverzF
        Simple Receiver class used for testing LoopbackRelay
        rkcCs|j|7_dS)z)Accumulate received data for verificationN)r�r�rrrrq�sz'LoopbackRelayTest.Receiver.dataReceivedN)r"r#r$�__doc__r�rqrrrr�Receiver�sr�cCsN|��}t�|�}|�d�|�d�|�|jd�|��|�|jd�dS)z8Test to verify that the write function works as expectedsabcsdefrksabcdefN)r�r�
LoopbackRelayrtr9r��clearBuffer�r�receiver�relayrrr�
test_write�s


zLoopbackRelayTest.test_writecCsV|��}t�|�}|�gd��|�gd��|�|jd�|��|�|jd�dS)z@Test to verify that the writeSequence function works as expected)sThe squick sbrown sfox )sjumps sover sthe lazy dogrks+The quick brown fox jumps over the lazy dogN)r�rr�rur9r�r�r�rrr�test_writeSequence�s
z$LoopbackRelayTest.test_writeSequenceN)r"r#r$r�r
r�r�r�rrrrr��s

r�N)r��zope.interfacer�twisted.internetrrr�twisted.internet.deferr�twisted.internet.interfacesrrr	�twisted.internet.protocolr
�twisted.protocolsrr�
twisted.trialr
�LineReceiverrr&r0�TestCaserJr�r�r�rrrr�<module>s"*J

Anon7 - 2022
AnonSec Team