+
    üÐjÆÆ  ã                   ó   € R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t	H
t
 ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RIHtHt ^ RIHt ^ R	IHtHtHtHtHt ^ R
IHt ^ RI H!t! ^ RI"H#t# ^ RI$H%t% ^ RI&H't' ^ RI(H)t) ^ RI*H+t+ ^ RI,H-t- ^ RI.H/t/ ]-! R4      t0]-! R4      t1]0'       d.    ^ RI2H3t3 ^ RI4H5t5 ^ RI6H7t7 ^ RI8H9t9 ^ RI:H;t;H<t< ^ RI=H>t> ^ RIH?t? RtAR]1]0]P„                  ! ]R4      39   d   RtA]! ]AR4       ! R R ]/4      4       tC ! R! R"]/4      tD ! R# R$]!4      tE ! R% R&4      tF ! R' R(4      tG]! ]4       ! R) R*]	4      4       tH]! ]AR4       ! R+ R,]/4      4       tI ! R- R.4      tJ ! R/ R0]P–                  4      tL ! R1 R2]4      tM]! ]AR4       ! R3 R4]M4      4       tN]! ]AR4       ! R5 R6]M4      4       tO]! ]AR4      ]! ]+! R74      '       * R84      ]! ]+! R94      '       * R:4       ! R; R<]M4      4       4       4       tPR#   ]@ d     EL6i ; i)=z*
Tests for L{twisted.conch.scripts.cftp}.
N)ÚBytesIOÚTextIOWrapper)ÚskipIf)Úimplementer)Úls)Ú	ISFTPFile)ÚFileTransferTestAvatarÚSFTPTestBase)Úportal)ÚdeferÚerrorÚ
interfacesÚprotocolÚreactor)ÚClock)ÚStringTransport)ÚgetProcessOutputAndValue)Úlog)ÚUserDatabase)ÚFilePath)Úwhich)ÚrequireModule)ÚTestCaseÚcryptographyztwisted.conch.unix)Úcftp)Ú
SSHSession)Úfiletransfer)ÚEXTENDED_DATA_STDERR)Ú
test_conchÚtest_ssh)Ú	FakeStdio)ÚFileTransferForTestAvatarFTz*don't run w/o spawnProcess or cryptographyc                   óZ   a € ] tR t^8t o RtV 3R lR ltV 3R lR ltV 3R lR ltRtV t	R	# )
ÚSSHSessionTestsz5
Tests for L{twisted.conch.scripts.cftp.SSHSession}.
c                ó   <€ V ^8„  d   QhRR/# ©é   ÚreturnN© )ÚformatÚ__classdict__s   "€Ú>/usr/lib/python3/dist-packages/twisted/conch/test/test_cftp.pyÚ__annotate__ÚSSHSessionTests.__annotate__>   s   ø€ ÷ *ñ *�tñ *ó    c                ó   € \        4       V n        \        4       V n        V P                  V P                  n        \	        4       V n        \        V P
                  4      V n        V P                  V P                  n        R # ©N)r    Ústdior   Úchannelr   ÚstderrBufferr   Ústderr©Úselfs   &r+   ÚsetUpÚSSHSessionTests.setUp>   sP   € Ü“[ˆŒ
Ü!“|ˆŒØ!ŸZ™Zˆ�‰ÔÜ#›IˆÔÜ# D×$5Ñ$5Ó6ˆŒØ"Ÿk™kˆ�‰Ör.   c                ó   <€ V ^8„  d   QhRR/# r%   r(   )r)   r*   s   "€r+   r,   r-   F   s   ø€ ÷ 2ñ 2 $ñ 2r.   c                ó„   € V P                   P                  4        V P                  V P                  P                  4       R# )zd
L{twisted.conch.scripts.cftp.SSHSession.eofReceived} loses the write
half of its stdio connection.
N)r2   ÚeofReceivedÚ
assertTruer1   ÚwriteConnLostr5   s   &r+   Útest_eofReceivedÚ SSHSessionTests.test_eofReceivedF   s*   € ð
 	�‰× Ñ Ô"Ø�‰˜Ÿ
™
×0Ñ0Ö1r.   c                ó   <€ V ^8„  d   QhRR/# r%   r(   )r)   r*   s   "€r+   r,   r-   N   s   ø€ ÷ 
ñ 
¨ñ 
r.   c                óÜ   € RpVP                  R4      pV P                  P                  \        VR,           4       V P	                  V P
                  P                  4       VR,           4       R# )z©
L{twisted.conch.scripts.cftp.SSHSession.extReceived} decodes
stderr data using UTF-8 with the "backslashescape" error handling and
writes the result to its own stderr.
u   â˜ƒúutf-8ó   ÿs   \xffN)Úencoder2   ÚextReceivedr   ÚassertEqualr3   Úgetvalue)r6   Ú	errorTextÚ
errorBytess   &  r+   Útest_extReceivedStderrÚ&SSHSessionTests.test_extReceivedStderrN   s`   € ð "ˆ	Ø×%Ñ% gÓ.ˆ
Ø�‰× Ñ Ü Ø˜Õ ô	
ð 	×ÑØ×Ñ×&Ñ&Ó(Ø˜Õ!ö	
r.   )r2   r4   r3   r1   N)
Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r7   r>   rJ   Ú__static_attributes__Ú__classdictcell__©r*   s   @r+   r#   r#   8   s(   ø‡ € ñ÷*ð *÷2ð 2÷
ö 
r.   r#   c                   ó–  a € ] tR t^`t o Rt]! ]RR4      f   RtR tR t	R t
R tR	 t]P                  ! 4       t  ]P                   ! ]P"                  R
4       Rt]P                   ! ]P"                  ]4       ]! ]R4      R 4       tR tRtV tR#   ]P&                   d    Rt LJi ; i  ]P                   ! ]P"                  ]4       i ; i)ÚListingTestszw
Tests for L{lsLine}, the function which generates an entry for a file or
directory in an SFTP I{ls} command's output.
ÚtzsetNz8Cannot test timestamp formatting code without time.tzsetc                ón  a € RS n         V 3R lpS P                  \        RV4       R\        P                  9   dg   S P                  \        P                  \        P                  R\        P                  R,          4       S P                  \        P                  4       R# R pS P                  V4       R# )zW
Patch the L{ls} module's time function so the results of L{lsLine} are
deterministic.
iÍ[c                  ó   <€ S P                   # r0   ©Únowr5   s   €r+   ÚfakeTimeÚ$ListingTests.setUp.<locals>.fakeTimep   s   ø€ Ø—8‘8ˆOr.   ÚtimeÚTZc                  óv   €  \         P                  R  \        P                  ! 4        R#   \         d     L$i ; i)r^   N)ÚosÚenvironÚKeyErrorr]   rV   r(   r.   r+   ÚcleanupÚ#ListingTests.setUp.<locals>.cleanup|   s2   € ðÜŸ
™
 4Ð(ô —
’
–øô  ô Ùðús   ‚* ª8·8N)
rZ   Úpatchr   r`   ra   Ú
addCleanupÚoperatorÚsetitemr]   rV   )r6   r[   rc   s   f  r+   r7   ÚListingTests.setUpi   sy   ø€ ð
 ˆŒõ	ð 	�
‰
”2�v˜xÔ(ð ”2—:‘:ÔØ�O‰OœH×,Ñ,¬b¯j©j¸$ÄÇ
Á
È4Õ@PÔQØ�O‰OœDŸJ™JÖ'òð �O‰O˜GÖ$r.   c                ó€   € V\         P                  R&   \        P                  ! 4        \        P
                  ! RV4      # )zT
Call L{ls.lsLine} after setting the timezone to C{timezone} and return
the result.
r^   Úfoo)r`   ra   r]   rV   r   ÚlsLine)r6   ÚtimezoneÚstats   &&&r+   Ú_lsInTimezoneÚListingTests._lsInTimezone†   s,   € ð $Œ�
‰
�4ÑÜ�
Š
ŒÜ�yŠy˜ Ó%Ð%r.   c                óô   € V P                   R,
          p\        P                  ! ^ ^ ^ ^ ^ ^ ^ ^ V^ 3
4      pV P                  V P	                  RV4      R4       V P                  V P	                  RV4      R4       R# )zy
A file with an mtime six months (approximately) or more in the past has
a listing including a low-resolution timestamp.
úAmerica/New_Yorkz;!---------    0 0        0               0 Apr 26  1973 fooúPacific/Aucklandz;!---------    0 0        0               0 Apr 27  1973 fooNé€©rZ   r`   Ústat_resultrF   ro   ©r6   Úthenrn   s   &  r+   Útest_oldFileÚListingTests.test_oldFile‘   ó|   € ð �x‰xÐ0Õ1ˆÜ�~Š~˜q ! Q¨¨1¨a°°A°t¸QÐ?Ó@ˆà×ÑØ×ÑÐ1°4Ó8ØIô	
ð 	×ÑØ×ÑÐ1°4Ó8ØIö	
r.   c                ó  € V P                   R,
          R,           p\        P                  ! ^ ^ ^ ^ ^ ^ ^ ^ V^ 3
4      pV P                  V P	                  RV4      R4       V P                  V P	                  RV4      R4       R# )úÆ
A file with a high-resolution timestamp which falls on a day of the
month which can be represented by one decimal digit is formatted with
one padding 0 to preserve the columns which come after it.
rr   z;!---------    0 0        0               0 May 01  1973 foors   z;!---------    0 0        0               0 May 02  1973 fooNrt   i€— ru   rw   s   &  r+   Útest_oldSingleDigitDayOfMonthÚ*ListingTests.test_oldSingleDigitDayOfMonth£   ó‚   € ð �x‰xÐ0Õ1Ð5EÕFˆÜ�~Š~˜q ! Q¨¨1¨a°°A°t¸QÐ?Ó@ˆà×ÑØ×ÑÐ1°4Ó8ØIô	
ð 	×ÑØ×ÑÐ1°4Ó8ØIö	
r.   c                óô   € V P                   R,
          p\        P                  ! ^ ^ ^ ^ ^ ^ ^ ^ V^ 3
4      pV P                  V P	                  RV4      R4       V P                  V P	                  RV4      R4       R# )z�
A file with an mtime fewer than six months (approximately) in the past
has a listing including a high-resolution timestamp excluding the year.
rr   ú;!---------    0 0        0               0 Aug 28 17:33 foors   ú;!---------    0 0        0               0 Aug 29 09:33 fooNé€›z ru   rw   s   &  r+   Útest_newFileÚListingTests.test_newFile·   r{   r.   ú
es_AR.UTF8FTz'The es_AR.UTF8 locale is not installed.c                óÆ  € V P                   R,
          p\        P                  ! ^ ^ ^ ^ ^ ^ ^ ^ V^ 3
4      p\        P                  ! 4       p\        P
                  ! \        P                  R4       V P                  \        P
                  \        P                  V4       V P                  V P                  RV4      R4       V P                  V P                  RV4      R4       R# )z3
The month name in the date is locale independent.
r‡   rr   r‚   rs   rƒ   Nr„   )
rZ   r`   rv   ÚlocaleÚ	getlocaleÚ	setlocaleÚLC_ALLrf   rF   ro   )r6   rx   rn   ÚcurrentLocales   &   r+   Útest_localeIndependentÚ#ListingTests.test_localeIndependentÖ   sº   € ð �x‰xÐ0Õ1ˆÜ�~Š~˜q ! Q¨¨1¨a°°A°t¸QÐ?Ó@ˆô ×(Ò(Ó*ˆÜ×ÒœŸ™¨Ô5Ø�‰œ×(Ñ(¬&¯-©-¸ÔGà×ÑØ×ÑÐ1°4Ó8ØIô	
ð 	×ÑØ×ÑÐ1°4Ó8ØIö	
r.   c                ó  € V P                   R,
          R,           p\        P                  ! ^ ^ ^ ^ ^ ^ ^ ^ V^ 3
