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_recvline.cpython-310.pyc
o

�bXc�@sbdZddlZddlZddlmZddlmZddlmZddl	m
Z
ddlmZm
Z
ddlmZmZmZdd	lmZdd
lmZddlmZddlmZmZed
�Zeej�Zej� ej!�ed<Gdd�de�Z"ddlm#Z#ddlm$Z$ddl%m&Z&Gdd�dej'�Z(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1ddl	m2Z2z dd l3m4Z4m5Z5m6Z6m7Z7m8Z8dd!l9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?Wne@y�d"ZAYnGwd#ZAGd$d%�d%e:jB�ZCGd&d'�d'e;jD�ZEGd(d)�d)e?jF�ZGGd*d+�d+e>jH�ZIGd,d-�d-e7�ZJGd.d/�d/e6�ZKGd0d1�d1e8�ZLe�MeKeLe=jN�Gd2d3�d3e$jO�ZPGd4d5�d5�ZQGd6d7�d7eQ�ZRdd8lSmTZTGd9d:�d:ejUeTjV�ZWGd;d<�d<ejXeTjV�ZYGd=d>�d>eQ�ZZGd?d@�d@eQ�Z[GdAdB�dB�Z\GdCdD�dDeZee\�Z]GdEdF�dFeRee\�Z^eedG�GdHdI�dIe[ee\��Z_GdJdK�dK�Z`GdLdM�dMeZee`�ZaGdNdO�dOeRee`�ZbeedP�GdQdR�dRe[ee`��ZcGdSdT�dTe�ZddS)UzU
Tests for L{twisted.conch.recvline} and fixtures for testing related
functionality.
�N)�skipIf)�recvline)�insults)�portal)�defer�error)�
components�filepath�reflect)�	iterbytes)�
requireModule)�StringTransport)�SkipTest�TestCaseztwisted.conch.stdio�
PYTHONPATHc@sleZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�ZdS)�ArrowsTestscsFt��_t���_t���_�fdd��j_��j_	�j�
�j�dS)Ncs�jS�N)�p���selfr�B/usr/lib/python3/dist-packages/twisted/conch/test/test_recvline.py�<lambda>"sz#ArrowsTests.setUp.<locals>.<lambda>)r
�underlyingTransportr�ServerProtocol�ptr�HistoricRecvLiner�protocolFactory�factory�makeConnectionrrrr�setUps

zArrowsTests.setUpcCs@|j�dd�|j�dd�|j�dd�|�|j��d�dS)zy
        When L{HistoricRecvLine} receives a printable character,
        it adds it to the current line buffer.
        �xN�y�z��xyz�)r�keystrokeReceived�assertEqual�currentLineBufferrrrr�test_printableCharacters&sz$ArrowsTests.test_printableCharacterscsF�fdd�}td�D]}||�q
���j��d�|�jj����j��d�|�jj����j��d�|�jj����j��d�|�jj����j��d�|�jj����j��d�|�jj����j��d�|�jj����j��d�|�jj����j��d�|�jj����j��d�dS)	z�
        When L{HistoricRecvLine} receives a LEFT_ARROW or
        RIGHT_ARROW keystroke it moves the cursor left or right
        in the current line buffer, respectively.
        c��j�|d�Sr�rr'��chrrrr7�z3ArrowsTests.test_horizontalArrows.<locals>.<lambda>r%r$)�xyr#)r!syz)r&r%N)rr(rr)r�RIGHT_ARROW�
LEFT_ARROW�r�kRr.rrr�test_horizontalArrows1s,
z!ArrowsTests.test_horizontalArrowscs|�fdd�}td�D]}||�q
���j��d�|d�|d�|d����j��d�|d����j��d	�d
S)z�
        When {HistoricRecvLine} receives a newline, it adds the current
        line buffer to the end of its history buffer.
        cr+rr,r-rrrr]r/z*ArrowsTests.test_newline.<locals>.<lambda>�xyz
abc
123
��r%�abc�123r�c�b�a�
))r%r9r:scbarN)rr(r�currentHistoryBufferr3rrr�test_newlineXs

�zArrowsTests.test_newlinecs6�fdd�}td�D]}||�q
���j��d����j��d�|�jj����j��d����j��d�|�jj����j��d����j��d	�|�jj����j��d
����j��d�|�jj����j��d
����j��d�td�D]}|�jj�q����j��d�d
S)a
        When L{HistoricRecvLine} receives UP_ARROW or DOWN_ARROW
        keystrokes it move the current index in the current history
        buffer up or down, and resets the current line buffer to the
        previous or next line in history, respectively for each.
        cr+rr,r-rrrrur/z1ArrowsTests.test_verticalArrows.<locals>.<lambda>r6r7�r&r&))r%r9)r:)r:r&))r%)r9r:)r9r&)rr8r$�N)	rr(rr?r)r�UP_ARROW�range�
