Ë
    ojv}  ã                   óv  — d Z ddlZddlZddlZddlmZ ddlmZmZ ddl	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ 	 ddlmZ eZ	 ddlmZ eZ	 ddlZeZ	 ddl m!Z" e"Z!	 ddl$m%Z%m&Z&m'Z'm(Z(  G d„ de!«      Z) G d„ de)«      Z* G d„ d«      Z+e€ddl,Z, e,jZ                  de›d�«       n) G d„ de«      Z. ej^                  e.e)e'j`                  «        G d„ de«      Z1 ee d«       G d„ de1«      «       Z2 G d„ d «      Z3 ee d«       G d!„ d"e«      «       Z4 ee d#«       G d$„ d%e«      «       Z5 ee d«       ee d#«       G d&„ d'e«      «       «       Z6 ee d#«       G d(„ d)e«      «       Z7y# e$ r dZY �Œ1w xY w# e$ r dZY �Œ6w xY w# e$ r dZY �Œ=w xY w# e$ r e#Z!Y �ŒBw xY w# e$ r Y �ŒAw xY w)*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                   ó   — e Zd Zd„ Zd„ Zy)Ú
TestAvatarc                 ó¢   — t         j                  | «       t        j                  | j                  d<   t
        j                  | j                  d<   y )Nó   sessionó   sftp)r   Ú__init__r   Ú
SSHSessionÚchannelLookupr   ÚFileTransferServerÚsubsystemLookup©Úselfs    úF/usr/lib/python3/dist-packages/twisted/conch/test/test_filetransfer.pyr   zTestAvatar.__init__>   s<   € Ü×Ñ˜4Ô Ü)0×);Ñ);ˆ×Ñ˜:Ñ&Ü(4×(GÑ(Gˆ×Ñ˜WÒ%ó    c                 óÔ   — 	 t        |«      }|D ]A  }|d   }t        |«      dkD  xr |d   xs d}t        |«      dkD  xr |d   xs i } ||i |¤Ž}ŒC S # t        $ r	 |||fg}Y ŒYw xY w)Nr   é   © é   )ÚiterÚ	TypeErrorÚlen)r   ÚfÚargsÚkwÚiÚfuncÚrs          r    Ú
_runAsUserzTestAvatar._runAsUserC   s”   € ð	 Ü�Q“ˆAð ò 	"ˆAØ�Q‘4ˆDÜ�q“6˜A‘:Ò& ! A¡$Ò,¨"ˆDÜ�Q“˜!‘Ò$  !¡Ò*¨ˆBÙ�dÐ!˜bÑ!‰Að		"ð
 ˆøô ò 	 Ø�T˜2��ŠAð	 ús   ‚A ÁA'Á&A'N)Ú__name__Ú
__module__Ú__qualname__r   r/   r$   r!   r    r   r   =   s   „ òHó

r!   r   c                   ó   — e Zd Zd„ Zd„ Zy)ÚFileTransferTestAvatarc                 ó<   — t         j                  | «       || _        y ©N)r   r   ÚhomeDir)r   r7   s     r    r   zFileTransferTestAvatar.__init__Q   s   € Ü×Ñ˜DÔ!Øˆ�r!   c                 ó‚   — t        t        j                  «       «      j                  | j                  j
                  «      S r6   )r   ÚosÚgetcwdÚpreauthChildr7   Úpathr   s    r    Ú
getHomeDirz!FileTransferTestAvatar.getHomeDirU   s(   € ÜœŸ	™	›Ó$×1Ñ1°$·,±,×2CÑ2CÓDÐDr!   N)r0   r1   r2   r   r=   r$   r!   r    r4   r4   P   s   „ òóEr!   r4   c                   ó   — e Zd Zd„ Zy)ÚConchSessionForTestAvatarc                 ó   — || _         y r6   ©Úavatar)r   rB   s     r    r   z"ConchSessionForTestAvatar.__init__Z   s	   € Øˆ�r!   N)r0   r1   r2   r   r$   r!   r    r?   r?   Y   s   „ ór!   r?   ztwisted.conch.unix imported z0, but doesn't define SFTPServerForUnixConchUser'c                   ó   — e Zd Zd„ Zd„ Zy)ÚFileTransferForTestAvatarc                 ó
   — ddiS )Nó	   conchTestó   ext datar$   )r   ÚversionÚotherExts      r    Ú