4      pV P                  V P	                  RV4      R4       V P                  V P	                  RV4      R4       R# )r}   rr   z;!---------    0 0        0               0 Sep 01 17:33 foors   z;!---------    0 0        0               0 Sep 02 09:33 fooNr„   i F ru   rw   s   &  r+   Útest_newSingleDigitDayOfMonthÚ*ListingTests.test_newSingleDigitDayOfMonthí   r€   r.   rY   )rL   rM   rN   rO   rP   Úgetattrr]   Úskipr7   ro   ry   r~   r…   r‰   rŠ   r�   r‹   rŒ   Ú
localeSkipÚErrorr   rŽ   r‘   rQ   rR   rS   s   @r+   rU   rU   `   sØ   ø‡ € ññ
 ˆt�W˜dÓ#Ò+ØIˆò%ò:	&ò
ò$
ò(
ð( ×$Ò$Ó&€Mð7ð	Ø×Ò˜VŸ]™]¨LÔ9ð ˆJà×Ò˜Ÿ™¨Ô6áˆJÐAÓBñ
ó Cð
÷,
ð 
øð= �|‰|ô 	ØŠJð	ûð
 	×Ò˜Ÿ™¨Õ6ús)   ¼B ÁB) ÂB&Â#B) Â%B&Â&B) Â)CrU   c                   ó6   a a€ ] tR tRt oRtV 3R ltRtVtV ;t# )ÚInMemorySSHChanneli  zd
Minimal implementation of a L{SSHChannel} like class which only reads and
writes data from memory.
c                ó>   <€ Wn         ^ V n        \        SV `  4        R# )z\
@param conn: The SSH connection associated with this channel.
@type conn: L{SSHConnection}
N)ÚconnÚlocalClosedÚsuperÚ__init__)r6   rš   Ú	__class__s   &&€r+   r�   ÚInMemorySSHChannel.__init__  s   ø€ ð
 Œ	ØˆÔÜ‰ÑÖr.   )rš   r›   )	rL   rM   rN   rO   rP   r�   rQ   rR   Ú__classcell__)rž   r*   s   @@r+   r˜   r˜     s   ù‡ € ñ÷
õ r.   r˜   c                   ó6   a € ] tR tRt o RtR tR tR tRtV t	R# )ÚFilesystemAccessExpectationsi  z;
A test helper used to support expected filesystem access.
c                ó   € / V n         R # r0   ©Ú_cacher5   s   &r+   r�   Ú%FilesystemAccessExpectations.__init__  s	   € ØˆŽr.   c                ó$   € W0P                   W3&   R# )zÄ

@param path: Path at which the stream is requested.
@type path: L{str}

@param path: Flags with which the stream is requested.
@type path: L{str}

@param stream: A stream.
@type stream: C{File}
Nr¤   )r6   ÚpathÚflagsÚstreams   &&&&r+   ÚputÚ FilesystemAccessExpectations.put  s   € ð &,�‰�T�MÓ"r.   c                ó:   € V P                   P                  W34      # )zÙ
Remove a stream from the memory.

@param path: Path at which the stream is requested.
@type path: L{str}

@param path: Flags with which the stream is requested.
@type path: L{str}

@return: A stream.
@rtype: C{File}
)r¥   Úpop)r6   r¨   r©   s   &&&r+   r®   Ú FilesystemAccessExpectations.pop(  s   € ð �{‰{�‰ ˜}Ó-Ð-r.   r¤   N)
rL   rM   rN   rO   rP   r�   r«   r®   rQ   rR   rS   s   @r+   r¢   r¢     s   ø‡ € ñòò,÷.ð .r.   r¢   c                   ó0   a € ] tR tRt o RtR tR tRtV tR# )ÚInMemorySFTPClienti8  a  
A L{filetransfer.FileTransferClient} which does filesystem operations in
memory, without touching the local disc or the network interface.

@ivar _availableFiles: File like objects which are available to the SFTP
    client.
@type _availableFiles: L{FilesystemRegister}
c                óH   € \        V 4      V n        R ^R^
/V n        Wn        R# )ÚrequestsÚ
buffersizeN)r˜   Ú	transportÚoptionsÚ_availableFiles)r6   ÚavailableFiless   &&r+   r�   ÚInMemorySFTPClient.__init__B  s)   € Ü+¨DÓ1ˆŒà˜Ø˜"ð
ˆŒð  .Ör.   c                ó8   € V P                   P                  W4      # )ze
@see: L{filetransfer.FileTransferClient.openFile}.

Retrieve and remove cached file based on flags.
)r·   r®   )r6   Úfilenamer©   Úattrss   &&&&r+   ÚopenFileÚInMemorySFTPClient.openFileJ  s   € ð ×#Ñ#×'Ñ'¨Ó8Ð8r.   )r·   r¶   rµ   N)	rL   rM   rN   rO   rP   r�   r½   rQ   rR   rS   s   @r+   r±   r±   8  s   ø‡ € ñò.÷9ð 9r.   r±   c                   óN   a € ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
tV tR# )ÚInMemoryRemoteFileiS  z3
An L{ISFTPFile} which handles all data in memory.
c                ó>   € Wn         \        P                  ! V 4       R# )z4
@param name: Name of this file.
@type name: L{str}
N)Únamer   r�   )r6   rÂ   s   &&r+   r�   ÚInMemoryRemoteFile.__init__Y  s   € ð
 Œ	Ü×Ò˜Ör.   c                ór   € V P                  V4       V P                  V4       \        P                  ! V 4      # )z
@see: L{ISFTPFile.writeChunk}
)ÚseekÚwriter   Úsucceed)r6   ÚstartÚdatas   &&&r+   Ú
writeChunkÚInMemoryRemoteFile.writeChunka  s+   € ð 	�	‰	�%ÔØ�
‰
�4ÔÜ�}Š}˜TÓ"Ð"r.   c                ó   € RV n         R# )zW
@see: L{ISFTPFile.writeChunk}

Keeps data after file was closed to help with testing.
TN)Ú_closedr5   s   &r+   ÚcloseÚInMemoryRemoteFile.closei  s   € ð ˆŽr.   c                ó   € R # r0   r(   r5   s   &r+   ÚgetAttrsÚInMemoryRemoteFile.getAttrsq  ó   € ár.   c                ó   € R # r0   r(   )r6   ÚoffsetÚlengths   &&&r+   Ú	readChunkÚInMemoryRemoteFile.readChunku  rÓ   r.   c                ó   € R # r0   r(   )r6   r¼   s   &&r+   ÚsetAttrsÚInMemoryRemoteFile.setAttrsy  rÓ   r.   c                ó.   € \         P                  ! V 4      # )zJ
Get current data of file.

Allow reading data event when file is closed.
)r   rG   r5   s   &r+   rG   ÚInMemoryRemoteFile.getvalue}  s   € ô ×Ò Ó%Ð%r.   )rÍ   rÂ   N)rL   rM   rN   rO   rP   r�   rÊ   rÎ   rÑ   r×   rÚ   rG   rQ   rR   rS   s   @r+   rÀ   rÀ   S  s2   ø‡ € ñòò#òòòò÷&ð &r.   rÀ   c                   ó˜   a € ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tRR ltRR ltR tR tR tR tRtV tR# )ÚStdioClientTestsi†  z 
Tests for L{cftp.StdioClient}.
c                óh  € \        4       V n        \        V P                  4      p\        P                  ! V4      V n        RV P
                  n        \        4       ;V n        V P
                  n	        V P                  R^4       V P
                  P
                  P                  V P
                  n        R# )zU
Create a L{cftp.StdioClient} hooked up to dummy transport and a fake
user database.
Ú/iô  N)r¢   ÚfakeFilesystemr±   r   ÚStdioClientÚclientÚcurrentDirectoryr   ÚdatabaseÚ_pwdÚsetKnownConsoleSizerµ   )r6   Ú
sftpClients   & r+   r7   ÚStdioClientTests.setUpŒ  s‚   € ô
 ;Ó<ˆÔÜ'¨×(;Ñ(;Ó<ˆ
Ü×&Ò& zÓ2ˆŒØ'*ˆ�‰Ô$Ü+7«>Ð9ˆŒ˜Ÿ™Ô(ð
 	× Ñ   bÔ)ð !%§¡× 2Ñ 2× <Ñ <ˆ�‰Ör.   c           	     ó  € V P                   P                  \        P                  ! 4       R\        P
                  ! 4       RRR\        P                  4       V P                  P                  R4      pVP                  V P                  R4       V# )z[
The I{exec} command runs its arguments locally in a child process
using the user's shell.
ÚsecretéÒ  rk   Úbarzexec print(1 + 2)s   3
)ræ   ÚaddUserÚgetpassÚgetuserr`   ÚgetuidÚsysÚ
executablerä   Ú_dispatchCommandÚaddCallbackrF   ©r6   Úds   & r+   Ú	test_execÚStdioClientTests.test_execŸ  sf   € ð
 	�‰×ÑÜ�OŠOÓ˜x¬¯ª«°d¸EÀ5Ì#Ï.É.ô	
ð �K‰K×(Ñ(Ð)<Ó=ˆØ	�‰�d×&Ñ&¨Ô/Øˆr.   c           	     ó  € V P                   P                  \        P                  ! 4       R\        P
                  ! 4       RRRR4       V P                  P                  R4      pVP                  V P                  R4       V# )zZ
If the local user has no shell, the I{exec} command runs its arguments
using I{/bin/sh}.
rì   rí   rk   rî   Ú zexec echo helloó   hello
©
ræ   rï   rð   rñ   r`   rò   rä   rõ   rö   rF   r÷   s   & r+   Útest_execWithoutShellÚ&StdioClientTests.test_execWithoutShell¬  sb   € ð
 	�‰×ÑÜ�OŠOÓ˜x¬¯ª«°d¸EÀ5È"ô	
