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: //proc/self/root/lib/python3/dist-packages/twisted/test/__pycache__/test_ftp_options.cpython-38.pyc
U


W[}
�@sXdZddlmZddlmZmZddlmZddlm	Z	ddl
mZGdd�de�Zd	S)
z
Tests for L{twisted.tap.ftp}.
�)�TestCase)�credentials�error)�Options)�versions)�FilePathc@s<eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
S)�FTPOptionsTestszJ
    Tests for the command line option parser used for C{twistd ftp}.
    )siamusersthisispasswordcCs2|��|_t|j�}|�d�|j��t�|_dS)z/
        Create a file with two users.
        �:N)Zmktemp�filenamerZ
setContent�join�usernamePasswordr�options)�self�f�r�?/usr/lib/python3/dist-packages/twisted/test/test_ftp_options.py�setUps

zFTPOptionsTests.setUpcCs$|�t�dddd�|jj|j�dS)zs
        The C{--password-file} option will emit a warning stating that
        said option is deprecated.
        ZTwisted��rN)ZcallDeprecatedrZVersionr
Zopt_password_filer
�rrrr�test_passwordfileDeprecation"s
�z,FTPOptionsTests.test_passwordfileDeprecationcCsBt|jd�}|j�dd|jg�|�t|jd�|d�dS)zf
        The C{--auth} command-line option will add a checker to the list of
        checkers
        �credCheckers�--auth�file:rN)�lenr
�parseOptionsr
�assertEqual)rZnumCheckersrrr�test_authAdded,szFTPOptionsTests.test_authAddedcsT�j�dd�jg��jdd}t��jdd�}|�|���fdd�d	d��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.
        rrr���rZfakecs
��d�S)Nz!Wrong password should raise error)Zfail)�ignorerrr�<lambda>A�z2FTPOptionsTests.test_authFailure.<locals>.<lambda>cSs|�tj�S�N)ZtraprZUnauthorizedLogin)�errrrrr Br!)r
rr
r�UsernamePasswordr�requestAvatarIdZaddCallbacks)r�checkerZinvalidrrr�test_authFailure6s

�z FTPOptionsTests.test_authFailurecsJ�j�dd�jg��jdd}tj�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.
        rrrrcs��|�j�Sr")r�username)r(�Zcorrectrrrr Or!z2FTPOptionsTests.test_authSuccess.<locals>.<lambda>)r
rr
rr$rr%ZaddCallback)rr&rr)r�test_authSuccessEs
�z FTPOptionsTests.test_authSuccessN)
�__name__�
__module__�__qualname__�__doc__rrrrr'r*rrrrrs


rN)
r.Ztwisted.trial.unittestrZtwisted.credrrZtwisted.tap.ftprZtwisted.pythonrZtwisted.python.filepathrrrrrr�<module>s