gotVersionz$FileTransferForTestAvatar.gotVersionm   s   € Ø  +Ð.Ð.r!   c                 ó   — |dk(  ryt         ‚)Nó   testExtendedRequestó   bar)ÚNotImplementedError)r   ÚextNameÚextDatas      r    ÚextendedRequestz)FileTransferForTestAvatar.extendedRequestp   s   € ØÐ0Ò0ØÜ%Ð%r!   N)r0   r1   r2   rJ   rQ   r$   r!   r    rD   rD   l   s   „ ò	/ó	&r!   rD   c                   ó   — e Zd Zd„ Zy)ÚSFTPTestBasec                 ó6  — t        | j                  «       «      | _        | j                  j                  d«      | _        | j                  j                  d«      j	                  d«       | j                  j                  d«      j                  d¬«      5 }|j                  d«       t        dd	«      5 }|j                  |j                  d
«      «       d d d «       d d d «       | j                  j                  d«      j                  d«       | j                  j                  d«      j                  d¬«      5 }|j                  d«       d d d «       | j                  j                  d«      j                  d¬«      5 }|j                  d«       d d d «       | j                  j                  d«      j                  d¬«      5 }|j                  d«       d d d «       y # 1 sw Y   �ŒxY w# 1 sw Y   �ŒxY w# 1 sw Y   Œ®xY w# 1 sw Y   ŒuxY w# 1 sw Y   y xY w)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    ÚsetUpz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÷	à�\‰\×ÑÐ 0Ó1×6Ñ6¸DÐ6ÓAð 	ÀQØ�G‰G�DŒM÷	à�\‰\×ÑÐ 1Ó2×7Ñ7¸TÐ7ÓBð 	ÀaØ�G‰G�DŒM÷	ð 	÷,ñ ,ú÷	,ñ 	,ú÷
	ð 	ú÷	ð 	ú÷	ð 	úsH   ÂG*Â2!GÃG*Ä8G7Å=HÇHÇG'	Ç"G*Ç*G4Ç7H ÈHÈHN)r0   r1   r2   rh   r$   r!   r    rS   rS   z   s   „ ór!   rS   z can't run on non-posix computersc                   óØ   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zej4                  d„ «       Zej4                  d„ «       Zy)ÚOurServerOurClientTestsc                 óL  ‡ — t         j                  ‰ «       t        ‰ j                  «      ‰ _        t        j                  ‰ j                  ¬«      ‰ _        t        j                  ‰ j                  «      }t        j                  «       ‰ _        d ‰ _        d ‰ _        ˆ fd„}|‰ j                  _        t        j                  ‰ j                  «      }‰ j                  j                  |«       ‰ j                  j                  |«       |‰ _        |‰ _        ‰ j%                  «        y )NrA   c                 ó"   •— | ‰_         |‰_        y r6   )Ú_serverVersionÚ_extData)ÚserverVersionrP   r   s     €r    Ú_z(OurServerOurClientTests.setUp.<locals>._œ   s   ø€ Ø"/ˆDÔØ#ˆD�Mr!   )rS   rh   r4   r`   rB   r   r   Úserverr	   ÚLoopbackRelayÚFileTransferClientÚclientrm   rn   ÚgotServerVersionÚmakeConnectionÚclientTransportÚserverTransportÚ_emptyBuffers)r   rw   rp   rx   s   `   r    rh   zOurServerOurClientTests.setUp‘   sÑ   ø€ Ü×Ñ˜4Ô ä,¨T¯\©\Ó:ˆŒÜ"×5Ñ5¸T¿[¹[ÔIˆŒÜ"×0Ñ0°·±Ó=ˆä"×5Ñ5Ó7ˆŒØ"ˆÔØˆŒô	$ð ()ˆ�‰Ô$Ü"×0Ñ0°·±Ó=ˆØ�‰×"Ñ" ?Ô3Ø�‰×"Ñ" ?Ô3à.ˆÔØ.ˆÔà×ÑÕr!   c                 ó"  — | j                   j                  s| j                  j                  rc| j                   j                  «        | j                  j                  «        | j                   j                  rŒK| j                  j                  rŒby y r6   )rx   Úbufferrw   ÚclearBufferr   s    r    ry   z%OurServerOurClientTests._emptyBuffersª   sb   € Ø×"Ñ"×)Ò)¨T×-AÑ-A×-HÒ-HØ× Ñ ×,Ñ,Ô.Ø× Ñ ×,Ñ,Ô.ð ×"Ñ"×)Ó)¨T×-AÑ-A×-HÕ-Hr!   c                 óÔ   — | j                   j                  «        | j                  j                  «        | j                   j                  «        | j                  j                  «        y r6   )rx   ÚloseConnectionrw   r|   r   s    r    ÚtearDownz OurServerOurClientTests.tearDown¯   sJ   € Ø×Ñ×+Ñ+Ô-Ø×Ñ×+Ñ+Ô-Ø×Ñ×(Ñ(Ô*Ø×Ñ×(Ñ(Õ*r!   c                 óx   — | j                  | j                  d«       | j                  | j                  ddi«       y )Né   rF   rG   )ÚassertEqualrm   rn   r   s    r    Útest_serverVersionz*OurServerOurClientTests.test_serverVersionµ   s1   € Ø×Ñ˜×,Ñ,¨aÔ0Ø×Ñ˜Ÿ™¨°{Ð(CÕDr!   c                 ó¸   — | j                  t        j                  j                  | j                  j
                  «      d| j                  j
                  ›�«       y)z:
        It implements the ISFTPServer interface.
        zISFTPServer not provided by N)Ú
assertTruer   ÚISFTPServerÚ
providedByrq   rt   r   s    r    Útest_interface_implementationz5OurServerOurClientTests.test_interface_implementation¹   sC   € ð 	�‰Ü×$Ñ$×/Ñ/°·±×0BÑ0BÓCØ*¨4¯;©;×+=Ñ+=Ð*@ÐAõ	
r!   c                 ó0  ‡ ‡‡— ‰ j                   j                  dt        j                  t        j                  z  i «      }‰ j                  «        t        j                  Šg Šˆˆfd„}‰ j                  t        d|«       ˆˆ fd„}|j                  |«       |S )zW
        A file opened with C{openFile} is closed when the connection is lost.
        ó	   testfile1c                 ó8   •— ‰j                  | «        ‰| «       y r6   ©Úappend)ÚfdÚclosedÚoldCloses    €€r    ÚclosezJOurServerOurClientTests.test_openedFileClosedWithConnection.<locals>.closeÎ   s   ø€ Ø�M‰M˜"ÔÙ�R�Lr!   r‘   c                 ó¦  •— ‰j                   j                  | j                  dd     j                  }‰j                  j                  «        ‰j                  j                  «        ‰j                  j                  «        ‰j                  j                  «        ‰j                  ‰j                   j                  i «       ‰j                  |‰«       y )Né   )
rq   Ú	openFilesÚhandlerŽ   rx   r~   rw   r|   r‚   ÚassertIn)ÚopenFilerŽ   r�   r   s     €€r    Ú_fileOpenedzPOurServerOurClientTests.test_openedFileClosedWithConnection.<locals>._fileOpenedÔ   s˜   ø€ Ø—‘×&Ñ& x§¡°q°rÐ':Ñ;×>Ñ>ˆBØ× Ñ ×/Ñ/Ô1Ø× Ñ ×/Ñ/Ô1Ø× Ñ ×,Ñ,Ô.Ø× Ñ ×,Ñ,Ô.Ø×Ñ˜TŸ[™[×2Ñ2°BÔ7Ø�M‰M˜"˜fÕ%r!   )
rt   r—   r   ÚFXF_READÚ	FXF_WRITEry   r9   r‘   ÚpatchÚaddCallback)r   Údr‘   r˜   r�   r�   s   `   @@r    Ú#test_openedFileClosedWithConnectionz;OurServerOurClientTests.test_openedFileClosedWithConnectionÂ   s|   ú€ ð �K‰K× Ñ Øœ,×/Ñ/´,×2HÑ2HÑHÈ"ó
ˆð 	×ÑÔä—8‘8ˆØˆõ	ð 	�
‰
”2�w Ô&õ	&ð 	
�‰�kÔ"Øˆr!   c                 óŠ   ‡ — ‰ j                   j                  d«      }‰ j                  «        ˆ fd„}|j                  |«       |S )zh
        A directory opened with C{openDirectory} is close when the connection
        is lost.
        Ú c                 ó"  •— ‰j                   j                  «        ‰j                  j                  «        ‰j                   j                  «        ‰j                  j                  «        ‰j	                  ‰j
                  j                  i «       y r6   )rx   r~   rw   r|   r‚   rq   ÚopenDirs)ÚopenDirr   s    €r    Ú	_getFileszSOurServerOurClientTests.test_openedDirectoryClosedWithConnection.<locals>._getFilesè   se   ø€ Ø× Ñ ×/Ñ/Ô1Ø× Ñ ×/Ñ/Ô1Ø× Ñ ×,Ñ,Ô.Ø× Ñ ×,Ñ,Ô.Ø×Ñ˜TŸ[™[×1Ñ1°2Õ6r!   ©rt   ÚopenDirectoryry   rœ   )r   r�   r¤   s   `  r    Ú(test_openedDirectoryClosedWithConnectionz@OurServerOurClientTests.test_openedDirectoryClosedWithConnectionà   s=   ø€ ð
 �K‰K×%Ñ% bÓ)ˆØ×ÑÔô	7ð 	