DOWN_ARROW)rr4r.�irrr�test_verticalArrowsns(
zArrowsTests.test_verticalArrowscsV�fdd�}td�D]}||�q
���j��d�|�jj����j��d�dS)z�
        When L{HistoricRecvLine} receives a HOME keystroke it moves the
        cursor to the beginning of the current line buffer.
        cr+rr,r-rrrr�r/z'ArrowsTests.test_home.<locals>.<lambda>�hello, world�rHr&)r&rHN)rr(rr)r�HOMEr3rrr�	test_home�s
zArrowsTests.test_homecsb�fdd�}td�D]}||�q
���j��d�|�jj�|�jj����j��d�dS)z�
        When L{HistoricRecvLine} receives an END keystroke it moves the cursor
        to the end of the current line buffer.
        cr+rr,r-rrrr�r/z&ArrowsTests.test_end.<locals>.<lambda>rHrIN)rr(rr)rrJ�ENDr3rrr�test_end�s
zArrowsTests.test_endcs��fdd�}td�D]}||�q
���j��d�|�jj����j��d�|�jj�|�jj����j��d�|�jj����j��d�dS)z�
        When L{HistoricRecvLine} receives a BACKSPACE keystroke it deletes
        the character immediately before the cursor.
        cr+rr,r-rrrr�r/z,ArrowsTests.test_backspace.<locals>.<lambda>r%r$�r0r&)r&r"N)rr(rr)r�	BACKSPACEr2r3rrr�test_backspace�s
zArrowsTests.test_backspacecs��fdd�}td�D]}||�q
���j��d�|�jj����j��d�|�jj�|�jj����j��d�|�jj�|�jj����j��d�|�jj�|�jj����j��d�|�jj����j��d�dS)	z�
        When L{HistoricRecvLine} receives a DELETE keystroke, it
        delets the character immediately after the cursor.
        cr+rr,r-rrrr�r/z)ArrowsTests.test_delete.<locals>.<lambda>r%r$rN)r!r&rAN)rr(rr)r�DELETEr2r3rrr�test_delete�s"
zArrowsTests.test_deletecsr�fdd�}td�D]}||�q
|�jj�|d����j��d�|�jj�|d����j��d�dS)	z�
        When not in INSERT mode, L{HistoricRecvLine} inserts the typed
        character at the cursor before the next character.
        cr+rr,r-rrrr�r/z)ArrowsTests.test_insert.<locals>.<lambda>r%�A)�xyAr#�B)�xyBsAzN)rrr2r(rr)r3rrr�test_insert�s
zArrowsTests.test_insertcs~�fdd�}td�D]}||�q
|�jj�|�jj�|d����j��d�|�jj�|d����j��d�dS)	a
        When in INSERT mode and upon receiving a keystroke with a printable
        character, L{HistoricRecvLine} replaces the character at
        the cursor with the typed character rather than inserting before.
        Ah, the ironies of INSERT mode.
        cr+rr,r-rrrr�r/z+ArrowsTests.test_typeover.<locals>.<lambda>r%rS)rTr&rU)rVr&N)rr�INSERTr2r(rr)r3rrr�
test_typeover�s
zArrowsTests.test_typeovercsr�fdd�}�j}|j|j|j|j|j|j|j|j|j	|j
|j|j|j
|jfD]}||����j��d�q'dS)z�
        When L{HistoricRecvLine} receives a keystroke for an unprintable
        function key with no assigned behavior, the line buffer is unmodified.
        cr+rr,r-rrrr
