U
    W[4b                  
   @   sP  d dl Z d dlZd dlZd dlZd dlmZ d dlmZ d dlm	Z	 e	dZ
d dlmZ e
r~d dlmZ d dlmZmZmZ nd d	lmZ G d
d dZd dlmZ d dlmZmZmZ d dlmZ d dlmZ d dlmZ d dl m!Z!m"Z"m#Z# d dl$m%Z% d dl&m'Z' zd dl(mZ) W n2 e*k
rJ Z+ zdZ)e,e+Z-[+W 5 dZ+[+X Y nX d dl.m/Z/ d dl0m1Z1 d dl2m3Z3m4Z4 d dl2m5Z5m6Z6 zd dl.m7Z7m8Z8 W n e*k
r   Y nX zd dl
Z
W n e*k
r   dZ
Y nX zd dl9Z9W n e*k
r   dZ9Y nX dd Z:e: Z;G dd de<Z=G dd de'j>Z?G d d! d!ej@ZAG d"d# d#ejBZCG d$d% d%ejDZEG d&d' d'ejDZFG d(d) d)ej@ZGdAd+d,ZHG d-d. d.ZIG d/d0 d0eIZJeeG d1d2 d2eZKG d3d4 d4ZLG d5d6 d6eIZMG d7d8 d8ZNG d9d: d:eIeNe'j>ZOG d;d< d<eJeNe'j>ZPG d=d> d>eMeNe'j>ZQG d?d@ d@eJe'j>ZRdS )B    N)count)implementer)requireModulecryptography)
ConchError)	ConchUser)ISession
SSHSessionwrapProtocol)r   c                   @   s   e Zd ZdS )r   N)__name__
__module____qualname__ r   r   ?/usr/lib/python3/dist-packages/twisted/conch/test/test_conch.pyr      s    r   )portal)reactordeferprotocol)ProcessExitedAlready)LoopingCall)getProcessValue)filepathlogruntime)unicode)unittest)r	   ConchTestRealm)which)publicRSA_opensshprivateRSA_openssh)publicDSA_opensshprivateDSA_openssh)ConchTestServerFactoryconchTestPublicKeyCheckerc                  C   sN   d} d}zt  t j} | d d}W n t jk
r<   Y nX | rJ|   |S )z5 Returns True if the system can bind an IPv6 address.NF)::1r   T)socketZAF_INET6binderrorclose)ZsockZhas_ipv6r   r   r   	_has_ipv6<   s    
r*   c                   @   s   e Zd ZdZdZdd ZdS )	FakeStdioz
    A fake for testing L{twisted.conch.scripts.conch.SSHSession.eofReceived} and
    L{twisted.conch.scripts.cftp.SSHSession.eofReceived}.

    @ivar writeConnLost: A flag which records whether L{loserWriteConnection}
        has been called.
    Fc                 C   s
   d| _ dS )z9
        Record the call to loseWriteConnection.
        TN)writeConnLostselfr   r   r   loseWriteConnectionZ   s    zFakeStdio.loseWriteConnectionN)r   r   r   __doc__r,   r/   r   r   r   r   r+   P   s   r+   c                   @   s$   e Zd ZdZedkreZdd ZdS )StdioInteractingSessionTestsz>
    Tests for L{twisted.conch.scripts.conch.SSHSession}.
    Nc                 C   s*   t  }t }||_|  | |j dS )z}
        L{twisted.conch.scripts.conch.SSHSession.eofReceived} loses the
        write half of its stdio connection.
        N)r+   StdioInteractingSessionstdioZeofReceivedZ
