Ë
    oj˜
  ã                   ó^   — 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     ú?/usr/lib/python3/dist-packages/twisted/test/test_ftp_options.pyÚsetUpzFTPOptionsTests.setUp   sC   € ð Ÿ™›ˆŒÜ�T—]‘]Ó#ˆØ	�‰�T—Y‘Y˜t×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¨¨A¨qÓ1Ø�L‰L×*Ñ*Ø�M‰Mõ	
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ˆØ�‰×!Ñ! 8¨W°t·}±}Ñ-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   ø€ ˜4Ÿ9™9Ð%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   ø€ ð 	�‰×!Ñ! 8¨W°t·}±}Ñ-DÐ"EÔFØ—,‘,˜~Ñ.¨rÑ2ˆÜ×.Ñ.¨t×/DÑ/DÀQÑ/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¸×8HÑ8HÓI€ r   )r   r%   r   r   r5   r   r6   ÚaddCallback)r   r8   r>   s   ` @r   Útest_authSuccessz FTPOptionsTests.test_authSuccessA   so   ù€ ð 	�‰×!Ñ! 8¨W°t·}±}Ñ-DÐ"EÔFØ—,‘,˜~Ñ.¨rÑ2ˆÜ×.Ñ.°×0EÑ0EÐ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   