r/z8ArrowsTests.test_unprintableCharacters.<locals>.<lambda>rAN)r�F1�F2�F3�F4�F5�F6�F7�F8�F9�F10�F11�F12�PGUP�PGDNr(rr))rr4rr.rrr�test_unprintableCharacterss(��z&ArrowsTests.test_unprintableCharactersN)�__name__�
__module__�__qualname__r r*r5r@rGrKrMrPrRrWrYrhrrrrrs'#r)�telnet)�helper)�
LoopbackRelayc@�eZdZdd�ZdS)�
EchoServercCs |j�|d|j|j�dS)Nr>)�terminal�write�ps�pn)r�linerrr�lineReceived*s zEchoServer.lineReceivedN)rirjrkrvrrrrrp)�rpsssss[2~s[1~s[3~s[4~�)�checkers)�ConchFactory�
TerminalRealm�TerminalSession�TerminalSessionTransport�TerminalUser)�channel�
connection�keys�session�	transport�userauthFTc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�SessionChannelssessioncO�<tjj|g|�Ri|��||_||_||_||_||_dSr)r�
SSHChannel�__init__r�protocolArgs�protocolKwArgs�width�height�rrr�r�r�r��a�kwrrrr�S�
zSessionChannel.__init__cCsht�d|j|jddfd�}|j�|d|�|j�|dd�|j|ji|j��|_	||j	_
|j	�|�dS)Nsvt102rr&spty-reqsshell)r��packRequest_pty_reqr�r��conn�sendRequestrr�r��_protocolInstancerr)r�data�termrrr�channelOpen_s���zSessionChannel.channelOpencCs|j�t���dSr)r��connectionLostr�ConnectionDonerrrr�closedlszSessionChannel.closedcC�|j�|�dSr)r��dataReceived�rr�rrrr�o�zSessionChannel.dataReceivedN)rirjrk�namer�r�r�r�rrrrr�Ps
r�c@�$eZdZdd�Zdd�Zdd�ZdS)�TestConnectioncOr�r)r��
SSHConnectionr�rr�r�r�r�r�rrrr�sr�zTestConnection.__init__cCs,t|j|j|j|j|j�|_|�|j�dSr)r�rr�r�r�r��_TestConnection__channel�openChannelrrrr�serviceStarteds�zTestConnection.serviceStartedcC�|j�|�Sr)r�rrr�rrrrr��zTestConnection.writeN)rirjrkr�r�rrrrrrr�rs
r�c@�eZdZdd�Zdd�ZdS)�TestAuthcOs&tjj||g|�Ri|��||_dSr)r��SSHUserAuthClientr��password)r�usernamer�r�r�rrrr��s
zTestAuth.__init__cCst�|j�Sr)r�succeedr�rrrr�getPassword�r�zTestAuth.getPasswordN)rirjrkr�r�rrrrr��sr�c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�
TestTransportc
Os.||_||_||_||_||_||_||_dSr)rr�r�r�r�r�r�)
rrr�r�r�r�r�r�r�r�rrrr��s
zTestTransport.__init__cCs
t�d�S)NT)rr�)r�hostKey�fingerprintrrr�
verifyHostKey�s
zTestTransport.verifyHostKeycCs8t|j|j|j|j|j�|_|�t|j	|j
|j��dSr)r�rr�r�r�r��_TestTransport__connection�requestServicer�r�r�rrrr�connectionSecure�s��zTestTransport.connectionSecurecCr�r)r�rrr�rrrrr�r�zTestTransport.writeN)rirjrkr�r�r�rrrrrrr��s
r�c@ro)�TestSessionTransportcCs|jjjj��Sr)�avatarr�r�r�serverProtocolrrrrr�r�z$TestSessionTransport.protocolFactoryN)rirjrkrrrrrr��rwr�c@seZdZeZdS)�TestSessionN)rirjrkr��transportFactoryrrrrr��sr�c@�eZdZdS)�TestUserN�rirjrkrrrrr���r�c@r�)�NotifyingExpectableBuffercCst��|_t��|_dSr)r�Deferred�onConnection�onDisconnectionrrrrr��s
z"NotifyingExpectableBuffer.__init__cCstj�|�|j�|�dSr)rm�ExpectableBuffer�connectionMader��callbackrrrrr��sz(NotifyingExpectableBuffer.connectionMadecCr�r)r��errback)r�reasonrrrr��r�z(NotifyingExpectableBuffer.connectionLostN)rirjrkr�r�r�rrrrr��sr�c@s$eZdZdZdZdd�Zdd�ZdS)�
_BaseMixin�P�c
Cs�|j����}|dg|jt|�d}|�t|�t|��tt|��D]-}|�||||d�|td|d�|d��dd�|td|d�|d���q%dS)Nr&�rs != )	�recvlineClient�	__bytes__�
splitlines�HEIGHT�lenr(rD�join�max)r�lines�
receivedLines�
expectedLinesrFrrr�
_assertBuffer�s����z_BaseMixin._assertBuffercs.�j�d�}��|���fdd�}|�|�S)Nsdonecs����dSr)r�)�ign��outputrrr�finished�sz)_BaseMixin._trivialTest.<locals>.finished)r��expect�
_testwrite�addCallback)r�	inputLiner��doner�rr�r�_trivialTest�s