ð �K‰K×(Ñ(Ð):Ó;ˆØ	�‰�d×&Ñ&¨
Ô3Øˆr.   c           	     ó  € V P                   P                  \        P                  ! 4       R\        P
                  ! 4       RRRR4       V P                  P                  R4      pVP                  V P                  R4       V# )z?
The I{exec} command is run for lines which start with C{"!"}.
rì   rí   rk   rî   z/bin/shz!echo hellorý   rþ   r÷   s   & r+   Ú	test_bangÚStdioClientTests.test_bang¹  sa   € ð 	�‰×ÑÜ�OŠOÓ˜x¬¯ª«°d¸EÀ5È)ô	
ð �K‰K×(Ñ(¨Ó7ˆØ	�‰�d×&Ñ&¨
Ô3Øˆr.   c                ój   aaa€ ^ RI o ! VVV3R lR4      pV P                  \        RV! 4       4       R# )zÜ
For the duration of this test, patch C{cftp}'s C{fcntl} module to return
a fixed width and height.

@param width: the width in characters
@type width: L{int}
@param height: the height in characters
@type height: L{int}
Nc                   ó2   <a € ] tR tRt o VVV3R ltRtV tR# )Ú7StdioClientTests.setKnownConsoleSize.<locals>.FakeFcntliÒ  c                ó|   <€ VSP                   8w  d   V P                  R 4       \        P                  ! RSS^ ^ 4      # )z#Only window-size queries supported.Ú4H)Ú
TIOCGWINSZÚfailÚstructÚpack)r6   ÚfdÚoptÚmutateÚheightÚttyÚwidths   &&&&€€€r+   ÚioctlÚ=StdioClientTests.setKnownConsoleSize.<locals>.FakeFcntl.ioctlÓ  s3   ø€ Ø˜#Ÿ.™.Ô(Ø—I‘IÐCÔDÜ—{’{ 4¨°¸¸1Ó=Ð=r.   r(   N)rL   rM   rN   rO   r  rQ   rR   )r*   r  r  r  s   @€€€r+   Ú	FakeFcntlr  Ò  s   ù‡ € ÷>õ >r.   r  Úfcntl)r  re   r   )r6   r  r  r  r  s   &ff @r+   rè   Ú$StdioClientTests.setKnownConsoleSizeÅ  s&   ú€ ó 	÷	>ö 	>ð 	�
‰
”4˜¡)£+Ö.r.   c                óÒ  € V P                  ^
^"4       \        4       ;qP                  n        \	        R4      pRVn        \        P                  ! V4      pRVn        VP                  4       pVP                  R4       V;P                  R,          un        V P                  P                  W44       RpV P                  V P                  P                  P                  4       V4       R# )a   
L{StdioClient._printProgressBar} prints a progress description,
including percent done, amount transferred, transfer rate, and time
remaining, all based the given start time, the given L{FileWrapper}'s
progress information and the reactor's current time.
ó   xó   sampleg       @i   s#   b'sample' 40% 4.0kB 2.0kBps 00:03 Ni (  )rè   r   rä   r   r   rÂ   r   ÚFileWrapperÚsizeÚsecondsÚadvanceÚtotalÚ_printProgressBarrF   rµ   Úvalue©r6   ÚclockÚwrappedÚwrapperÚ	startTimeÚresults   &     r+   Útest_printProgressBarReportingÚ/StdioClientTests.test_printProgressBarReportingÚ  s«   € ð 	× Ñ   RÔ(Ü&+£gÐ-ˆ—‘Ô#Ü˜$“-ˆØ ˆŒÜ×"Ò" 7Ó+ˆØ ˆŒØ—M‘M“Oˆ	Ø�‰�cÔØ�Š˜Õ�à�‰×%Ñ% gÔ9à8ˆØ×Ñ˜Ÿ™×.Ñ.×4Ñ4Ó6¸Ö?r.   c                óp  € V P                  ^
^"4       \        4       ;qP                  n        \	        R4      pRVn        \        P                  ! V4      pVP                  4       pV P                  P                  W44       RpV P                  V P                  P                  P                  4       V4       R# )z�
L{StdioClient._printProgressBar} prints a progress description that
indicates 0 bytes transferred if no bytes have been transferred and no
time has passed.
r  r  s!   b'sample'  0% 0.0B 0.0Bps 00:00 N)rè   r   rä   r   r   rÂ   r   r  r  r   rF   rµ   r!  r"  s   &     r+   Útest_printProgressBarNoProgressÚ0StdioClientTests.test_printProgressBarNoProgressò  sŠ   € ð 	× Ñ   RÔ(Ü&+£gÐ-ˆ—‘Ô#Ü˜$“-ˆØ ˆŒÜ×"Ò" 7Ó+ˆØ—M‘M“Oˆ	à�‰×%Ñ% gÔ9à6ˆØ×Ñ˜Ÿ™×.Ñ.×4Ñ4Ó6¸Ö?r.   c                ó  € V P                  ^
^"4       \        4       pRVn        \        P                  ! V4      pV P
                  P                  V^ 4       RpV P                  W0P
                  P                  P                  4       4       R# )z%
Print the progress for empty files.
s
   empty-files%   b'empty-file'100% 0.0B 0.0Bps 00:00 N)
rè   r   rÂ   r   r  rä   r   rF   rµ   r!  )r6   r$  r%  r'  s   &   r+   Útest_printProgressBarEmptyFileÚ/StdioClientTests.test_printProgressBarEmptyFile  sl   € ð 	× Ñ   RÔ(Ü“)ˆØ$ˆŒÜ×"Ò" 7Ó+ˆà�‰×%Ñ% g¨qÔ1à:ˆØ×Ñ˜§¡×!6Ñ!6×!<Ñ!<Ó!>Ö?r.   c                ó`   € V P                   P                  R4      pV P                  RV4       R# )z;
Returns empty value for both filename and remaining data.
z  N)rü   rü   ©rä   Ú_getFilenamerF   ©r6   r'  s   & r+   Útest_getFilenameEmptyÚ&StdioClientTests.test_getFilenameEmpty  s(   € ð —‘×)Ñ)¨$Ó/ˆà×Ñ˜ 6Ö*r.   c                ó`   € V P                   P                  R4      pV P                  RV4       R# )zL
Returns empty value for remaining data when line contains
only a filename.
ú
only-localN)r7  rü   r1  r3  s   & r+   Útest_getFilenameOnlyLocalÚ*StdioClientTests.test_getFilenameOnlyLocal  s)   € ð
 —‘×)Ñ)¨,Ó7ˆà×ÑÐ+¨VÖ4r.   c                ó`   € V P                   P                  R4      pV P                  RV4       R# )zM
Returns filename and remaining data striped of leading and trailing
spaces.
z local  remote file  N)Úlocalzremote filer1  r3  s   & r+   Útest_getFilenameNotQuotedÚ*StdioClientTests.test_getFilenameNotQuoted#  s*   € ð
 —‘×)Ñ)Ð*AÓBˆà×ÑÐ1°6Ö:r.   c                ó`   € V P                   P                  R4      pV P                  RV4       R# )zq
Returns filename and remaining data not striped of leading and trailing
spaces when quoted paths are requested.
z" " local file "  " remote  file " N)z local file z" remote  file "r1  r3  s   & r+   Útest_getFilenameQuotedÚ'StdioClientTests.test_getFilenameQuoted,  s*   € ð
 —‘×)Ñ)Ð*NÓOˆà×ÑÐ=¸vÖFr.   Nc                ó²   € Vf   V P                  4       p\        VR4      ;_uu_ 4       pVP                  V4       RRR4       V#   + '       g   i     T# ; i)a"  
Create a local file and return its path.

When `path` is L{None}, it will create a new temporary file.

@param path: Optional path for the new file.
@type path: L{str}

@param content: Content to be written in the new file.
@type content: L{bytes}

@return: Path to the newly create file.
NÚwb)ÚmktempÚopenrÆ   )r6   r¨   ÚcontentÚfiles   &&& r+   ÚmakeFileÚStdioClientTests.makeFile5  sG   € ð Š<Ø—;‘;“=ˆDÜ�$˜×Ô Ø�J‰J�wÔ÷ àˆ÷ Öàˆús   ©AÁA	c                ó4  € V P                   P                  P                  4       pVP                  R4      pVP	                  R4      p. p. pV EFl  w  rgp. p	V F  p
V	P                  V RV
 24       K  	  V	P                  RV RV 24       VP                  V	4       VP                  ^ 4      P                  R4      P	                  R4      pVRR
 pVR
,          P                  R4      P	                  R4      pVP                  V4       . pVRR
  F|  p
V
P                  4       P                  R^4      ^ ,          p
V
P                  4       P	                  R^4      p
VP                  V
^ ,           RV
^,          P                  4        24       K~  	  VP                  VR
,          4       VP                  V4       EKo  	  V'       d&   V P                  \        V4      \        V4      4       MV P                  WE4       V P                  ^ \        V4      R	4       R# )zÛ
Check output of cftp client for a put request.


@param transfers: List with tuple of (local, remote, progress).
@param randomOrder: When set to C{True}, it will ignore the order
    in which put reposes are received

rB   z
Ú zTransferred z to ÚNÚ
z5There are still put responses which were not checked.éÿÿÿÿ)rä   rµ   r!  ÚdecodeÚsplitÚappendr®   ÚstripÚextendÚrsplitrF   ÚsortedÚlen)r6   Ú	transfersÚrandomOrderÚoutputÚexpectedOutputÚactualOutputr;  ÚremoteÚexpectedÚexpectedTransferÚlineÚprogressPartsÚactualÚlastÚactualTransfers   &&&            r+   ÚcheckPutMessageÚ StdioClientTests.checkPutMessageI  sä  € ð —‘×&Ñ&×,Ñ,Ó.ˆØ—‘˜wÓ'ˆØ—‘˜fÓ%ˆàˆØˆä'0Ñ#ˆE˜8ð  "ÐÛ �Ø ×'Ñ'¨5¨'°°4°&Ð(9Ö:ñ !à×#Ñ# l°5°'¸¸f¸XÐ$FÔGØ×!Ñ!Ð"2Ô3à"ŸJ™J q›M×/Ñ/°Ó5×;Ñ;¸DÓAˆMØ" 3 BÐ'ˆFà  Õ$×*Ñ*¨4Ó0×6Ñ6°tÓ<ˆDØ�M‰M˜$ÔàˆNð ˜s ›�ð —z‘z“|×*Ñ*¨3°Ó2°1Õ5�ð —z‘z“|×)Ñ)¨#¨qÓ1�Ø×%Ñ%¨¨a­¨	°°4¸µ7·=±=³?Ð2CÐ&DÖEñ $ð ×!Ñ! &¨¥*Ô-Ø×Ñ ×/ñ? (1÷B Ø×ÑœV NÓ3´V¸LÓ5IÕJà×Ñ˜^Ô:à×ÑØÜ�‹KØCö	
r.   c                óÐ  € RpV P                  VR7      p\        P                  \        P                  ,          \        P                  ,          p\
        P                  P                  R\
        P                  P                  V4      4      p\        V4      pV P                  P                  WC\        P                  ! V4      4       ^
V P                  P                  P                  R&   V P                  P!                  V4      pV P#                  V4       V P%                  WP'                  4       4       V P)                  VP*                  4       V P-                  W$. RO3.4       R# )z}
A name based on local path is used when remote path is not
provided.