assertTruer,   )r.   r3   Zchannelr   r   r   test_eofReceivedj   s
    z-StdioInteractingSessionTests.test_eofReceived)r   r   r   r0   r2   _reasonskipr4   r   r   r   r   r1   b   s   r1   c                   @   s$   e Zd Zdd Zdd Zdd ZdS )Echoc                 C   s   t d d S )NzECHO CONNECTION MADEr   msgr-   r   r   r   connectionMadex   s    zEcho.connectionMadec                 C   s   t d d S )NzECHO CONNECTION DONEr8   r.   reasonr   r   r   connectionLost|   s    zEcho.connectionLostc                 C   s"   | j | d|kr| j   d S )N   
)	transportwriteloseConnectionr.   datar   r   r   dataReceived   s    zEcho.dataReceivedN)r   r   r   r:   r=   rD   r   r   r   r   r7   w   s   r7   c                   @   s   e Zd ZeZdS )EchoFactoryN)r   r   r   r7   r   r   r   r   r   rE      s   rE   c                   @   s0   e Zd ZdZdZdZdd Zdd Zdd	 ZdS )
ConchTestOpenSSHProcessa  
    Test protocol for launching an OpenSSH client process.

    @ivar deferred: Set by whatever uses this object. Accessed using
    L{_getDeferred}, which destroys the value so the Deferred is not
    fired twice. Fires when the process is terminated.
    N    c                 C   s   | j d  }| _ |S Ndeferredr.   dr   r   r   _getDeferred   s    z$ConchTestOpenSSHProcess._getDeferredc                 C   s   |  j |7  _ d S rH   )bufrB   r   r   r   outReceived   s    z#ConchTestOpenSSHProcess.outReceivedc                 C   sJ   |j jdkr*|  td|j j n| jdd}|  | dS )z~
        Called when the process has ended.

        @param reason: a Failure giving the reason for the process' end.
        r   zexit code was not 0: {}s   
r>   N)	valueZexitCoderM   Zerrbackr   formatrN   replacecallback)r.   r<   rN   r   r   r   processEnded   s    z$ConchTestOpenSSHProcess.processEnded)	r   r   r   r0   rJ   rN   rM   rO   rT   r   r   r   r   rF      s   rF   c                   @   sT   e Zd ZdZdZdd Zdd Zdd Zd	d
 Zdd Z	dd Z
dd Zdd ZdS )ConchTestForwardingProcessa  
    Manages a third-party process which launches a server.

    Uses L{ConchTestForwardingPort} to connect to the third-party server.
    Once L{ConchTestForwardingPort} has disconnected, kill the process and fire
    a Deferred with the data received by the L{ConchTestForwardingPort}.

    @ivar deferred: Set by whatever uses this object. Accessed using
    L{_getDeferred}, which destroys the value so the Deferred is not
    fired twice. Fires when the process is terminated.
    Nc                 C   s   || _ d| _|| _dS )aF  
        @type port: L{int}
        @param port: The port on which the third-party server is listening.
        (it is assumed that the server is running on localhost).

        @type data: L{str}
        @param data: This is sent to the third-party server. Must end with '
'
        in order to trigger a disconnect.
        N)portbufferrC   )r.   rV   rC   r   r   r   __init__   s    
z#ConchTestForwardingProcess.__init__c                 C   s   | j d  }| _ |S rH   rI   rK   r   r   r   rM      s    z'ConchTestForwardingProcess._getDeferredc                 C   s   |    d S rH   )_connectr-   r   r   r   r:      s    z)ConchTestForwardingProcess.connectionMadec                 C   s0   t tt| | j}|d| j}|| j |S )a  
        Connect to the server, which is often a third-party process.
        Tries to reconnect if it fails because we have no way of determining
        exactly when the port becomes available for listening -- we can only
        know when the process starts.
        	127.0.0.1)	r   ZClientCreatorr   ConchTestForwardingPortrC   Z
