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

�b�3�@s0UdZddlZddlmZdZeeed<ddlmZddl	m
Z
ddlmZm
Z
mZmZmZddlmZmZdd	lmZdd
lmZdd�Ze�ZGd
d�dej�ZGdd�dej�ZGdd�dej�ZGdd�d�ZGdd�deeje�ZGdd�deeje�ZGdd�de
eje�Z Gdd�dej�Z!dS)z%
Tests for L{twisted.conch.manhole}.
�N)�Optional�ssh)�manhole)�insults)�	_SSHMixin�_StdioMixin�_TelnetMixinr�stdio)�defer�error)�StringTransport)�unittestcCs2zddWdStyt��ddYSw)z�
    Return the string used by Python as the name for code objects which are
    compiled from interactive input or at the top-level of modules.
    �r����N)�
BaseException�	traceback�
extract_stack�rr�A/usr/lib/python3/dist-packages/twisted/conch/test/test_manhole.py�determineDefaultFunctionNames
�rc@�eZdZdZdd�ZdS)�ManholeInterpreterTestsz2
    Tests for L{manhole.ManholeInterpreter}.
    cCs2t�d�}|j�ddg�|��|�|j�dS)zR
        L{ManholeInterpreter.resetBuffer} should empty the input buffer.
        N�1�2)r�ManholeInterpreter�buffer�extend�resetBuffer�assertFalse)�self�interpreterrrr�test_resetBuffer4s
z(ManholeInterpreterTests.test_resetBufferN)�__name__�
__module__�__qualname__�__doc__r"rrrrr/�rc@r)�ManholeProtocolTestsz'
    Tests for L{manhole.Manhole}.
    cCsPt�}t�tj�}|�|�|j}|j}|j�	ddg�|�
�|�|j�dS)zn
        L{manhole.Manhole.handle_INT} should cause the interpreter input buffer
        to be reset.
        rrN)rr�ServerProtocolr�Manhole�makeConnection�terminalProtocolr!rr�
handle_INTr)r �	transport�terminal�protocolr!rrr�%test_interruptResetsInterpreterBufferCs
z:ManholeProtocolTests.test_interruptResetsInterpreterBufferN)r#r$r%r&r1rrrrr(>r'r(c@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�WriterTestscC�t�d�dS)z&
        Colorize an integer.
        rN�r�lastColorizedLine�r rrr�test_IntegerS�zWriterTests.test_IntegercCr3)z7
        Colorize an integer in double quotes.
        z"1"Nr4r6rrr�test_DoubleQuoteStringYr8z"WriterTests.test_DoubleQuoteStringcCr3)z7
        Colorize an integer in single quotes.
        z'1'Nr4r6rrr�test_SingleQuoteString_r8z"WriterTests.test_SingleQuoteStringcCr3)z7
        Colorize an integer in triple quotes.
        z'''1'''Nr4r6rrr�test_TripleSingleQuotedStringer8z)WriterTests.test_TripleSingleQuotedStringcCr3)zB
        Colorize an integer in triple and double quotes.
        z"""1"""Nr4r6rrr�test_TripleDoubleQuotedStringkr8z)WriterTests.test_TripleDoubleQuotedStringcCr3)z1
        Colorize a function definition.
        z
def foo():Nr4r6rrr�test_FunctionDefinitionqr8z#WriterTests.test_FunctionDefinitioncCr3)z.
        Colorize a class definition.
        z
class foo:Nr4r6rrr�test_ClassDefinitionwr8z WriterTests.test_ClassDefinitioncC�t�d�}|�t|t��dS)z,
        Colorize a Unicode string.
        �иN�rr5�
assertTrue�
isinstance�bytes�r �resrrr�test_unicode}�
zWriterTests.test_unicodecCr?)z/
        Colorize a UTF-8 byte string.
        �иNrArErrr�
test_bytes�rHzWriterTests.test_bytescCs|�t�d�t�d��dS)zT
        The output of UTF-8 bytestrings and Unicode strings are identical.
        rIr@N)�assertEqualrr5r6rrr�test_identicalOutput�s�z WriterTests.test_identicalOutputN)
r#r$r%r7r9r:r;r<r=r>rGrJrLrrrrr2Rsr2c@s�eZdZejZdd�Zdd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zejdd��Zejdd��Zdd�Zdd�Zejdd��ZdS)�ManholeLoopbackMixincCs
t�|�S)N)r
�waitForDeferred�r �drrr�wfd�s
zManholeLoopbackMixin.wfdc�,�j�d�}��d��fdd�}|�|�S)z-
        Evaluate simple expression.
        �dones