The progress is updated while chunks are transferred.
s   Test
Content)rE  rá   r´   N)z	76% 10.0Bú
100% 13.0Brf  )rG  r   Ú	FXF_WRITEÚ	FXF_CREATÚ	FXF_TRUNCr`   r¨   ÚjoinÚbasenamerÀ   râ   r«   r   rÇ   rä   r¶   Úcmd_PUTÚsuccessResultOfrF   rG   r<   rÍ   rc  )r6   rE  Ú	localPathr©   Ú
remoteNameÚ
remoteFileÚdeferreds   &      r+   Útest_cmd_PUTSingleNoRemotePathÚ/StdioClientTests.test_cmd_PUTSingleNoRemotePath†  s  € ð %ˆØ—M‘M¨'�MÓ2ˆ	Ü×&Ñ&¬×)?Ñ)?Õ?Ä,×BXÑBXÕXˆÜ—W‘W—\‘\ #¤r§w¡w×'7Ñ'7¸	Ó'BÓCˆ
Ü'¨
Ó3ˆ
Ø×Ñ×Ñ 
´5·=²=ÀÓ3LÔMØ35ˆ�‰×Ñ×"Ñ" <Ñ0à—;‘;×&Ñ& yÓ1ˆØ×Ñ˜XÔ&à×Ñ˜×"5Ñ"5Ó"7Ô8Ø�‰˜
×*Ñ*Ô+Ø×ÑØÒ%NÐOÐPö	
r.   c                ó  € V P                  4       p\        P                  \        P                  ,          \        P                  ,          pRp\        V4      pV P                  P                  W2\        P                  ! V4      4       V P                  P                  V RV R24      pV P                  V4       V P                  WR.3.4       V P                  VP                  4       V P!                  RVP#                  4       4       R# )zh
Remote path is extracted from first filename after local file.

Any other data in the line is ignored.
z/remote-pathrJ  z ignoredú	100% 0.0Br.   N)rG  r   rg  rh  ri  rÀ   râ   r«   r   rÇ   rä   rl  rm  rc  r<   rÍ   rF   rG   )r6   rn  r©   ro  rp  rq  s   &     r+   Útest_cmd_PUTSingleRemotePathÚ-StdioClientTests.test_cmd_PUTSingleRemotePathž  sÐ   € ð —M‘M“Oˆ	Ü×&Ñ&¬×)?Ñ)?Õ?Ä,×BXÑBXÕXˆØ#ˆ
Ü'¨
Ó3ˆ
Ø×Ñ×Ñ 
´5·=²=ÀÓ3LÔMà—;‘;×&Ñ&¨)¨°A°j°\ÀÐ'JÓKˆØ×Ñ˜XÔ&à×Ñ˜y°{°mÐDÐEÔFØ�‰˜
×*Ñ*Ô+Ø×Ñ˜˜j×1Ñ1Ó3Ö4r.   c                ó.  € V P                  4       p\        P                  P                  V4      pRp\        P                  P	                  V4      pV P                  \        P                  P                  WC4      R7      p\        P                  \        P                  ,          \        P                  ,          pRV 2pRV 2p\        V4      p	\        V4      p
V P                  P                  Wv\        P                  ! V	4      4       V P                  P                  W†\        P                  ! V
4      4       V P                  P!                  \        P                  P                  VR4      4      pV P#                  V4       V P%                  V	P&                  4       V P)                  RV	P+                  4       4       V P%                  V
P&                  4       V P)                  RV
P+                  4       4       V P-                  WR.3WXR.3.RR7       R	# )
zl
When a gobbing expression is used local files are transferred with
remote file names based on local names.
úsecond-name©r¨   rá   Ú*r.   ru  T©rW  N)rG  r`   r¨   rk  Údirnamerj  r   rg  rh  ri  rÀ   râ   r«   r   rÇ   rä   rl  rm  r<   rÍ   rF   rG   rc  )r6   ÚfirstÚ	firstNameÚ
secondNameÚparentÚsecondr©   ÚfirstRemotePathÚsecondRemotePathÚfirstRemoteFileÚsecondRemoteFilerq  s   &           r+   Ú test_cmd_PUTMultipleNoRemotePathÚ1StdioClientTests.test_cmd_PUTMultipleNoRemotePath±  s¤  € ð
 —‘“ˆÜ—G‘G×$Ñ$ UÓ+ˆ	Ø"ˆ
Ü—‘—‘ Ó'ˆØ—‘¤B§G¡G§L¡L°Ó$D�ÓEˆÜ×&Ñ&¬×)?Ñ)?Õ?Ä,×BXÑBXÕXˆØ˜i˜[˜/ˆØ˜z˜lÐ+ÐÜ,¨_Ó=ˆÜ-Ð.>Ó?ÐØ×Ñ×Ñ ¼¿ºÀoÓ8VÔWØ×Ñ×ÑØ¤U§]¢]Ð3CÓ%Dô	
ð —;‘;×&Ñ&¤r§w¡w§|¡|°F¸CÓ'@ÓAˆØ×Ñ˜XÔ&à�‰˜×/Ñ/Ô0Ø×Ñ˜˜o×6Ñ6Ó8Ô9Ø�‰Ð(×0Ñ0Ô1Ø×Ñ˜Ð.×7Ñ7Ó9Ô:Ø×Ñà¨+¨Ð7Ø¨K¨=Ð9ðð ð 	ö 	
r.   c                óL  € V P                  4       p\        P                  P                  V4      pRp\        P                  P	                  V4      pV P                  \        P                  P                  WC4      R7      p\        P                  \        P                  ,          \        P                  ,          p\        V4      p\        V4      pRV 2p	RV 2p
V P                  P                  W–\        P                  ! V4      4       V P                  P                  W¦\        P                  ! V4      4       V P                  P!                  RP#                  \        P                  P                  VR4      4      4      pV P%                  V4       V P'                  VP(                  4       V P+                  RVP-                  4       4       V P'                  VP(                  4       V P+                  RVP-                  4       4       V P/                  WR.3WSR.3.RR	7       R
# )zÍ
When a gobbing expression is used local files are transferred with
remote file names based on local names.
when a remote folder is requested remote paths are composed from
remote path and local filename.
ry  rz  z/remote/z	{} remoter{  r.   ru  Tr|  N)rG  r`   r¨   rk  r}  rj  r   rg  rh  ri  rÀ   râ   r«   r   rÇ   rä   rl  r)   rm  r<   rÍ   rF   rG   rc  )r6   r~  r  r€  r�  r‚  r©   r…  r†  rƒ  r„  rq  s   &           r+   Ú"test_cmd_PUTMultipleWithRemotePathÚ3StdioClientTests.test_cmd_PUTMultipleWithRemotePathÔ  s¯  € ð —‘“ˆÜ—G‘G×$Ñ$ UÓ+ˆ	Ø"ˆ
Ü—‘—‘ Ó'ˆØ—‘¤B§G¡G§L¡L°Ó$D�ÓEˆÜ×&Ñ&¬×)?Ñ)?Õ?Ä,×BXÑBXÕXˆÜ,¨YÓ7ˆÜ-¨jÓ9ÐØ$ Y KÐ0ˆØ% j \Ð2ÐØ×Ñ×Ñ ¼¿ºÀoÓ8VÔWØ×Ñ×ÑØ¤U§]¢]Ð3CÓ%Dô	
ð —;‘;×&Ñ& {×'9Ñ'9¼"¿'¹'¿,¹,ÀvÈsÓ:SÓ'TÓUˆØ×Ñ˜XÔ&à�‰˜×/Ñ/Ô0Ø×Ñ˜˜o×6Ñ6Ó8Ô9Ø�‰Ð(×0Ñ0Ô1Ø×Ñ˜Ð.×7Ñ7Ó9Ô:Ø×Ñà K =Ð1Ø k ]Ð3ðð ð 	ö 	
r.   )rä   ræ   râ   )Nr.   )F)rL   rM   rN   rO   rP   r7   rù   rÿ   r  rè   r(  r+  r.  r4  r8  r<  r?  rG  rc  rr  rv  r‡  rŠ  rQ   rR   rS   s   @r+   rß   rß   †  so   ø‡ € ñò=ò&òò
ò/ò*@ò0@ò$@ò+ò5ò;òGôô(;
òz
ò05ò&!
÷F#
ð #
r.   rß   c                   ó,   a € ] tR tRt o R tR tRtV tR# )ÚFileTransferTestRealmiú  c                ó   € Wn         R # r0   ©ÚtestDir)r6   r�  s   &&r+   r�   ÚFileTransferTestRealm.__init__û  s   € ØŽr.   c                óF   € \        V P                  4      pV^ ,          VR 3# )é    c                  ó   € R # r0   r(   r(   r.   r+   Ú<lambda>Ú5FileTransferTestRealm.requestAvatar.<locals>.<lambda>   s   € ©r.   )r   r�  )r6   ÚavatarIDÚmindr   Úas   &&&* r+   ÚrequestAvatarÚ#FileTransferTestRealm.requestAvatarþ  s!   € Ü" 4§<¡<Ó0ˆØ˜!�}˜a¡Ð-Ð-r.   r�  N)rL   rM   rN   rO   r�   rš  rQ   rR   rS   s   @r+   r�  r�  ú  s   ø‡ € ò÷.ð .r.   r�  c                   ó`   a € ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tRtV tR# )ÚSFTPTestProcessi  z£
Protocol for testing cftp. Provides an interface between Python (where all
the tests are) and the cftp client process (which does the work that is
being tested).
c                ó\   € V P                  4        Wn        RV n        RV n        RV n        R# )zZ
@param onOutReceived: A L{Deferred} to be fired as soon as data is
received from stdout.
NF)ÚclearBufferÚonOutReceivedÚonProcessEndÚ_expectingCommandÚ_processEnded)r6   r   s   &&r+   r�   ÚSFTPTestProcess.__init__
  s.   € ð
 	×ÑÔØ*ÔØ ˆÔØ!%ˆÔØ"ˆÖr.   c                ó0   € RV n         . V n        RV n        R# )zB
Clear any buffered data received from stdout. Should be private.
r.   N)ÚbufferÚ_linesReceivedÚ_lineBufferr5   s   &r+   rŸ  ÚSFTPTestProcess.clearBuffer  s   € ð ˆŒØ ˆÔØˆÖr.   c                óœ  € \         P                  ! RV,          4       V P                  V,           P                  R4      pVP	                  R4      V n        V P
                  P                  V4       V P                  e%   V P                  Ruq0n        VP                  V4       V ;P                  V,          un	        V P                  4        R# )z?
