ó
    Ö›‘hv}  ã                   ó´  • S r SSKrSSKrSSKrSSKJr  SSKJrJr  SSK	J
r
  SSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr   SSKJr  \r SSKJr  \r SSKr\r SSK J!r"  \"r! SSK$J%r%J&r&J'r'J(r(   " S S\!5      r) " S S\)5      r* " S S5      r+\c  SSK,r,\,RZ                  " S\< S35        O) " S S\5      r.\R^                  " \.\)\'R`                  5         " S S\5      r1\" \(       + S5       " S S\15      5       r2 " S S 5      r3\" \(       + S5       " S! S"\5      5       r4\" \(       + S#5       " S$ S%\5      5       r5\" \(       + S5      \" \(       + S#5       " S& S'\5      5       5       r6\" \(       + S#5       " S( S)\5      5       r7g! \ a    Sr GNLf = f! \ a    Sr GNRf = f! \ a    Sr GNZf = f! \ a    \#r! GN`f = f! \ a     GN`f = f)*z.
Tests for L{twisted.conch.ssh.filetransfer}.
é    N)ÚskipIf)Úassert_thatÚequal_to)Údefer)ÚConnectionLost)ÚStringTransport)Úloopback)Ú
components)ÚFilePath)ÚTestCase)Úunix)ÚSFTPServerForUnixConchUser)Ú	ConchUser)ÚcommonÚ
connectionÚfiletransferÚsessionc                   ó    • \ rS rSrS rS rSrg)Ú
TestAvataré=   c                 ó¢   • [         R                  U 5        [        R                  U R                  S'   [
        R                  U R                  S'   g )Nó   sessionó   sftp)r   Ú__init__r   Ú
SSHSessionÚchannelLookupr   ÚFileTransferServerÚsubsystemLookup©Úselfs    ÚhC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/conch/test/test_filetransfer.pyr   ÚTestAvatar.__init__>   s<   € Ü×Ñ˜4Ô Ü)0×);Ñ);ˆ×Ñ˜:Ñ&Ü(4×(GÑ(Gˆ×Ñ˜WÒ%ó    c                 ó   •  [        U5      nU HV  nUS   n[        U5      S:„  =(       a    US   =(       d    Sn[        U5      S:„  =(       a    US   =(       d    0 nU" U0 UD6nMX     W$ ! [         a    XU4/n Nof = f)Nr   é   © é   )ÚiterÚ	TypeErrorÚlen)r    ÚfÚargsÚkwÚiÚfuncÚrs          r!   Ú
_runAsUserÚTestAvatar._runAsUserC   s�   € ð	 Ü�Q“ˆAó ˆAØ�Q‘4ˆDÜ�q“6˜A‘:×& ! A¡$×,¨"ˆDÜ�Q“˜!‘×$  !¡×*¨ˆBÙ�dÐ!˜bÑ!ŠAñ	 ð
 ˆøô ó 	 Ø˜2��ŠAð	 ús   ‚A+ Á+A=Á<A=r&   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   r1   Ú__static_attributes__r&   r#   r!   r   r   =   s   † òHõ

r#   r   c                   ó    • \ rS rSrS rS rSrg)ÚFileTransferTestAvataréP   c                 ó:   • [         R                  U 5        Xl        g ©N)r   r   ÚhomeDir)r    r=   s     r!   r   ÚFileTransferTestAvatar.__init__Q   s   € Ü×Ñ˜DÔ!Ø�r#   c                 ó„   • [        [        R                  " 5       5      R                  U R                  R
                  5      $ r<   )r   ÚosÚgetcwdÚpreauthChildr=   Úpathr   s    r!   Ú
getHomeDirÚ!FileTransferTestAvatar.getHomeDirU   s(   € ÜœŸ	š	›Ó$×1Ñ1°$·,±,×2CÑ2CÓDÐDr#   )r=   N)r3   r4   r5   r6   r   rD   r7   r&   r#   r!   r9   r9   P   s   † òõEr#   r9   c                   ó   • \ rS rSrS rSrg)ÚConchSessionForTestAvataréY   c                 ó   • Xl         g r<   ©Úavatar)r    rK   s     r!   r   Ú"ConchSessionForTestAvatar.__init__Z   s   € Ø�r#   rJ   N)r3   r4   r5   r6   r   r7   r&   r#   r!   rG   rG   Y   s   † õr#   rG   ztwisted.conch.unix imported z0, but doesn't define SFTPServerForUnixConchUser'c                   ó    • \ rS rSrS rS rSrg)ÚFileTransferForTestAvatarél   c                 ó
   • SS0$ )Nó	   conchTestó   ext datar&   )r    ÚversionÚotherExts      r!   Ú
gotVersionÚ$FileTransferForTestAvatar.gotVersionm   s   € Ø  +Ð.Ð.r#   c                 ó   • US:X  a  g[         e)Nó   testExtendedRequestó   bar)ÚNotImplementedError)r    ÚextNameÚextDatas      r!   ÚextendedRequestÚ)FileTransferForTestAvatar.extendedRequestp   s   € ØÐ0Ó0ØÜ%Ð%r#   r&   N)r3   r4   r5   r6   rU   r]   r7   r&   r#   r!   rN   rN   l   s   † ò	/õ	&r#   rN   c                   ó   • \ rS rSrS rSrg)ÚSFTPTestBaseéz   c                 óP  • [        U R                  5       5      U l        U R                  R                  S5      U l        U R                  R                  S5      R	                  S5        U R                  R                  S5      R                  SS9 nUR                  S5        [        SS	5       nUR                  UR                  S
5      5        S S S 5        S S S 5        U R                  R                  S5      R                  S5        U R                  R                  S5      R                  SS9 nUR                  S5        S S S 5        U R                  R                  S5      R                  SS9 nUR                  S5        S S S 5        U R                  R                  S5      R                  SS9 nUR                  S5        S S S 5        g ! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       N·= f! , (       d  f       N†= f! , (       d  f       g = f)NÚextraÚtestDirectoryTÚ	testfile1Úwb)Úmodeó   aaaaaaaaaabbbbbbbbbbz/dev/urandomÚrbi   i¤  ÚtestRemoveFileó   aÚtestRenameFilez.testHiddenFile)	r   ÚmktempÚtestDirÚchildÚmakedirsÚopenÚwriteÚreadÚchmod)r    r+   Úf2s      r!   ÚsetUpÚSFTPTestBase.setUp{   s‹  € Ü §¡£Ó.ˆŒð —|‘|×)Ñ)¨'Ó2ˆŒØ�‰×Ñ˜?Ó+×4Ñ4°TÔ:à�\‰\×Ñ Ó,×1Ñ1°tÐ1Ñ<ÀØ�G‰GÐ)Ô*Ü�n dÔ+¨rØ—‘˜Ÿ™ 	Ó*Ô+÷ ,÷ =ð 	�‰×Ñ˜;Ó'×-Ñ-¨eÔ4Ø�\‰\×ÑÐ 0Ó1×6Ñ6¸DÐ6ÑAÀQØ�G‰G�DŒM÷ Bà�\‰\×ÑÐ 0Ó1×6Ñ6¸DÐ6ÑAÀQØ�G‰G�DŒM÷ Bà�\‰\×ÑÐ 1Ó2×7Ñ7¸TÐ7ÑBÀaØ�G‰G�DŒM÷ CÐB÷ ,Ö+ú÷ =Ö<ú÷
 BÕAúçAÕAúçBÕBúsH   ÂG#Â/!GÃG#Ä2G5Å4HÆ6HÇ
G 	ÇG#Ç#
G2Ç5
HÈ
HÈ
H%)rn   N)r3   r4   r5   r6   rv   r7   r&   r#   r!   r`   r`   z   s   † õr#   r`   z can't run on non-posix computersc                   óà   • \ rS rSrS rS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS r\R6                  S 5       r\R6                  S 5       rSrg)ÚOurServerOurClientTestsé�   c                 óP  ^ • [         R                  T 5        [        T R                  5      T l        [
        R                  " T R                  S9T l        [        R                  " T R                  5      n[
        R                  " 5       T l        S T l        S T l        U 4S jnUT R                  l        [        R                  " T R                  5      nT R                  R                  U5        T R                  R                  U5        UT l        UT l        T R%                  5         g )NrJ   c                 ó"   >• U Tl         UTl        g r<   )Ú_serverVersionÚ_extData)ÚserverVersionr\   r    s     €r!   Ú_Ú(OurServerOurClientTests.setUp.<locals>._œ   s   ø€ Ø"/ˆDÔØ#ˆD�Mr#   )r`   rv   r9   rn   rK   r   r   Úserverr	   ÚLoopbackRelayÚFileTransferClientÚclientr}   r~   ÚgotServerVersionÚmakeConnectionÚclientTransportÚserverTransportÚ_emptyBuffers)r    rˆ   r€   r‰   s   `   r!   rv   ÚOurServerOurClientTests.setUp‘   sÑ   ø€ Ü×Ñ˜4Ô ä,¨T¯\©\Ó:ˆŒÜ"×5Ò5¸T¿[¹[ÑIˆŒÜ"×0Ò0°·±Ó=ˆä"×5Ò5Ó7ˆŒØ"ˆÔØˆŒõ	$ð ()ˆ�‰Ô$Ü"×0Ò0°·±Ó=ˆØ�‰×"Ñ" ?Ô3Ø�‰×"Ñ" ?Ô3à.ˆÔØ.ˆÔà×ÑÕr#   c                 óN  • U R                   R                  (       d  U R                  R                  (       ao  U R                   R                  5         U R                  R                  5         U R                   R                  (       a  MQ  U R                  R                  (       a  Mn  g g r<   )r‰   Úbufferrˆ   ÚclearBufferr   s    r!   rŠ   Ú%OurServerOurClientTests._emptyBuffersª   sh   € Ø×"Ñ"×)×)¨T×-AÑ-A×-H×-HØ× Ñ ×,Ñ,Ô.Ø× Ñ ×,Ñ,Ô.ð ×"Ñ"×)×)Ñ)¨T×-AÑ-A×-H×-HÓ-Hr#   c                 óÔ   • U R                   R                  5         U R                  R                  5         U R                   R                  5         U R                  R                  5         g r<   )r‰   ÚloseConnectionrˆ   rŽ   r   s    r!   ÚtearDownÚ OurServerOurClientTests.tearDown¯   sJ   € Ø×Ñ×+Ñ+Ô-Ø×Ñ×+Ñ+Ô-Ø×Ñ×(Ñ(Ô*Ø×Ñ×(Ñ(Õ*r#   c                 óx   • U R                  U R                  S5        U R                  U R                  SS05        g )Né   rQ   rR   )ÚassertEqualr}   r~   r   s    r!   Útest_serverVersionÚ*OurServerOurClientTests.test_serverVersionµ   s1   € Ø×Ñ˜×,Ñ,¨aÔ0Ø×Ñ˜Ÿ™¨°{Ð(CÕDr#   c                 óº   • U R                  [        R                  R                  U R                  R
                  5      SU R                  R
                  < 35        g)z*
It implements the ISFTPServer interface.
zISFTPServer not provided by N)Ú
assertTruer   ÚISFTPServerÚ
providedByr‚   r…   r   s    r!   Útest_interface_implementationÚ5OurServerOurClientTests.test_interface_implementation¹   sC   € ð 	�‰Ü×$Ñ$×/Ñ/°·±×0BÑ0BÓCØ*¨4¯;©;×+=Ñ+=Ñ*@ÐAõ	
r#   c                 ó4  ^ ^^• T R                   R                  S[        R                  [        R                  -  0 5      nT R                  5         [        R                  m/ mUU4S jnT R                  [        SU5        UU 4S jnUR                  U5        U$ )zG
A file opened with C{openFile} is closed when the connection is lost.
ó	   testfile1c                 ó8   >• TR                  U 5        T" U 5        g r<   ©Úappend)ÚfdÚclosedÚoldCloses    €€r!   ÚcloseÚJOurServerOurClientTests.test_openedFileClosedWithConnection.<locals>.closeÎ   s   ø€ Ø�M‰M˜"ÔÙ�R�Lr#   r§   c                 ó¦  >• TR                   R                  U R                  SS     R                  nTR                  R                  5         TR                  R                  5         TR                  R                  5         TR                  R                  5         TR                  TR                   R                  0 5        TR                  UT5        g )Né   )
r‚   Ú	openFilesÚhandler¤   r‰   r‘   rˆ   rŽ   r–   ÚassertIn)ÚopenFiler¤   r¥   r    s     €€r!   Ú_fileOpenedÚPOurServerOurClientTests.test_openedFileClosedWithConnection.<locals>._fileOpenedÔ   s˜   ø€ Ø—‘×&Ñ& x§¡°q°rÐ':Ñ;×>Ñ>ˆBØ× Ñ ×/Ñ/Ô1Ø× Ñ ×/Ñ/Ô1Ø× Ñ ×,Ñ,Ô.Ø× Ñ ×,Ñ,Ô.Ø×Ñ˜TŸ[™[×2Ñ2°BÔ7Ø�M‰M˜"˜fÕ%r#   )
r…   r®   r   ÚFXF_READÚ	FXF_WRITErŠ   r@   r§   ÚpatchÚaddCallback)r    Údr§   r¯   r¥   r¦   s   `   @@r!   Ú#test_openedFileClosedWithConnectionÚ;OurServerOurClientTests.test_openedFileClosedWithConnectionÂ   s|   ú€ ð �K‰K× Ñ Øœ,×/Ñ/´,×2HÑ2HÑHÈ"ó
ˆð 	×ÑÔä—8‘8ˆØˆö	ð 	�
‰
”2�w Ô&ö	&ð 	
�‰�kÔ"Øˆr#   c                 óŒ   ^ • T R                   R                  S5      nT R                  5         U 4S jnUR                  U5        U$ )zP
A directory opened with C{openDirectory} is close when the connection
is lost.
Ú c                 ó"  >• TR                   R                  5         TR                  R                  5         TR                   R                  5         TR                  R                  5         TR	                  TR
                  R                  0 5        g r<   )r‰   r‘   rˆ   rŽ   r–   r‚   ÚopenDirs)ÚopenDirr    s    €r!   Ú	_getFilesÚSOurServerOurClientTests.test_openedDirectoryClosedWithConnection.<locals>._getFilesè   se   ø€ Ø× Ñ ×/Ñ/Ô1Ø× Ñ ×/Ñ/Ô1Ø× Ñ ×,Ñ,Ô.Ø× Ñ ×,Ñ,Ô.Ø×Ñ˜TŸ[™[×1Ñ1°2Õ6r#   ©r…   ÚopenDirectoryrŠ   r´   )r    rµ   r½   s   `  r!   Ú(test_openedDirectoryClosedWithConnectionÚ@OurServerOurClientTests.test_openedDirectoryClosedWithConnectionà   s=   ø€ ð
 �K‰K×%Ñ% bÓ)ˆØ×ÑÔõ	7ð 	
