File: //usr/lib/python3/dist-packages/twisted/conch/test/__pycache__/test_tap.cpython-310.pyc
o
�b� � @ s� d Z ddlmZ ddlmZ ddlmZmZmZ ddl m
Z
ddlmZ e
d�Z
e
d�Ze
d �Ze
rBerBerBdd
lmZ ddlmZ G dd
� d
e�ZdS )z!
Tests for L{twisted.conch.tap}.
� )�StreamServerEndpointService)�error)�ISSHPrivateKey�IUsernamePassword�UsernamePassword)�
requireModule)�TestCase�cryptography�pyasn1ztwisted.conch.unix)�tap)�OpenSSHFactoryc @ sl e Zd ZdZes
dZesdZesdZdZdd� Z dd � Z
d
d� Zdd
� Zdd� 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)s iamusers thisispasswordc C sV | � � | _t| jd��}|�d�| j�� W d � n1 sw Y t�� | _dS )z/
Create a file with two users.
zwb+� :N) �mktemp�filename�open�write�join�usernamePasswordr �Options�options)�self�f� r �=/usr/lib/python3/dist-packages/twisted/conch/test/test_tap.py�setUp( s
�zMakeServiceTests.setUpc C s@ 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)
r r �makeService�assertIsInstancer �assertEqual�endpoint�_port�factoryr )r �config�servicer r r �
test_basic1 s
zMakeServiceTests.test_basicc C sN d}| � t| jd d� | � t| jd d� | �|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
� �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 r r r �len)r �numCheckersr r r �test_defaultAuths= s ���z"MakeServiceTests.test_defaultAuthsc C s0 | j �dd| j g� | �t| j d �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 r r* �r r r r �test_authAddedT s zMakeServiceTests.test_authAddedc C s4 | j �dd| j ddg� | �t| j d �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&