Called by Twisted when the cftp client prints data to stdout.
zgot %ró   
NrM  )r   Úmsgr¨  rO  r®   r§  rR  r   Úcallbackr¦  Ú_checkForCommand)r6   rÉ   Úlinesrø   s   &&  r+   ÚoutReceivedÚSFTPTestProcess.outReceived  sš   € ô 	�Š�˜4•Ô Ø×!Ñ! DÕ(×/Ñ/°Ó6ˆØ Ÿ9™9 R›=ˆÔØ×Ñ×"Ñ" 5Ô)ð ×ÑÒ)Ø$(×$6Ñ$6¸Ð!ˆAÔ!Ø�J‰J�tÔØ�Š�tÕ�Ø×ÑÖr.   c                ó@  € R pV P                   '       dŠ   V P                  V8X  dw   RP                  V P                  4      pVP	                  V4      '       d   V\        V4      R pV P                  4        V P                   Ruq0n         VP                  V4       R# R# R# )s   cftp> r«  N)r¢  r¨  rj  r§  Ú
startswithrU  rŸ  r­  )r6   ÚpromptÚbufrø   s   &   r+   r®  Ú SFTPTestProcess._checkForCommand.  s†   € ØˆØ×!×!Ð! d×&6Ñ&6¸&Ô&@Ø—*‘*˜T×0Ñ0Ó1ˆCØ�~‰~˜f×%Ò%Øœ#˜f›+˜-Ð(�Ø×ÑÔØ(,×(>Ñ(>ÀÐ%ˆAÔ%Ø�J‰J�sŽOñ 'AÑ!r.   c                ó@   € \         P                  ! RV,          4       R# )z?
Called by Twisted when the cftp client prints data to stderr.
zerr: %sN)r   r¬  )r6   rÉ   s   &&r+   ÚerrReceivedÚSFTPTestProcess.errReceived8  s   € ô 	�Š�	˜DÕ Ö!r.   c                ó   € V P                   # )zA
Return the contents of the buffer of data received from stdout.
)r¦  r5   s   &r+   Ú	getBufferÚSFTPTestProcess.getBuffer>  s   € ð �{‰{Ðr.   c                ó   € \         P                  ! 4       V n        V P                  4        \	        V\
        4      '       d   VP                  R4      pV P                  P                  VR,           4       V P                  # )at  
Issue the given command via the cftp client. Return a C{Deferred} that
fires when the server returns a result. Note that the C{Deferred} will
callback even if the server returns some kind of error.

@param command: A string containing an sftp command.

@return: A C{Deferred} that fires when the sftp server returns a
result. The payload is the server's response string.
rB   r«  )	r   ÚDeferredr¢  rŸ  Ú
isinstanceÚstrrD   rµ   rÆ   ©r6   Úcommands   &&r+   Ú
runCommandÚSFTPTestProcess.runCommandD  s\   € ô "'§¢Ó!1ˆÔØ×ÑÔÜ�gœs×#Ò#Ø—n‘n WÓ-ˆGØ�‰×Ñ˜W u�_Ô-Ø×%Ñ%Ð%r.   c                ó¸   € \         P                  ! ^4      pV Uu. uF  q2P                  V P                  V4      NK   	  pp\         P                  ! V4      # u upi )a@  
Run each command in sequence and return a Deferred that fires when all
commands are completed.

@param commands: A list of strings containing sftp commands.

@return: A C{Deferred} that fires when all commands are completed. The
payload is a list of response strings from the server, in the same
order as the commands.
)r   ÚDeferredSemaphoreÚrunrÃ  ÚgatherResults)r6   ÚcommandsÚsemrÂ  Údls   &&   r+   Ú	runScriptÚSFTPTestProcess.runScriptV  sL   € ô ×%Ò% aÓ(ˆÙ?GÓH¹x°G�g‰g�d—o‘o wÖ/¹xˆÐHÜ×"Ò" 2Ó&Ð&ùò Is   ›$Ac                óÔ   € V P                   '       d   \        P                  ! R4      # \        P                  ! 4       V n        V P
                  P                  R4       V P                  # )zÐ
Kill the process if it is still running.

If the process is still running, sends a KILL signal to the transport
and returns a C{Deferred} which fires when L{processEnded} is called.

@return: a C{Deferred}.
NÚKILL)r£  r   rÇ   r¾  r¡  rµ   ÚsignalProcessr5   s   &r+   ÚkillProcessÚSFTPTestProcess.killProcesse  sL   € ð ××ÐÜ—=’= Ó&Ð&Ü!ŸNšNÓ,ˆÔØ�‰×$Ñ$ VÔ,Ø× Ñ Ð r.   c                ó„   € RV n         V P                  '       d'   V P                  Ruq n        VP                  R4       R# R# )z6
Called by Twisted when the cftp client process ends.
TN)r£  r¡  r­  )r6   Úreasonrø   s   && r+   ÚprocessEndedÚSFTPTestProcess.processEndedt  s<   € ð "ˆÔØ××ÐØ#'×#4Ñ#4°dÐ ˆAÔ Ø�J‰J�tÖñ r.   )r¢  r¨  r§  r£  r¦  r   r¡  N)rL   rM   rN   rO   rP   r�   rŸ  r°  r®  r¸  r»  rÃ  rÌ  rÑ  rÕ  rQ   rR   rS   s   @r+   r�  r�    sA   ø‡ € ñò	#òò ò"ò"òò&ò$'ò!÷ð r.   r�  c                   ó>   a € ] tR tRt o R tR tR tR tR tRt	V t
R# )	ÚCFTPClientTestBasei~  c                óD  € \        R R4      ;_uu_ 4       pVP                  \        P                  4       RRR4       \        RR4      ;_uu_ 4       pVP                  \        P                  4       RRR4       \
        P                  ! RR4       \        RR4      ;_uu_ 4       pVP                  R\        P                  ,           4       RRR4       \        P                  ! V 4      #   + '       g   i     L¼; i  + '       g   i     L“; i  + '       g   i     LL; i)úrsa_test.pubrB  NÚrsa_testi€�  Úkh_tests
   127.0.0.1 )	rD  rÆ   r   ÚpublicRSA_opensshÚprivateRSA_opensshr`   Úchmodr	   r7   ©r6   Úfs   & r+   r7   ÚCFTPClientTestBase.setUp  s±   € Ü�. $×'Ô'¨1Ø�G‰G”H×.Ñ.Ô/÷ (ä�*˜d×#Ô# qØ�G‰G”H×/Ñ/Ô0÷ $ä
�Š�˜UÔ#Ü�)˜T×"Ô" aØ�G‰G�M¤H×$>Ñ$>Õ>Ô?÷ #ä×!Ò! $Ó'Ð'÷ (×'úç#×#ú÷ #×"ús#   • C)Á C<Â$'DÃ)C9	Ã<D	ÄD	c                ó  € \        V P                  4      p\        P                  ! V4      pVP	                  \
        P                  ! 4       4       \
        P                  ! 4       pW#n        \        P                  ! ^ VRR7      V n
        R# )r“  z	127.0.0.1)Ú	interfaceN)r�  r�  r
   ÚPortalÚregisterCheckerr   ÚconchTestPublicKeyCheckerÚConchTestServerFactoryr   Ú	listenTCPÚserver)r6   ÚrealmÚpÚfacs   &   r+   ÚstartServerÚCFTPClientTestBase.startServer‰  s^   € Ü% d§l¡lÓ3ˆÜ�MŠM˜%Ó ˆØ	×Ñœ(×<Ò<Ó>Ô?Ü×-Ò-Ó/ˆØŒ
Ü×'Ò'¨¨3¸+ÔFˆŽr.   c                ó„  € \        V P                  P                  R 4      '       g   V P                  R4      # ^V P                  P                  P                  n        \        P                  ! V P                  P                  P                  P                  P                  4      pVP                  V P                  4       V# )ÚprotoN)Úhasattrrê  ÚfactoryÚ_cbStopServerrñ  ÚexpectedLoseConnectionr   ÚmaybeDeferredrµ   ÚloseConnectionrö   r÷   s   & r+   Ú
stopServerÚCFTPClientTestBase.stopServer‘  s…   € Ü�t—{‘{×*Ñ*¨G×4Ò4Ø×%Ñ% dÓ+Ð+Ø;<ˆ�‰×Ñ×!Ñ!Ô8Ü×Ò §¡× 3Ñ 3× 9Ñ 9× CÑ C× RÑ RÓSˆØ	�‰�d×(Ñ(Ô)Øˆr.   c                óV   € \         P                  ! V P                  P                  4      # r0   )r   rö  rê  ÚstopListening©r6   Úignoreds   &&r+   rô  Ú CFTPClientTestBase._cbStopServer™  s   € Ü×"Ò" 4§;¡;×#<Ñ#<Ó=Ð=r.   c                ó’   € R F  p \         P                  ! V4       K  	  \        P                  ! V 4      #   \         d     KB  i ; i)rÚ  )rÚ  rÛ  rÜ  )r`   ÚremoveÚBaseExceptionr	   ÚtearDownrà  s   & r+   r  ÚCFTPClientTestBase.tearDownœ  sC   € Û8ˆAðÜ—	’	˜!–ñ 9ô
 ×$Ò$ TÓ*Ð*øô !ô Úðús   ‡7·AÁA)rê  N)rL   rM   rN   rO   r7   rî  rø  rô  r  rQ   rR   rS   s   @r+   rØ  rØ  ~  s$   ø‡ € ò(òGòò>÷+ð +r.   rØ  c                   ó¦   a € ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tRR ltR tR tR tR tR tR tR tR tR tR tR tRtV tR# )ÚOurServerCmdLineClientTestsi¥  zÙ
Functional tests which launch a SFTP server over TCP on localhost and check
cftp command line interface using a spawned process.

Due to the spawned process you can not add a debugger breakpoint for the
client code.
c                ód  a € \         P                  S 4       S P                  4        R pS P                  P	                  4       P
                  p\        P                  ! W,          P                  4       RR7      p\        P                  ! R\        P                   RV 24       \        P                  ! 4       p\        V4      S n        VP#                  V 3R l4       \$        P&                  P)                  4       p\$        P*                  P-                  \        P.                  4      VR&   . p/ pV F;  p\1        V\2        4      '       d   VP5                  R4      pVP7                  V4       K=  	  V F]  pWH,          p	\1        V\2        4      '       d   VP5                  R4      p\1        V	\2        4      '       d   V	P5                  R4      p	W–V&   K_  	  \        P                  ! V4       \        P                  ! V4       \8        P:                  ! S P                   \        P                  WVR7       V# )	z‚-p %i -l testuser --known-hosts kh_test --user-authentications publickey --host-key-algorithms ssh-rsa -i rsa_test -a -v 127.0.0.1r   ©Úmodúrunning rJ  c                 ó8   <€ SP                   P                  4       # r0   )ÚprocessProtocolrŸ  ©Ú_r6   s   &€r+   r•  Ú3OurServerCmdLineClientTests.setUp.<locals>.<lambda>Â  ó   ø€  × 4Ñ 4× @Ñ @Ô Br.   Ú
PYTHONPATHrB   ©Úenv)rØ  r7   rî  rê  ÚgetHostÚportr   Ú	_makeArgsrO  r   r¬  ró   rô   r   r¾  r�  r  rö   r`   ra   ÚcopyÚpathseprj  r¨   r¿  rÀ  rD   rP  r   ÚspawnProcess)
r6   Úcmdsr  rø   r  ÚencodedCmdsÚ
encodedEnvÚcmdÚvarÚvals
   f         r+   r7   Ú!OurServerCmdLineClientTests.setUp¯  sš  ø€ Ü× Ñ  Ô&à×ÑÔðð 	ð �{‰{×"Ñ"Ó$×)Ñ)ˆÜ×#Ò# T¥[×$7Ñ$7Ó$9¸vÔFˆÜ�Š�(œ3Ÿ>™>Ð*¨!¨D¨6Ð2Ô3Ü�NŠNÓˆÜ.¨qÓ1ˆÔØ	�‰ÔBÔCÜ�j‰j�o‰oÓˆÜŸJ™JŸO™O¬C¯H©HÓ5ˆˆLÑØˆØˆ
ÛˆCÜ˜#œs×#Ò#Ø—j‘j Ó)�Ø×Ñ˜sÖ#ñ ó ˆCØ•(ˆCÜ˜#œs×#Ò#Ø—j‘j Ó)�Ü˜#œs×#Ò#Ø—j‘j Ó)�Ø!�s‹Oñ ô 	�Š�ÔÜ�Š�
ÔÜ×ÒØ× Ñ ¤#§.¡.°+õ	
ð ˆr.   c                óR   a € S P                  4       pVP                  V 3R  l4       V# )c                 ó8   <€ SP                   P                  4       # r0   )r  rÑ  r  s   &€r+   r•  Ú6OurServerCmdLineClientTests.tearDown.<locals>.<lambda>Û  r  r.   )rø  rö   r÷   s   f r+   r  Ú$OurServerCmdLineClientTests.tearDownÙ  s!   ø€ Ø�O‰OÓˆØ	�‰ÔBÔCØˆr.   c                óŠ   €  V P                   P                  P                  R 4       R#   \        P                   d     R# i ; i)rÏ  N)r  rµ   rÐ  r   ÚProcessExitedAlreadyrü  s   &&r+   Ú_killProcessÚ(OurServerCmdLineClientTests._killProcessÞ  s9   € ð	Ø× Ñ ×*Ñ*×8Ñ8¸Ö@øÜ×)Ñ)ô 	Úð	ús   ‚%) ©AÁAc                ó8   € V P                   P                  V4      # )zœ
Run the given command with the cftp client. Return a C{Deferred} that
fires when the command is complete. Payload is the server's output for
that command.
)r  rÃ  rÁ  s   &&r+   rÃ  Ú&OurServerCmdLineClientTests.runCommandä  s   € ð ×#Ñ#×.Ñ.¨wÓ7Ð7r.   c                ó8   € V P                   P                  V4      # )z³
Run the given commands with the cftp client. Returns a C{Deferred}
that fires when the commands are all complete. The C{Deferred}'s
payload is a list of output for each command.
)r  rÌ  )r6   rÉ  s   &*r+   rÌ  Ú%OurServerCmdLineClientTests.runScriptì  s   € ð ×#Ñ#×-Ñ-¨hÓ7Ð7r.   c                óþ   € V P                   pV P                  RRRRR4      pR pVP                  V4       VP                  V P                  VP                  \
        P                  ! 4       RVP                  .4       V# )zÕ
Test that 'pwd' reports the current remote directory, that 'lpwd'
reports the current local directory, and that changing to a
subdirectory then changing to its parent leaves you in the original
remote directory.
ÚpwdÚlpwdzcd testDirectoryúcd ..c                ó¶   € . pV  F;  p\        V\        4      '       d   VP                  R4      pVP                  V4       K=  	  VR,          VR,          ,           # )z0
Callback function for handling command output.
rB   :Né   N:é   NN)r¿  ÚbytesrN  rP  )rX  r  r  s   &  r+   Ú	cmdOutputÚ8OurServerCmdLineClientTests.testCdPwd.<locals>.cmdOutputÿ  sO   € ð ˆDÛ�Ü˜c¤5×)Ò)ØŸ*™* WÓ-�CØ—‘˜CÖ ñ ð ˜•8˜d 2�hÕ&Ð&r.   rü   )r�  rÌ  rö   rF   r¨   r`   Úgetcwd)r6   ÚhomeDirrø   r4  s   &   r+   Ú	testCdPwdÚ%OurServerCmdLineClientTests.testCdPwdô  sg   € ð —,‘,ˆØ�N‰N˜5 &Ð*<¸gÀuÓMˆò		'ð 	
�‰�iÔ Ø	�‰�d×&Ñ&¨¯©´r·y²y³{ÀBÈÏÉÐ(UÔVØˆr.   c                óZ   a € V 3R lpS P                  RRRR4      pVP                  V4      # )zt
Check that 'ls -l' output includes the access permissions and that
this output changes appropriately with 'chmod'.
c                 ó8  <€ SP                  4        SP                  V ^ ,          P                  R4      4       SP                  V ^,          R4       SP                  V ^,          P                  R4      V ^,          4       SP                  V ^,          R4       R# )r“  s
   -rw-r--r--r.   s
   ----------N)ÚflushLoggedErrorsr<   r³  rF   ©Úresultsr6   s   &€r+   Ú_checkÚ7OurServerCmdLineClientTests.testChAttrs.<locals>._check  ss   ø€ Ø×"Ñ"Ô$Ø�O‰O˜G A�J×1Ñ1°-Ó@ÔAØ×Ñ˜W Q�Z¨Ô-Ø�O‰O˜G A�J×1Ñ1°-Ó@À'È!Å*ÔMØ×Ñ˜W Q�Z¨Ö-r.   zls -l testfile1zchmod 0 testfile1zchmod 644 testfile1©rÌ  rö   ©r6   r?  rø   s   f  r+   ÚtestChAttrsÚ'OurServerCmdLineClientTests.testChAttrs  s5   ø€ õ	.ð �N‰NØØØØ!ó	
ˆð �}‰}˜VÓ$Ð$r.   c                ó¾   a € V 3R lpS P                  RRS P                  P                  4       ,           RRR4      pVP                  R 4       VP                  V4      # )zv
Check 'ls' works as expected. Checks for wildcards, hidden files,
listing directories and listing empty directories.
c                 ó  <€ SP                  V ^ ,          . RO4       SP                  V ^,          . RO4       SP                  V ^,          RR.4       SP                  V ^,          . RO4       SP                  V ^,          R.4       R# )r“  ó   testRemoveFileó   testRenameFiler.   N©s   testDirectoryrG  rH  s	   testfile1)s   .testHiddenFilerG  rH  ©rF   r=  s   &€r+   r?  Ú4OurServerCmdLineClientTests.testList.<locals>._check*  s‚   ø€ Ø×ÑØ˜•
ÚVôð ×ÑØ˜•
ÚVôð ×Ñ˜W Q�ZÐ*;Ð=NÐ)OÔPØ×ÑØ˜•
ÒVôð ×Ñ˜W Q�Z¨#¨Ö/r.   r   zls ../zls *Filezls -a *Filezls -l testDirectoryc                 óL   € V  Uu. uF  qP                  R 4      NK  	  up# u upi )r«  )rO  )ÚxsÚxs   & r+   r•  Ú6OurServerCmdLineClientTests.testList.<locals>.<lambda>@  s   € ¹"Ó!=¹"°Q§'¡'¨%¦.¹"Ò!=ùÒ!=s   …!)rÌ  r�  rk  rö   rB  s   f  r+   ÚtestListÚ$OurServerCmdLineClientTests.testList$  sW   ø€ õ	0ð �N‰NØØ�t—|‘|×,Ñ,Ó.Õ.ØØØ!ó
ˆð 	
�‰Ñ=Ô>Ø�}‰}˜VÓ$Ð$r.   c                ó  € V P                  R4      p\        P                  ! R4      P                  R4      P	                  4       p\        V\        4      '       d   VP                  R4      pVP                  V P                  V4       V# )z2
Check that running the '?' command returns help.
Ú?Nrü   rB   )
rÃ  r   rã   Úcmd_HELPrQ  r¿  rÀ  rD   rö   rF   )r6   rø   ÚhelpTexts   &  r+   ÚtestHelpÚ$OurServerCmdLineClientTests.testHelpC  sj   € ð �O‰O˜CÓ ˆä×#Ò# DÓ)×2Ñ2°2Ó6×<Ñ<Ó>ˆÜ�h¤×$Ò$Ø—‘ wÓ/ˆHØ	�‰�d×&Ñ&¨Ô1Øˆr.   Nc                ód   € V P                  VP                  4       VP                  4       V4       R# )zO
Assert that the files at C{name1} and C{name2} contain exactly the
same data.
N)rF   Ú
getContent)r6   Úname1Úname2r¬  s   &&&&r+   ÚassertFilesEqualÚ,OurServerCmdLineClientTests.assertFilesEqualO  s(   € ð
 	×Ñ˜×)Ñ)Ó+¨U×-=Ñ-=Ó-?ÀÖEr.   c                óx  a a€ RP                  S P                  P                  S P                  P                  4      o\        S\        4      '       d   SP                  R4      oVV 3R lpS P                  RS P                  P                   R24      pVP                  V4       VP                  V 3R l4       V# )z“
