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_tap.cpython-38.pyc
U


W[W�@s�dZzddlZWnek
r(dZYnXzddlZWnek
rNdZYnXzddlmZWnek
rxdZYnXer�er�er�ddlmZddlmZddl	m
Z
ddlmZddl
mZdd	l
mZmZdd
lmZGdd�de�ZdS)
z!
Tests for L{twisted.conch.tap}.
�N)�unix)�tap)�OpenSSHFactory)�StreamServerEndpointService)�error)�ISSHPrivateKey)�IUsernamePassword�UsernamePassword)�TestCasec@sleZdZdZesdZesdZes$dZdZdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zdd�Zdd�ZdS)�MakeServiceTestsz'
    Tests for L{tap.makeService}.
    zcan't run without cryptographyzCannot run without PyASN1z can't run on non-posix computers)siamusersthisispasswordc	CsB|��|_t|jd��}|�d�|j��W5QRXt��|_dS)z/
        Create a file with two users.
        zwb+�:N)	Zmktemp�filename�open�write�join�usernamePasswordr�Options�options)�self�f�r�=/usr/lib/python3/dist-packages/twisted/conch/test/test_tap.py�setUp4s
zMakeServiceTests.setUpcCs@t��}t�|�}|�|t�|�|jjd�|�|jt	�dS)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�makeServiceZassertIsInstancer�assertEqualZendpointZ_port�factoryr)r�config�servicerrr�
test_basic>s

zMakeServiceTests.test_basiccCsNd}|�t|jdd�|�t|jdd�|�|t|jd�d|f�dS)z�
        Make sure that if the C{--auth} command-line option is not passed,
        the default checkers are (for backwards compatibility): SSH and UNIX
        �ZcredInterfacesz)SSH should be one of the default checkersz*UNIX should be one of the default checkers�credCheckersz&There should be %d checkers by defaultN)ZassertInrrrr�len)rZnumCheckersrrr�test_defaultAuthsKs���z"MakeServiceTests.test_defaultAuthscCs0|j�dd|jg�|�t|jd�d�dS)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:r!�N�r�parseOptionsr
rr"�rrrr�test_authAddedZszMakeServiceTests.test_authAddedcCs4|j�dd|jddg�|�t|jd�d�dS)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).
        r$r%zmemory:testuser:testpasswordr!r Nr'r)rrr�test_multipleAuthAddedcs
�z'MakeServiceTests.test_multipleAuthAddedcCsH|j�dd|jg�|jdd}t|jdd�}|�|�|�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.
        r$r%r!���rZfake)	rr(r
r	rZ
assertFailure�requestAvatarIdrZUnauthorizedLogin)r�checkerZinvalidrrr�test_authFailurens�z!MakeServiceTests.test_authFailurecsP�j�dd�jg��jdd}t�j��|���}��fdd�}|�|�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.
        r$r%r!r,cs��|�j�dS)N)r�username)r0�Zcorrectrrr�checkSuccess�sz7MakeServiceTests.test_authSuccess.<locals>.checkSuccess)rr(r
r	rr-ZaddCallback)rr.�dr2rr1r�test_authSuccess|s

z!MakeServiceTests.test_authSuccesscCs<t��}t�|�}|jj}|�t|j���tt	t
g��dS)z�
        The L{OpenSSHFactory} built by L{tap.makeService} has a portal with
        L{ISSHPrivateKey} and L{IUsernamePassword} interfaces registered as
        checkers.
        N)rrrr�portalr�setZcheckers�keysrr)rrrr5rrr�
test_checkers�s

�zMakeServiceTests.test_checkersN)�__name__�
__module__�__qualname__�__doc__�cryptography�skip�pyasn1rrrrr#r*r+r/r4r8rrrrr$s 

	r)r<r=�ImportErrorr?Z
twisted.conchrrZ$twisted.conch.openssh_compat.factoryrZtwisted.application.internetrZtwisted.credrZtwisted.cred.credentialsrrr	Ztwisted.trial.unittestr
rrrrr�<module>s*