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 :  /usr/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 : /usr/lib/python3/dist-packages/twisted/test/__pycache__/test_protocols.cpython-310.pyc
o

�b��@s�dZddlmZmZmZmZddlmZmZddl	m
Z
ddlmZddl
mZGdd�dej�ZGd	d
�d
ej�ZGdd�dej�ZGd
d�dej�ZGdd�dej�ZdS)z+
Test cases for twisted.protocols package.
�)�address�defer�protocol�reactor)�portforward�wire)�	iterbytes)�
proto_helpers)�unittestc@�0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�	WireTestsz
    Test wire protocols.
    cC�`t��}t��}|�|�|�d�|�d�|�d�|�d�|�d�|�|��d�dS)zT
        Test wire.Echo protocol: send some data and check it send it back.
        �hello�world�how�are�youshelloworldhowareyouN)r	�StringTransportr�Echo�makeConnection�dataReceived�assertEqual�value��self�t�a�r�=/usr/lib/python3/dist-packages/twisted/test/test_protocols.py�	test_echo�





zWireTests.test_echocC�.t��}t��}|�|�|�|��d�dS)z)
        Test wire.Who protocol.
        sroot
N)r	rr�Whorrrrrrr�test_who"�
zWireTests.test_whocCr!)z*
        Test wire.QOTD protocol.
        s'An apple a day keeps the doctor away.
N)r	rr�QOTDrrrrrrr�	test_QOTD+r$zWireTests.test_QOTDcCr
)z-
        Test wire.Discard protocol.
        rrrrr�N)r	rr�Discardrrrrrrrr�test_discard4r zWireTests.test_discardN)�__name__�
__module__�__qualname__�__doc__rr#r&r)rrrrrs		rc@�eZdZdZdd�ZdS)�TestableProxyClientFactoryz�
    Test proxy client factory that keeps the last created protocol instance.

    @ivar protoInstance: the last instance of the protocol.
    @type protoInstance: L{portforward.ProxyClient}
    cCstj�||�}||_|S)zE
        Create the protocol instance and keeps track of it.
        )r�ProxyClientFactory�
buildProtocol�
protoInstance�r�addr�protorrrr1Ksz(TestableProxyClientFactory.buildProtocolN�r*r+r,r-r1rrrrr/Csr/c@r.)�TestableProxyFactoryal
    Test proxy factory that keeps the last created protocol instance.

    @ivar protoInstance: the last instance of the protocol.
    @type protoInstance: L{portforward.ProxyServer}

    @ivar clientFactoryInstance: client factory used by C{protoInstance} to
        create forward connections.
    @type clientFactoryInstance: L{TestableProxyClientFactory}
    cs.tj��|�}t��_�fdd�|_|�_|S)z�
        Create the protocol instance, keeps track of it, and makes it use
        C{clientFactoryInstance} as client factory.
        c��jS�N)�clientFactoryInstancer�rrr�<lambda>h�z4TestableProxyFactory.buildProtocol.<locals>.<lambda>)r�ProxyFactoryr1r/r:�clientProtocolFactoryr2r3rr;rr1`s
z"TestableProxyFactory.buildProtocolNr6rrrrr7Tsr7c@r)�PortforwardingTestsz
    Test port forwarding.
    cCst��|_t��|_g|_dSr9)rr�serverProtocolr�Protocol�clientProtocol�	openPortsr;rrr�setUprs


zPortforwardingTests.setUpcCs�z	|jjj��Wn	tyYnwz|jjj}|j��Wn	ty(Ynwz|jj��Wn	ty:Ynwz|jj��Wn	tyLYnwt�	dd�|j
D��S)NcSsg|]}t�|j��qSr)r�
maybeDeferred�
stopListening)�.0�prrr�
<listcomp>�sz0PortforwardingTests.tearDown.<locals>.<listcomp>)�proxyServerFactoryr2�	transport�loseConnection�AttributeErrorr:rCrAr�
gatherResultsrD)r�pirrr�tearDownws0�
����zPortforwardingTests.tearDowncs�t��}�fdd�|_tjd|dd�}�j�|�td|��j��_	tjd�j	dd�}�j�|�d�g�t
�������fdd�}|�j_
��fd	d
�}|�j_t��}�fdd�|_t�d|��j|��S)z=
        Test port forwarding through Echo protocol.
        cr8r9)rArr;rrr<�r=z6PortforwardingTests.test_portforward.<locals>.<lambda>r�	127.0.0.1)�	interfacei�csB��t|��t���kr��d���d����d�dSdS)Nr'�x)�extendr�lenr�join�callback)�data��d�nBytes�receivedrrr�testDataReceived�s
�z>PortforwardingTests.test_portforward.<locals>.testDataReceivedcs�jj�d��dS)NrT)rCrL�writer)r\rrr�testConnectionMade�sz@PortforwardingTests.test_portforward.<locals>.testConnectionMadecr8r9)rCrr;rrr<�r=)r�
ServerFactoryr�	listenTCPrD�appendr7�getHost�portrKr�DeferredrCr�connectionMade�
ClientFactory�
connectTCP)r�realServerFactory�realServerPort�proxyServerPortr^r`�
clientFactoryrrZr�test_portforward�s,
��z$PortforwardingTests.test_portforwardcCs�t�ddd�}t�dd��|�}t��}||_t��}|�	|�|�
t|j�d�|jd\}}}}}	|�
|tj�|�|�}
t��}|
�	|�|�|j|�|�|j|�|�|j�|�|j�dS)zm
        The proxy client registers itself as a producer of the proxy server and
        vice versa.
        �TCPrRr�N)r�IPv4Addressrr>r1r	�
MemoryReactorrrrrrV�
tcpClients�assertIsInstancer0�assertIs�producer�
assertTrue�	streaming)rr4�serverr�serverTransport�hostrerm�timeout�_�client�clientTransportrrr�test_registerProducers�s 


z*PortforwardingTests.test_registerProducersN)r*r+r,r-rErQrnr�rrrrr@ms(r@c@r.)�StringTransportTestszA
    Test L{proto_helpers.StringTransport} helper behaviour.
    cCst��}|�t|jd�dS)zY
        Test that L{proto_helpers.StringTransport} doesn't accept unicode data.
        �fooN)r	r�assertRaises�	TypeErrorr_)r�srrr�test_noUnicode�sz#StringTransportTests.test_noUnicodeN)r*r+r,r-r�rrrrr��sr�N)r-�twisted.internetrrrr�twisted.protocolsrr�twisted.python.compatr�twisted.testr	�
twisted.trialr
�TestCaserr0r/r>r7r@r�rrrr�<module>s4l

Anon7 - 2022
AnonSec Team