connectTCPrV   Z
addErrback
_ebConnect)r.   ZccrL   r   r   r   rY      s    
z#ConchTestForwardingProcess._connectc                 C   s   t d| j d S )Ng?)r   	callLaterrY   r.   fr   r   r   r\      s    z%ConchTestForwardingProcess._ebConnectc                 C   s.   || _ | jd | j  td| j dS )z
        The network connection has died; save the buffer of output
        from the network and attempt to quit the process gracefully,
        and then (after the reactor has spun) send it a KILL signal.
           r   N)rW   r?   r@   rA   r   r]   
_reallyDie)r.   rW   r   r   r   forwardingPortDisconnected   s    
z5ConchTestForwardingProcess.forwardingPortDisconnectedc                 C   s*   z| j d W n tk
r$   Y nX d S )NZKILL)r?   ZsignalProcessr   r-   r   r   r   ra      s    z%ConchTestForwardingProcess._reallyDiec                 C   s   |   | j dS )z
        Fire the Deferred at self.deferred with the data collected
        from the L{ConchTestForwardingPort} connection, if any.
        N)rM   rS   rW   r;   r   r   r   rT      s    z'ConchTestForwardingProcess.processEnded)r   r   r   r0   rJ   rX   rM   r:   rY   r\   rb   ra   rT   r   r   r   r   rU      s   rU   c                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )r[   z
    Connects to server launched by a third-party process (managed by
    L{ConchTestForwardingProcess}) sends data, then reports whatever it
    received back to the L{ConchTestForwardingProcess} once the connection
    is ended.
    c                 C   s   || _ || _dS )z
        @type protocol: L{ConchTestForwardingProcess}
        @param protocol: The L{ProcessProtocol} which made this connection.

        @type data: str
        @param data: The data to be sent to the third-party server.
        N)r   rC   )r.   r   rC   r   r   r   rX     s    z ConchTestForwardingPort.__init__c                 C   s   d| _ | j| j d S )NrG   )rW   r?   r@   rC   r-   r   r   r   r:     s    z&ConchTestForwardingPort.connectionMadec                 C   s   |  j |7  _ d S rH   )rW   rB   r   r   r   rD     s    z$ConchTestForwardingPort.dataReceivedc                 C   s   | j | j d S rH   )r   rb   rW   r;   r   r   r   r=   #  s    z&ConchTestForwardingPort.connectionLostN)r   r   r   r0   rX   r:   rD   r=   r   r   r   r   r[     s
   r[   conchc                 C   sF   t jd| g}g }|t|  D ]"}t|tr6|d}|| q|S )Na$  -c
### Twisted Preamble
import sys, os
path = os.path.abspath(sys.argv[0])
while os.path.dirname(path) != path:
    if os.path.basename(path).startswith('Twisted'):
        sys.path.insert(0, path)
        break
    path = os.path.dirname(path)

from twisted.conch.scripts.%s import run
run()utf-8)sys
executablelist
isinstancer   encodeappend)argsmodstartZmadeArgsargr   r   r   	_makeArgs(  s    

ro   c                   @   sP   e Zd ZesdZesdZedd Zdd Zdd Z	d	d
 Z
dd Zdd ZdS )ConchServerSetupMixinzcan't run without cryptographyzCannot run without PyASN1c                   C   s   t dS )Ns   testuserr   r   r   r   r   <lambda>F  rG   zConchServerSetupMixin.<lambda>c              	   C   s   dD ]}t j|rt | qtdd}|t W 5 Q R X tdd}|t W 5 Q R X tdd}|t W 5 Q R X tdd}|t	 W 5 Q R X t 
dd t 
dd tdd}|d	t  W 5 Q R X d S )
N)rsa_testrsa_test.pubdsa_testdsa_test.pubkh_testrr   wbrs   ru   rt   i  rv   s
   127.0.0.1 )ospathexistsremoveopenr@   r    r   r!   r"   chmodr^   r   r   r   _createFilesH  s    z"ConchServerSetupMixin._createFilesc                 C   s*   t   }|d | d }|  |S )N) r      )r&   r'   Zgetsocknamer)   )r.   srV   r   r   r   _getFreePort[  s
    
