HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/twisted/test/__pycache__/test_ftp_options.cpython-310.pyc
o

�b�
�@sXdZddlmZmZddlmZddlmZddlm	Z	ddl
mZGdd�de�Zd	S)
z
Tests for L{twisted.tap.ftp}.
�)�credentials�error)�versions)�FilePath)�Options)�TestCasec@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)�mktemp�filenamer�
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.
        �Twisted��rN)�callDeprecatedr�Versionr�opt_password_filer�rrrr�test_passwordfileDeprecations
�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)r�numCheckersrrr�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���r�fakecs
��d�S)Nz!Wrong password should raise error)�fail)�ignorerrr�<lambda>=s
z2FTPOptionsTests.test_authFailure.<locals>.<lambda>cSs|�tj�S�N)�trapr�UnauthorizedLogin)�errrrrr)>s)rr!rr�UsernamePasswordr�requestAvatarId�addCallbacks)r�checker�invalidrrr�test_authFailure3s

�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.
        rrrr%cs��|�j�Sr*)r"�username)r4��correctrrrr)Ksz2FTPOptionsTests.test_authSuccess.<locals>.<lambda>)rr!rrr.rr/�addCallback)rr1rr5r�test_authSuccessAs
�z FTPOptionsTests.test_authSuccessN)
�__name__�
__module__�__qualname__�__doc__rrrr$r3r8rrrrrs		rN)
r<�twisted.credrr�twisted.pythonr�twisted.python.filepathr�twisted.tap.ftpr�twisted.trial.unittestrrrrrr�<module>s