�‰�iÔ Øˆr!   c                 óö   ‡ ‡‡‡— ‰ j                   j                  dt        j                  t        j                  z  i «      }‰ j                  «        ˆˆˆ fd„}ˆ fd„Šˆˆ fd„Šˆ fd„Š|j                  |«       |S )NrŠ   c                 ó†   •— ‰j                  | t        j                  | «      «        ‰| «      }|j                  ‰| «       |S r6   )r‚   r   Ú	ISFTPFilerœ   )r—   r�   Ú
_readChunkÚ_writeChunkr   s     €€€r    r˜   z<OurServerOurClientTests.test_openFileIO.<locals>._fileOpenedø   s;   ø€ Ø×Ñ˜X¤|×'=Ñ'=¸hÓ'GÔHÙ˜8Ó$ˆAØ�M‰M˜+ xÔ0ØˆHr!   c                 ó„   •— | j                  dd«      }‰j                  «        |j                  ‰j                  d«       |S )Nr   é   rZ   ©Ú	readChunkry   rœ   r‚   )r—   r�   r   s     €r    r«   z;OurServerOurClientTests.test_openFileIO.<locals>._readChunkþ   s;   ø€ Ø×"Ñ" 1 bÓ)ˆAØ×ÑÔ Ø�M‰M˜$×*Ñ*Ð,AÔBØˆHr!   c                 óp   •— |j                  dd«      }‰j                  «        |j                  ‰|«       |S )Nr®   s
   cccccccccc)Ú
writeChunkry   rœ   )rp   r—   r�   Ú_readChunk2r   s      €€r    r¬   z<OurServerOurClientTests.test_openFileIO.<locals>._writeChunk  s4   ø€ Ø×#Ñ# B¨	Ó2ˆAØ×ÑÔ Ø�M‰M˜+ xÔ0ØˆHr!   c                 ó„   •— |j                  dd«      }‰j                  «        |j                  ‰j                  d«       |S )Nr   é   s   aaaaaaaaaabbbbbbbbbbccccccccccr¯   ©rp   r—   r�   r   s      €r    r³   z<OurServerOurClientTests.test_openFileIO.<locals>._readChunk2
  s;   ø€ Ø×"Ñ" 1 bÓ)ˆAØ×ÑÔ Ø�M‰M˜$×*Ñ*Ð,MÔNØˆHr!   ©rt   r—   r   r™   rš   ry   rœ   )r   r�   r˜   r«   r³   r¬   s   `  @@@r    Útest_openFileIOz'OurServerOurClientTests.test_openFileIOò   sd   û€ Ø�K‰K× Ñ Øœ,×/Ñ/´,×2HÑ2HÑHÈ"ó
ˆð 	×ÑÔö	ô	õ	ô	ð 	
�‰�kÔ"Øˆr!   c                 óè   ‡ ‡‡— ‰ j                   j                  dt        j                  t        j                  z  i «      }‰ j                  «        ˆ fd„Šˆ fd„Šˆˆˆ fd„}|j                  |«       |S )NrŠ   c                 óH   •— |j                  «       }‰j                  «        |S r6   )ÚgetAttrsry   r¶   s      €r    Ú	_getAttrszBOurServerOurClientTests.test_closedFileGetAttrs.<locals>._getAttrs  s"   ø€ Ø×!Ñ!Ó#ˆAØ×ÑÔ ØˆHr!   c                 ó(   •— ‰j                  «        | S r6   )ÚflushLoggedErrors)r)   r   s    €r    Ú_errz=OurServerOurClientTests.test_closedFileGetAttrs.<locals>._err  s   ø€ Ø×"Ñ"Ô$ØˆHr!   c                 óÊ   •— | j                  «       }‰j                  «        |j                  ‰| «       |j                  ‰«       ‰j	                  |t
        j                  «      S r6   )r‘   ry   rœ   Ú
addErrbackÚassertFailurer   Ú	SFTPError)r—   r�   r¿   r¼   r   s     €€€r    Ú_closez?OurServerOurClientTests.test_closedFileGetAttrs.<locals>._close"  sN   ø€ Ø—‘Ó ˆAØ×ÑÔ Ø�M‰M˜) XÔ.Ø�L‰L˜ÔØ×%Ñ% a¬×)?Ñ)?Ó@Ð@r!   r·   )r   r�   rÄ   r¿   r¼   s   `  @@r    Útest_closedFileGetAttrsz/OurServerOurClientTests.test_closedFileGetAttrs  s`   ú€ Ø�K‰K× Ñ Øœ,×/Ñ/´,×2HÑ2HÑHÈ"ó
ˆð 	×ÑÔô	ô
	ö	Að 	
�‰�fÔØˆr!   c                 óÖ   ‡ ‡— ‰ j                   j                  dt        j                  t        j                  z  i «      }‰ j                  «        ˆˆ fd„}ˆ fd„Š|j                  |«      S )NrŠ   c                 ój   •— | j                  «       }‰j                  «        |j                  ‰«       |S r6   ©r»   ry   rœ   )r—   r�   Ú
_getAttrs2r   s     €€r    r¼   zBOurServerOurClientTests.test_openFileAttributes.<locals>._getAttrs2  s.   ø€ Ø×!Ñ!Ó#ˆAØ×ÑÔ Ø�M‰M˜*Ô%ØˆHr!   c                 ó–   •— ‰j                   j                  d«      }‰j                  «        |j                  ‰j                  | «       |S ©NrŠ   ©rt   r»   ry   rœ   r‚   )Úattrs1r�   r   s     €r    rÉ   zCOurServerOurClientTests.test_openFileAttributes.<locals>._getAttrs28  s<   ø€ Ø—‘×$Ñ$ \Ó2ˆAØ×ÑÔ Ø�M‰M˜$×*Ñ*¨FÔ3ØˆHr!   r·   )r   r�   r¼   rÉ   s   `  @r    Útest_openFileAttributesz/OurServerOurClientTests.test_openFileAttributes,  sX   ù€ Ø�K‰K× Ñ Øœ,×/Ñ/´,×2HÑ2HÑHÈ"ó
ˆð 	×ÑÔõ	ô	ð �}‰}˜YÓ'Ð'r!   c                 óè   ‡ ‡‡— ‰ j                   j                  dt        j                  t        j                  z  i «      }‰ j                  «        ˆˆ fd„}ˆˆ fd„Šˆ fd„Š|j                  |«       |S )NrŠ   c                 ój   •— | j                  «       }‰j                  «        |j                  ‰«       |S r6   rÈ   )r—   r�   Ú	_setAttrsr   s     €€r    r¼   z@OurServerOurClientTests.test_openFileSetAttrs.<locals>._getAttrsH  s.   ø€ Ø×!Ñ!Ó#ˆAØ×ÑÔ Ø�M‰M˜)Ô$ØˆHr!   c                 óÄ   •— d| d<   ‰j                   j                  d| «      }‰j                  «        |j                  ‰«       |j                  ‰j                  | «       |S )Nr   ÚatimerŠ   )rt   ÚsetAttrsry   rœ   r‚   )Úattrsr�   rÉ   r   s     €€r    rÑ   z@OurServerOurClientTests.test_openFileSetAttrs.<locals>._setAttrsN  sS   ø€ ØˆE�'‰NØ—‘×$Ñ$ \°5Ó9ˆAØ×ÑÔ Ø�M‰M˜*Ô%Ø�M‰M˜$×*Ñ*¨EÔ2ØˆHr!   c                 ó^   •— ‰j                   j                  d«      }‰j                  «        |S rË   ©rt   r»   ry   ©rp   r�   r   s     €r    rÉ   zAOurServerOurClientTests.test_openFileSetAttrs.<locals>._getAttrs2V  s(   ø€ Ø—‘×$Ñ$ \Ó2ˆAØ×ÑÔ ØˆHr!   r·   )r   r�   r¼   rÉ   rÑ   s   `  @@r    Útest_openFileSetAttrsz-OurServerOurClientTests.test_openFileSetAttrs@  sa   ú€ ð �K‰K× Ñ Øœ,×/Ñ/´,×2HÑ2HÑHÈ"ó
ˆð 	×ÑÔõ	õ	ô	ð
 	
