ó N ­Nc@svdZddlmZddlmZmZddlmZddlm Z ddl m Z defd„ƒYZ d S( s Tests for L{twisted.tap.ftp}. iÿÿÿÿ(tTestCase(t credentialsterror(tOptions(tversions(tFilePathtFTPOptionsTestCasecBsAeZdZdZd„Zd„Zd„Zd„Zd„ZRS( sJ Tests for the command line option parser used for C{twistd ftp}. tiamusertthisispasswordcCsG|jƒ|_t|jƒ}|jdj|jƒƒtƒ|_dS(s/ Create a file with two users. t:N(tmktemptfilenameRt setContenttjointusernamePasswordRtoptions(tselftf((sA/usr/lib/python2.7/dist-packages/twisted/test/test_ftp_options.pytsetUpscCs2|jtjddddƒ|jj|jƒdS(ss The C{--password-file} option will emit a warning stating that said option is deprecated. tTwistedi iiN(tcallDeprecatedRtVersionRtopt_password_fileR (R((sA/usr/lib/python2.7/dist-packages/twisted/test/test_ftp_options.pyttest_passwordfileDeprecation"scCsUt|jdƒ}|jjdd|jgƒ|jt|jdƒ|dƒdS(sf The C{--auth} command-line option will add a checker to the list of checkers t credCheckerss--authsfile:iN(tlenRt parseOptionsR t assertEqual(Rt numCheckers((sA/usr/lib/python2.7/dist-packages/twisted/test/test_ftp_options.pyttest_authAdded,scslˆjjddˆjgƒˆjdd}tjˆjddƒ}|j|ƒj‡fd†d„ƒS( s× 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. s--authsfile:Riÿÿÿÿitfakecs ˆjdƒS(Ns!Wrong password should raise error(tfail(tignore(R(sA/usr/lib/python2.7/dist-packages/twisted/test/test_ftp_options.pytAscSs|jtjƒS(N(ttrapRtUnauthorizedLogin(terr((sA/usr/lib/python2.7/dist-packages/twisted/test/test_ftp_options.pyR!Bs(RRR RtUsernamePasswordRtrequestAvatarIdt addCallbacks(Rtcheckertinvalid((RsA/usr/lib/python2.7/dist-packages/twisted/test/test_ftp_options.pyttest_authFailure6s  csbˆjjddˆjgƒˆjdd}tjˆjŒ‰|jˆƒj‡‡fd†ƒS(sË 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. s--authsfile:Riÿÿÿÿcsˆj|ˆjƒS(N(Rtusername(R+(tcorrectR(sA/usr/lib/python2.7/dist-packages/twisted/test/test_ftp_options.pyR!Os(RRR RR%RR&t addCallback(RR(((R,RsA/usr/lib/python2.7/dist-packages/twisted/test/test_ftp_options.pyttest_authSuccessEs (RR( t__name__t __module__t__doc__RRRRR*R.(((sA/usr/lib/python2.7/dist-packages/twisted/test/test_ftp_options.pyRs N( R1ttwisted.trial.unittestRt twisted.credRRttwisted.tap.ftpRttwisted.pythonRttwisted.python.filepathRR(((sA/usr/lib/python2.7/dist-packages/twisted/test/test_ftp_options.pyts