HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/conch/test/__pycache__/test_filetransfer.cpython-38.pyc
U

\�[7r�@s�dZddlmZmZddlZddlZddlZddlmZddl	m
Z
ed�Zed�Zer~ddl
mZdd	lmZmZmZmZnGd
d�d�ZddlmZdd
lmZddlmZddlmZmZddlmZGdd�dej�Z Gdd�de �Z!Gdd�d�Z"e�rNe#ed��s,ddl$Z$e$�%def�dZn"Gdd�dej&�Z'e�(e'e ej)�Gdd�de
j*�Z+Gdd�de+�Z,Gdd �d �Z-Gd!d"�d"e
j*�Z.Gd#d$�d$e
j*�Z/Gd%d&�d&e
j*�Z0dS)'z.
Tests for L{twisted.conch.ssh.filetransfer}.
�)�division�absolute_importN)�
requireModule)�unittest�cryptographyztwisted.conch.unix��avatar)�common�
connection�filetransfer�sessionc@seZdZGdd�d�ZdS)rc@seZdZdS)zavatar.ConchUserN)�__name__�
__module__�__qualname__�rr�F/usr/lib/python3/dist-packages/twisted/conch/test/test_filetransfer.py�	ConchUsersrN)r
rrrrrrrrsr)�defer)�loopback)�
components)�long�	_PY37PLUS)�FilePathc@seZdZdd�Zdd�ZdS)�
TestAvatarcCs(tj�|�tj|jd<tj|jd<dS)N�session�sftp)	rr�__init__r�
SSHSessionZ
channelLookupr�FileTransferServerZsubsystemLookup��selfrrrr$szTestAvatar.__init__cOs~zt|�}Wn tk
r,|||fg}YnX|D]F}|d}t|�dkrR|dpTd}t|�dkrj|dpli}|||�}q2|S)Nr�r�)�iter�	TypeError�len)r �f�args�kw�i�func�rrrr�
_runAsUser)szTestAvatar._runAsUserN)r
rrrr,rrrrr#src@seZdZdd�Zdd�ZdS)�FileTransferTestAvatarcCst�|�||_dS�N)rr�homeDir)r r/rrrr8s
zFileTransferTestAvatar.__init__cCstt����|jj�Sr.)r�os�getcwd�preauthChildr/�pathrrrr�
getHomeDir<sz!FileTransferTestAvatar.getHomeDirN)r
rrrr4rrrrr-6sr-c@seZdZdd�ZdS)�ConchSessionForTestAvatarcCs
||_dSr.r)r rrrrrBsz"ConchSessionForTestAvatar.__init__N)r
rrrrrrrr5@sr5�SFTPServerForUnixConchUserzNtwisted.conch.unix imported %r, but doesn't define SFTPServerForUnixConchUser'c@seZdZdd�Zdd�ZdS)�FileTransferForTestAvatarcCsddiS)N�	conchTest�ext datar)r �versionZotherExtrrr�
gotVersionQsz$FileTransferForTestAvatar.gotVersioncCs|dkrdSt�dS)N�testExtendedRequest�bar)�NotImplementedError)r ZextName�extDatarrr�extendedRequestTsz)FileTransferForTestAvatar.extendedRequestN)r
rrr;r@rrrrr7Osr7c@seZdZdd�ZdS)�SFTPTestBasec
Cst|���|_|j�d�|_|j�d��d�|j�d�jdd��6}|�d�tdd	��}|�|�d
��W5QRXW5QRX|j�d��d�|j�d�jdd��}|�d
�W5QRX|j�d�jdd��}|�d
�W5QRX|j�d�jdd��}|�d
�W5QRXdS)NZextraZ
testDirectoryT�	testfile1�wb)�mode�aaaaaaaaaabbbbbbbbbbz/dev/urandom�rbii�ZtestRemoveFile�aZtestRenameFilez.testHiddenFile)	rZmktemp�testDir�child�makedirs�open�write�read�chmod)r r&�f2rrr�setUp_s
$zSFTPTestBase.setUpN)r
rrrPrrrrrA]srAc@s�eZdZesdZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zejd.d/��Zer�d0e_ejd1d2��Zd3S)4�OurServerOurClientTests� can't run on non-posix computerscs�t���t�j��_tj�jd��_t�	�j�}t�
��_d�_d�_
�fdd�}|�j_t�	�j�}�j�|��j�|�|�_|�_���dS)Nrcs|�_|�_dSr.)�_serverVersion�_extData)Z
serverVersionr?rrr�_�sz(OurServerOurClientTests.setUp.<locals>._)rArPr-rHrrr�serverrZ
LoopbackRelay�FileTransferClient�clientrSrTZgotServerVersionZmakeConnection�clientTransport�serverTransport�
_emptyBuffers)r rYrUrZrrrrPxs