�‰�iÔ Øˆr#   c                 óþ   ^ ^^^• T R                   R                  S[        R                  [        R                  -  0 5      nT R                  5         UUU 4S jnU 4S jmUU 4S jmU 4S jmUR                  U5        U$ )Nr    c                 óˆ   >• TR                  U [        R                  " U 5      5        T" U 5      nUR                  TU 5        U$ r<   )r–   r   Ú	ISFTPFiler´   )r®   rµ   Ú
_readChunkÚ_writeChunkr    s     €€€r!   r¯   Ú<OurServerOurClientTests.test_openFileIO.<locals>._fileOpenedø   s;   ø€ Ø×Ñ˜X¤|×'=Ò'=¸hÓ'GÔHÙ˜8Ó$ˆAØ�M‰M˜+ xÔ0ØˆHr#   c                 ó„   >• U R                  SS5      nTR                  5         UR                  TR                  S5        U$ )Nr   é   rh   ©Ú	readChunkrŠ   r´   r–   )r®   rµ   r    s     €r!   rÆ   Ú;OurServerOurClientTests.test_openFileIO.<locals>._readChunkþ   s;   ø€ Ø×"Ñ" 1 bÓ)ˆAØ×ÑÔ Ø�M‰M˜$×*Ñ*Ð,AÔBØˆHr#   c                 óp   >• UR                  SS5      nTR                  5         UR                  TU5        U$ )NrÊ   s
   cccccccccc)Ú