z"ConchServerSetupMixin._getFreePortc                 C   s.   |   }t|}|t  t }||_|S )z
        Make a L{ConchTestServerFactory}, which allows us to start a
        L{ConchTestServer} -- i.e. an actually listening conch.
        )realmFactoryr   ZPortalZregisterCheckerr$   r#   )r.   Zrealmpfactoryr   r   r   _makeConchFactoryc  s    
z'ConchServerSetupMixin._makeConchFactoryc                 C   sv   |    |  | _d| j_tjd| jdd| _tdt | _| j	 j
| _trrtjdt dd| _| j	 j
| _d S )Nr   r   rZ   )Z	interfacer%   )r~   r   conchFactoryZexpectedLoseConnectionr   Z	listenTCPconchServerrE   
echoServergetHostrV   echoPortHAS_IPV6echoServerV6
echoPortV6r-   r   r   r   setUpp  s    

zConchServerSetupMixin.setUpc                 C   sp   zd| j j_W n tk
r"   Y nX | j jj  t| jj	t| j
j	g}trf|t| jj	 t|S )Nr   )r   protoZdoneAttributeErrorr?   rA   r   ZmaybeDeferredr   ZstopListeningr   r   rj   r   ZgatherResults)r.   Z	deferredsr   r   r   tearDown}  s    zConchServerSetupMixin.tearDownN)r   r   r   r   r6   pyasn1staticmethodr   r~   r   r   r   r   r   r   r   r   rp   ?  s   rp   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	ForwardingMixina  
    Template class for tests of the Conch server's ability to forward arbitrary
    protocols over SSH.

    These tests are integration tests, not unit tests. They launch a Conch
    server, a custom TCP server (just an L{EchoProtocol}) and then call
    L{execute}.

    L{execute} is implemented by subclasses of L{ForwardingMixin}. It should
    cause an SSH client to connect to the Conch server, asking it to forward
    data to the custom TCP server.
    c                 C   s   |  dt }|| jdS )z
        Test that we can use whatever client to send the command "echo goodbye"
        to the Conch server. Make sure we receive "goodbye" back from the
        server.
        echo goodbye   goodbye
executerF   addCallbackassertEqualrK   r   r   r   	test_exec  s    zForwardingMixin.test_execc                 C   s>   |   }t|d}| jd|d|| jf d}|| jd |S )zy
        Test that we can use whatever client to forward a local port to a
        specified port on the server.
           test
r   z-N -L%i:127.0.0.1:%isshArgsr   rU   r   r   r   r   r.   Z	localPortprocessrL   r   r   r   test_localToRemoteForwarding  s    
z,ForwardingMixin.test_localToRemoteForwardingc                 C   s>   |   }t|d}| jd|d|| jf d}|| jd |S )zs
        Test that we can use whatever client to forward a port from the server
        to a port locally.
        r   r   z-N -R %i:127.0.0.1:%ir   r   r   r   r   r   test_remoteToLocalForwarding  s    
z,ForwardingMixin.test_remoteToLocalForwardingN)r   r   r   r0   r   r   r   r   r   r   r   r     s   
r   c                   @   s(   e Zd ZdZdd Zdd Zdd ZdS )	RekeyAvatara#  
    This avatar implements a shell which sends 60 numbered lines to whatever
    connects to it, then closes the session with a 0 exit status.

    60 lines is selected as being enough to send more than 2kB of traffic, the
    amount the client is configured to initiate a rekey after.
    c                 C   s   t |  t| jd< d S )Ns   session)r   rX   r	   ZchannelLookupr-   r   r   r   rX     s    
zRekeyAvatar.__init__c                    sH   t  }| t|  fdd}t|t   d dS )zE
        Write 60 lines of data to the transport, then exit.
        c                    sX   t | }|dkr6   jjjdd   nd|f }|d}| d S )N<   s   exit-statuss       zline #%02d