zOurServerOurClientTests.setUpcCs*|jjs|jjr&|j��|j��qdSr.)rZ�bufferrY�clearBufferrrrrr[�s
z%OurServerOurClientTests._emptyBufferscCs,|j��|j��|j��|j��dSr.)rZ�loseConnectionrYr]rrrr�tearDown�s


z OurServerOurClientTests.tearDowncCs$|�|jd�|�|jddi�dS)N�r8r9)�assertEqualrSrTrrrr�test_serverVersion�sz*OurServerOurClientTests.test_serverVersioncCs&|�tj�|jj�d|jjf�dS)z:
        It implements the ISFTPServer interface.
        zISFTPServer not provided by %rN)�
assertTruer�ISFTPServerZ
providedByrVrXrrrr�test_interface_implementation�s�z5OurServerOurClientTests.test_interface_implementationcsb�j�dtjtjBi�}���tj�g���fdd�}��td|���fdd�}|�	|�|S)zV
        A file opened with C{openFile} is close when the connection is lost.
        �	testfile1cs��|��|�dSr.��append)�fd)�closed�oldCloserr�close�s
zJOurServerOurClientTests.test_openedFileClosedWithConnection.<locals>.closerlcs`�jj|jdd�j}�j���j���j���j�����jji���	|��dS)N�)
rVZ	openFilesZhandlerirZr^rYr]raZassertIn)�openFileri)rjr rr�_fileOpened�s



zPOurServerOurClientTests.test_openedFileClosedWithConnection.<locals>._fileOpened)
rXrnr�FXF_READ�	FXF_WRITEr[r0rlZpatch�addCallback)r �drlror)rjrkr r�#test_openedFileClosedWithConnection�s��	
z;OurServerOurClientTests.test_openedFileClosedWithConnectioncs.�j�d�}����fdd�}|�|�|S)zh
        A directory opened with C{openDirectory} is close when the connection
        is lost.
        �cs<�j���j���j���j�����jji�dSr.)rZr^rYr]rarVZopenDirs��openDirrrr�	_getFiles�s




zSOurServerOurClientTests.test_openedDirectoryClosedWithConnection.<locals>._getFiles�rX�
openDirectoryr[rr)r rsrxrrr�(test_openedDirectoryClosedWithConnection�s

z@OurServerOurClientTests.test_openedDirectoryClosedWithConnectioncsd�j�dtjtjBi�}������fdd�}�fdd����fdd���fdd	��|�|�|S)
Nrfcs*��|t�|���|�}|��|�|Sr.)rarZ	ISFTPFilerr�rnrs)�
_readChunk�_writeChunkr rrro�sz<OurServerOurClientTests.test_openFileIO.<locals>._fileOpenedcs&|�dd�}���|��jd�|S)Nr�rE�Z	readChunkr[rrrar|rrrr}�sz;OurServerOurClientTests.test_openFileIO.<locals>._readChunkcs$|�dd�}���|��|�|S)Nrs
cccccccccc)Z
writeChunkr[rr�rUrnrs)�_readChunk2r rrr~�sz<OurServerOurClientTests.test_openFileIO.<locals>._writeChunkcs&|�dd�}���|��jd�|S)Nr�saaaaaaaaaabbbbbbbbbbccccccccccr�r�rrrr��sz<OurServerOurClientTests.test_openFileIO.<locals>._readChunk2�rXrnrrprqr[rr)r rsror)r}r�r~r r�test_openFileIO�s��
z'OurServerOurClientTests.test_openFileIOcsV�j�dtjtjBi�}����fdd���fdd�����fdd�}|�|�|S)Nrfcs|��}���|Sr.)�getAttrsr[r�rrr�	_getAttrsszBOurServerOurClientTests.test_closedFileGetAttrs.<locals>._getAttrscs���|Sr.)ZflushLoggedErrors�r&rrr�_errsz=OurServerOurClientTests.test_closedFileGetAttrs.<locals>._errcs4|��}���|��|�|�����|tj�Sr.)rlr[rr�
addErrback�
assertFailurer�	SFTPErrorr|�r�r�r rr�_close
s

z?OurServerOurClientTests.test_closedFileGetAttrs.<locals>._closer�)r rsr�rr�r�test_closedFileGetAttrs�s��
z/OurServerOurClientTests.test_closedFileGetAttrscsD�j�dtjtjBi�}�����fdd�}�fdd��|�|�S)Nrfcs|��}���|���|Sr.�r�r[rrr|��
_getAttrs2r rrr�s
zBOurServerOurClientTests.test_openFileAttributes.<locals>._getAttrscs&�j�d�}���|��j|�|S�Nrf�rXr�r[rrra)Zattrs1rsrrrr� szCOurServerOurClientTests.test_openFileAttributes.<locals>._getAttrs2r��r rsr�rr�r�test_openFileAttributess��z/OurServerOurClientTests.test_openFileAttributescsV�j�dtjtjBi�}�����fdd�}��fdd���fdd��|�|�|S)Nrfcs|��}���|���|Sr.r�r|)�	_setAttrsr rrr�0s
z@OurServerOurClientTests.test_openFileSetAttrs.<locals>._getAttrscs:d|d<�j�d|�}���|���|��j|�|S)NrZatimerf)rXZsetAttrsr[rrra��attrsrsr�rrr�6s
z@OurServerOurClientTests.test_openFileSetAttrs.<locals>._setAttrscs�j�d�}���|Sr��rXr�r[�rUrsrrrr�>szAOurServerOurClientTests.test_openFileSetAttrs.<locals>._getAttrs2r�r�r)r�r�r r�test_openFileSetAttrs)s��
z-OurServerOurClientTests.test_openFileSetAttrscsbi��jjj���fdd�}|�jj_�j�dtjtjBddi�}�����fdd�}|�|�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.
        cs��|��|||�Sr.)�update)�filename�flagsr�)�oldOpenFile�savedAttributesrrrnOs
zIOurServerOurClientTests.test_openFileExtendedAttributes.<locals>.openFilerf�ext_foor=cs���ddi�dS)Nr�r=�ra)Zign)r�r rr�checkXszFOurServerOurClientTests.test_openFileExtendedAttributes.<locals>.check)rVrXrnrrprqr[rr)r rnrsr�r)r�r�r r�test_openFileExtendedAttributesGs

��z7OurServerOurClientTests.test_openFileExtendedAttributescsB�j�d�}����fdd�}|�|�|�|���|tj�S)N�testRemoveFilecs�j�d�}���|S)Nr�)rXZ
removeFiler[)�ignoredrsrrr�_removeFilebsz<OurServerOurClientTests.test_removeFile.<locals>._removeFile)rXr�r[rrr�rr�)r rsr�rrr�test_removeFile^s

z'OurServerOurClientTests.test_removeFilecs8�j�d�}�����fdd�}�fdd��|�|�S)N�testRenameFilecs&�j�dd�}���|��|�|S)Nr��testRenamedFile)rXZ
renameFiler[rrr���_testRenamedr rr�_renamepsz8OurServerOurClientTests.test_renameFile.<locals>._renamecs&�j�d�}���|��j|�dS)Nr�r�)rUr�rsrrrr�vsz=OurServerOurClientTests.test_renameFile.<locals>._testRenamed)rXr�r[rr)r rsr�rr�r�test_renameFilels
z'OurServerOurClientTests.test_renameFilecCs"|j�d�}|��|�|tj�S�N�testMakeDirectory�rXr�r[r�rr��r rsrrr�test_directoryBad~sz)OurServerOurClientTests.test_directoryBadcsZ�j�di�}����fdd�}�fdd�}|�|�|�|�|�|���|tj�S)Nr�cs�j�d�}���|Sr�r�r�rrrr��szAOurServerOurClientTests.test_directoryCreation.<locals>._getAttrscs�j�d�}���|Sr�)rXZremoveDirectoryr[r�rrr�_removeDirectory�szHOurServerOurClientTests.test_directoryCreation.<locals>._removeDirectory)rXZ
makeDirectoryr[rrr�rr�)r rsr�r�rrr�test_directoryCreation�s	


z.OurServerOurClientTests.test_directoryCreationcs\�j�d�}���g�����fdd����fdd�}�fdd��|���|�|�|S)N�csF��fdd�}t��j�}���|�|�|���|����|S)Ncs��|��Sr.rgr�)�filesrwrrrh�s
zMOurServerOurClientTests.test_openDirectory.<locals>._getFiles.<locals>.append)rZ
maybeDeferred�nextr[rrr�)rwrhrs�r�rxr�r rvrrx�s

z=OurServerOurClientTests.test_openDirectory.<locals>._getFilescs6ttt���d�}|����|dddddg�dS)Nr�.testHiddenFile�
testDirectoryr�r�rf)�list�zip�sortra)r�Zfs)r�r rr�_checkFiles�s��z?OurServerOurClientTests.test_openDirectory.<locals>._checkFilescs|��}���|Sr.)rlr[)rUrwrsrrrr��sz:OurServerOurClientTests.test_openDirectory.<locals>._closery)r rsr�rr�r�test_openDirectory�s

z*OurServerOurClientTests.test_openDirectorycCs"|j�d�}|��|�|tj�S)N�testLinkr�r�rrr�test_linkDoesntExist�sz,OurServerOurClientTests.test_linkDoesntExistcsB�j�dd�}����fdd�}�fdd�}|�|�|�|�S)Nr�rfcs�j�dd�}���|S)Nr�r!r�r�rrr�_getFirstAttrs�szDOurServerOurClientTests.test_linkSharesAttrs.<locals>._getFirstAttrscs&�j�d�}���|��j|�|Sr�r�)Z
firstAttrsrsrrr�_getSecondAttrs�szEOurServerOurClientTests.test_linkSharesAttrs.<locals>._getSecondAttrs�rXZmakeLinkr[rr)r rsr�r�rrr�test_linkSharesAttrs�s
z,OurServerOurClientTests.test_linkSharesAttrscsF�j�dd�}����fdd�}�fdd�}|�|�|�|�|S)Nr�rfcsH�j�d�}���tt�����jj�}|�	d�}|�
�j|j�|S�Nr�rB)rXZreadLinkr[rr0r1r2rHr3rIrrra)rUrsZtestFilerrr�	_readLink�s
�z8OurServerOurClientTests.test_linkPath.<locals>._readLinkcsH�j�d�}���tt�����jj�}|�	d�}|�
�j|j�|Sr�)rXZrealPathr[rr0r1r2rHr3rIrrra)rUrsZtestLinkrrr�	_realPath�s
�z8OurServerOurClientTests.test_linkPath.<locals>._realPathr�)r rsr�r�rrr�
test_linkPath�s



z%OurServerOurClientTests.test_linkPathcCs4|j�dd�}|��|�|jd�|�|j�|S)Nr<sfoor=)rXr@r[rrra�_cbTestExtendedRequestr�rrr�test_extendedRequest�s
z,OurServerOurClientTests.test_extendedRequestcCs"|j�dd�}|��|�|t�S)NstestBadRequestr�)rXr@r[r�r>)r r�rsrrrr��sz.OurServerOurClientTests._cbTestExtendedRequestc	cs�|j�d�}|��|V}t�}z,|D]"}|��|V\}}}|�|�q&W5|��}|��|VX|��|�|tdddddg��dS)z�
        Check that the object returned by
        L{filetransfer.FileTransferClient.openDirectory} can be used
        as an iterator.
        r�r�r�r�r�rfN)rXrzr[�setrl�addra)r rsrw�	filenamesr&r�rUZ	fileattrsrrr�test_openDirectoryIterators(
��z2OurServerOurClientTests.test_openDirectoryIteratorz!Broken by PEP 479 and deprecated.ccsj|j�d�}|��|V}|��|��}d}|�dt|��|�t|dd�|�||dd�dS)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)rXrzr[r�Z
flushWarningsrar%�DeprecationWarning)r rsrw�warningsr�rrr�$test_openDirectoryIteratorDeprecated+s�z<OurServerOurClientTests.test_openDirectoryIteratorDeprecatedN) r
rr�unix�skiprPr[r_rbrertr{r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rZinlineCallbacksr�rr�rrrrrQss>	!"
#�rQc@seZdZdd�ZdS)�FakeConncCsdSr.r)r Zchannelrrr�	sendCloseAszFakeConn.sendCloseN)r
rrr�rrrrr�@sr�c@sLeZdZesdZdd�Zdd�Zdd�Zdd	�Zd
d�Z	dd
�Z
dd�ZdS)�FileTransferCloseTestsrRcCst�|_dSr.)rrrrrrrPJszFileTransferCloseTests.setUpcCs,t��}Gdd�d�}|�|_|j|j_|S)Nc@s$eZdZdd�Zdd�Zdd�ZdS)zDFileTransferCloseTests.buildServerConnection.<locals>.DummyTransportcSs
||_dSr.)�	transportrrrrrRszMFileTransferCloseTests.buildServerConnection.<locals>.DummyTransport.__init__cSsdSr.r)r Zkind�datarrr�
sendPacketTszOFileTransferCloseTests.buildServerConnection.<locals>.DummyTransport.sendPacketcSsdS)Nzdummy transportrrrrr�	logPrefixVszNFileTransferCloseTests.buildServerConnection.<locals>.DummyTransport.logPrefixN)r
rrrr�r�rrrr�DummyTransportQsr�)r
Z
SSHConnectionr�r)r �connr�rrr�buildServerConnectionMs

z,FileTransferCloseTests.buildServerConnectioncs$d�_|j���fdd�}||_dS)NFcsd�_�|�dS)NT)�connectionLostFired)�reason�ZorigConnectionLostr rr�connectionLost`szFFileTransferCloseTests.interceptConnectionLost.<locals>.connectionLost)r�r�)r �
sftpServerr�rr�r�interceptConnectionLost]sz.FileTransferCloseTests.interceptConnectionLostcCs|�|jd�dS)Nz*sftpServer's connectionLost was not called)rcr�rrrr�assertSFTPConnectionLostfs�z/FileTransferCloseTests.assertSFTPConnectionLostcCsJtjt�|jd�}|�t�d��|jjj	}|�
|�|��|��dS)ze
        Closing a session should notify an SFTP subsystem launched by that
        session.
        )r�rrN)