Test that 'get' saves the remote file to the correct local location,
that the output of 'get' is correct and that 'rm' actually removes
the file.
z)Transferred {}/testfile1 to {}/test file2rB   c                 óð   <€ SP                  V P                  S4      4       SP                  SP                  P	                  R 4      SP                  P	                  R4      R4       SP                  R4      # )Ú	testfile1ú
test file2z
get failedzrm "test file2")r<   Úendswithr\  r�  ÚchildrÃ  ©r'  rY  r6   s   &€€r+   Ú	_checkGetÚ6OurServerCmdLineClientTests.testGet.<locals>._checkGetd  s_   ø€ Ø�O‰O˜FŸO™O¨NÓ;Ô<Ø×!Ñ!Ø—‘×"Ñ" ;Ó/Ø—‘×"Ñ" <Ó0Øôð
 —?‘?Ð#4Ó5Ð5r.   zget testfile1 "z/test file2"c                 ót   <€ SP                  SP                  P                  R 4      P                  4       4      # )ra  ©ÚassertFalser�  rc  Úexistsr  s   &€r+   r•  Ú5OurServerCmdLineClientTests.testGet.<locals>.<lambda>p  ó(   ø€ �d×&Ñ& t§|¡|×'9Ñ'9¸,Ó'G×'NÑ'NÓ'PÔQr.   )r)   r�  r¨   r¿  rÀ  rD   rÃ  rö   )r6   re  rø   rY  s   f  @r+   ÚtestGetÚ#OurServerCmdLineClientTests.testGetV  sš   ù€ ð E×KÑKØ�L‰L×ÑØ�L‰L×Ñó
ˆô �n¤c×*Ò*Ø+×2Ñ2°7Ó;ˆNö	6ð �O‰O˜o¨d¯l©l×.?Ñ.?Ð-@ÀÐMÓNˆØ	�‰�iÔ Ø	�‰ÜQô	
ð ˆr.   c                óT   a € V 3R lpS P                  R4      pVP                  V4      # )zA
Test that 'get' works correctly when given wildcard parameters.
c                 óÜ   <€ SP                  SP                  P                  R 4      \        R 4      R4       SP                  SP                  P                  R4      \        R4      R4       R# )ÚtestRemoveFileútestRemoveFile get failedÚtestRenameFileútestRenameFile get failedN)r\  r�  rc  r   )rý  r6   s   &€r+   r?  Ú;OurServerCmdLineClientTests.testWildcardGet.<locals>._checky  s_   ø€ Ø×!Ñ!Ø—‘×"Ñ"Ð#3Ó4ÜÐ)Ó*Ø+ôð
 ×!Ñ!Ø—‘×"Ñ"Ð#3Ó4ÜÐ)Ó*Ø+ör.   z
get testR*)rÃ  rö   rB  s   f  r+   ÚtestWildcardGetÚ+OurServerCmdLineClientTests.testWildcardGett  s'   ø€ õ

	ð �O‰O˜LÓ)ˆØ�}‰}˜VÓ$Ð$r.   c                óz  a a€ RS P                   P                  4       P                  ,           R,           S P                   P                  4       P                  ,           R,           oVV 3R lpS P                  RS P                   P                   R24      pVP	                  V4       VP	                  V 3R l4       V# )z
