
    Vh
                     ^    d Z ddlmZmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ  G d de      Zy	)
z
Tests for L{twisted.tap.ftp}.
    )credentialserror)versions)FilePath)Options)TestCasec                   8    e Zd ZdZdZd	dZd	dZd	dZd Zd Z	y)
FTPOptionsTestszJ
    Tests for the command line option parser used for C{twistd ftp}.
    )s   iamusers   thisispasswordNc                     | j                         | _        t        | j                        }|j                  dj	                  | j
                               t               | _        y)z/
        Create a file with two users.
           :N)mktempfilenamer   
setContentjoinusernamePasswordr   options)selffs     M/home/dcms/DCMS/lib/python3.12/site-packages/twisted/test/test_ftp_options.pysetUpzFTPOptionsTests.setUp   sC     T]]#	TYYt4456y    c                     | j                  t        j                  dddd      | j                  j                  | j
                         y)zs
        The C{--password-file} option will emit a warning stating that
        said option is deprecated.
        Twisted      r   N)callDeprecatedr   Versionr   opt_password_filer   )r   s    r   test_passwordfileDeprecationz,FTPOptionsTests.test_passwordfileDeprecation   s:    
 	YAq1LL**MM	
r   c                     t        | j                  d         }| j                  j                  dd| j                  z   g       | j	                  t        | j                  d         |dz          y)zf
        The C{--auth} command-line option will add a checker to the list of
        checkers
        credCheckers--authfile:r   N)lenr   parseOptionsr   assertEqual)r   numCheckerss     r   test_authAddedzFTPOptionsTests.test_authAdded*   sY    
 $,,~67!!8Wt}}-D"EFT\\.9:K!OLr   c                      j                   j                  dd j                  z   g        j                   d   d   }t        j                   j
                  d   d      }|j                  |      j                   f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.
        r"   r#   r!   r   fakec                 &    j                  d      S )Nz!Wrong password should raise error)fail)ignorer   s    r   <lambda>z2FTPOptionsTests.test_authFailure.<locals>.<lambda>=   s    499%HI r   c                 @    | j                  t        j                        S N)trapr   UnauthorizedLogin)errs    r   r/   z2FTPOptionsTests.test_authFailure.<locals>.<lambda>>   s    !8!89 r   )r   r%   r   r   UsernamePasswordr   requestAvatarIdaddCallbacks)r   checkerinvalids   `  r   test_authFailurez FTPOptionsTests.test_authFailure3   sy     	!!8Wt}}-D"EF,,~.r2..t/D/DQ/GP&&w/<<I9
 	
r   c                       j                   j                  dd j                  z   g        j                   d   d   }t        j                   j
                   |j                        j                   fd      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*   c                 <    j                  | j                        S r1   )r&   username)r=   correctr   s    r   r/   z2FTPOptionsTests.test_authSuccess.<locals>.<lambda>K   s    T--h8H8HI r   )r   r%   r   r   r5   r   r6   addCallback)r   r8   r>   s   ` @r   test_authSuccessz FTPOptionsTests.test_authSuccessA   so     	!!8Wt}}-D"EF,,~.r2..0E0EF&&w/;;I
 	
r   )returnN)
__name__
__module____qualname____doc__r   r   r   r(   r:   r@    r   r   r
   r
      s)     7!	
M

r   r
   N)rE   twisted.credr   r   twisted.pythonr   twisted.python.filepathr   twisted.tap.ftpr   twisted.trial.unittestr   r
   rF   r   r   <module>rL      s'    , # , # +=
h =
r   