rrr�r�request_subsystemr	�NSrXr��protor�Z
closeReceivedr�)r ZtestSessionr�rrr�test_sessionCloseks

z(FileTransferCloseTests.test_sessionClosecCs�|��}t�d�t�dd�d}|�|�|jd}|�t�d��|jj	j
}|�|�|�|�|�t�dd��|�
�dS)zy
        A client sending CHANNEL_CLOSE should trigger closeReceived on the
        associated channel instance.
        r�>Lrr`rN)r�r	r��struct�pack�ssh_CHANNEL_OPEN�channelsr�rXr�r�r�Zssh_CHANNEL_CLOSEr��r r�ZpacketZsessionChannelr�rrr�%test_clientClosesChannelOnConnnection�s




z<FileTransferCloseTests.test_clientClosesChannelOnConnnectioncCsn|��}t�d�t�dd�d}|�|�|jd}|�t�d��|jj	j
}|�|�|��|�
�dS)zP
        Closing an SSH connection should close all sessions within it.
        rr�rr`rN)r�r	r�r�r�r�r�r�rXr�r�r�ZserviceStoppedr�r�rrr�'test_stopConnectionServiceClosesChannel�s



z>FileTransferCloseTests.test_stopConnectionServiceClosesChannelN)r
rrr�r�rPr�r�r�r�r�r�rrrrr�Es	r�c@s,eZdZdZesdZddddgZdd�Zd	S)
�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.
    �Cannot run without cryptographya�
           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
        cCs�i}|jD]<}|��D].}t�d|�}|rt|�d�d�||�d�<qq