writeChunkrŠ   r´   )r€   r®   rµ   Ú_readChunk2r    s      €€r!   rÇ   Ú<OurServerOurClientTests.test_openFileIO.<locals>._writeChunk  s4   ø€ Ø×#Ñ# B¨	Ó2ˆAØ×ÑÔ Ø�M‰M˜+ xÔ0ØˆHr#   c                 ó„   >• UR                  SS5      nTR                  5         UR                  TR                  S5        U$ )Nr   é   s   aaaaaaaaaabbbbbbbbbbccccccccccrË   ©r€   r®   rµ   r    s      €r!   rÐ   Ú<OurServerOurClientTests.test_openFileIO.<locals>._readChunk2
  s;   ø€ Ø×"Ñ" 1 bÓ)ˆAØ×ÑÔ Ø�M‰M˜$×*Ñ*Ð,MÔNØˆHr#   ©r…   r®   r   r±   r²   rŠ   r´   )r    rµ   r¯   rÆ   rÐ   rÇ   s   `  @@@r!   Útest_openFileIOÚ'OurServerOurClientTests.test_openFileIOò   sd   û€ Ø�K‰K× Ñ Øœ,×/Ñ/´,×2HÑ2HÑHÈ"ó
ˆð 	×ÑÔ÷	õ	ö	õ	ð 	
�‰�kÔ"Øˆr#   c                 óî   ^ ^^• T R                   R                  S[        R                  [        R                  -  0 5      nT R                  5         U 4S jmU 4S jmUUU 4S jnUR                  U5        U$ )Nr    c                 óH   >• UR                  5       nTR                  5         U$ r<   )ÚgetAttrsrŠ   rÔ   s      €r!   Ú	_getAttrsÚBOurServerOurClientTests.test_closedFileGetAttrs.<locals>._getAttrs  s"   ø€ Ø×!Ñ!Ó#ˆAØ×ÑÔ ØˆHr#   c                 ó(   >• TR                  5         U $ r<   )ÚflushLoggedErrors)r+   r    s    €r!   Ú_errÚ=OurServerOurClientTests.test_closedFileGetAttrs.<locals>._err  s   ø€ Ø×"Ñ"Ô$ØˆHr#   c                 óÊ   >• U R                  5       nTR                  5         UR                  TU 5        UR                  T5        TR	                  U[
        R                  5      $ r<   )r§   rŠ   r´   Ú
addErrbackÚassertFailurer   Ú	SFTPError)r®   rµ   rà   rÜ   r    s     €€€r!   Ú_closeÚ?OurServerOurClientTests.test_closedFileGetAttrs.<locals>._close"  sN   ø€ Ø—‘Ó ˆAØ×ÑÔ Ø�M‰M˜) XÔ.Ø�L‰L˜ÔØ×%Ñ% a¬×)?Ñ)?Ó@Ð@r#   rÖ   )r    rµ   ræ   rà   rÜ   s   `  @@r!   Útest_closedFileGetAttrsÚ/OurServerOurClientTests.test_closedFileGetAttrs  s`   ú€ Ø�K‰K× Ñ Øœ,×/Ñ/´,×2HÑ2HÑHÈ"ó
ˆð 	×ÑÔõ	õ
	÷	Að 	
�‰�fÔØˆr#   c                 óÚ   ^ ^• T R                   R                  S[        R                  [        R                  -  0 5      nT R                  5         UU 4S jnU 4S jmUR                  U5      $ )Nr    c                 ój   >• U R                  5       nTR                  5         UR                  T5        U$ r<   ©rÛ   rŠ   r´   )r®   rµ   Ú
_getAttrs2r    s     €€r!   rÜ   ÚBOurServerOurClientTests.test_openFileAttributes.<locals>._getAttrs2  s.   ø€ Ø×!Ñ!Ó#ˆAØ×ÑÔ Ø�M‰M˜*Ô%ØˆHr#   c                 ó–   >• TR                   R                  S5      nTR                  5         UR                  TR                  U 5        U$ ©Nr    ©r…   rÛ   rŠ   r´   r–   )Úattrs1rµ   r    s     €r!   rí   ÚCOurServerOurClientTests.test_openFileAttributes.<locals>._getAttrs28  s<   ø€ Ø—‘×$Ñ$ \Ó2ˆAØ×ÑÔ Ø�M‰M˜$×*Ñ*¨FÔ3ØˆHr#   rÖ   )r    rµ   rÜ   rí   s   `  @r!   Útest_openFileAttributesÚ/OurServerOurClientTests.test_openFileAttributes,  sX   ù€ Ø�K‰K× Ñ Øœ,×/Ñ/´,×2HÑ2HÑHÈ"ó
ˆð 	×ÑÔö	õ	ð �}‰}˜YÓ'Ð'r#   c                 óî   ^ ^^• T R                   R                  S[        R                  [        R                  -  0 5      nT R                  5         UU 4S jnUU 4S jmU 4S jmUR                  U5        U$ )Nr    c                 ój   >• U R                  5       nTR                  5         UR                  T5        U$ r<   rì   )r®   rµ   Ú	_setAttrsr    s     €€r!   rÜ   Ú@OurServerOurClientTests.test_openFileSetAttrs.<locals>._getAttrsH  s.   ø€ Ø×!Ñ!Ó#ˆAØ×ÑÔ Ø�M‰M˜)Ô$ØˆHr#   c                 óÄ   >• SU S'   TR                   R                  SU 5      nTR                  5         UR                  T5        UR                  TR                  U 5        U$ )Nr   Úatimer    )r…   ÚsetAttrsrŠ   r´   r–   )Úattrsrµ   rí   r    s     €€r!   rø   Ú@OurServerOurClientTests.test_openFileSetAttrs.<locals>._setAttrsN  sS   ø€ ØˆE�'‰NØ—‘×$Ñ$ \°5Ó9ˆAØ×ÑÔ Ø�M‰M˜*Ô%Ø�M‰M˜$×*Ñ*¨EÔ2ØˆHr#   c                 ó^   >• TR                   R                  S5      nTR                  5         U$ rð   ©r…   rÛ   rŠ   ©r€   rµ   r    s     €r!   rí   ÚAOurServerOurClientTests.test_openFileSetAttrs.<locals>._getAttrs2V  s(   ø€ Ø—‘×$Ñ$ \Ó2ˆAØ×ÑÔ ØˆHr#   rÖ   )r    rµ   rÜ   rí   rø   s   `  @@r!   Útest_openFileSetAttrsÚ-OurServerOurClientTests.test_openFileSetAttrs@  sa   ú€ ð �K‰K× Ñ Øœ,×/Ñ/´,×2HÑ2HÑHÈ"ó
ˆð 	×ÑÔö	ö	õ	ð
 	