�‰�iÔ Øˆr!   c                 óX  ‡ ‡‡— i Š‰ j                   j                  j                  Šˆˆfd„}|‰ j                   j                  _        ‰ j                  j                  dt        j                  t        j
                  z  ddi«      }‰ j                  «        ˆˆ fd„}|j                  |«      S )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                 ó:   •— ‰j                  |«        ‰| ||«      S r6   )Úupdate)ÚfilenameÚflagsrÕ   ÚoldOpenFileÚsavedAttributess      €€r    r—   zIOurServerOurClientTests.test_openFileExtendedAttributes.<locals>.openFileg  s    ø€ Ø×"Ñ" 5Ô)Ù˜x¨°Ó6Ð6r!   rŠ   Úext_foorM   c                 ó.   •— ‰j                  ‰ddi«       y )Nrá   rM   ©r‚   )Úignrà   r   s    €€r    ÚcheckzFOurServerOurClientTests.test_openFileExtendedAttributes.<locals>.checkt  s   ø€ Ø×Ñ˜_¨y¸&Ð.AÕBr!   )rq   rt   r—   r   r™   rš   ry   rœ   )r   r—   r�   rå   rß   rà   s   `   @@r    Útest_openFileExtendedAttributesz7OurServerOurClientTests.test_openFileExtendedAttributes^  s�   ú€ ð ˆØ—k‘k×(Ñ(×1Ñ1ˆõ	7ð '/ˆ�‰×ÑÔ#à�K‰K× Ñ ØÜ×!Ñ!¤L×$:Ñ$:Ñ:Ø˜Ðó
ˆð
 	×ÑÔõ	Cð �}‰}˜UÓ#Ð#r!   c                 óè   ‡ — ‰ j                   j                  d«      }‰ j                  «        ˆ fd„}|j                  |«       |j                  |«       ‰ j	                  |t
        j                  «      S )Nó   testRemoveFilec                 ó^   •— ‰j                   j                  d«      }‰j                  «        |S )Nrè   )rt   Ú
removeFilery   )Úignoredr�   r   s     €r    Ú_removeFilez<OurServerOurClientTests.test_removeFile.<locals>._removeFile}  s)   ø€ Ø—‘×&Ñ&Ð'8Ó9ˆAØ×ÑÔ ØˆHr!   )rt   r»   ry   rœ   rÂ   r   rÃ   )r   r�   rì   s   `  r    Útest_removeFilez'OurServerOurClientTests.test_removeFiley  s\   ø€ Ø�K‰K× Ñ Ð!2Ó3ˆØ×ÑÔô	ð
 	