|�t|�dkd�|��D]\}}|�	|t
t|��qddS)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"rr!z,No constants found (the test must be buggy).N)�filexferSpecExcerpts�
splitlines�re�matchr�grouprcr%�itemsra�getattrr)r Z	constantsZexcerpt�line�m�k�vrrr�test_constantsAgainstSpecs

�z(ConstantsTests.test_constantsAgainstSpecN)r
rr�__doc__rr�r�rrrrrr��s&
�Lr�c@sPeZdZdZesdZdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
d�Zdd�ZdS)�RawPacketDataTestsz�
    Tests for L{filetransfer.FileTransferClient} which explicitly craft certain
    less common protocol messages to exercise their handling.
    r�cCst��|_dSr.)rrW�ftcrrrrrP"szRawPacketDataTests.setUpcCsTt��}|�|j�||jjd<t�ddtj	�t
�d�t
�d�}|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�Deferredrr�_cbTestPacketSTATUSr�openRequestsr�r�r�FX_OKr	r��
packet_STATUS�r rsr�rrr�test_packetSTATUS&s$z$RawPacketDataTests.test_packetSTATUScCs$|�|dd�|�|dd�dS)z{
        Assert that the result is a two-tuple containing the message and
        language from the STATUS packet.
        rrr!r	Nr��r �resultrrrr6sz&RawPacketDataTests._cbTestPacketSTATUScCs@t��}|�|j�||jjd<t�ddtj	�}|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)rr