rd   )nextstopZsessionZconnZsendRequestrA   ri   r@   )Zcounterilinecallr?   r   r   r@     s      


z$RekeyAvatar.openShell.<locals>.writeg{Gz?N)r   ProtocolZmakeConnectionr
   r   r   rm   )r.   r?   r   r@   r   r   r   	openShell  s    
zRekeyAvatar.openShellc                 C   s   dS )z2
        Ignore the close of the session.
        Nr   r-   r   r   r   closed  s    zRekeyAvatar.closedN)r   r   r   r0   rX   r   r   r   r   r   r   r     s   !r   c                   @   s   e Zd ZdZdd ZdS )
RekeyRealmzS
    This realm gives out new L{RekeyAvatar} instances for any avatar request.
    c                 G   s   |d t  dd fS )Nr   c                   S   s   d S rH   r   r   r   r   r   rq     rG   z*RekeyRealm.requestAvatar.<locals>.<lambda>)r   )r.   ZavatarIDZmindZ
interfacesr   r   r   requestAvatar  s    zRekeyRealm.requestAvatarN)r   r   r   r0   r   r   r   r   r   r     s   r   c                   @   s   e Zd ZdZeZdd ZdS )RekeyTestsMixinzp
    TestCase mixin which defines tests exercising L{SSHTransportBase}'s handling
    of rekeying messages.
    c                    s.   t  } d|d} fdd}|| |S )z
        After a client-initiated rekey is completed, application data continues
        to be passed over the SSH connection.
        r   z-o RekeyLimit=2Kc                    s6   d dd tdD d }|d} | | d S )N
c                 S   s   g | ]}d |f qS )z
line #%02dr   ).0r   r   r   r   
<listcomp>  s     zFRekeyTestsMixin.test_clientRekey.<locals>.finished.<locals>.<listcomp>r   rd   )joinrangeri   r   )resultZexpectedResultr-   r   r   finished  s    
z2RekeyTestsMixin.test_clientRekey.<locals>.finished)rF   r   r   )r.   r   rL   r   r   r-   r   test_clientRekey  s
    
z RekeyTestsMixin.test_clientRekeyN)r   r   r   r0   r   r   r   r   r   r   r   r     s   r   c                   @   s"   e Zd ZedsdZdddZdS )OpenSSHClientMixinsshz$no ssh command-line client availabler   c                    s.   t tdd d} fdd}||S )a  
        Connects to the SSH server started in L{ConchServerSetupMixin.setUp} by
        running the 'ssh' command line tool.

        @type remoteCommand: str
        @param remoteCommand: The command (with arguments) to run on the
        remote end.

        @type process: L{ConchTestOpenSSHProcess}

        @type sshArgs: str
        @param sshArgs: Arguments to pass to the 'ssh' process.

        @return: L{defer.Deferred}
        r   r   )z-ozPubkeyAcceptedKeyTypes=ssh-dssz-Vc                    s   | dkrd}nd}t   _d|  d  }j j}||  }g }|D ]"}t|trh|	d}|
| qPt tdd |  jS )Nr   z!-oPubkeyAcceptedKeyTypes=ssh-dss r   zssh -2 -l testuser -p %i -F /dev/null -oUserKnownHostsFile=kh_test -oPasswordAuthentication=no -oHostKeyAlgorithms=ssh-rsa -a -i dsa_test  127.0.0.1 rd   r   )r   DeferredrJ   r   r   rV   splitrh   r   ri   rj   r   spawnProcessr   )ZstatusZoptsZcmdlinerV   cmdsencodedCmdscmdr   remoteCommandr.   r   r   r   hasPAKT8  s,    
	