1 + 1
donec���gd��dS)N)�	>>> 1 + 1�2�>>> done��
_assertBuffer��ignr6rr�finished��z<ManholeLoopbackMixin.test_SimpleExpression.<locals>.finished��recvlineClient�expect�
_testwrite�addCallback�r �doner\rr6r�test_SimpleExpression��

z*ManholeLoopbackMixin.test_SimpleExpressioncrR)z>
        Evaluate line continuation in triple quotes.
        rSs'''
'''
donecrT)N)s>>> '''s... '''s'\n'rWrXrZr6rrr\�r]zGManholeLoopbackMixin.test_TripleQuoteLineContinuation.<locals>.finishedr^rcrr6r� test_TripleQuoteLineContinuation�rfz5ManholeLoopbackMixin.test_TripleQuoteLineContinuationcrR)z/
        Evaluate function definition.
        rSs'def foo(bar):
	print(bar)

foo(42)
donecrT)N)s>>> def foo(bar):s...     print(bar)�... s>>> foo(42)s42rWrXrZr6rrr\���z>ManholeLoopbackMixin.test_FunctionDefinition.<locals>.finishedr^rcrr6rr=��

z,ManholeLoopbackMixin.test_FunctionDefinitioncrR)z,
        Evaluate class definition.
        rSsEclass Foo:
	def bar(self):
		print('Hello, world!')

Foo().bar()
donecrT)N)s>>> class Foo:s...     def bar(self):s"...         print('Hello, world!')rhs>>> Foo().bar()s
Hello, world!rWrXrZr6rrr\�riz;ManholeLoopbackMixin.test_ClassDefinition.<locals>.finishedr^rcrr6rr>�s�

z)ManholeLoopbackMixin.test_ClassDefinitioncrR)z0
        Evaluate raising an exception.
        rSs#raise Exception('foo bar baz')
donecs"��dddt�d�ddg�dS)Ns">>> raise Exception('foo bar baz')s"Traceback (most recent call last):s  File "<console>", line 1, in zutf-8sException: foo bar bazrW)rY�defaultFunctionName�encoderZr6rrr\�s���z5ManholeLoopbackMixin.test_Exception.<locals>.finishedr^rcrr6r�test_Exception�rjz#ManholeLoopbackMixin.test_Exceptioncs6�j�d�}��dtjd��fdd�}|�|�S)z4
        Evaluate interrupting with CTRL-C.
        rS�cancelled linecrT)N)�>>> cancelled line�KeyboardInterruptrWrXrZr6rrr\riz4ManholeLoopbackMixin.test_ControlC.<locals>.finished)r_r`rar�CTRL_Crbrcrr6r�
test_ControlC�s
z"ManholeLoopbackMixin.test_ControlCcsF�j�d�}��d��fdd�}|�|��fdd�}|�|�|S)z�
        Sending ^C to Manhole while in a state where more input is required to
        complete a statement should discard the entire ongoing statement and
        reset the input prompt to the non-continuation prompt.
        sthingss(
thingscs*��ddg��j�d�}��tj�|S)N�>>> (�
... things�>>> )rYr_r`rarrq)�ignored�interruptedr6rr�gotContinuationszNManholeLoopbackMixin.test_interruptDuringContinuation.<locals>.gotContinuationcrT)N)rsrtrprurX)rvr6rr�gotInterruptionr]zNManholeLoopbackMixin.test_interruptDuringContinuation.<locals>.gotInterruptionr^)r �
continuingrxryrr6r� test_interruptDuringContinuations


z5ManholeLoopbackMixin.test_interruptDuringContinuationcs>��d��j�d�}�fdd�}�fdd�}|�|��|�S)z2
        Evaluate cancelling with CTRL-\.
        rncs.��dg���tj��jj}��|tj�S)Nro)	rYrar�CTRL_BACKSLASHr_�onDisconnection�
assertFailurer�ConnectionDone)r[rPr6rr�gotPartialLine*szBManholeLoopbackMixin.test_ControlBackslash.<locals>.gotPartialLinec���dg�dS)N�rXrZr6rr�gotClearedLine1�zBManholeLoopbackMixin.test_ControlBackslash.<locals>.gotClearedLine�rar_r`rb)r �partialLiner�r�rr6r�test_ControlBackslash#s

z*ManholeLoopbackMixin.test_ControlBackslashccs��|�d�|j�d�V|�dg�|�tjd�|j�d�V|�dg�|�d�|j�d�V|�tj�|jj}|�|tj	�VdS)	z~
        A CTRL+D in the middle of a line doesn't close a connection,
        but at the beginning of a line it does.
        s1 + 1�\+ 1rU� + 1�
>>> 1 + 1 + 1�
s3
>>> N)
rar_r`rYr�CTRL_Dr}r~rrrOrrr�
test_controlD6s�

z"ManholeLoopbackMixin.test_controlDccsV�|�d�|j�d�V|�ddg�|�tjd�|j�d�V|�dg�dS)	a
        CTRL+L is generally used as a redraw-screen command in terminal
        applications.  Manhole doesn't currently respect this usage of it,
        but it should at least do something reasonable in response to this
        event (rather than, say, eating your face).
        s
1 + 1r�rurUr�s1 \+ 1 \+ 1r�N)rar_r`rYr�CTRL_Lr6rrr�
test_ControlLKs�

z"ManholeLoopbackMixin.test_ControlLc�,��d��j�d�}�fdd�}|�|�S)zl
        CTRL-A can be used as HOME - returning cursor to beginning of
        current line buffer.
        srint "hello"p�
print "hello"cr��Ns>>> print "hello"rX��ignorer6rr�cber�z.ManholeLoopbackMixin.test_controlA.<locals>.cbr��r rPr�rr6r�
test_controlA]�

z"ManholeLoopbackMixin.test_controlAcr�)zc
        CTRL-E can be used as END - setting cursor to end of current
        line buffer.
        srint "hellop"r�cr�r�rXr�r6rrr�rr�z.ManholeLoopbackMixin.test_controlE.<locals>.cbr�r�rr6r�
test_controlEjr�z"ManholeLoopbackMixin.test_controlEccsR�|�d�|j�d�V|�d�|j�d�V|j�d�V|�gd��dS)z�
        When a deferred is returned to the manhole REPL, it is displayed with
        a sequence number, and when the deferred fires, the result is printed.
        sCfrom twisted.internet import defer, reactor
d = defer.Deferred()
d
�
<Deferred #0>s.c = reactor.callLater(0.1, d.callback, 'Hi!')
rus#Deferred #0 called back: 'Hi!'
>>> )s/>>> from twisted.internet import defer, reactors>>> d = defer.Deferred()s>>> dr�s1>>> c = reactor.callLater(0.1, d.callback, 'Hi!')sDeferred #0 called back: 'Hi!'ruN)rar_r`rYr6rrr�
test_deferredws��
�z"ManholeLoopbackMixin.test_deferredN)r#r$r%r�ColoredManhole�serverProtocolrQrergr=r>rmrrr{r�r
�inlineCallbacksr�r�r�r�r�rrrrrM�s&





rMc@seZdZdZdS)�ManholeLoopbackTelnetTestsz,
    Test manhole loopback over Telnet.
    N)r#r$r%r&rrrrr��sr�c@s eZdZdZedurdZdSdS)�ManholeLoopbackSSHTestsz)
    Test manhole loopback over SSH.
    Nz!cryptography requirements missing)r#r$r%r&r�skiprrrrr��s
�r�c@s&eZdZdZedurdZdSejZdS)�ManholeLoopbackStdioTestsz1
    Test manhole loopback over standard IO.
    N�Terminal requirements missing)r#r$r%r&r	r��ConsoleManholer�rrrrr��s

r�c@s$eZdZdZedurdZdd�ZdS)�ManholeMainTestsz=
    Test the I{main} method from the I{manhole} module.
    Nr�cCs*|jttjdgd�}|�d|jd�dS)z�
        Will raise an exception when called with an argument which is a
        dotted patch which can not be imported..
        z
no-such-class)�argvzEmpty module namerN)�assertRaises�
ValueErrorr	�mainrK�args)r �	exceptionrrr�test_mainClassNotFound�s�z'ManholeMainTests.test_mainClassNotFound)r#r$r%r&r	r�r�rrrrr��s
r�)"r&r�typingrr�bool�__annotations__�
twisted.conchr�twisted.conch.insultsr� twisted.conch.test.test_recvlinerrrr	�twisted.internetr
r�twisted.test.proto_helpersr�
twisted.trialr
rrk�TestCaserr(r2rMr�r�r�r�rrrr�<module>s,B	

Anon7 - 2022
AnonSec Team