�‰�kÔ"Ø	�‰�kÔ"Ø×!Ñ! !¤\×%;Ñ%;Ó<Ð<r!   c                 ó”   ‡ ‡— ‰ j                   j                  d«      }‰ j                  «        ˆˆ fd„}ˆ fd„Š|j                  |«      S )Nó   testRenameFilec                 ó„   •— ‰j                   j                  dd«      }‰j                  «        |j                  ‰| «       |S )Nrï   ó   testRenamedFile)rt   Ú
renameFilery   rœ   )rÕ   r�   Ú_testRenamedr   s     €€r    Ú_renamez8OurServerOurClientTests.test_renameFile.<locals>._renameŠ  s:   ø€ Ø—‘×&Ñ&Ð'8Ð:LÓMˆAØ×ÑÔ Ø�M‰M˜,¨Ô.ØˆHr!   c                 ó”   •— ‰j                   j                  d«      }‰j                  «        |j                  ‰j                  |«       y )Nrñ   rÌ   )rp   rÕ   r�   r   s      €r    ró   z=OurServerOurClientTests.test_renameFile.<locals>._testRenamed�  s8   ø€ Ø—‘×$Ñ$Ð%7Ó8ˆAØ×ÑÔ Ø�M‰M˜$×*Ñ*¨EÕ2r!   )rt   r»   ry   rœ   )r   r�   rô   ró   s   `  @r    Útest_renameFilez'OurServerOurClientTests.test_renameFile†  s?   ù€ Ø�K‰K× Ñ Ð!2Ó3ˆØ×ÑÔõ	ô	3ð
 �}‰}˜WÓ%Ð%r!   c                 ó˜   — | j                   j                  d«      }| j                  «        | j                  |t        j
                  «      S ©Nó   testMakeDirectory©rt   r»   ry   rÂ   r   rÃ   ©r   r�   s     r    Útest_directoryBadz)OurServerOurClientTests.test_directoryBad—  s<   € Ø�K‰K× Ñ Ð!5Ó6ˆØ×ÑÔØ×!Ñ! !¤\×%;Ñ%;Ó<Ð<r!   c                 ó  ‡ — ‰ j                   j                  di «      }‰ j                  «        ˆ fd„}ˆ fd„}|j                  |«       |j                  |«       |j                  |«       ‰ j	                  |t
        j                  «      S )Nrù   c                 ó^   •— ‰j                   j                  d«      }‰j                  «        |S rø   r×   rØ   s     €r    r¼   zAOurServerOurClientTests.test_directoryCreation.<locals>._getAttrs   s)   ø€ Ø—‘×$Ñ$Ð%9Ó:ˆAØ×ÑÔ ØˆHr!   c                 ó^   •— ‰j                   j                  d«      }‰j                  «        |S rø   )rt   ÚremoveDirectoryry   rØ   s     €r    Ú_removeDirectoryzHOurServerOurClientTests.test_directoryCreation.<locals>._removeDirectory©  s)   ø€ Ø—‘×+Ñ+Ð,@ÓAˆAØ×ÑÔ ØˆHr!   )rt   ÚmakeDirectoryry   rœ   rÂ   r   rÃ   )r   r�   r¼   r  s   `   r    Útest_directoryCreationz.OurServerOurClientTests.test_directoryCreationœ  sp   ø€ Ø�K‰K×%Ñ%Ð&:¸BÓ?ˆØ×ÑÔô	ô	ð
 	
�‰�iÔ Ø	�‰Ð&Ô'Ø	�‰�iÔ Ø×!Ñ! !¤\×%;Ñ%;Ó<Ð<r!   c                 óÒ   ‡ ‡‡‡— ‰ j                   j                  d«      }‰ j                  «        g Šˆˆˆˆ fd„Šˆˆ fd„}ˆ fd„Š|j                  ‰«       |j                  |«       |S )Nr!   c                 óÜ   •‡ — ˆˆ fd„}t        j                  ‰ j                  «      }‰j                  «        |j	                  |«       |j	                  ‰«       |j                  ‰‰ «       |S )Nc                 ó*   •— ‰j                  | «       ‰S r6   rŒ   )r)   Úfilesr£   s    €€r    r�   zMOurServerOurClientTests.test_openDirectory.<locals>._getFiles.<locals>.append¹  s   ø€ Ø—‘˜Q”Ø�r!   )r   ÚmaybeDeferredÚnextry   rœ   rÁ   )r£   r�   r�   rÄ   r¤   r  r   s   `  €€€€r    r¤   z=OurServerOurClientTests.test_openDirectory.<locals>._getFiles¸  sU   ù€ õô ×#Ñ# G§L¡LÓ1ˆAØ×ÑÔ Ø�M‰M˜&Ô!Ø�M‰M˜)Ô$Ø�L‰L˜ Ô)ØˆHr!   c                 óˆ   •— t        t        t        ‰Ž «      d   «      }|j                  «        ‰j                  |g d¢«       y )Nr   )s   .testHiddenFiles   testDirectoryrè   rï   rŠ   )ÚlistÚzipÚsortr‚   )rë   Úfsr  r   s     €€r    Ú_checkFilesz?OurServerOurClientTests.test_openDirectory.<locals>._checkFilesÄ  s:   ø€ Ü”dœ3 ˜;Ó'¨Ñ*Ó+ˆBØ�G‰GŒIØ×ÑØòõ	r!   c                 óH   •— |j                  «       }‰j                  «        |S r6   )r‘   ry   )rp   r£   r�   r   s      €r    rÄ   z:OurServerOurClientTests.test_openDirectory.<locals>._closeÒ  s   ø€ Ø—‘“ˆAØ×ÑÔ ØˆHr!   r¥   )r   r�   r  rÄ   r¤   r  s   `  @@@r    Útest_openDirectoryz*OurServerOurClientTests.test_openDirectory³  sV   û€ Ø�K‰K×%Ñ% cÓ*ˆØ×ÑÔØˆ÷
	õ	ô	ð
 	
�‰�iÔ Ø	�‰�kÔ"Øˆr!   c                 ó˜   — | j                   j                  d«      }| j                  «        | j                  |t        j
                  «      S )Nó   testLinkrú   rû   s     r    Útest_linkDoesntExistz,OurServerOurClientTests.test_linkDoesntExistÛ  s;   € Ø�K‰K× Ñ  Ó-ˆØ×ÑÔØ×!Ñ! !¤\×%;Ñ%;Ó<Ð<r!   c                 ó´   ‡ — ‰ j                   j                  dd«      }‰ j                  «        ˆ fd„}ˆ fd„}|j                  |«       |j                  |«      S )Nr  rŠ   c                 ó`   •— ‰j                   j                  dd«      }‰j                  «        |S )Nr  r#   r×   rØ   s     €r    Ú_getFirstAttrszDOurServerOurClientTests.test_linkSharesAttrs.<locals>._getFirstAttrsä  s*   ø€ Ø—‘×$Ñ$ [°!Ó4ˆAØ×ÑÔ ØˆHr!   c                 ó–   •— ‰j                   j                  d«      }‰j                  «        |j                  ‰j                  | «       |S rË   rÌ   )Ú
firstAttrsr�   r   s     €r    Ú_getSecondAttrszEOurServerOurClientTests.test_linkSharesAttrs.<locals>._getSecondAttrsé  s<   ø€ Ø—‘×$Ñ$ \Ó2ˆAØ×ÑÔ Ø�M‰M˜$×*Ñ*¨JÔ7ØˆHr!   ©rt   ÚmakeLinkry   rœ   )r   r�   r  r  s   `   r    Útest_linkSharesAttrsz,OurServerOurClientTests.test_linkSharesAttrsà  sL   ø€ Ø�K‰K× Ñ  ¨lÓ;ˆØ×ÑÔô	ô
	ð 	