Check that 'put' uploads files correctly and that they can be
successfully removed. Also check the output of the put command.
s   Transferred s   /testfile1 to s   /test"file2c                 óî   <€ SP                  SP                  P                  R 4      SP                  P                  R4      4       SP                  V P	                  S4      4       SP                  R4      # )r`  ú
test"file2zrm "test\"file2")r\  r�  rc  r<   rb  rÃ  rd  s   &€€r+   Ú	_checkPutÚ6OurServerCmdLineClientTests.testPut.<locals>._checkPut–  s[   ø€ Ø×!Ñ!Ø—‘×"Ñ" ;Ó/°·±×1CÑ1CÀLÓ1Qôð �O‰O˜FŸO™O¨NÓ;Ô<Ø—?‘?Ð#6Ó7Ð7r.   úput z/testfile1 "test\"file2"c                 ót   <€ SP                  SP                  P                  R 4      P                  4       4      # )rz  rh  r  s   &€r+   r•  Ú5OurServerCmdLineClientTests.testPut.<locals>.<lambda>   rl  r.   )r�  ÚasBytesModer¨   rÃ  rö   )r6   r{  rø   rY  s   f  @r+   ÚtestPutÚ#OurServerCmdLineClientTests.testPutˆ  s£   ù€ ð Ø�l‰l×&Ñ&Ó(×-Ñ-õ.àõ ð �l‰l×&Ñ&Ó(×-Ñ-õ.ð õ	ð 	ö	8ð �O‰O˜d 4§<¡<×#4Ñ#4Ð"5Ð5NÐOÓPˆØ	�‰�iÔ Ø	�‰ÜQô	
ð ˆr.   c                ó  a € S P                   P                  R4      P                  RR7      ;_uu_ 4       pVP                  R4       RRR4       S P                   P                  R4      P                  RR7      ;_uu_ 4       pVP                  R4       RRR4       V 3R lpS P	                  R	S P                   P
                   R
24      pVP                  V4       V#   + '       g   i     LŸ; i  + '       g   i     Le; i)zJ
Check that 'put' uploads files correctly when overwriting a longer
file.
ÚshorterFileÚw©Úmodeó   aNÚ
longerFileó   bbc                 ó�   <€ SP                  SP                  P                  R 4      SP                  P                  R4      4       R# )r„  r‰  N)r\  r�  rc  )r'  r6   s   &€r+   r{  ÚEOurServerCmdLineClientTests.test_putOverLongerFile.<locals>._checkPut¯  s4   ø€ Ø×!Ñ!Ø—‘×"Ñ" =Ó1°4·<±<×3EÑ3EÀlÓ3Sör.   r}  z/shorterFile longerFile)r�  rc  rD  rÆ   rÃ  r¨   rö   )r6   rá  r{  rø   s   f   r+   Útest_putOverLongerFileÚ2OurServerCmdLineClientTests.test_putOverLongerFile¤  sº   ø€ ð �\‰\×Ñ Ó.×3Ñ3¸Ð3×=Ô=ÀØ�G‰G�DŒM÷ >à�\‰\×Ñ Ó-×2Ñ2¸Ð2×<Ô<ÀØ�G‰G�EŒN÷ =õ	ð
 �O‰O˜d 4§<¡<×#4Ñ#4Ð"5Ð5LÐMÓNˆØ	�‰�iÔ Øˆ÷ >×=úç<×<ús   µCÂC1ÃC.	Ã1D	c                óN  a a€ S P                   P                  R4      oSP                  4        SP                  R4      P                  RR7      ;_uu_ 4       pVP	                  R4       RRR4       S P                   P                  R4      P                  RR7      ;_uu_ 4       pVP	                  R4       RRR4       V V3R lpS P                  R	S P                   P                   R
24      pVP                  V4       V#   + '       g   i     L ; i  + '       g   i     Lf; i)z€
Check that 'put' uploads files correctly when overwriting a longer
file and you use a wildcard to specify the files to upload.
ÚdirrF  r…  r†  rˆ  NrŠ  c                 ó|   <€ SP                  SP                  R 4      SP                  P                  R 4      4       R# )rF  N)r\  rc  r�  )r'  r6   ÚsomeDirs   &€€r+   r{  ÚMOurServerCmdLineClientTests.test_putMultipleOverLongerFile.<locals>._checkPutÅ  s+   ø€ Ø×!Ñ! '§-¡-°Ó"7¸¿¹×9KÑ9KÈFÓ9SÖTr.   r}  z/dir/*)r�  rc  ÚcreateDirectoryrD  rÆ   rÃ  r¨   rö   )r6   rá  r{  rø   r’  s   f   @r+   Útest_putMultipleOverLongerFileÚ:OurServerCmdLineClientTests.test_putMultipleOverLongerFile¸  sÔ   ù€ ð —,‘,×$Ñ$ UÓ+ˆØ×ÑÔ!Ø�]‰]˜6Ó"×'Ñ'¨SÐ'×1Ô1°QØ�G‰G�DŒM÷ 2à�\‰\×Ñ Ó'×,Ñ,°#Ð,×6Ô6¸!Ø�G‰G�EŒN÷ 7ö	Uð �O‰O˜d 4§<¡<×#4Ñ#4Ð"5°VÐ<Ó=ˆØ	�‰�iÔ Øˆ÷ 2×1úç6×6ús   ÁDÂ$DÄD	ÄD$	c                óÊ   a € V 3R lpS P                  RRS P                  P                   R2RS P                  P                  4       ,          4      pVP	                  V4       V# )z­
What happens if you issue a 'put' command and include a wildcard (i.e.
'*') in parameter? Check that all files matching the wildcard are
uploaded to the correct directory.
c                 ó¸  <€ SP                  V ^ ,          R4       SP                  V ^,          R4       SP                  SP                  P                  R4      SP                  P	                  4       P                  R4      R4       SP                  SP                  P                  R4      SP                  P	                  4       P                  R4      R4       R# )r“  r.   rq  rr  rs  rt  N)rF   r\  r�  rc  r�  r=  s   &€r+   ÚcheckÚ:OurServerCmdLineClientTests.testWildcardPut.<locals>.checkÓ  s­   ø€ Ø×Ñ˜W Q�Z¨Ô-Ø×Ñ˜W Q�Z¨Ô-à×!Ñ!Ø—‘×"Ñ"Ð#3Ó4Ø—‘×#Ñ#Ó%×+Ñ+Ð,<Ó=Ø+ôð
 ×!Ñ!Ø—‘×"Ñ"Ð#3Ó4Ø—‘×#Ñ#Ó%×+Ñ+Ð,<Ó=Ø+ör.   r/  r}  z/testR*zcd %s)rÌ  r�  r¨   rk  rö   )r6   r™  rø   s   f  r+   ÚtestWildcardPutÚ+OurServerCmdLineClientTests.testWildcardPutÌ  sZ   ø€ õ	ð �N‰NØØ�4—<‘<×$Ñ$Ð% WÐ-Ø�d—l‘l×+Ñ+Ó-Õ-ó
ˆð
 	
�‰�eÔØˆr.   c                ó’   a € V 3R lpS P                  RR4      pVP                  V4       VP                  S P                  R4       V# )zˆ
Test that 'ln' creates a file which appears as a link in the output of
'ls'. Check that removing the new file succeeds without output.
c                 óÈ   <€ SP                  4        SP                  V ^ ,          R4       SP                  V ^,          P                  R4      R4       SP	                  R4      # )r“  r.   ó   lzlink failedzrm testLink)r<  rF   r<   r³  rÃ  r=  s   &€r+   r?  Ú4OurServerCmdLineClientTests.testLink.<locals>._checkð  sO   ø€ Ø×"Ñ"Ô$Ø×Ñ˜W Q�Z¨Ô-Ø�O‰O˜G A�J×1Ñ1°$Ó7¸ÔGØ—?‘? =Ó1Ð1r.   zln testLink testfile1zls -l testLinkr.   ©rÌ  rö   rF   rB  s   f  r+   ÚtestLinkÚ$OurServerCmdLineClientTests.testLinkê  sA   ø€ õ	2ð �N‰NÐ2Ð4DÓEˆØ	�‰�fÔØ	�‰�d×&Ñ&¨Ô,Øˆr.   c                ó’   a € V 3R lpS P                  RR4      pVP                  V4       VP                  S P                  R4       V# )zF
Test that we can create and remove directories with the cftp client.
c                 ó¦   <€ SP                  V ^ ,          R4       SP                  V ^,          P                  R4      4       SP                  R4      # )r“  r.   ó   dzrmdir testMakeDirectory)rF   r<   r³  rÃ  r=  s   &€r+   r?  Ú?OurServerCmdLineClientTests.testRemoteDirectory.<locals>._check   sB   ø€ Ø×Ñ˜W Q�Z¨Ô-Ø�O‰O˜G A�J×1Ñ1°$Ó7Ô8Ø—?‘?Ð#<Ó=Ð=r.   úmkdir testMakeDirectoryzls -l testMakeDirector?r.   r¡  rB  s   f  r+   ÚtestRemoteDirectoryÚ/OurServerCmdLineClientTests.testRemoteDirectoryû  sA   ø€ õ
	>ð
 �N‰NÐ4Ð6OÓPˆØ	�‰�fÔØ	�‰�d×&Ñ&¨Ô,Øˆr.   c                óZ   a € V 3R lpS P                  RR4      pVP                  V4       V# )z
Test that a C{mkdir} on an existing directory fails with the
appropriate error, and doesn't log an useless error server side.
c                 ól   <€ SP                  V ^ ,          R4       SP                  V ^,          R4       R# )r“  r.   s   remote error 11: mkdir failedNrJ  r=  s   &€r+   r?  ÚHOurServerCmdLineClientTests.test_existingRemoteDirectory.<locals>._check  s,   ø€ Ø×Ñ˜W Q�Z¨Ô-Ø×Ñ˜W Q�ZÐ)IÖJr.   r¨  rA  rB  s   f  r+   Útest_existingRemoteDirectoryÚ8OurServerCmdLineClientTests.test_existingRemoteDirectory
  s.   ø€ õ	Kð �N‰NÐ4Ð6OÓPˆØ	�‰�fÔØˆr.   c                óô   a € S P                  RS P                  P                   R24      pVP                  S P                  R4       VP                  V 3R l4       VP                  S P                  R4       V# )z¢
Test that we can create a directory locally and remove it with the
cftp client. This test works because the 'remote' server is running
out of a local directory.
zlmkdir z/testLocalDirectoryr.   c                 ó&   <€ SP                  R 4      # )zrmdir testLocalDirectory)rÃ  r  s   &€r+   r•  Ú@OurServerCmdLineClientTests.testLocalDirectory.<locals>.<lambda>   s   ø€  §¡Ð0JÔ Kr.   )rÃ  r�  r¨   rö   rF   r÷   s   f r+   ÚtestLocalDirectoryÚ.OurServerCmdLineClientTests.testLocalDirectory  sb   ø€ ð �O‰O˜g d§l¡l×&7Ñ&7Ð%8Ð8KÐLÓMˆØ	�‰�d×&Ñ&¨Ô,Ø	�‰ÔKÔLØ	�‰�d×&Ñ&¨Ô,Øˆr.   c                ó’   a € V 3R lpS P                  RR4      pVP                  V4       VP                  S P                  R4       V# )z!
Test that we can rename a file.
c                 óŠ   <€ SP                  V ^ ,          R4       SP                  V ^,          R4       SP                  R4      # )r“  r.   s	   testfile2zrename testfile2 testfile1)rF   rÃ  r=  s   &€r+   r?  Ú6OurServerCmdLineClientTests.testRename.<locals>._check)  s;   ø€ Ø×Ñ˜W Q�Z¨Ô-Ø×Ñ˜W Q�Z¨Ô6Ø—?‘?Ð#?Ó@Ð@r.   zrename testfile1 testfile2zls testfile?r.   r¡  rB  s   f  r+   Ú
testRenameÚ&OurServerCmdLineClientTests.testRename$  sA   ø€ õ
	Að
 �N‰NÐ7¸ÓHˆØ	�‰�fÔØ	�‰�d×&Ñ&¨Ô,Øˆr.   )r  r0   )rL   rM   rN   rO   rP   r7   r  r&  rÃ  rÌ  r8  rC  rP  rV  r\  rm  rv  r�  r�  r•  r›  r¢  r©  r®  r³  r¸  rQ   rR   rS   s   @r+   r  r  ¥  sz   ø‡ € ñò(òTò
ò8ò8òò4%ò,%ò>
ôFòò<%ò(ò8ò(ò(ò<ò"òò
÷ð r.   r  c                   óH   a € ] tR tRt o RtR tR tR tR tR t	R t
R	tV tR
# )ÚOurServerBatchFileTestsi4  za
Functional tests which launch a SFTP server over localhost and checks csftp
in batch interface.
c                óP   € \         P                  V 4       V P                  4        R # r0   ©rØ  r7   rî  r5   s   &r+   r7   ÚOurServerBatchFileTests.setUp;  s   € Ü× Ñ  Ô&Ø×ÑÖr.   c                óL   € \         P                  V 4       V P                  4       # r0   )rØ  r  rø  r5   s   &r+   r  Ú OurServerBatchFileTests.tearDown?  s   € Ü×#Ñ# DÔ)Ø�‰Ó Ð r.   c                ó  a€ V P                  4       o\        SR 4      ;_uu_ 4       pVP                  V4       RRR4       V P                  P	                  4       P
                  pRVS3,          p\        P                  ! VP                  4       RR7      R,          p\        P                  ! R\        P                   RV 24       \        P                  P                  4       p\        P                   P#                  \        P$                  4      VR&   ^V P                  P&                  n        \+        \        P                  WER	7      pV3R
 lpVP-                  R 4       VP/                  V4       V#   + '       g   i     ELF; i)r…  Nzˆ-p %i -l testuser --known-hosts kh_test --user-authentications publickey --host-key-algorithms ssh-rsa -i rsa_test -a -v -b %s 127.0.0.1r   r  :é   NNr	  rJ  r  r  c                 ó4   <€ \         P                  ! S4       V # r0   )r`   r   )ÚresÚfns   &€r+   Ú_cleanupÚ9OurServerBatchFileTests._getBatchOutput.<locals>._cleanupZ  s   ø€ Ü�IŠI�bŒMØˆJr.   c                 ó   € V ^ ,          # )r“  r(   )rÄ  s   &r+   r•  Ú9OurServerBatchFileTests._getBatchOutput.<locals>.<lambda>^  s   €  # a¦&r.   )rC  rD  rÆ   rê  r  r  r   r  rO  r   r¬  ró   rô   r`   ra   r  r  rj  r¨   ró  rõ  r   rö   ÚaddBoth)	r6   rá  Úfpr  r  r  rø   rÆ  rÅ  s	   &&      @r+   Ú_getBatchOutputÚ'OurServerBatchFileTests._getBatchOutputC  s  ø€ Ø�[‰[‹]ˆÜ�"�c�]Œ]˜bØ�H‰H�QŒK÷ à�{‰{×"Ñ"Ó$×)Ñ)ˆð!ð �2ˆJõˆô ×#Ò# D§J¡J£L°fÔ=¸bÕAˆÜ�Š�(œ3Ÿ>™>Ð*¨!¨D¨6Ð2Ô3Ü�j‰j�o‰oÓˆÜŸJ™JŸO™O¬C¯H©HÓ5ˆˆLÑà56ˆ�‰×ÑÔ2ä$¤S§^¡^°TÔCˆõ	ð 	
�‰Ñ(Ô)Ø	�	‰	�(Ôàˆ÷9 �]ˆ]ús   ¦E5Å5F	c                ó\   a € RpV 3R lpS P                  V4      pVP                  V4       V# )z‚
Test whether batch file function of cftp ('cftp -b batchfile').
This works by treating the file as a list of commands to be run.
zpwd
ls
exit
c                 ó  <€ V P                  R 4      p \        P                  ! R\        V 4      ,          4       SP	                  SP
                  P                  4       P                  V ^,          4       SP                  V ^R . RO4       R# )r«  zRES %sNéþÿÿÿrI  )	rO  r   r¬  ÚreprÚassertInr�  r€  r¨   rF   ©rÄ  r6   s   &€r+   Ú_cbCheckResultÚ=OurServerBatchFileTests.testBatchFile.<locals>._cbCheckResultm  se   ø€ Ø—)‘)˜EÓ"ˆCÜ�GŠG�Hœt C›yÕ(Ô)Ø�M‰M˜$Ÿ,™,×2Ñ2Ó4×9Ñ9¸3¸q½6ÔBØ×ÑØ�A�b�	ÚVör.   ©rÌ  rö   ©r6   r  rÔ  rø   s   f   r+   ÚtestBatchFileÚ%OurServerBatchFileTests.testBatchFilec  s2   ø€ ð
ˆõ
	ð × Ñ  Ó&ˆØ	�‰�nÔ%Øˆr.   c                ó\   a € RpV 3R lpS P                  V4      pVP                  V4       V# )z?
Test that an error in the batch file stops running the batch.
zchown 0 missingFile
pwd
exit
c                 óp   <€ SP                  SP                  P                  4       P                  V 4       R # r0   )ÚassertNotInr�  r€  r¨   rÓ  s   &€r+   rÔ  Ú9OurServerBatchFileTests.testError.<locals>._cbCheckResultƒ  s&   ø€ Ø×Ñ˜TŸ\™\×5Ñ5Ó7×<Ñ<¸cÖBr.   rÖ  r×  s   f   r+   Ú	testErrorÚ!OurServerBatchFileTests.testErrorz  s3   ø€ ðˆõ
	Cð × Ñ  Ó&ˆØ	�‰�nÔ%Øˆr.   c                ó\   a € RpV 3R lpS P                  V4      pVP                  V4       V# )zG
Test that a minus sign '-' at the front of a line ignores
any errors.
z-chown 0 missingFile
pwd
exit
c                 óp   <€ SP                  SP                  P                  4       P                  V 4       R # r0   )rÒ  r�  r€  r¨   rÓ  s   &€r+   rÔ  Ú@OurServerBatchFileTests.testIgnoredError.<locals>._cbCheckResult”  s$   ø€ Ø�M‰M˜$Ÿ,™,×2Ñ2Ó4×9Ñ9¸3Ö?r.   rÖ  r×  s   f   r+   ÚtestIgnoredErrorÚ(OurServerBatchFileTests.testIgnoredErrorŠ  s3   ø€ ð
ˆõ
	@ð × Ñ  Ó&ˆØ	�‰�nÔ%Øˆr.   r(   N)rL   rM   rN   rO   rP   r7   r  rÌ  rØ  rÞ  rã  rQ   rR   rS   s   @r+   r»  r»  4  s.   ø‡ € ñò
ò!òò@ò.÷ ð r.   r»  Ússhz$no ssh command-line client availableÚsftpz%no sftp command-line client availablec                   ó6   a € ] tR tRt o RtR tR tR tRtV t	R# )ÚOurServerSftpClientTestsiœ  z8
Test the sftp server against sftp command line client.
c                óL   € \         P                  V 4       V P                  4       # r0   r½  r5   s   &r+   r7   ÚOurServerSftpClientTests.setUp¤  s   € Ü× Ñ  Ô&Ø×ÑÓ!Ð!r.   c                ó"   € V P                  4       # r0   )rø  r5   s   &r+   r  Ú!OurServerSftpClientTests.tearDown¨  s   € Ø�‰Ó Ð r.   c                ó*  a a	€ \        \        P                  4      pS P                  4       p\	        VR4      ;_uu_ 4       pVP                  R4       RRR4       S P                  P                  4       P                  p\        P                  o	V	3R lpS P                  \        RV4       RS P                  P                  n        RRR	R
R	RR	RR	RR	RV3,          RVR3pV 3R lp\        RWa4      pVP                  V4      #   + '       g   i     L¸; i)zô
Test the return of extended attributes by the server: the sftp client
should ignore them, but still be able to parse the response correctly.

This test is mainly here to check that
L{filetransfer.FILEXFER_ATTR_EXTENDED} has the correct value.
r…  z	ls .
exitNc                 ó"   <€ S! W4      pR VR&   V# )rî   Úext_foor(   )r6   Úsr¼   Ú
oldGetAttrs   && €r+   Ú	_getAttrsÚCOurServerSftpClientTests.test_extendedAttributes.<locals>._getAttrs¾  s   ø€ Ù˜tÓ'ˆEØ$ˆE�)ÑØˆLr.   rò  Tz-Fz	/dev/nullz-ozIdentitiesOnly=yeszIdentityFile=rsa_testzUserKnownHostsFile=kh_testzHostKeyAlgorithms=ssh-rsazPort=%iz-bztestuser@127.0.0.1c                 óª   <€ SP                  V ^,          ^ V ^,          P                  R4      4       R F  pSP                  W^ ,          4       K  	  R# )r&   ÚasciiNrI  )rF   rN  rÒ  )r'  Úir6   s   & €r+   r™  Ú?OurServerSftpClientTests.test_extendedAttributes.<locals>.checkÛ  sF   ø€ Ø×Ñ˜V A�Y¨¨6°!­9×+;Ñ+;¸GÓ+DÔEó�ð —‘˜a¨¥Ö+ór.   ræ  )Údictr`   ra   rC  rD  rÆ   rê  r  r  r!   rò  re   ró  rõ  r   rö   )
r6   r  rÅ  rá  r  rò  Úargsr™  rø   rñ  s
   f        @r+   Útest_extendedAttributesÚ0OurServerSftpClientTests.test_extendedAttributes«  sñ   ù€ ô ”2—:‘:Óˆà�[‰[‹]ˆÜ�"�c�]Œ]˜aØ�G‰G�LÔ!÷ à�{‰{×"Ñ"Ó$×)Ñ)ˆä.×8Ñ8ˆ
õ	ð
 	�
‰
Ô,¨k¸9ÔEØ59ˆ�‰×ÑÔ2ð ØØØ ØØ#ØØ(ØØ'ØØ˜˜ÕØØØ ð
ˆõ$	,ô % V¨TÓ7ˆØ�}‰}˜UÓ#Ð#÷] �]ús   Á DÄD	r(   N)
rL   rM   rN   rO   rP   r7   r  rú  rQ   rR   rS   s   @r+   rè  rè  œ  s   ø‡ € ñò"ò!÷;$ð ;$r.   rè  )QrP   rð   r‰   rg   r`   r  ró   r]   Úior   r   Úunittestr   Úzope.interfacer   Útwisted.conchr   Útwisted.conch.interfacesr   Ú$twisted.conch.test.test_filetransferr   r	   Útwisted.credr
   Útwisted.internetr   r   r   r   r   Útwisted.internet.taskr   Útwisted.internet.testingr   Útwisted.internet.utilsr   Útwisted.pythonr   Útwisted.python.fakepwdr   Útwisted.python.filepathr   Útwisted.python.procutilsr   Útwisted.python.reflectr   Útwisted.trial.unittestr   r   ÚunixÚtwisted.conch.scriptsr   Útwisted.conch.scripts.cftpr   Útwisted.conch.sshr   Útwisted.conch.ssh.connectionr   Útwisted.conch.testr   r   Útwisted.conch.test.test_conchr    r!   ÚImportErrorÚ	skipTestsÚIReactorProcessr#   rU   r˜   r¢   r±   rÀ   rß   r�  ÚProcessProtocolr�  rØ  r  r»  rè  r(   r.   r+   Ú<module>r     s:  ðñ
ó Û Û Û 	Û Û 
Û ß %Ý å &å Ý .ß UÝ ß HÕ HÝ 'Ý 4Ý ;Ý Ý /Ý ,Ý *Ý 0Ý +á˜^Ó,€ÙÐ)Ó*€çð	Ý.Ý9Ý2ÝEß;Ý;ÝRð €	ØˆD�, 
× :Ò :¸7ÀDÓ IÐJÔJØ€Iñ ˆ	Ð?Ó@ô$
�hó $
ó Að$
ôN_
�8ô _
ôD˜ô ÷ #.ñ #.÷L9ñ 9ñ6 ˆYÓô/&˜ó /&ó ð/&ñd ˆ	Ð?Ó@ôp
�xó p
ó Aðp
÷f.ñ .ôx�h×.Ñ.ô xôv$+˜ô $+ñN ˆ	Ð?Ó@ôKÐ"4ó Kó AðKñ\ ˆ	Ð?Ó@ôdÐ0ó dó AðdñN ˆ	Ð?Ó@Ù‰E�%‹LÔÐ@ÓAÙ‰E�&‹MÔÐBÓCôG$Ð1ó G$ó Dó Bó AòG$øð_+ ô Úðús   Â*,H ÈHÈH