%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f�����dZddlmZmZmZddlmZddlmZddl	m
Z
mZddlm
Z
mZmZddlmZddlmZdd	lmZed
�Zed�ZererddlmZdd
lmZGd�de�Zy)z!
Tests for L{twisted.conch.tap}.
�)�Any�Tuple�Union)�StreamServerEndpointService)�error)�FilePasswordDB�ICredentialsChecker)�ISSHPrivateKey�IUsernamePassword�UsernamePassword)�Deferred)�
requireModule)�TestCase�cryptographyztwisted.conch.unix)�tap)�OpenSSHFactoryc�r�eZdZdZesdZesdZdZdd�Zdd�Z	dd	�Z
dd
�Zdd�Zde
fd�Zdedfd
�Zdd�Zy)�MakeServiceTestsz'
    Tests for L{tap.makeService}.
    zcan't run without cryptographyz can't run on non-posix computers)siamusersthisispassword�returnNc�
�|j�|_t|jd�5}|jdj	|j
��ddd�t
j�|_y#1swY�#xYw)z/
        Create a file with two users.
        zwb+�:N)	�mktemp�filename�open�write�join�usernamePasswordr�Options�options)�self�fs  �=/usr/lib/python3/dist-packages/twisted/conch/test/test_tap.py�setUpzMakeServiceTests.setUp(s^�����
��
�
�$�-�-��
'�	6�1�
�G�G�D�I�I�d�3�3�4�5�	6��{�{�}���	6�	6�s�+A9�9Bc��tj�}tj|�}|j|t�|j|jjd�|j|jt�y)z�
        L{tap.makeService} returns a L{StreamServerEndpointService} instance
        running on TCP port 22, and the linked protocol factory is an instance
        of L{OpenSSHFactory}.
        �N)
rr�makeService�assertIsInstancer�assertEqual�endpoint�_port�factoryr)r �config�services   r"�
test_basiczMakeServiceTests.test_basic1s^��������/�/�&�)�����g�'B�C�����)�)�/�/��4����g�o�o�~�>�c���d}|jt|jdd�|jt|jdd�|j	|t|jd�d|fz�y)z�
        Make sure that if the C{--auth} command-line option is not passed,
        the default checkers are (for backwards compatibility): SSH and UNIX
        ��credInterfacesz)SSH should be one of the default checkersz*UNIX should be one of the default checkers�credCheckersz&There should be %d checkers by defaultN)�assertInr
rrr(�len)r �numCheckerss  r"�test_defaultAuthsz"MakeServiceTests.test_defaultAuths=sw��
���
�
���L�L�)�*�7�	
�
	
�
�
���L�L�)�*�8�	
�
	
��������^�,�-�4��~�E�	
r/c��|jjdd|jzg�|jt	|jd�d�y)z�
        The C{--auth} command-line option will add a checker to the list of
        checkers, and it should be the only auth checker
        �--auth�file:r3�N�r�parseOptionsrr(r5�r s r"�test_authAddedzMakeServiceTests.test_authAddedTsB��
	
���!�!�8�W�t�}�}�-D�"E�F�����T�\�\�.�9�:�A�>r/c��|jjdd|jzddg�|jt	|jd�d�y)z�
        Multiple C{--auth} command-line options will add all checkers specified
        to the list ofcheckers, and there should only be the specified auth
        checkers (no default checkers).
        r9r:zmemory:testuser:testpasswordr3r1Nr<r>s r"�test_multipleAuthAddedz'MakeServiceTests.test_multipleAuthAdded\sP��	
���!�!���$�-�-�'��.�	
�	
�	
����T�\�\�.�9�:�A�>r/c�6�|jjdd|jzg�|jdd}|j|t�t|jdd�}|j|j|�tj�S)z�
        The checker created by the C{--auth} command-line option returns a
        L{Deferred} that fails with L{UnauthorizedLogin} when
        presented with credentials that are unknown to that checker.
        r9r:r3���rsfake)rr=rr'rrr�
assertFailure�requestAvatarIdr�UnauthorizedLogin)r �checker�invalids   r"�test_authFailurez!MakeServiceTests.test_authFailurels���	
���!�!�8�W�t�}�}�-D�"E�F�"&�,�,�~�">�r�"B�����g�~�6�"�4�#8�#8��#;�W�E���!�!��#�#�G�,�e�.E�.E�
�	
r/c�$����jjdd�jzg��jdd}t�j��|j��}dtttdfddf��fd	�}|j|�S)
z�
        The checker created by the C{--auth} command-line option returns a
        L{Deferred} that returns the avatar id when presented with credentials
        that are known to that checker.
        r9r:r3rC�username�rNc�>���j|�j�y)N)r(rK)rK�correctr s ��r"�checkSuccessz7MakeServiceTests.test_authSuccess.<locals>.checkSuccess�s������X�w�'7�'7�8r/)
rr=rrrrEr�bytesr�addCallback)r rG�drOrNs`   @r"�test_authSuccessz!MakeServiceTests.test_authSuccess{s����	
���!�!�8�W�t�}�}�-D�"E�F�'+�|�|�N�'C�B�'G��"�D�$9�$9�:���#�#�G�,��	9�5���b�	�)9�#:�	9�t�	9��}�}�\�*�*r/c��tj�}tj|�}|jj}|jt
|jj��tth�y)z�
        The L{OpenSSHFactory} built by L{tap.makeService} has a portal with
        L{ISSHPrivateKey} and L{IUsernamePassword} interfaces registered as
        checkers.
        N)rrr&r+�portalr(�set�checkers�keysr
r)r r,r-rUs    r"�
test_checkerszMakeServiceTests.test_checkers�sW��������/�/�&�)�����'�'���������$�$�&�'�.�:K�)L�	
r/)rN)�__name__�
__module__�__qualname__�__doc__r�skip�unixrr#r.r7r?rArrIr
rSrYrLr/r"rrsY����/���1��6��%�
?�
�.?�?� 

�#�

�+�(�4�.�+� 
r/rN)r]�typingrrr�twisted.application.internetr�twisted.credr�twisted.cred.checkersrr	�twisted.cred.credentialsr
rr�twisted.internet.deferr
�twisted.python.reflectr�twisted.trial.unittestrrr_�
twisted.conchr�$twisted.conch.openssh_compat.factoryrrrLr/r"�<module>rjsZ���%�$�D��E�X�X�+�0�+��^�,���)�*���D�!�C�{
�x�{
r/

Zerion Mini Shell 1.0