�‰�nÔ%Ø�}‰}˜_Ó-Ð-r!   c                 ó¸   ‡ — ‰ j                   j                  dd«      }‰ j                  «        ˆ fd„}ˆ fd„}|j                  |«       |j                  |«       |S )Nr  rŠ   c                 óL  •— ‰j                   j                  d«      }‰j                  «        t        t	        j
                  «       «      j                  ‰j                  j                  «      }|j                  d«      }|j                  ‰j                  |j                  «       |S ©Nr  rW   )rt   ÚreadLinkry   r   r9   r:   r;   r`   r<   ra   rœ   r‚   )rp   r�   ÚtestFiler   s      €r    Ú	_readLinkz8OurServerOurClientTests.test_linkPath.<locals>._readLinkö  ós   ø€ Ø—‘×$Ñ$ [Ó1ˆAØ×ÑÔ Ü¤§	¡	£Ó,×9Ñ9¸$¿,¹,×:KÑ:KÓLˆHØ—~‘~ kÓ2ˆHØ�M‰M˜$×*Ñ*¨H¯M©MÔ:ØˆHr!   c                 óL  •— ‰j                   j                  d«      }‰j                  «        t        t	        j
                  «       «      j                  ‰j                  j                  «      }|j                  d«      }|j                  ‰j                  |j                  «       |S r   )rt   ÚrealPathry   r   r9   r:   r;   r`   r<   ra   rœ   r‚   )rp   r�   ÚtestLinkr   s      €r    Ú	_realPathz8OurServerOurClientTests.test_linkPath.<locals>._realPathþ  r$  r!   r  )r   r�   r#  r(  s   `   r    Útest_linkPathz%OurServerOurClientTests.test_linkPathò  sN   ø€ Ø�K‰K× Ñ  ¨lÓ;ˆØ×ÑÔô	ô	ð 	
�‰�iÔ Ø	�‰�iÔ Øˆr!   c                 óÌ   — | j                   j                  dd«      }| j                  «        |j                  | j                  d«       |j                  | j
                  «       |S )NrL   s   foorM   )rt   rQ   ry   rœ   r‚   Ú_cbTestExtendedRequestrû   s     r    Útest_extendedRequestz,OurServerOurClientTests.test_extendedRequest
  sP   € Ø�K‰K×'Ñ'Ð(>ÀÓGˆØ×ÑÔØ	�‰�d×&Ñ&¨Ô/Ø	�‰�d×1Ñ1Ô2Øˆr!   c                 ó†   — | j                   j                  dd«      }| j                  «        | j                  |t        «      S )Ns   testBadRequestr!   )rt   rQ   ry   rÂ   rN   )r   rë   r�   s      r    r+  z.OurServerOurClientTests._cbTestExtendedRequest  s9   € Ø�K‰K×'Ñ'Ð(9¸3Ó?ˆØ×ÑÔØ×!Ñ! !Ô%8Ó9Ð9r!   c              #   ót  K  — | j                   j                  d«      }| j                  «        |–—}|j                  «       }| j                  «        |–— | j	                  «       }d}| j                  dt        |«      «       | j                  t        |d   d   «       | j                  ||d   d   «       y­w)zJ
        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)rt   r¦   ry   r	  ÚflushWarningsr‚   r(   ÚDeprecationWarning)r   r�   r£   ÚoneFileÚwarningsr0  s         r    Ú$test_openDirectoryIteratorDeprecatedz<OurServerOurClientTests.test_openDirectoryIteratorDeprecated  s­   è ø€ ð
 �K‰K×%Ñ% cÓ*ˆØ×ÑÔØ‘'ˆØ—,‘,“.ˆØ×ÑÔØŠà×%Ñ%Ó'ˆð@ð 	ð 	×Ñ˜œC ›MÔ*Ø×ÑÔ+¨X°a©[¸Ñ-DÔEØ×Ñ˜ (¨1¡+¨iÑ"8Õ9ùs   ‚B6B8c              #   ó  ‡ ‡K  — ‰ j                   j                  dt        j                  i «      }‰ j	                  «        |–—}g Šˆˆ fd„}‰ j
                  j                  j                  «       \  }||_        ~|j                  dd«      }‰ j	                  «        ‰ j                  t        ‰«      d«       ‰ j                  |«       ‰ j                  j                  «        ‰ j                  j                  «        ‰ j                  j                  «        ‰ j	                  «        ‰ j!                  ‰ j                   j"                  «       ‰ j%                  |t&        «       |j)                  «       }‰ j%                  |t&        «       y­w)z{
        If there are requests outstanding when the connection
        is closed for any reason, they should fail.
        rŠ   c                 óv   •— ‰j                  ‰g «       t        j                  «       }‰j                  | «       |S r6   )r‚   r   ÚDeferredr�   )ÚoffsetÚlengthr�   ÚgotReadRequestr   s      €€r    Ú	_slowReadzOOurServerOurClientTests.test_closedConnectionCancelsRequests.<locals>._slowRead9  s2   ø€ Ø×Ñ˜^¨RÔ0Ü—‘Ó ˆAØ×!Ñ! &Ô)ØˆHr!   éd   éÈ   r#   N)rt   r—   r   r™   ry   rq   r”   Úvaluesr°   r‚   r(   ÚassertNoResultrx   r~   r|   rw   ÚassertFalseÚ	connectedÚfailureResultOfr   r»   )r   r�   Úfhr<  ÚserverSideFhr;  s   `    @r    Ú$test_closedConnectionCancelsRequestsz<OurServerOurClientTests.test_closedConnectionCancelsRequests+  s7  ùè ø€ ð �K‰K× Ñ  ¬|×/DÑ/DÀbÓIˆØ×ÑÔØ‰Wˆð ˆõ	ð Ÿ™×.Ñ.×5Ñ5Ó7‰ˆØ!*ˆÔØð �L‰L˜˜cÓ"ˆØ×ÑÔØ×Ñœ˜^Ó,¨aÔ0Ø×Ñ˜AÔð 	×Ñ×+Ñ+Ô-Ø×Ñ×(Ñ(Ô*Ø×Ñ×(Ñ(Ô*Ø×ÑÔà×Ñ˜Ÿ™×.Ñ.Ô/Ø×Ñ˜Q¤Ô/ð �K‰K‹MˆØ×Ñ˜Q¤Õ/ùs   „FFN)r0   r1   r2   rh   ry   r   rƒ   rˆ   rž   r§   r¸   rÅ   rÎ   rÙ   ræ   rí   rö   rü   r  r  r  r  r)  r,  r+  r   ÚinlineCallbacksr5  rF  r$   r!   r    rj   rj   �   s§   „ òò2/ò