z_BaseMixin._trivialTestN)rirjrk�WIDTHr�r�r�rrrrr��s

r�c@r�)�	_SSHMixincs>tstd��d\}}t�}t|_�fdd�|_t��}|�||�t	�
|�}|�|�t|�}t
jt�|���dd�}||jd<||jd<|j|_|��|���t��fdd���|�d�}t|�}	t��t��fd	d���t�fd
d�di|||j|j�}
t|
�}|
�|	�|�|��|_ |
|_!||_"|	|_#||_$�j%S)NzMcryptography requirements missing, can't run historic recvline tests over ssh)stestuserstestpassc��Srrr��
insultsServerrrr��z!_SSHMixin.setUp.<locals>.<lambda>i)�keySizesssh-rsacr�rrr��recvlineServerrrrr�cr�rrr�r�rrrr�cr�rrr��
insultsClientrrrr�r)&�sshrr{r��userFactory�chainedProtocolFactoryry�'InMemoryUsernamePasswordDatabaseDontUse�addUserr�Portal�registerCheckerrzr��_getPersistentRSAKeyr	�FilePath�mktemp�
publicKeys�privateKeysr��startFactoryrr�
buildProtocolrnr��ClientProtocolr�r�r�rr��	sshClient�	sshServer�clientTransport�serverTransportr�)r�ur�rlm�checker�ptl�
sshFactory�sshKeyr�r�r�r�r�r�r�r�r�rr �sL�

�


�

z_SSHMixin.setUpcCr�r)r�rrr�rrrr�$r�z_SSHMixin._testwriteN�rirjrkr r�rrrrr��s2r�)�test_telnetc@r�)�TestInsultsClientProtocolNr�rrrrr	+r�r	c@r�)�TestInsultsServerProtocolNr�rrrrr
/r�r
c@r�)�_TelnetMixincs�|���t�fdd���t��fdd��}t|�}t��t�fdd���t��fdd��}t|�}|�|�|�|�|��|���|_	||_
||_||_�j
S)Ncr�rrrr�rrr6r�z$_TelnetMixin.setUp.<locals>.<lambda>cr�rrrr�rrr7r�cr�rrrr�rrr;r�cr�rrrr�rrr<r�)r�r
rl�TelnetTransportrnr�r	r�clearBufferr��telnetClientr�r�r�)r�telnetServerr�rr�rrrr 4s"

z_TelnetMixin.setUpcCr�r)rrrr�rrrr�Lr�z_TelnetMixin._testwriteNrrrrrr3src@r�)�_StdioMixincs�t��t��fdd��}t�|�}tj}tj}|�d�s!|�d�r'|dd�}||t	�
|j�g}ddlm
}|j|||tdd	�}�|_|_||_||_t�td|j��d
�g��S)Ncr�rrr��testTerminalrrr[r�z#_StdioMixin.setUp.<locals>.<lambda>z.pycz.pyo���r)�reactorT)�env�usePTYs>>> )r�rr��stdio�TerminalProcessProtocol�sys�
executable�__file__�endswithr
�qualr��twisted.internetr�spawnProcess�	properEnvr�r�
processClientr�r�
gatherResults�filterr�r�)rr�r!�exe�module�argsrr�rrrr Qs$

