
    Yf
                     f    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d	S )
z
Tests for L{twisted.tap.ftp}.
    )credentialserror)versions)FilePath)Options)TestCasec                   :    e Zd ZdZdZd
dZd
dZd
dZd Zd	 Z	dS )FTPOptionsTestszJ
    Tests for the command line option parser used for C{twistd ftp}.
    )s   iamusers   thisispasswordreturnNc                     |                                  | _        t          | j                  }|                    d                    | j                             t                      | _        dS )z/
        Create a file with two users.
           :N)mktempfilenamer   
setContentjoinusernamePasswordr   options)selffs     O/var/www/html/env/lib/python3.11/site-packages/twisted/test/test_ftp_options.pysetUpzFTPOptionsTests.setUp   sR     T]##	TYYt455666yy    c                 |    |                      t          j        dddd          | j        j        | j                   dS )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   sG    
 	YAq11L*M	
 	
 	
 	
 	
r   c                     t          | j        d                   }| j                            dd| j        z   g           |                     t          | j        d                   |dz              dS )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*   si    
 $,~677!!8Wt}-D"EFFFT\.9::K!OLLLLLr   c                      j                             dd j        z   g            j         d         d         }t          j         j        d         d          }|                    |                               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                 .                         d          S )Nz!Wrong password should raise error)fail)ignorer   s    r   <lambda>z2FTPOptionsTests.test_authFailure.<locals>.<lambda>=   s    499%HII r   c                 @    |                      t          j                  S N)trapr   UnauthorizedLogin)errs    r   r0   z2FTPOptionsTests.test_authFailure.<locals>.<lambda>>   s    !899 r   )r   r&   r   r   UsernamePasswordr   requestAvatarIdaddCallbacks)r   checkerinvalids   `  r   test_authFailurez FTPOptionsTests.test_authFailure3   s     	!!8Wt}-D"EFFF,~.r2.t/DQ/GPP&&w//<<IIII99
 
 	
r   c                       j                             dd j        z   g            j         d         d         }t          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                  S r2   )r'   username)r>   correctr   s    r   r0   z2FTPOptionsTests.test_authSuccess.<locals>.<lambda>K   s    T--h8HII r   )r   r&   r   r   r6   r   r7   addCallback)r   r9   r?   s   ` @r   test_authSuccessz FTPOptionsTests.test_authSuccessA   s~     	!!8Wt}-D"EFFF,~.r2.0EF&&w//;;IIIII
 
 	
r   )r   N)
__name__
__module____qualname____doc__r   r   r    r)   r;   rA    r   r   r
   r
      s          7! ! ! !	
 	
 	
 	
M M M 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   