+òEò
òò<ò$òBò2(ò(ò<$ò6=ò&ò"=ò
=ò.&òP=ò
.ò$ò0ò:ð
 ×Ññ:ó ð:ð( ×Ññ*0ó ñ*0r!   rj   c                   ó   — e Zd Zd„ Zy)ÚFakeConnc                  ó   — y r6   r$   )r   Úchannels     r    Ú	sendClosezFakeConn.sendCloseZ  s   € Ør!   N)r0   r1   r2   rL  r$   r!   r    rI  rI  Y  s   „ ór!   rI  c                   ó6   — e Zd Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	y)	ÚFileTransferCloseTestsc                 ó"   — t        «       | _        y r6   )r   rB   r   s    r    rh   zFileTransferCloseTests.setUp`  s   € Ü “lˆ�r!   c                 ó�   — t        j                  «       } G d„ d«      } |«       |_        | j                  |j                  _        |S )Nc                   ó   — e Zd Zd„ Zd„ Zd„ Zy)úDFileTransferCloseTests.buildServerConnection.<locals>.DummyTransportc                 ó   — | | _         y r6   )Ú	transportr   s    r    r   zMFileTransferCloseTests.buildServerConnection.<locals>.DummyTransport.__init__i  s	   € Ø!%�•r!   c                  ó   — y r6   r$   )r   ÚkindÚdatas      r    Ú