�‰�iÔ Øˆr#   c                 ó\  ^ ^^• 0 mT R                   R                  R                  mUU4S jnUT R                   R                  l        T R                  R                  S[        R                  [        R
                  -  SS05      nT R                  5         UU 4S jnUR                  U5      $ )zÇ
Check that L{filetransfer.FileTransferClient.openFile} can send
extended attributes, that should be extracted server side. By default,
they are ignored, so we just verify they are correctly parsed.
c                 ó8   >• TR                  U5        T" XU5      $ r<   )Úupdate)ÚfilenameÚflagsrý   ÚoldOpenFileÚsavedAttributess      €€r!   r®   ÚIOurServerOurClientTests.test_openFileExtendedAttributes.<locals>.openFileg  s   ø€ Ø×"Ñ" 5Ô)Ù˜x°Ó6Ð6r#   r    Úext_foorY   c                 ó.   >• TR                  TSS05        g )Nr  rY   ©r–   )Úignr  r    s    €€r!   ÚcheckÚFOurServerOurClientTests.test_openFileExtendedAttributes.<locals>.checkt  s   ø€ Ø×Ñ˜_¨y¸&Ð.AÕBr#   )r‚   r…   r®   r   r±   r²   rŠ   r´   )r    r®   rµ   r  r
  r  s   `   @@r!   Útest_openFileExtendedAttributesÚ7OurServerOurClientTests.test_openFileExtendedAttributes^  s�   ú€ ð ˆØ—k‘k×(Ñ(×1Ñ1ˆö	7ð '/ˆ�‰×ÑÔ#à�K‰K× Ñ ØÜ×!Ñ!¤L×$:Ñ$:Ñ:Ø˜Ðó
ˆð
 	×ÑÔö	Cð �}‰}˜UÓ#Ð#r#   c                 óê   ^ • T R                   R                  S5      nT R                  5         U 4S jnUR                  U5        UR                  U5        T R	                  U[
        R                  5      $ )Nó   testRemoveFilec                 ó^   >• TR                   R                  S5      nTR                  5         U$ )Nr  )r…   Ú
removeFilerŠ   )Úignoredrµ   r    s     €r!   Ú_removeFileÚ<OurServerOurClientTests.test_removeFile.<locals>._removeFile}  s)   ø€ Ø—‘×&Ñ&Ð'8Ó9ˆAØ×ÑÔ ØˆHr#   )r…   rÛ   rŠ   r´   rä   r   rå   )r    rµ   r  s   `  r!   Útest_removeFileÚ'OurServerOurClientTests.test_removeFiley  s\   ø€ Ø�K‰K× Ñ Ð!2Ó3ˆØ×ÑÔõ	ð
 	
�‰�kÔ"Ø	�‰�kÔ"Ø×!Ñ! !¤\×%;Ñ%;Ó<Ð<r#   c                 ó˜   ^ ^• T R                   R                  S5      nT R                  5         UU 4S jnU 4S jmUR                  U5      $ )Nó   testRenameFilec                 ó„   >• TR                   R                  SS5      nTR                  5         UR                  TU 5        U$ )Nr  ó   testRenamedFile)r…   Ú
renameFilerŠ   r´   )rý   rµ   Ú_testRenamedr    s     €€r!   Ú_renameÚ8OurServerOurClientTests.test_renameFile.<locals>._renameŠ  s:   ø€ Ø—‘×&Ñ&Ð'8Ð:LÓMˆAØ×ÑÔ Ø�M‰M˜,¨Ô.ØˆHr#   c                 ó”   >• TR                   R                  S5      nTR                  5         UR                  TR                  U5        g )Nr!  rñ   )r€   rý   rµ   r    s      €r!   r#  Ú=OurServerOurClientTests.test_renameFile.<locals>._testRenamed�  s8   ø€ Ø—‘×$Ñ$Ð%7Ó8ˆAØ×ÑÔ Ø�M‰M˜$×*Ñ*¨EÕ2r#   )r…   rÛ   rŠ   r´   )r    rµ   r$  r#  s   `  @r!   Útest_renameFileÚ'OurServerOurClientTests.test_renameFile†  s?   ù€ Ø�K‰K× Ñ Ð!2Ó3ˆØ×ÑÔö	õ	3ð
 �}‰}˜WÓ%Ð%r#   c                 ó˜   • U R                   R                  S5      nU R                  5         U R                  U[        R
                  5      $ ©Nó   testMakeDirectory©r…   rÛ   rŠ   rä   r   rå   ©r    rµ   s     r!   Útest_directoryBadÚ)OurServerOurClientTests.test_directoryBad—  s<   € Ø�K‰K× Ñ Ð!5Ó6ˆØ×ÑÔØ×!Ñ! !¤\×%;Ñ%;Ó<Ð<r#   c                 ó  ^ • T R                   R                  S0 5      nT R                  5         U 4S jnU 4S jnUR                  U5        UR                  U5        UR                  U5        T R	                  U[
        R                  5      $ )Nr,  c                 ó^   >• TR                   R                  S5      nTR                  5         U$ r+  r   r  s     €r!   rÜ   ÚAOurServerOurClientTests.test_directoryCreation.<locals>._getAttrs   s)   ø€ Ø—‘×$Ñ$Ð%9Ó:ˆAØ×ÑÔ ØˆHr#   c                 ó^   >• TR                   R                  S5      nTR                  5         U$ r+  )r…   ÚremoveDirectoryrŠ   r  s     €r!   Ú_removeDirectoryÚHOurServerOurClientTests.test_directoryCreation.<locals>._removeDirectory©  s)   ø€ Ø—‘×+Ñ+Ð,@ÓAˆAØ×ÑÔ ØˆHr#   )r…   ÚmakeDirectoryrŠ   r´   rä   r   rå   )r    rµ   rÜ   r6  s   `   r!   Útest_directoryCreationÚ.OurServerOurClientTests.test_directoryCreationœ  sp   ø€ Ø�K‰K×%Ñ%Ð&:¸BÓ?ˆØ×ÑÔõ	õ	ð
 	
�‰�iÔ Ø	�‰Ð&Ô'Ø	�‰�iÔ Ø×!Ñ! !¤\×%;Ñ%;Ó<Ð<r#   c                 óØ   ^ ^^^• T R                   R                  S5      nT R                  5         / mUUUU 4S jmUU 4S jnU 4S jmUR                  T5        UR                  U5        U$ )Nr#   c                 óà   >^ • UU 4S jn[         R                  " T R                  5      nTR                  5         UR	                  U5        UR	                  T5        UR                  TT 5        U$ )Nc                 ó*   >• TR                  U 5        T$ r<   r¢   )r+   Úfilesr¼   s    €€r!   r£   ÚMOurServerOurClientTests.test_openDirectory.<locals>._getFiles.<locals>.append¹  s   ø€ Ø—‘˜Q”Ø�r#   )r   ÚmaybeDeferredÚnextrŠ   r´   rã   )r¼   r£   rµ   ræ   r½   r>  r    s   `  €€€€r!   r½   Ú=OurServerOurClientTests.test_openDirectory.<locals>._getFiles¸  sU   ù€ öô ×#Ò# G§L¡LÓ1ˆAØ×ÑÔ Ø�M‰M˜&Ô!Ø�M‰M˜)Ô$Ø�L‰L˜ Ô)ØˆHr#   c                 óˆ   >• [        [        [        T6 5      S   5      nUR                  5         TR                  U/ SQ5        g )Nr   )s   .testHiddenFiles   testDirectoryr  r  r    )ÚlistÚzipÚsortr–   )r  Úfsr>  r    s     €€r!   Ú_checkFilesÚ?OurServerOurClientTests.test_openDirectory.<locals>._checkFilesÄ  s:   ø€ Ü”dœ3 ˜;Ó'¨Ñ*Ó+ˆBØ�G‰GŒIØ×ÑØòõ	r#   c                 óH   >• UR                  5       nTR                  5         U$ r<   )r§   rŠ   )r€   r¼   rµ   r    s      €r!   ræ   Ú:OurServerOurClientTests.test_openDirectory.<locals>._closeÒ  s   ø€ Ø—‘“ˆAØ×ÑÔ ØˆHr#   r¿   )r    rµ   rH  ræ   r½   r>  s   `  @@@r!   Útest_openDirectoryÚ*OurServerOurClientTests.test_openDirectory³  s[   û€ Ø�K‰K×%Ñ% cÓ*ˆØ×ÑÔØˆ÷
	ð 
	ö	õ	ð
 	