z+OpenSSHClientMixin.execute.<locals>.hasPAKT)r   r   r   )r.   r   r   r   rL   r   r   r   r   r   "  s    
 zOpenSSHClientMixin.executeN)r   )r   r   r   r   r6   r   r   r   r   r   r     s   r   c                   @   sP   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd ZdS )OpenSSHKeyExchangeTestsz\
    Tests L{SSHTransportBase}'s key exchange algorithm compatibility with
    OpenSSH.
    c                 C   s   g }z>t jtdd ddgt jd}t|ts8|d}| }W n   Y nX ||krht	d
|| dt d	| }|| jd
S )aI  
        Call execute() method of L{OpenSSHClientMixin} with an ssh option that
        forces the exclusive use of the key exchange algorithm specified by
        keyExchangeAlgo

        @type keyExchangeAlgo: L{str}
        @param keyExchangeAlgo: The key exchange algorithm to use

        @return: L{defer.Deferred}
        r   r   z-QZkex)stderrrd   z{} not supported by ssh clientz
echo helloz-oKexAlgorithms=s   hello
)
subprocessZcheck_outputr   ZSTDOUTrh   strdecoder   r   SkipTestrQ   r   rF   r   r   )r.   ZkeyExchangeAlgoZkexAlgorithmsoutputrL   r   r   r   assertExecuteWithKexAlgorithm_  s(    


z5OpenSSHKeyExchangeTests.assertExecuteWithKexAlgorithmc                 C   s
   |  dS )zb
        The ecdh-sha2-nistp256 key exchange algorithm is compatible with
        OpenSSH
        zecdh-sha2-nistp256r   r-   r   r   r   test_ECDHSHA256~  s    z'OpenSSHKeyExchangeTests.test_ECDHSHA256c                 C   s
   |  dS )zb
        The ecdh-sha2-nistp384 key exchange algorithm is compatible with
        OpenSSH
        zecdh-sha2-nistp384r   r-   r   r   r   test_ECDHSHA384  s    z'OpenSSHKeyExchangeTests.test_ECDHSHA384c                 C   s
   |  dS )zb
        The ecdh-sha2-nistp521 key exchange algorithm is compatible with
        OpenSSH
        zecdh-sha2-nistp521r   r-   r   r   r   test_ECDHSHA521  s    z'OpenSSHKeyExchangeTests.test_ECDHSHA521c                 C   s
   |  dS )zl
        The diffie-hellman-group14-sha1 key exchange algorithm is compatible
        with OpenSSH.
        zdiffie-hellman-group14-sha1r   r-   r   r   r   test_DH_GROUP14  s    z'OpenSSHKeyExchangeTests.test_DH_GROUP14c                 C   s
   |  dS )zs
        The diffie-hellman-group-exchange-sha1 key exchange algorithm is
        compatible with OpenSSH.
        z"diffie-hellman-group-exchange-sha1r   r-   r   r   r   test_DH_GROUP_EXCHANGE_SHA1  s    z3OpenSSHKeyExchangeTests.test_DH_GROUP_EXCHANGE_SHA1c                 C   s
   |  dS )zu
        The diffie-hellman-group-exchange-sha256 key exchange algorithm is
        compatible with OpenSSH.
        z$diffie-hellman-group-exchange-sha256r   r-   r   r   r   test_DH_GROUP_EXCHANGE_SHA256  s    z5OpenSSHKeyExchangeTests.test_DH_GROUP_EXCHANGE_SHA256c                 C   s   |  tj| jd dS )zy
        The list of key exchange algorithms supported
        by OpenSSH client is obtained with C{ssh -Q kex}.
        zunsupported-algorithmN)ZassertRaisesr   r   r   r-   r   r   r   test_unsupported_algorithm  s    z2OpenSSHKeyExchangeTests.test_unsupported_algorithmN)r   r   r   r0   r   r   r   r   r   r   r   r   r   r   r   r   r   X  s   						r   c                   @   s"   e Zd ZdZdd Zesde_dS )OpenSSHClientForwardingTestszR
    Connection forwarding tests run against the OpenSSL command line client.
    c                 C   s>   |   }t|d}| jd|d|| jf d}|| jd |S )zG
        Forwarding of arbitrary IPv6 TCP connections via SSH.
        r   r   z-N -L%i:[::1]:%ir   )r   rU   r   r   r   r   r   r   r   r   test_localToRemoteForwardingV6  s    