sendPacketzOFileTransferCloseTests.buildServerConnection.<locals>.DummyTransport.sendPacketl  s   € Ør!   c                  ó   — y)Nzdummy transportr$   r   s    r    Ú	logPrefixzNFileTransferCloseTests.buildServerConnection.<locals>.DummyTransport.logPrefixo  s   € Ø(r!   N)r0   r1   r2   r   rX  rZ  r$   r!   r    ÚDummyTransportrR  h  s   „ ò&òó)r!   r[  )r   ÚSSHConnectionrT  rB   )r   Úconnr[  s      r    ÚbuildServerConnectionz,FileTransferCloseTests.buildServerConnectionc  s;   € ä×'Ñ'Ó)ˆ÷	)ñ 	)ñ (Ó)ˆŒØ $§¡ˆ�‰ÔØˆr!   c                 óH   ‡ ‡— d‰ _         |j                  Šˆˆ fd„}||_        y )NFc                 ó$   •— d‰_          ‰| «       y )NT)ÚconnectionLostFired)ÚreasonÚorigConnectionLostr   s    €€r    ÚconnectionLostzFFileTransferCloseTests.interceptConnectionLost.<locals>.connectionLostz  s   ø€ Ø'+ˆDÔ$Ù˜vÕ&r!   )ra  rd  )r   Ú
sftpServerrd  rc  s   `  @r    ÚinterceptConnectionLostz.FileTransferCloseTests.interceptConnectionLostv  s&   ù€ Ø#(ˆÔ Ø'×6Ñ6Ðõ	'ð %3ˆ
Õ!r!   c                 ó<   — | j                  | j                  d«       y )Nz*sftpServer's connectionLost was not called)r…   ra  r   s    r    ÚassertSFTPConnectionLostz/FileTransferCloseTests.assertSFTPConnectionLost€  s   € Ø�‰Ø×$Ñ$Ð&Rõ	
r!   c                 ó@  — t        j                  t        «       | j                  ¬«      }|j	                  t        j                  d«      «       |j                  j                  j                  }| j                  |«       |j                  «        | j                  «        y)ze
        Closing a session should notify an SFTP subsystem launched by that
        session.
        )r]  rB   r   N)r   r   rI  rB   Úrequest_subsystemr   ÚNSrt   rT  Úprotorf  ÚcloseReceivedrh  )r   ÚtestSessionre  s      r    Útest_sessionClosez(FileTransferCloseTests.test_sessionClose…  sv   € ô ×(Ñ(¬h«jÀÇÁÔMˆð 	×%Ñ%¤f§i¡i°Ó&8Ô9Ø ×'Ñ'×1Ñ1×7Ñ7ˆ
ð 	×$Ñ$ ZÔ0ð 	×!Ñ!Ô#à×%Ñ%Õ'r!   c                 óø  — | j                  «       }t        j                  d«      t        j                  dd«      dz  z   }|j                  |«       |j                  d   }|j                  t        j                  d«      «       |j                  j                  j                  }| j                  |«       | j                  |«       |j                  t        j                  dd«      «       | j                  «        y)zy
        A client sending CHANNEL_CLOSE should trigger closeReceived on the
        associated channel instance.
        r   ú>Lr   r�   r   N)r^  r   rk  ÚstructÚpackÚssh_CHANNEL_OPENÚchannelsrj  rt   rT  rl  rf  Ússh_CHANNEL_CLOSErh  ©r   r]  ÚpacketÚsessionChannelre  s        r    Ú%test_clientClosesChannelOnConnnectionz<FileTransferCloseTests.test_clientClosesChannelOnConnnection™  sÆ   € ð
 ×)Ñ)Ó+ˆô —‘˜:Ó&¬¯©°T¸1Ó)=ÀÑ)AÑAˆØ×Ñ˜fÔ%ØŸ™ qÑ)ˆà×(Ñ(¬¯©°7Ó);Ô<Ø#×*Ñ*×4Ñ4×:Ñ:ˆ
Ø×$Ñ$ ZÔ0ð 	×$Ñ$ ZÔ0ð 	×ÑœvŸ{™{¨4°Ó3Ô4à×%Ñ%Õ'r!   c                 ó¬  — | j                  «       }t        j                  d«      t        j                  dd«      dz  z   }|j                  |«       |j                  d   }|j                  t        j                  d«      «       |j                  j                  j                  }| j                  |«       |j                  «        | j                  «        y)zP
        Closing an SSH connection should close all sessions within it.
        r   rq  r   r�   r   N)r^  r   rk  rr  rs  rt  ru  rj  rt   rT  rl  rf  ÚserviceStoppedrh  rw  s        r    Ú'test_stopConnectionServiceClosesChannelz>FileTransferCloseTests.test_stopConnectionServiceClosesChannel±  s©   € ð ×)Ñ)Ó+ˆô —‘˜:Ó&¬¯©°T¸1Ó)=ÀÑ)AÑAˆØ×Ñ˜fÔ%ØŸ™ qÑ)ˆà×(Ñ(¬¯©°7Ó);Ô<Ø#×*Ñ*×4Ñ4×:Ñ:ˆ
Ø×$Ñ$ ZÔ0ð 	×ÑÔà×%Ñ%Õ'r!   N)
r0   r1   r2   rh   r^  rf  rh  ro  rz  r}  r$   r!   r    rN  rN  ^  s%   „ ò#òò&3ò
ò
(ò((ó0(r!   rN  zCannot run without cryptographyc                   ó   — e Zd ZdZg d¢Zd„ Zy)ÚConstantsTestsag  
    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                 óŒ  — i }| j                   D ]]  }|j                  «       D ]H  }t        j                  d|«      }|sŒt	        |j                  d«      d«      ||j                  d«      <   ŒJ Œ_ | j                  t        |«      dkD  d«       |j                  «       D ]%  \  }}| j                  |t        t        |«      «       Œ' y)z�
        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_constantsAgainstSpecz(ConstantsTests.test_constantsAgainstSpec  s»   € ð
 ˆ	Ø×0Ñ0ò 	?ˆGØ×*Ñ*Ó,ò ?�Ü—H‘HÐIÈ4ÓP�ÚÜ,/°·±¸³
¸AÓ,>�I˜aŸg™g a›jÒ)ñ?ð	?ð
 	�‰Ü�	‹N˜QÑÐ Nô	
ð —O‘OÓ%ò 	:‰DˆAˆqØ×Ñ˜Q¤¬°aÓ 8Õ9ñ	:r!   N)r0   r1   r2   Ú__doc__r�  r�  r$   r!   r    r  r  Æ  s   „ ñòJÐóX:r!   r  c                   ó   — e Zd ZdZd„ Zd„ Zy)ÚRawPacketDataServerTestszŒ
    Tests for L{filetransfer.FileTransferServer} which explicitly craft
    certain less common situations to exercise their handling.
    c                 óJ   — t        j                  t        «       ¬«      | _        y )NrA   )r   r   r   Úftsr   s    r    rh   zRawPacketDataServerTests.setUp9  s   € Ü×2Ñ2¼*»,ÔGˆ�r!   c                 óú  — t        «       }| j                  j                  |«       d}d}t        j                  t        dg«      |z   t        j                  |«      z   «      }| j                  j                  |«       t        j                  t        dg«      |z   t        g d¢«      z   t        j                  d«      z   t        j                  d«      z   «      }t        |j                  «       t        |«      «       y)	zl
        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”  rv   r   rk  ÚbytesÚdataReceivedr   Úvaluer   )r   rT  Ú	requestIdr•   r‘   Úexpecteds         r    Útest_closeInvalidHandlez0RawPacketDataServerTests.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!   N)r0   r1   r2   r�  rh   rœ  r$   r!   r    r’  r’  1  s   „ ñò
Hó1
r!   r’  c                   ó:   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zd„ Z	d„ Z
y	)
ÚRawPacketDataTestsz“
    Tests for L{filetransfer.FileTransferClient} which explicitly craft certain
    less common protocol messages to exercise their handling.
    c                 ó6   — t        j                  «       | _        y r6   )r   rs   Úftcr   s    r    rh   zRawPacketDataTests.setUpw  s   € Ü×2Ñ2Ó4ˆ�r!   c                 ón  — t        j                  «       }|j                  | j                  «       || j                  j
                  d<   t        j                  ddt        j                  «      t        j                  d«      z   t        j                  d«      z   }| j                  j                  |«       |S )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   r8  rœ   Ú_cbTestPacketSTATUSr   ÚopenRequestsrr  rs  r   ÚFX_OKr   rk  Úpacket_STATUS©r   r�   rW  s      r    Útest_packetSTATUSz$RawPacketDataTests.test_packetSTATUSz  sŒ   € ô �N‰NÓˆØ	�‰�d×.Ñ.Ô/Ø#$ˆ�‰×Ñ˜aÑ ä�K‰K˜˜q¤,×"4Ñ"4Ó5Ü�i‰i˜Óñ ä�i‰i˜Ó ñ!ð 	ð
 	�‰×Ñ˜tÔ$Øˆr!   c                 óX   — | j                  |d   d«       | j                  |d   d«       y)z{
        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¥  z&RawPacketDataTests._cbTestPacketSTATUS�  s,   € ð
 	×Ñ˜ ™ FÔ+Ø×Ñ˜ ™ GÕ,r!   c                 ó  — t        j                  «       }|j                  | j                  «       || j                  j
                  d<   t        j                  ddt        j                  «      }| j                  j                  |«       |S )az  
        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   r8  rœ   Ú_cbTestPacketSTATUSShortr   r¦  rr  rs  r   r§  r¨  r©  s      r    Útest_packetSTATUSShortz)RawPacketDataTests.test_packetSTATUSShort•  se   € ô �N‰NÓˆØ	�‰�d×3Ñ3Ô4Ø#$ˆ�‰×Ñ˜aÑ Ü�{‰{˜5 !¤\×%7Ñ%7Ó8ˆØ�‰×Ñ˜tÔ$Øˆr!   c                 óX   — | j                  |d   d«       | j                  |d   d«       y)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¯  z+RawPacketDataTests._cbTestPacketSTATUSShort¥  s,   € ð
 	×Ñ˜ ™ CÔ(Ø×Ñ˜ ™ CÕ(r!   c                 óB  — t        j                  «       }|j                  | j                  «       || j                  j
                  d<   t        j                  ddt        j                  «      t        j                  d«      z   }| j                  j                  |«       |S )a›  
        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   r8  rœ   Ú_cbTestPacketSTATUSWithoutLangr   r¦  rr  rs  r   r§  r   rk  r¨  r©  s      r    Útest_packetSTATUSWithoutLangz/RawPacketDataTests.test_packetSTATUSWithoutLang­  ss   € ô �N‰NÓˆØ	�‰�d×9Ñ9Ô:Ø#$ˆ�‰×Ñ˜aÑ Ü�{‰{˜5 !¤\×%7Ñ%7Ó8¼6¿9¹9ÀVÓ;LÑLˆØ�‰×Ñ˜tÔ$Øˆr!   c                 óX   — | j                  |d   d«       | j                  |d   d«       y)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³  z1RawPacketDataTests._cbTestPacketSTATUSWithoutLang¾  s,   € ð
 	×Ñ˜ ™ FÔ+Ø×Ñ˜ ™ CÕ(r!   N)r0   r1   r2   r�  rh   rª  r¥  r°  r¯  r´  r³  r$   r!   r    rž  rž  p  s*   „ ñò
5òò&-òò )òó")r!   rž  )8r�  r9   rƒ  rr  Ú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   r4   r?   r4  ÚwarnrD   ÚregisterAdapterr†   rS   rj   rI  rN  r  r’  rž  r$   r!   r    ú<module>rÌ     sM  ðñ
ó
 
Û 	Û Ý ç *å "Ý 1Ý 4Ý &Ý %Ý ,Ý +ðÝ+ð €Dð=õð "=Ðð!Û(ð !€LðÝ<ð €Ið	ßKÓKô
�ô ô&E˜Zô E÷ñ ð
 Ð%ó à€H‡M‚Mò
 ð		õô&Ð$>ô &ð €J×ÑØ! :¨|×/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   ÁE7 ÁF ÁF Á!F! Á*F/ Å7FÆFÆFÆFÆFÆFÆ!F,Æ+F,Æ/F8Æ7F8