�‰�iÔ Ø	�‰�kÔ"Øˆr#   c                 ó˜   • U R                   R                  S5      nU R                  5         U R                  U[        R
                  5      $ )Nó   testLinkr-  r.  s     r!   Útest_linkDoesntExistÚ,OurServerOurClientTests.test_linkDoesntExistÛ  s;   € Ø�K‰K× Ñ  Ó-ˆØ×ÑÔØ×!Ñ! !¤\×%;Ñ%;Ó<Ð<r#   c                 ó¸   ^ • T R                   R                  SS5      nT R                  5         U 4S jnU 4S jnUR                  U5        UR                  U5      $ )NrO  r    c                 ó`   >• TR                   R                  SS5      nTR                  5         U$ )NrO  r%   r   r  s     €r!   Ú_getFirstAttrsÚDOurServerOurClientTests.test_linkSharesAttrs.<locals>._getFirstAttrsä  s*   ø€ Ø—‘×$Ñ$ [°!Ó4ˆAØ×ÑÔ ØˆHr#   c                 ó–   >• TR                   R                  S5      nTR                  5         UR                  TR                  U 5        U$ rð   rñ   )Ú
firstAttrsrµ   r    s     €r!   Ú_getSecondAttrsÚEOurServerOurClientTests.test_linkSharesAttrs.<locals>._getSecondAttrsé  s<   ø€ Ø—‘×$Ñ$ \Ó2ˆAØ×ÑÔ Ø�M‰M˜$×*Ñ*¨JÔ7ØˆHr#   ©r…   ÚmakeLinkrŠ   r´   )r    rµ   rT  rX  s   `   r!   Útest_linkSharesAttrsÚ,OurServerOurClientTests.test_linkSharesAttrsà  sL   ø€ Ø�K‰K× Ñ  ¨lÓ;ˆØ×ÑÔõ	õ
	ð 	
�‰�nÔ%Ø�}‰}˜_Ó-Ð-r#   c                 ó¼   ^ • T R                   R                  SS5      nT R                  5         U 4S jnU 4S jnUR                  U5        UR                  U5        U$ )NrO  r    c                 óN  >• TR                   R                  S5      nTR                  5         [        [        R
                  " 5       5      R                  TR                  R                  5      nUR                  S5      nUR                  TR                  UR                  5        U$ ©NrO  re   )r…   ÚreadLinkrŠ   r   r@   rA   rB   rn   rC   ro   r´   r–   )r€   rµ   ÚtestFiler    s      €r!   Ú	_readLinkÚ8OurServerOurClientTests.test_linkPath.<locals>._readLinkö  ós   ø€ Ø—‘×$Ñ$ [Ó1ˆAØ×ÑÔ Ü¤§	¢	£Ó,×9Ñ9¸$¿,¹,×:KÑ:KÓLˆHØ—~‘~ kÓ2ˆHØ�M‰M˜$×*Ñ*¨H¯M©MÔ:ØˆHr#   c                 óN  >• TR                   R                  S5      nTR                  5         [        [        R
                  " 5       5      R                  TR                  R                  5      nUR                  S5      nUR                  TR                  UR                  5        U$ r`  )r…   ÚrealPathrŠ   r   r@   rA   rB   rn   rC   ro   r´   r–   )r€   rµ   ÚtestLinkr    s      €r!   Ú	_realPathÚ8OurServerOurClientTests.test_linkPath.<locals>._realPathþ  re  r#   rZ  )r    rµ   rc  ri  s   `   r!   Útest_linkPathÚ%OurServerOurClientTests.test_linkPathò  sN   ø€ Ø�K‰K× Ñ  ¨lÓ;ˆØ×ÑÔõ	õ	ð 	