z;OpenSSHClientForwardingTests.test_localToRemoteForwardingV6zRequires IPv6 supportN)r   r   r   r0   r   r   r6   r   r   r   r   r     s   r   c                   @   s   e Zd ZdZdS )OpenSSHClientRekeyTestszE
    Rekeying tests run against the OpenSSL command line client.
    N)r   r   r   r0   r   r   r   r   r     s   r   c                   @   s8   e Zd ZdZejdkrdZdddZdd	 Zd
d Z	dS )CmdLineClientTestszP
    Connection forwarding tests run against the Conch command line client.
    Zwin32z!can't run cmdline client on win32r   Nc                 C   s   |dkrg }t  |_| j j}d|| d | }t||  }t	j
 }t	jtj|d< g }	i }
|D ]"}t|tr|d}|	| qp|D ]<}|| }t|tr|d}t|tr|d}||
|< qtj|tj|	|
d |jS )z{
        As for L{OpenSSHClientTestCase.execute}, except it runs the 'conch'
        command line tool, not 'ssh'.
        Nz[-p {} -l testuser --known-hosts kh_test --user-authentications publickey -a -i dsa_test -v r   
PYTHONPATHrd   )env)r   r   rJ   r   r   rV   rQ   ro   r   rx   environcopypathsepr   re   ry   rh   r   ri   rj   r   r   rf   )r.   r   r   r   	conchArgsrV   r   r   r   r   Z
encodedEnvvarvalr   r   r   r     s>    








zCmdLineClientTests.executec                    sV    fdd}t   jdt dd jddgd}|jd	 || |S )
z4
        It can store logs to a local file.
        c                    s      }d| d S )Ns   Log opened.)Z
getContentZassertIn)r   Z
logContentZlogPathr.   r   r   cb_check_log  s    z<CmdLineClientTests.test_runWithLogFile.<locals>.cb_check_logr   z--logz	--logfilez--host-key-algorithmszssh-rsa)r   r   r   r   )r   ZFilePathZmktempr   rF   ry   r   r   )r.   r   rL   r   r   r   test_runWithLogFile	  s     
z&CmdLineClientTests.test_runWithLogFilec                 C   s"   | j dt d}|| jd |S )zH
        Do not use --host-key-algorithms flag on command line.
        r   )r   r   r   r   rK   r   r   r   %test_runWithNoHostAlgorithmsSpecified  s    z8CmdLineClientTests.test_runWithNoHostAlgorithmsSpecified)r   N)
r   r   r   r0   r   ZplatformTyper6   r   r   r   r   r   r   r   r     s   

%r   )rc   )Srx   re   r&   r   	itertoolsr   Zzope.interfacer   Ztwisted.python.reflectr   r   Ztwisted.conch.errorr   Ztwisted.conch.avatarr   Ztwisted.conch.ssh.sessionr   r	   r
   Ztwisted.conch.interfacesZtwisted.credr   Ztwisted.internetr   r   r   Ztwisted.internet.errorr   Ztwisted.internet.taskr   Ztwisted.internet.utilsr   Ztwisted.pythonr   r   r   Ztwisted.python.compatr   Ztwisted.trialr   Ztwisted.conch.scripts.conchr2   ImportErrorer   r5   Ztwisted.conch.test.test_sshr   Ztwisted.python.procutilsr   Ztwisted.conch.test.keydatar   r    r!   r"   r#   r$   r   r*   r   objectr+   ZTestCaser1   r   r7   ZFactoryrE   ZProcessProtocolrF   rU   r[   ro   rp   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>   s   

%U"
O95	;g