HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/conch/test/__pycache__/test_manhole_tap.cpython-38.pyc
U


W[��@s�dZzddlZWnek
r(dZYnXzddlZWnek
rNdZYnXerherhddlmZmZddlmZddl	m
Z
ddlmZddl
mZddlmZdd	lmZdd
lmZGdd�de�ZdS)
z)
Tests for L{twisted.conch.manhole_tap}.
�N)�manhole_tap�manhole_ssh)�StreamServerEndpointService)�MultiService)�error)�UsernamePassword)�telnet)�usage)�TestCasec@sLeZdZdZesdZesdZdZdd�Zdd�Z	d	d
�Z
dd�Zd
d�ZdS)�MakeServiceTestsz/
    Tests for L{manhole_tap.makeService}.
    zcan't run without cryptographyzCannot run without PyASN1)siamusersthisispasswordc	CsB|��|_t|jd��}|�d�|j��W5QRXt��|_dS)z8
        Create a passwd-like file with a user.
        �wb�:N)	�mktemp�filename�open�write�join�usernamePasswordr�Options�options)�self�f�r�E/usr/lib/python3/dist-packages/twisted/conch/test/test_manhole_tap.py�setUp0s
zMakeServiceTests.setUpc	Cs>|�tj��}t���g�W5QRX|�|jjdd�dS)zk
        L{manhole_tap.makeService} requires either 'telnetPort' or 'sshPort' to
        be given.
        rz<At least one of --telnetPort and --sshPort must be specifiedN)	ZassertRaisesr	Z
UsageErrorrr�parseOptions�assertEqualZ	exception�args)r�errr�test_requiresPort:sz"MakeServiceTests.test_requiresPortcCs~|j�ddg�t�|j�}|�|t�|�t|j�d�|�|jdt	�|�|jdj
jtj�|�|jdj
jd�dS)z�
        L{manhole_tap.makeService} will make a telnet service on the port
        defined by C{--telnetPort}. It will not make a SSH service.
        �--telnetPortztcp:222�r��N)rrr�makeService�assertIsInstancerr�len�servicesr�factory�protocolZmakeTelnetProtocol�endpoint�_port�r�servicerrr�test_telnetPortFs�z MakeServiceTests.test_telnetPortcCs�|j�d|��ddddg�t�|j�}|�|t�|�t|j	�d�|�|j	dt
�|�|j	djtj
�|�|j	djjd�d	S)
z�
        L{manhole_tap.makeService} will make a SSH service on the port
        defined by C{--sshPort}. It will not make a telnet service.
        z--sshKeyDirz--sshKeySizeZ512z	--sshPortztcp:223r!r��N)rrrrr#r$rrr%r&rr'rZConchFactoryr)r*r+rrr�test_sshPortUs��zMakeServiceTests.test_sshPortc	Cs�|j�ddd|jg�t�|j�}|jdjjj}|�	t
|j���d�|�
|�|�t|j�dtj���|�|�|�tdd�dtj��jtj�dS)	zS
        The C{--passwd} command-line option will load a passwd-like file.
        r ztcp:22z--passwdr�Nswrongsuser)rrrrr#r&r'r(�portalrr%Zcheckers�keysZ
assertTrueZsuccessResultOfZloginrrrZITelnetProtocolr$ZfailureResultOf�valuerZUnauthorizedLogin)rr,r1rrr�test_passwdis*
������zMakeServiceTests.test_passwdN)
�__name__�
__module__�__qualname__�__doc__�cryptography�skip�pyasn1rrrr-r/r4rrrrr#s
r)r8r9�ImportErrorr;Z
twisted.conchrrZtwisted.application.internetrZtwisted.application.servicerZtwisted.credrZtwisted.cred.credentialsrrZtwisted.pythonr	Ztwisted.trial.unittestr
rrrrr�<module>s$