�‰�iÔ Ø	�‰�iÔ Øˆr#   c                 óÌ   • U R                   R                  SS5      nU R                  5         UR                  U R                  S5        UR                  U R
                  5        U$ )NrX   s   foorY   )r…   r]   rŠ   r´   r–   Ú_cbTestExtendedRequestr.  s     r!   Útest_extendedRequestÚ,OurServerOurClientTests.test_extendedRequest
  sP   € Ø�K‰K×'Ñ'Ð(>ÀÓGˆØ×ÑÔØ	�‰�d×&Ñ&¨Ô/Ø	�‰�d×1Ñ1Ô2Øˆr#   c                 ó†   • U R                   R                  SS5      nU R                  5         U R                  U[        5      $ )Ns   testBadRequestr#   )r…   r]   rŠ   rä   rZ   )r    r  rµ   s      r!   rn  Ú.OurServerOurClientTests._cbTestExtendedRequest  s9   € Ø�K‰K×'Ñ'Ð(9¸3Ó?ˆØ×ÑÔØ×!Ñ! !Ô%8Ó9Ð9r#   c              #   ór  #   • U R                   R                  S5      nU R                  5         Uv •nUR                  5       nU R                  5         Uv •  U R	                  5       nSnU R                  S[        U5      5        U R                  [        US   S   5        U R                  XTS   S   5        g7f)z:
Using client.openDirectory as an iterator is deprecated.
r#   zeUsing twisted.conch.ssh.filetransfer.ClientDirectory as an iterator was deprecated in Twisted 18.9.0.r%   r   ÚcategoryÚmessageN)r…   rÀ   rŠ   rA  ÚflushWarningsr–   r*   ÚDeprecationWarning)r    rµ   r¼   ÚoneFileÚwarningsru  s         r!   Ú$test_openDirectoryIteratorDeprecatedÚ<OurServerOurClientTests.test_openDirectoryIteratorDeprecated  sª   é € ð
 �K‰K×%Ñ% cÓ*ˆØ×ÑÔØ‘'ˆØ—,‘,“.ˆØ×ÑÔØŠà×%Ñ%Ó'ˆð@ð 	ð 	×Ñ˜œC ›MÔ*Ø×ÑÔ+¨X°a©[¸Ñ-DÔEØ×Ñ˜¨1¡+¨iÑ"8Õ9ùs   ‚B5B7c              #   ó  ^ ^#   • T R                   R                  S[        R                  0 5      nT R	                  5         Uv •n/ mUU 4S jnT R
                  R                  R                  5       u  nX4l        AUR                  SS5      nT R	                  5         T R                  [        T5      S5        T R                  U5        T R                  R                  5         T R                  R                  5         T R                  R                  5         T R	                  5         T R!                  T R                   R"                  5        T R%                  U[&        5        UR)                  5       nT R%                  U[&        5        g7f)zc
If there are requests outstanding when the connection
is closed for any reason, they should fail.
r    c                 óx   >• TR                  T/ 5        [        R                  " 5       nTR                  U 5        U$ r<   )r–   r   ÚDeferredr£   )ÚoffsetÚlengthrµ   ÚgotReadRequestr    s      €€r!   Ú	_slowReadÚOOurServerOurClientTests.test_closedConnectionCancelsRequests.<locals>._slowRead9  s2   ø€ Ø×Ñ˜^¨RÔ0Ü—’Ó ˆAØ×!Ñ! &Ô)ØˆHr#   éd   éÈ   r%   N)r…   r®   r   r±   rŠ   r‚   r«   ÚvaluesrÌ   r–   r*   ÚassertNoResultr‰   r‘   rŽ   rˆ   ÚassertFalseÚ	connectedÚfailureResultOfr   rÛ   )r    rµ   Úfhr‚  ÚserverSideFhr�  s   `    @r!   Ú$test_closedConnectionCancelsRequestsÚ<OurServerOurClientTests.test_closedConnectionCancelsRequests+  s4  ùé € ð �K‰K× Ñ  ¬|×/DÑ/DÀbÓIˆØ×ÑÔØ‰Wˆð ˆö	ð Ÿ™×.Ñ.×5Ñ5Ó7‰ˆØ!*ÔØð �L‰L˜˜cÓ"ˆØ×ÑÔØ×Ñœ˜^Ó,¨aÔ0Ø×Ñ˜AÔð 	×Ñ×+Ñ+Ô-Ø×Ñ×(Ñ(Ô*Ø×Ñ×(Ñ(Ô*Ø×ÑÔà×Ñ˜Ÿ™×.Ñ.Ô/Ø×Ñ˜Q¤Ô/ð �K‰K‹MˆØ×Ñ˜Q¤Õ/ùs   „FF)r~   r}   rK   r…   rˆ   r‚   r‰   N)r3   r4   r5   r6   rv   rŠ   r’   r—   r�   r¶   rÁ   r×   rè   rô   r  r  r  r(  r/  r9  rL  rP  r\  rk  ro  rn  r   ÚinlineCallbacksrz  r�  r7   r&   r#   r!   ry   ry   �   s§   † òò2/ò
+òEò
òò<ò$òBò2(ò(ò<$ò6=ò&ò"=ò
=ò.&òP=ò
.ò$ò0ò:ð
 ×Ññ:ó ð:ð( ×Ññ*0ó ó*0r#   ry   c                   ó   • \ rS rSrS rSrg)ÚFakeConniY  c                 ó   • g r<   r&   )r    Úchannels     r!   Ú	sendCloseÚFakeConn.sendCloseZ  s   € Ør#   r&   N)r3   r4   r5   r6   r”  r7   r&   r#   r!   r‘  r‘  Y  s   † õr#   r‘  c                   ó>   • \ rS rSrS rS rS rS rS rS r	S r
S	rg
)ÚFileTransferCloseTestsi^  c                 ó"   • [        5       U l        g r<   )r   rK   r   s    r!   rv   ÚFileTransferCloseTests.setUp`  s   € Ü “lˆ�r#   c                 ó’   • [         R                  " 5       n " S S5      nU" 5       Ul        U R                  UR                  l        U$ )Nc                   ó&   • \ rS rSrS rS rS rSrg)ÚDFileTransferCloseTests.buildServerConnection.<locals>.DummyTransportih  c                 ó   • X l         g r<   ©Ú	transportr   s    r!   r   ÚMFileTransferCloseTests.buildServerConnection.<locals>.DummyTransport.__init__i  s   € Ø!%•r#   c                 ó   • g r<   r&   )r    ÚkindÚdatas      r!   Ú
sendPacketÚOFileTransferCloseTests.buildServerConnection.<locals>.DummyTransport.sendPacketl  s   € Ør#   c                 ó   • g)Nzdummy transportr&   r   s    r!   Ú	logPrefixÚNFileTransferCloseTests.buildServerConnection.<locals>.DummyTransport.logPrefixo  s   € Ø(r#   rž  N)r3   r4   r5   r6   r   r¤  r§  r7   r&   r#   r!   ÚDummyTransportrœ  h  s   † ò&òõ)r#   r©  )r   ÚSSHConnectionrŸ  rK   )r    Úconnr©  s      r!   ÚbuildServerConnectionÚ,FileTransferCloseTests.buildServerConnectionc  s;   € ä×'Ò'Ó)ˆ÷	)ñ 	)ñ (Ó)ˆŒØ $§¡ˆ�‰ÔØˆr#   c                 óH   ^ ^• ST l         UR                  mUU 4S jnX!l        g )NFc                 ó$   >• STl         T" U 5        g )NT)ÚconnectionLostFired)ÚreasonÚorigConnectionLostr    s    €€r!   ÚconnectionLostÚFFileTransferCloseTests.interceptConnectionLost.<locals>.connectionLostz  s   ø€ Ø'+ˆDÔ$Ù˜vÕ&r#   )r°  r³  )r    Ú
sftpServerr³  r²  s   `  @r!   ÚinterceptConnectionLostÚ.FileTransferCloseTests.interceptConnectionLostv  s$   ù€ Ø#(ˆÔ Ø'×6Ñ6Ðö	'ð %3Õ!r#   c                 ó<   • U R                  U R                  S5        g )Nz*sftpServer's connectionLost was not called)rš   r°  r   s    r!   ÚassertSFTPConnectionLostÚ/FileTransferCloseTests.assertSFTPConnectionLost€  s   € Ø�‰Ø×$Ñ$Ð&Rõ	
r#   c                 ó>  • [         R                  " [        5       U R                  S9nUR	                  [
        R                  " S5      5        UR                  R                  R                  nU R                  U5        UR                  5         U R                  5         g)zM
Closing a session should notify an SFTP subsystem launched by that
session.
)r«  rK   r   N)r   r   r‘  rK   Úrequest_subsystemr   ÚNSr…   rŸ  Úprotor¶  ÚcloseReceivedr¹  )r    ÚtestSessionrµ  s      r!   Útest_sessionCloseÚ(FileTransferCloseTests.test_sessionClose…  sv   € ô ×(Ò(¬h«jÀÇÁÑMˆð 	×%Ñ%¤f§i¢i°Ó&8Ô9Ø ×'Ñ'×1Ñ1×7Ñ7ˆ
ð 	×$Ñ$ ZÔ0ð 	×!Ñ!Ô#à×%Ñ%Õ'r#   c                 ó   • U R                  5       n[        R                  " S5      [        R                  " SS5      S-  -   nUR                  U5        UR                  S   nUR                  [        R                  " S5      5        UR                  R                  R                  nU R                  U5        U R                  U5        UR                  [        R                  " SS5      5        U R                  5         g)za
A client sending CHANNEL_CLOSE should trigger closeReceived on the
associated channel instance.
r   ú>Lr   r•   r   N)r¬  r   r½  ÚstructÚpackÚssh_CHANNEL_OPENÚchannelsr¼  r…   rŸ  r¾  r¶  Ússh_CHANNEL_CLOSEr¹  ©r    r«  ÚpacketÚsessionChannelrµ  s        r!   Ú%test_clientClosesChannelOnConnnectionÚ<FileTransferCloseTests.test_clientClosesChannelOnConnnection™  sÆ   € ð
 ×)Ñ)Ó+ˆô —’˜:Ó&¬¯ª°T¸1Ó)=ÀÑ)AÑAˆØ×Ñ˜fÔ%ØŸ™ qÑ)ˆà×(Ñ(¬¯ª°7Ó);Ô<Ø#×*Ñ*×4Ñ4×:Ñ:ˆ
Ø×$Ñ$ ZÔ0ð 	×$Ñ$ ZÔ0ð 	×ÑœvŸ{š{¨4°Ó3Ô4à×%Ñ%Õ'r#   c                 ó²  • U R                  5       n[        R                  " S5      [        R                  " SS5      S-  -   nUR                  U5        UR                  S   nUR                  [        R                  " S5      5        UR                  R                  R                  nU R                  U5        UR                  5         U R                  5         g)z@
Closing an SSH connection should close all sessions within it.
r   rÄ  r   r•   r   N)r¬  r   r½  rÅ  rÆ  rÇ  rÈ  r¼  r…   rŸ  r¾  r¶  ÚserviceStoppedr¹  rÊ  s        r!   Ú'test_stopConnectionServiceClosesChannelÚ>FileTransferCloseTests.test_stopConnectionServiceClosesChannel±  s©   € ð ×)Ñ)Ó+ˆô —’˜:Ó&¬¯ª°T¸1Ó)=ÀÑ)AÑAˆØ×Ñ˜fÔ%ØŸ™ qÑ)ˆà×(Ñ(¬¯ª°7Ó);Ô<Ø#×*Ñ*×4Ñ4×:Ñ:ˆ
Ø×$Ñ$ ZÔ0ð 	×ÑÔà×%Ñ%Õ'r#   )rK   r°  N)r3   r4   r5   r6   rv   r¬  r¶  r¹  rÁ  rÍ  rÑ  r7   r&   r#   r!   r—  r—  ^  s%   † ò#òò&3ò
ò
(ò((õ0(r#   r—  zCannot run without cryptographyc                   ó&   • \ rS rSrSr/ SQrS rSrg)ÚConstantsTestsiÆ  aO  
Tests for the constants used by the SFTP protocol implementation.

@ivar filexferSpecExcerpts: Excerpts from the
    draft-ietf-secsh-filexfer-02.txt (draft) specification of the SFTP
    protocol.  There are more recent drafts of the specification, but this
    one describes version 3, which is what conch (and OpenSSH) implements.
)aµ  
           The following values are defined for packet types.

                #define SSH_FXP_INIT                1
                #define SSH_FXP_VERSION             2
                #define SSH_FXP_OPEN                3
                #define SSH_FXP_CLOSE               4
                #define SSH_FXP_READ                5
                #define SSH_FXP_WRITE               6
                #define SSH_FXP_LSTAT               7
                #define SSH_FXP_FSTAT               8
                #define SSH_FXP_SETSTAT             9
                #define SSH_FXP_FSETSTAT           10
                #define SSH_FXP_OPENDIR            11
                #define SSH_FXP_READDIR            12
                #define SSH_FXP_REMOVE             13
                #define SSH_FXP_MKDIR              14
                #define SSH_FXP_RMDIR              15
                #define SSH_FXP_REALPATH           16
                #define SSH_FXP_STAT               17
                #define SSH_FXP_RENAME             18
                #define SSH_FXP_READLINK           19
                #define SSH_FXP_SYMLINK            20
                #define SSH_FXP_STATUS            101
                #define SSH_FXP_HANDLE            102
                #define SSH_FXP_DATA              103
                #define SSH_FXP_NAME              104
                #define SSH_FXP_ATTRS             105
                #define SSH_FXP_EXTENDED          200
                #define SSH_FXP_EXTENDED_REPLY    201

           Additional packet types should only be defined if the protocol
           version number (see Section ``Protocol Initialization'') is
           incremented, and their use MUST be negotiated using the version
           number.  However, the SSH_FXP_EXTENDED and SSH_FXP_EXTENDED_REPLY
           packets can be used to implement vendor-specific extensions.  See
           Section ``Vendor-Specific-Extensions'' for more details.
        aŸ  
            The flags bits are defined to have the following values:

                #define SSH_FILEXFER_ATTR_SIZE          0x00000001
                #define SSH_FILEXFER_ATTR_UIDGID        0x00000002
                #define SSH_FILEXFER_ATTR_PERMISSIONS   0x00000004
                #define SSH_FILEXFER_ATTR_ACMODTIME     0x00000008
                #define SSH_FILEXFER_ATTR_EXTENDED      0x80000000

        aË  
            The `pflags' field is a bitmask.  The following bits have been
           defined.

                #define SSH_FXF_READ            0x00000001
                #define SSH_FXF_WRITE           0x00000002
                #define SSH_FXF_APPEND          0x00000004
                #define SSH_FXF_CREAT           0x00000008
                #define SSH_FXF_TRUNC           0x00000010
                #define SSH_FXF_EXCL            0x00000020
        aÇ  
            Currently, the following values are defined (other values may be
           defined by future versions of this protocol):

                #define SSH_FX_OK                            0
                #define SSH_FX_EOF                           1
                #define SSH_FX_NO_SUCH_FILE                  2
                #define SSH_FX_PERMISSION_DENIED             3
                #define SSH_FX_FAILURE                       4
                #define SSH_FX_BAD_MESSAGE                   5
                #define SSH_FX_NO_CONNECTION                 6
                #define SSH_FX_CONNECTION_LOST               7
                #define SSH_FX_OP_UNSUPPORTED                8
        c                 ó¢  • 0 nU R                    Hf  nUR                  5        HO  n[        R                  " SU5      nU(       d  M#  [	        UR                  S5      S5      XR                  S5      '   MQ     Mh     U R                  [        U5      S:„  S5        UR                  5        H%  u  pVU R                  U[        [        U5      5        M'     g)zi
The constants used by the SFTP protocol implementation match those
found by searching through the spec.
z)^\s*#define SSH_([A-Z_]+)\s+([0-9x]*)\s*$r'   r   r%   z,No constants found (the test must be buggy).N)ÚfilexferSpecExcerptsÚ
splitlinesÚreÚmatchÚintÚgrouprš   r*   Úitemsr–   Úgetattrr   )r    Ú	constantsÚexcerptÚlineÚmÚkÚvs          r!   Útest_constantsAgainstSpecÚ(ConstantsTests.test_constantsAgainstSpec  sª   € ð
 ˆ	Ø×0Ô0ˆGØ×*Ñ*Ö,�Ü—H’HÐIÈ4ÓP�ß�1Ü,/°·±¸³
¸AÓ,>�IŸg™g a›jÓ)ó -ñ 1ð
 	�‰Ü�	‹N˜QÑÐ Nô	
ð —O‘OÖ%‰DˆAØ×Ñ˜Q¤¬°aÓ 8Ö9ò &r#   r&   N)r3   r4   r5   r6   Ú__doc__rÖ  rä  r7   r&   r#   r!   rÔ  rÔ  Æ  s   † ñòJÐõX:r#   rÔ  c                   ó$   • \ rS rSrSrS rS rSrg)ÚRawPacketDataServerTestsi1  z€
Tests for L{filetransfer.FileTransferServer} which explicitly craft
certain less common situations to exercise their handling.
c                 óF   • [         R                  " [        5       S9U l        g )NrJ   )r   r   r   Úftsr   s    r!   rv   ÚRawPacketDataServerTests.setUp9  s   € Ü×2Ò2¼*»,ÑGˆ�r#   c                 ó  • [        5       nU R                  R                  U5        SnSn[        R                  " [        S/5      U-   [        R                  " U5      -   5      nU R                  R                  U5        [        R                  " [        S/5      U-   [        / SQ5      -   [        R                  " S5      -   [        R                  " S5      -   5      n[        UR                  5       [        U5      5        g)	zT
A close request with an unknown handle receives an FX_NO_SUCH_FILE error
response.
s   1234s   invalid handlerª   ée   )r   r   r   r'   s   No such file or directoryr#   N)
r   rê  r‡   r   r½  ÚbytesÚdataReceivedr   Úvaluer   )r    rŸ  Ú	requestIdr¬   r§   Úexpecteds         r!   Útest_closeInvalidHandleÚ0RawPacketDataServerTests.test_closeInvalidHandle<  sè   € ô
 $Ó%ˆ	Ø�‰×Ñ 	Ô*ð ˆ	à"ˆô —	’	ô �1�#‹JØñä�iŠi˜Óñ ó
ˆð 	�‰×Ñ˜eÔ$ô —9’9ô �3�%‹Lð ñô ’,Óñ ô �IŠIÐ2Ó3ñ	4ô �IŠI�c‹Nñó
ˆô& 	Ø�O‰OÓÜ�XÓõ	
r#   )rê  N)r3   r4   r5   r6   ræ  rv   ró  r7   r&   r#   r!   rè  rè  1  s   † ñò
Hõ1
r#   rè  c                   óB   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
rg)ÚRawPacketDataTestsip  z‡
Tests for L{filetransfer.FileTransferClient} which explicitly craft certain
less common protocol messages to exercise their handling.
c                 ó8   • [         R                  " 5       U l        g r<   )r   r„   Úftcr   s    r!   rv   ÚRawPacketDataTests.setUpw  s   € Ü×2Ò2Ó4ˆ�r#   c                 ót  • [         R                  " 5       nUR                  U R                  5        XR                  R
                  S'   [        R                  " SS[        R                  5      [        R                  " S5      -   [        R                  " S5      -   nU R                  R                  U5        U$ )a  
A STATUS packet containing a result code, a message, and a language is
parsed to produce the result of an outstanding request L{Deferred}.

@see: U{section 9.1<http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-9.1>}
    of the SFTP Internet-Draft.
r%   ú!LLó   msgó   lang)r   r~  r´   Ú_cbTestPacketSTATUSrø  ÚopenRequestsrÅ  rÆ  r   ÚFX_OKr   r½  Úpacket_STATUS©r    rµ   r£  s      r!   Útest_packetSTATUSÚ$RawPacketDataTests.test_packetSTATUSz  sŠ   € ô �NŠNÓˆØ	�‰�d×.Ñ.Ô/Ø#$�‰×Ñ˜aÑ ä�KŠK˜˜q¤,×"4Ñ"4Ó5Ü�iŠi˜Óñ ä�iŠi˜Ó ñ!ð 	ð
 	�‰×Ñ˜tÔ$Øˆr#   c                 óX   • U R                  US   S5        U R                  US   S5        g)zc
Assert that the result is a two-tuple containing the message and
language from the STATUS packet.
r   rü  r%   rý  Nr  ©r    Úresults     r!   rþ  Ú&RawPacketDataTests._cbTestPacketSTATUS�  s,   € ð
 	×Ñ˜ ™ FÔ+Ø×Ñ˜ ™ GÕ,r#   c                 ó  • [         R                  " 5       nUR                  U R                  5        XR                  R
                  S'   [        R                  " SS[        R                  5      nU R                  R                  U5        U$ )aJ  
A STATUS packet containing only a result code can also be parsed to
produce the result of an outstanding request L{Deferred}.  Such packets
are sent by some SFTP implementations, though not strictly legal.

@see: U{section 9.1<http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-9.1>}
    of the SFTP Internet-Draft.
r%   rû  )r   r~  r´   Ú_cbTestPacketSTATUSShortrø  rÿ  rÅ  rÆ  r   r   r  r  s      r!   Útest_packetSTATUSShortÚ)RawPacketDataTests.test_packetSTATUSShort•  sc   € ô �NŠNÓˆØ	�‰�d×3Ñ3Ô4Ø#$�‰×Ñ˜aÑ Ü�{Š{˜5 !¤\×%7Ñ%7Ó8ˆØ�‰×Ñ˜tÔ$Øˆr#   c                 óX   • U R                  US   S5        U R                  US   S5        g)z
Assert that the result is a two-tuple containing empty strings, since
the STATUS packet had neither a message nor a language.
r   r#   r%   Nr  r  s     r!   r
  Ú+RawPacketDataTests._cbTestPacketSTATUSShort¥  s,   € ð
 	×Ñ˜ ™ CÔ(Ø×Ñ˜ ™ CÕ(r#   c                 óF  • [         R                  " 5       nUR                  U R                  5        XR                  R
                  S'   [        R                  " SS[        R                  5      [        R                  " S5      -   nU R                  R                  U5        U$ )ac  
A STATUS packet containing a result code and a message but no language
can also be parsed to produce the result of an outstanding request
L{Deferred}.  Such packets are sent by some SFTP implementations, though
not strictly legal.

@see: U{section 9.1<http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-9.1>}
    of the SFTP Internet-Draft.
r%   rû  rü  )r   r~  r´   Ú_cbTestPacketSTATUSWithoutLangrø  rÿ  rÅ  rÆ  r   r   r   r½  r  r  s      r!   Útest_packetSTATUSWithoutLangÚ/RawPacketDataTests.test_packetSTATUSWithoutLang­  sq   € ô �NŠNÓˆØ	�‰�d×9Ñ9Ô:Ø#$�‰×Ñ˜aÑ Ü�{Š{˜5 !¤\×%7Ñ%7Ó8¼6¿9º9ÀVÓ;LÑLˆØ�‰×Ñ˜tÔ$Øˆr#   c                 óX   • U R                  US   S5        U R                  US   S5        g)zŠ
Assert that the result is a two-tuple containing the message from the
STATUS packet and an empty string, since the language was missing.
r   rü  r%   r#   Nr  r  s     r!   r  Ú1RawPacketDataTests._cbTestPacketSTATUSWithoutLang¾  s,   € ð
 	×Ñ˜ ™ FÔ+Ø×Ñ˜ ™ CÕ(r#   )rø  N)r3   r4   r5   r6   ræ  rv   r  rþ  r  r
  r  r  r7   r&   r#   r!   rö  rö  p  s*   † ñò
5òò&-òò )òõ")r#   rö  )8ræ  r@   rØ  rÅ  Úunittestr   Úhamcrestr   r   Útwisted.internetr   Útwisted.internet.errorr   Útwisted.internet.testingr   Útwisted.protocolsr	   Útwisted.pythonr
   Útwisted.python.filepathr   Útwisted.trial.unittestr   Útwisted.conchr   Ú_unixÚImportErrorÚtwisted.conch.unixr   Ú_SFTPServerForUnixConchUserÚcryptographyÚ_cryptographyÚtwisted.conch.avatarr   Ú
_ConchUserÚobjectÚtwisted.conch.sshr   r   r   r   r   r9   rG   ry  ÚwarnrN   ÚregisterAdapterr›   r`   ry   r‘  r—  rÔ  rè  rö  r&   r#   r!   Ú<module>r+     sI  ðñ
ó
 
Û 	Û Ý ç *å "Ý 1Ý 4Ý &Ý %Ý ,Ý +ðÝ+ð €Dð=õð "=Ðð!Û(ð !€LðÝ<ð €Ið	ßKÓKô
�ô ô&E˜Zô E÷ñ ð
 Ñ%ó à‡MƒMó
 ð		õô&Ð$>ô &ð ×ÒØ! :¨|×/GÑ/Gôô
�8ô ñ* ˆDŒÐ4Ó5ôF0˜ló F0ó 6ðF0÷Rñ ñ
 ˆDŒÐ4Ó5ôd(˜Xó d(ó 6ðd(ñN ˆLÔÐ;Ó<ôe:�Xó e:ó =ðe:ñT ˆDŒÐ4Ó5ÙˆLÔÐ;Ó<ô:
˜xó :
ó =ó 6ð:
ñz ˆLÔÐ;Ó<ôS)˜ó S)ó =ñS)øðm ó ØƒDðûð ó &Ø!%Óð&ûð ó ØƒLðûð ó ØƒIðûð ó 	Úð	úsZ   ÁF ÁF  ÁF/ Á!F> Á*G ÆFÆFÆ F,Æ+F,Æ/F;Æ:F;Æ>G
Ç	G
ÇGÇG