��z_StdioMixin.setUpc	sDz�j�d�WntjtfyYnw�fdd�}�jj�|�S)N�KILLcs.|�tj���|jj���|jjd�dS)N�	)�trapr�ProcessTerminated�assertIsNone�value�exitCoder(�status)�failurerrrr)�sz"_StdioMixin.tearDown.<locals>.trap)r��
signalProcessr�ProcessExitedAlready�OSErrorrr��
addErrback)rr)rrr�tearDown|s�z_StdioMixin.tearDowncCr�r)r�rrr�rrrr��r�z_StdioMixin._testwriteN)rirjrkr r4r�rrrrrPs+rc@sXeZdZeZdd�Zdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�Zdd�Z
dS)�RecvlineLoopbackMixincCs|�dgd��S)Nsfirst line
done)�>>> first line�
first line�>>> done)r�rrrr�
testSimple�s�z RecvlineLoopbackMixin.testSimplecCs |�tdtddgd��S)Nr7rB�	xxxx
done)s>>> first xxxxs
first xxxxr8)r��insert�leftrrrr�
testLeftArrow���z#RecvlineLoopbackMixin.testLeftArrowcCs(|�tdtdtddgd��S)Ns
right linerB�sxx
done)s>>> right lixxs
right lixxr8)r�r;r<�rightrrrr�testRightArrow�s�z$RecvlineLoopbackMixin.testRightArrowcC�|�dtddgd��S)N�second linerBr:)s>>> second xxxxssecond xxxxr8)r��	backspacerrrr�
testBackspace���z#RecvlineLoopbackMixin.testBackspacecCs$|�dtdtddgd��S)Nsdelete xxxxrB�	line
done)s>>> delete linesdelete liner8)r�r<�deleterrrr�
testDelete�s�z RecvlineLoopbackMixin.testDeletecCrB)Ns	third ine��l
done)s>>> third lines
third liner8)r�r<rrrr�
testInsert�rFz RecvlineLoopbackMixin.testInsertcC� |�dtdtdgd��S)Nsfourth xinerBrK)s>>> fourth linesfourth liner8)r�r<r;rrrr�testTypeover�r>z"RecvlineLoopbackMixin.testTypeovercCs|�tdtdgd��S)Ns	blah lines	home
done)s
>>> home lines	home liner8)r�r;�homerrrr�testHome�rFzRecvlineLoopbackMixin.testHomecCrM)Nsend rBrG)s>>> end linesend liner8)r�r<�endrrrr�testEnd�r>zRecvlineLoopbackMixin.testEndN)rirjrkrpr�r9r=rArErIrLrNrPrRrrrrr5�sr5c@r�)�RecvlineLoopbackTelnetTestsNr�rrrrrS�r�rSc@r�)�RecvlineLoopbackSSHTestsNr�rrrrrT�r�rTzBTerminal requirements missing, can't run recvline tests over stdioc@r�)�RecvlineLoopbackStdioTestsNr�rrrrrU�srUc@s(eZdZeZdd�Zdd�Zdd�ZdS)�HistoricRecvlineLoopbackMixincCs|�dtdgd��S)Nsfirst line
�
done)r6r7r6r7r8)r��uprrrr�testUpArrow�s
�z)HistoricRecvlineLoopbackMixin.testUpArrowcCs|�dttdgd��S)aH
        Pressing down arrow to visit an entry that was added to the
        history by pressing the up arrow instead of return does not
        raise a L{TypeError}.

        @see: U{http://twistedmatrix.com/trac/ticket/9031}

        @return: A L{defer.Deferred} that fires when C{b"done"} is
            echoed back.
        sfirst line
partial linerW)r6r7s>>> partial linespartial liner8�r�rX�downrrrr�$test_DownArrowToPartialLineInHistory�s�zBHistoricRecvlineLoopbackMixin.test_DownArrowToPartialLineInHistorycCrM)Nsfirst line
second line
r?rW)r6r7�>>> second linerCr]rCr8rZrrrr�
testDownArrow�r>z+HistoricRecvlineLoopbackMixin.testDownArrowN)rirjrkrpr�rYr\r^rrrrrV�s
rVc@r�)�#HistoricRecvlineLoopbackTelnetTestsNr�rrrrr_	�r_c@r�)� HistoricRecvlineLoopbackSSHTestsNr�rrrrrar`razKTerminal requirements missing, can't run historic recvline tests over stdioc@r�)�"HistoricRecvlineLoopbackStdioTestsNr�rrrrrbsrbc@seZdZdZdd�ZdS)�TransportSequenceTestsz5
    L{twisted.conch.recvline.TransportSequence}
    cCs|�ttj�dS)zh
        Initializing a L{recvline.TransportSequence} with no args
        raises an assertion.
        N)�assertRaises�AssertionErrorr�TransportSequencerrrr�test_invalidSequence$sz+TransportSequenceTests.test_invalidSequenceN)rirjrk�__doc__rgrrrrrcsrc)erh�osr�unittestr�
twisted.conchr�twisted.conch.insultsr�twisted.credrrrr�twisted.pythonrr	r
�twisted.python.compatr�twisted.python.reflectr�twisted.test.proto_helpersr
�twisted.trial.unittestrrr�dict�environr �pathsepr��pathrrlrm�twisted.conch.test.loopbackrnrrpr<r@rXr[r;rOrHrQrDry�twisted.conch.manhole_sshrzr{r|r}r~�twisted.conch.sshrr�r�r�r�r��ImportErrorr�r�r�r�r�r�r��SSHClientTransportr�r�r�r��registerAdapter�ISessionr�r�r�r��twisted.conch.testrr��TestProtocolr	rr
rrr5rSrTrUrVr_rarbrcrrrr�<module>s�
	$�"'
7>9

5�
��
�

Anon7 - 2022
AnonSec Team