rr�_cbTestPacketSTATUSShortrrr�r�rr
rrrrr�test_packetSTATUSShort?s	z)RawPacketDataTests.test_packetSTATUSShortcCs$|�|dd�|�|dd�dS)z�
        Assert that the result is a two-tuple containing empty strings, since
        the STATUS packet had neither a message nor a language.
        rr�r!Nr�rrrrrPsz+RawPacketDataTests._cbTestPacketSTATUSShortcCsJt��}|�|j�||jjd<t�ddtj	�t
�d�}|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!rr)
rr
rr�_cbTestPacketSTATUSWithoutLangrrr�r�rr
r	r�rrrrr�test_packetSTATUSWithoutLangYs
z/RawPacketDataTests.test_packetSTATUSWithoutLangcCs$|�|dd�|�|dd�dS)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.
        rrr!r�Nr�rrrrrksz1RawPacketDataTests._cbTestPacketSTATUSWithoutLangN)
r
rrrrr�rPrrrrrrrrrrrs		r)1rZ
__future__rrr0r�r�Ztwisted.python.reflectrZ
twisted.trialrrr�Z
twisted.conchrZtwisted.conch.sshr	r
rrZtwisted.internetrZtwisted.protocolsrZtwisted.pythonrZtwisted.python.compatrrZtwisted.python.filepathrrrr-r5�hasattrr��warnr6r7ZregisterAdapterrdZTestCaserArQr�r�r�rrrrr�<module>sR
�
�Pjj