ó
    Ö›‘hÀÛ  ã                   ó   • S r SSKrSSKJr  SSKJr  SSKJr  SSK	J
r
  SSKJrJr  SSKrSSKJrJrJr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJrJrJrJr  SSK J!r!J"r"J#r#J$r$  SSK%J&r&J'r'  SSK(J)r)J*r*  SSK+J,r,J-r-J.r.  SSK/J0r0J1r1  SSK2J3r3  SSK4J5r5  SSK6J7r7  SSK8J9r9  SSK:J;r;  SSK<J=r=  \;" S5      (       ac  SSK>J?r?  SSK@JArAJBrB  SSKCJDrDJErE  SSKFJGrGJHrHJIrIJJrJJKrKJLrL  SSKMJNrN  SSKOJPrP  SS KQJRrR  SS!KSJTrT  SS"KUJVrV  SS#KWJXrX  SS$KYJZrZ  SS%K[J\r\  SS&K]J^r^J_r_J`r`Jara  OS'rb\crV\cr\\crT\crX\crR\crP\crE\crB\cr?SS(KdJereJfrf   " S) S*\e5      rg " S+ S,\R5      rh " S- S.\R5      ri " S/ S0\R5      rj " S1 S25      rk " S3 S4\)5      rl " S5 S65      rm " S7 S8\\5      rn " S9 S:\V5      ro\
" \&5       " S; S<5      5       rp\
" \'5       " S= S>5      5       rq " S? S@5      rr " SA SB\=\r5      rs " SC SD\=\r5      rt " SE SF\=5      ru " SG SH\5      rv " SI SJ5      rw " SK SL\=5      rxg)Mz'
Tests for L{twisted.conch.endpoints}.
é    N)ÚBytesIO)Úpack)ÚIO)Úimplementer)ÚverifyClassÚverifyObject)Ú
ConchErrorÚHostKeyChangedÚUserRejectedKey)Ú
IConchUser)Ú'InMemoryUsernamePasswordDatabaseDontUse)ÚPortal)ÚIPv4Address)ÚCancelledErrorÚDeferredÚfailÚsucceed)ÚConnectingCancelledErrorÚConnectionDoneÚConnectionRefusedErrorÚProcessTerminated)ÚIAddressÚIStreamClientEndpoint)ÚFactoryÚProtocol)ÚEventLoggingObserverÚMemoryReactorClockÚStringTransport)ÚLogLevelÚglobalLogPublisher)ÚnetworkString)ÚFailure)ÚFilePath)Úmsg)ÚrequireModule)ÚTestCaseÚcryptography)Ú	ConchUser)ÚInMemorySSHKeyDBÚSSHPublicKeyChecker)Ú	ConsoleUIÚKnownHostsFile)ÚAuthenticationFailedÚSSHCommandAddressÚSSHCommandClientEndpointÚ_ExistingConnectionHelperÚ_ISSHConnectionCreatorÚ_NewConnectionHelper)Úcommon)ÚSSHAgentServer)Ú
SSHChannel)ÚSSHConnection)Ú
SSHFactory)ÚKey)ÚSSHClientTransport)ÚSSHUserAuthServer)ÚprivateDSA_opensshÚprivateRSA_opensshÚ privateRSA_openssh_encrypted_aesÚpublicRSA_opensshzcan't run w/o cryptography)ÚFakeTransportÚconnectc                   ó"   • \ rS rSrSrSrS rSrg)ÚAbortableFakeTransportéV   z;
A L{FakeTransport} with added C{abortConnection} support.
Fc                 ó   • SU l         g)ze
Abort the connection in a fake manner.

This should really be implemented in the underlying module.
TN©Úaborted©Úselfs    ÚeC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/conch/test/test_endpoints.pyÚabortConnectionÚ&AbortableFakeTransport.abortConnection]   s   € ð ˆ�ó    rE   N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rF   rJ   Ú__static_attributes__© rL   rI   rB   rB   V   s   † ñð €GõrL   rB   c                   ó   • \ rS rSrSrS rSrg)ÚBrokenExecSessionéf   zG
L{BrokenExecSession} is a session on which exec requests always fail.
c                 ó   • g)z˜
Fail all exec requests.

@param data: Information about what is being executed.
@type data: L{bytes}

@return: C{0} to indicate failure
@rtype: L{int}
r   rS   ©rH   Údatas     rI   Úrequest_execÚBrokenExecSession.request_execk   ó   € ð rL   rS   N©rM   rN   rO   rP   rQ   rZ   rR   rS   rL   rI   rU   rU   f   ó   † ñõ
rL   rU   c                   ó   • \ rS rSrSrS rSrg)ÚWorkingExecSessionéx   zK
L{WorkingExecSession} is a session on which exec requests always succeed.
c                 ó   • g)z›
Succeed all exec requests.

@param data: Information about what is being executed.
@type data: L{bytes}

@return: C{1} to indicate success
@rtype: L{int}
é   rS   rX   s     rI   rZ   ÚWorkingExecSession.request_exec}   r\   rL   rS   Nr]   rS   rL   rI   r`   r`   x   r^   rL   r`   c                   ó   • \ rS rSrSrS rSrg)ÚUnsatisfiedExecSessionéŠ   z}
L{UnsatisfiedExecSession} is a session on which exec requests are always
delayed indefinitely, never succeeding or failing.
c                 ó   • [        5       $ )z·
Delay all exec requests indefinitely.

@param data: Information about what is being executed.
@type data: L{bytes}

@return: A L{Deferred} which will never fire.
@rtype: L{Deferred}
)r   rX   s     rI   rZ   Ú#UnsatisfiedExecSession.request_exec�   s   € ô ‹zÐrL   rS   Nr]   rS   rL   rI   rf   rf   Š   s   † ñõ

rL   rf   c                   ó    • \ rS rSrS rS rSrg)ÚTrivialRealmé�   c                 ó   • 0 U l         g ©N©ÚchannelLookuprG   s    rI   Ú__init__ÚTrivialRealm.__init__ž   s
   € ØˆÕrL   c                 óL   • [        5       nU R                  Ul        [        US 4$ )Nc                  ó   • g rn   rS   rS   rL   rI   Ú<lambda>Ú,TrivialRealm.requestAvatar.<locals>.<lambda>¤   s   € ¨DrL   )r(   rp   r   )rH   ÚavatarIdÚmindÚ
interfacesÚavatars        rI   ÚrequestAvatarÚTrivialRealm.requestAvatar¡   s$   € Ü“ˆØ#×1Ñ1ˆÔÜ˜F¡LÐ1Ð1rL   ro   N)rM   rN   rO   rP   rq   r{   rR   rS   rL   rI   rk   rk   �   s   † ò õ2rL   rk   c                   ó   • \ rS rSrSrS rSrg)ÚAddressSpyFactoryé§   Nc                 ó:   • Xl         [        R                  " X5      $ rn   )Úaddressr   ÚbuildProtocol)rH   r�   s     rI   r‚   ÚAddressSpyFactory.buildProtocolª   s   € ØŒÜ×$Ò$ TÓ3Ð3rL   )r�   )rM   rN   rO   rP   r�   r‚   rR   rS   rL   rI   r~   r~   §   s   † Ø€Gõ4rL   r~   c                   ó&   • \ rS rSrS rS rS rSrg)ÚFixedResponseUIé¯   c                 ó   • Xl         g rn   ©Úresult)rH   r‰   s     rI   rq   ÚFixedResponseUI.__init__°   s   € Ø�rL   c                 ó,   • [        U R                  5      $ rn   )r   r‰   ©rH   Útexts     rI   ÚpromptÚFixedResponseUI.prompt³   s   € Ü�t—{‘{Ó#Ð#rL   c                 ó   • g rn   rS   rŒ   s     rI   ÚwarnÚFixedResponseUI.warn¶   s   € ØrL   rˆ   N)rM   rN   rO   rP   rq   rŽ   r‘   rR   rS   rL   rI   r…   r…   ¯   s   † òò$õrL   r…   c                   ó4   • \ rS rSr\S 5       r\S 5       rSrg)ÚFakeClockSSHUserAuthServeréº   c                 óB   • U R                   R                  R                  $ )za
Use the C{attemptsBeforeDisconnect} value defined by the factory to make
it easier to override.
)Ú	transportÚfactoryÚattemptsBeforeDisconnectrG   s    rI   r™   Ú3FakeClockSSHUserAuthServer.attemptsBeforeDisconnect¼   s   € ð �~‰~×%Ñ%×>Ñ>Ð>rL   c                 óB   • U R                   R                  R                  $ )z¨
Use the reactor defined by the factory, rather than the default global
reactor, to simplify testing (by allowing an alternate implementation
to be supplied by tests).
)r—   r˜   ÚreactorrG   s    rI   ÚclockÚ FakeClockSSHUserAuthServer.clockÄ   s   € ð �~‰~×%Ñ%×-Ñ-Ð-rL   rS   N)rM   rN   rO   rP   Úpropertyr™   r�   rR   rS   rL   rI   r”   r”   º   s(   † àñ?ó ð?ð ñ.ó ó.rL   r”   c                   óB   • \ rS rSr\S 5       r\S 5       r\\S.r	Sr
Srg)ÚCommandFactoryéÎ   c                 ó6   • S[         R                  " [        S90$ ©Nó   ssh-rsa)rY   )r8   Ú
fromStringr>   rG   s    rI   Ú
publicKeysÚCommandFactory.publicKeysÏ   s   € àœCŸNšNÔ0AÑBÐCÐCrL   c                 ó6   • S[         R                  " [        S90$ r¤   )r8   r¦   r<   rG   s    rI   ÚprivateKeysÚCommandFactory.privateKeysÓ   s   € àœCŸNšNÔ0BÑCÐDÐDrL   )s   ssh-userauths   ssh-connectionr   rS   N)rM   rN   rO   rP   rŸ   r§   rª   r”   r6   Úservicesr™   rR   rS   rL   rI   r¡   r¡   Î   sC   † ØñDó ðDð ñEó ðEð 4Ø(ñ€Hð  !ÓrL   r¡   c                   ó   • \ rS rSrSrg)ÚMemoryAddresséã   rS   N)rM   rN   rO   rP   rR   rS   rL   rI   r®   r®   ã   s   † ârL   r®   c                   ó$   • \ rS rSrSrS rS rSrg)ÚSingleUseMemoryEndpointéè   aA  
L{SingleUseMemoryEndpoint} is a client endpoint which allows one connection
to be set up and then exposes an API for moving around bytes related to
that connection.

@ivar pump: L{None} until a connection is attempted, then a L{IOPump}
    instance associated with the protocol which is connected.
@type pump: L{IOPump}
c                 ó   • SU l         Xl        g)zx
@param server: An L{IProtocol} provider to which the client will be
    connected.
@type server: L{IProtocol} provider
N)ÚpumpÚ_server)rH   Úservers     rI   rq   Ú SingleUseMemoryEndpoint.__init__ô   s   € ð ˆŒ	Ø�rL   c           
      ó  • U R                   b  [        S5      e UR                  [        5       5      n[	        U R
                  [        U R
                  SS9U[        USS95      U l         [        U5      $ ! [         a    [        5       s $ f = f)Nz(SingleUseMemoryEndpoint was already usedT©ÚisServerF)
r´   Ú	Exceptionr‚   r®   r@   rµ   rB   r   ÚBaseExceptionr   )rH   r˜   Úprotocols      rI   r@   ÚSingleUseMemoryEndpoint.connectý   s„   € Ø�9‰9Ñ ÜÐFÓGÐGð	%Ø×,Ñ,¬]«_Ó=ˆHô  Ø—‘Ü& t§|¡|¸dÑCØÜ& x¸%Ñ@ó	ˆDŒIô ˜8Ó$Ð$øô ó 	Ü“6ŠMð	ús   šA5 Á5BÂB)rµ   r´   N)rM   rN   rO   rP   rQ   rq   r@   rR   rS   rL   rI   r±   r±   è   s   † ñòõ%rL   r±   c                   óŽ   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rSS jrS rS rSrg)Ú"SSHCommandClientEndpointTestsMixini  a¼  
Tests for L{SSHCommandClientEndpoint}, an L{IStreamClientEndpoint}
implementations which connects a protocol with the stdin and stdout of a
command running in an SSH session.

These tests apply to L{SSHCommandClientEndpoint} whether it is constructed
using L{SSHCommandClientEndpoint.existingConnection} or
L{SSHCommandClientEndpoint.newConnection}.

Subclasses must override L{create}, L{assertClientTransportState}, and
L{finishConnection}.
c                 óÄ  • SU l         SU l        SU l        SU l        [	        5       U l        [        5       U l        [        U R                  5      U l	        [        5       U l        U R                  R                  U R                  U R                  5        U R                  R                  U R                  5        [        5       U l        U R
                  U R                  l        U R                  U R                  l	        U R                  R!                  5         U R#                  U R                  R$                  5        ['        SSS5      U l        ['        SSS	5      U l        g )
Ns   ssh.example.comi&¤  s   users   passwordÚTCPz10.0.0.1i90  z192.168.100.200i1Ô  )ÚhostnameÚportÚuserÚpasswordr   rœ   rk   Úrealmr   Úportalr   ÚpasswdDBÚaddUserÚregisterCheckerr¡   r˜   ÚdoStartÚ
addCleanupÚdoStopr   ÚclientAddressÚserverAddressrG   s    rI   ÚsetUpÚ(SSHCommandClientEndpointTestsMixin.setUp  sð   € Ø*ˆŒØˆŒ	ØˆŒ	Ø#ˆŒÜ)Ó+ˆŒÜ!“^ˆŒ
Ü˜TŸZ™ZÓ(ˆŒÜ?ÓAˆŒØ�‰×Ñ˜dŸi™i¨¯©Ô7Ø�‰×#Ñ# D§M¡MÔ2Ü%Ó'ˆŒØ#Ÿ|™|ˆ�‰ÔØ"Ÿk™kˆ�‰ÔØ�‰×ÑÔØ�‰˜Ÿ™×+Ñ+Ô,ä(¨°
¸EÓBˆÔÜ(¨Ð0AÀ5ÓIˆÕrL   c                 óH   • [        U R                  R                  < S35      e)z‹
Create and return a new L{SSHCommandClientEndpoint} to be tested.
Override this to implement creation in an interesting way the endpoint.
z did not implement create©ÚNotImplementedErrorÚ	__class__rM   rG   s    rI   ÚcreateÚ)SSHCommandClientEndpointTestsMixin.create1  s'   € ô
 "Ø�~‰~×&Ñ&Ñ)Ð)BÐCó
ð 	
rL   c                 óH   • [        U R                  R                  < S35      e)aa  
Make an assertion about the connectedness of the given protocol's
transport.  Override this to implement either a check for the
connection still being open or having been closed as appropriate.

@param client: The client whose state is being checked.

@param immediateClose: Boolean indicating whether the connection was
    closed immediately or not.
z- did not implement assertClientTransportStaterÔ   ©rH   ÚclientÚimmediateCloses      rI   ÚassertClientTransportStateÚ=SSHCommandClientEndpointTestsMixin.assertClientTransportState:  s#   € ô "à�~‰~×&Ô&ð)ó
ð 	
rL   c                 óH   • [        U R                  R                  < S35      e)zp
Do any remaining work necessary to complete an in-memory connection
attempted initiated using C{self.reactor}.
z# did not implement finishConnectionrÔ   rG   s    rI   ÚfinishConnectionÚ3SSHCommandClientEndpointTestsMixin.finishConnectionJ  s'   € ô
 "Ø�~‰~×&Ñ&Ñ)Ð)LÐMó
ð 	
rL   c                 óæ   • UR                  S5      nUR                  S5      n[        USU R                  U R                  S9n[        USU R                  U R                  S9n[	        XFX55      nXCU4$ )a?  
Set up an in-memory connection between protocols created by
C{serverFactory} and C{clientFactory}.

@return: A three-tuple.  The first element is the protocol created by
    C{serverFactory}.  The second element is the protocol created by
    C{clientFactory}.  The third element is the L{IOPump} connecting
    them.
NF)rº   ÚhostAddressÚpeerAddressT)r‚   rB   rÏ   rÐ   r@   )rH   ÚserverFactoryÚclientFactoryÚclientProtocolÚserverProtocolÚclientTransportÚserverTransportr´   s           rI   ÚconnectedServerAndClientÚ;SSHCommandClientEndpointTestsMixin.connectedServerAndClientS  sƒ   € ð '×4Ñ4°TÓ:ˆØ&×4Ñ4°TÓ:ˆä0ØØØ×*Ñ*Ø×*Ñ*ñ	
ˆô 1ØØØ×*Ñ*Ø×*Ñ*ñ	
ˆô �~¸ÓXˆØ¨tÐ3Ð3rL   c                 ó6  • U R                  5       n[        5       n[        Ul        UR	                  U5      nU R                  5       u  pEnU R                  [        5      nU R                  SUS   R                  R                  US   R                  R                  45        U R                  S[        U5      5        U R                  U5      nUR                  [        5        U R                  SUR                  R                  5        U R                  US5        g)zÅ
If a channel cannot be opened on the authenticated SSH connection, the
L{Deferred} returned by L{SSHCommandClientEndpoint.connect} fires with
a L{Failure} wrapping the reason given by the server.
úunknown channelr   rc   ó   unknown channelFN)r×   r   r   r½   r@   rà   ÚflushLoggedErrorsr	   ÚassertInÚvaluerY   ÚassertEqualÚlenÚfailureResultOfÚtraprÝ   )	rH   Úendpointr˜   Ú	connectedr¶   rÛ   r´   ÚerrorsÚfs	            rI   Útest_channelOpenFailureÚ:SSHCommandClientEndpointTestsMixin.test_channelOpenFailurep  sÞ   € ð —;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜ð ×'Ñ'¬
Ó3ˆØ�‰Ð'¨&°©)¯/©/×*>Ñ*>ÀÀqÁ	ÇÁ×@UÑ@UÐ)VÔWØ×Ñ˜œC ›KÔ(ð × Ñ  Ó+ˆØ	�‰ŒzÔØ×ÑÐ+¨Q¯W©W¯]©]Ô;à×'Ñ'¨°Õ6rL   c                 óŒ  • [         U R                  R                  S'   U R                  5       n[	        5       n[
        Ul        UR                  U5      nU R                  5       u  pEnU R                  U5      nUR                  [        5        U R                  SUR                  R                  5        U R                  US5        g)z¥
If execution of the command fails, the L{Deferred} returned by
L{SSHCommandClientEndpoint.connect} fires with a L{Failure} wrapping
the reason given by the server.
ó   sessionzchannel request failedFN)rU   rÇ   rp   r×   r   r   r½   r@   rà   rõ   rö   r	   ró   rò   rÝ   ©rH   r÷   r˜   rø   r¶   rÛ   r´   rú   s           rI   Útest_execFailureÚ3SSHCommandClientEndpointTestsMixin.test_execFailureŠ  s›   € ô 0Aˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜à× Ñ  Ó+ˆØ	�‰ŒzÔØ×ÑÐ1°1·7±7·=±=ÔAà×'Ñ'¨°Õ6rL   c                 ó`  • [         U R                  R                  S'   U R                  5       n[	        5       n[
        Ul        UR                  U5      nU R                  5       u  pEnUR                  5         U R                  U5      nUR                  [        5        U R                  US5        g)z•
If execution of the command is cancelled via the L{Deferred} returned
by L{SSHCommandClientEndpoint.connect}, the connection is closed
immediately.
rþ   TN)rf   rÇ   rp   r×   r   r   r½   r@   rà   Úcancelrõ   rö   r   rÝ   rÿ   s           rI   Útest_execCancelledÚ5SSHCommandClientEndpointTestsMixin.test_execCancelledŸ  sŽ   € ô 0Fˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	Ø#×4Ñ4Ó6Ñˆ˜à×ÑÔà× Ñ  Ó+ˆØ	�‰Œ~Ôà×'Ñ'¨°Õ5rL   c                 ó8  • [         U R                  R                  S'   U R                  5       n[	        5       n[
        Ul        UR                  U5        U R                  5       u  p4nU R                  UR                  [        5        U R                  UR                  R                  5       UR                  R                  5        U R                  U R                   UR                  R"                  5        U R                  SUR                  R$                  5        g)a  
Once the necessary SSH actions have completed successfully,
L{SSHCommandClientEndpoint.connect} uses the factory passed to it to
construct a protocol instance by calling its C{buildProtocol} method
with an address object representing the SSH connection and command
executed.
rþ   ó
   /bin/ls -lN)r`   rÇ   rp   r×   r~   r   r½   r@   rà   ÚassertIsInstancer�   r.   ró   r—   ÚgetHostr¶   rÅ   ÚusernameÚcommand)rH   r÷   r˜   r¶   rÛ   r´   s         rI   Útest_buildProtocolÚ5SSHCommandClientEndpointTestsMixin.test_buildProtocol´  sË   € ô 0Bˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä#Ó%ˆÜ#ˆÔà×Ñ˜Ô!à#×4Ñ4Ó6Ñˆ˜à×Ñ˜gŸo™oÔ/@ÔAØ×Ñ˜×)Ñ)×1Ñ1Ó3°W·_±_×5KÑ5KÔLØ×Ñ˜Ÿ™ G§O¡O×$<Ñ$<Ô=Ø×Ñ˜¨¯©×(?Ñ(?Õ@rL   c                 ó(  • [         U R                  R                  S'   U R                  5       n[	        5       n[
        Ul        UR                  U5      nU R                  5       u  pEnU R                  U5      nU R                  UR                  5        g)zí
L{SSHCommandClientEndpoint} establishes an SSH connection, creates a
channel in it, runs a command in that channel, and uses the protocol's
C{makeConnection} to associate it with a protocol representing that
command's stdin and stdout.
rþ   N)r`   rÇ   rp   r×   r   r   r½   r@   rà   ÚsuccessResultOfÚassertIsNotNoner—   ©rH   r÷   r˜   rø   r¶   rÛ   r´   r½   s           rI   Útest_makeConnectionÚ6SSHCommandClientEndpointTestsMixin.test_makeConnectionË  sz   € ô 0Bˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜à×'Ñ'¨	Ó2ˆØ×Ñ˜X×/Ñ/Õ0rL   c                 óö  • [         U R                  R                  S'   U R                  5       n[	        5       n[
        Ul        UR                  U5      nU R                  5       u  pEnU R                  U5      n/ nUR                  Ul        UR                  R                  n	UR                  R                  U	   R!                  S5        UR#                  5         U R%                  SSR'                  U5      5        g)z’
After establishing the connection, when the command on the SSH server
produces output, it is delivered to the protocol's C{dataReceived}
method.
rþ   ó   hello, worldrL   N)r`   rÇ   rp   r×   r   r   r½   r@   rà   r  ÚappendÚdataReceivedr—   ÚidÚserviceÚchannelsÚwriter´   ró   Újoin)
rH   r÷   r˜   rø   r¶   rÛ   r´   r½   r  Ú	channelIds
             rI   Útest_dataReceivedÚ4SSHCommandClientEndpointTestsMixin.test_dataReceivedÞ  sË   € ô 0Bˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜à×'Ñ'¨	Ó2ˆØˆØ ,× 3Ñ 3ˆÔð ×&Ñ&×)Ñ)ˆ	à�‰×Ñ 	Ñ*×0Ñ0°ÔAØ�	‰	ŒØ×Ñ˜¨#¯(©(°<Ó*@ÕArL   c                 ó  • [         U R                  R                  S'   U R                  5       n[	        5       n[
        Ul        UR                  U5      nU R                  5       u  pEnU R                  U5      n/ nUR                  Ul        UR                  R                  n	UR                  R                  U	   R!                  5         UR#                  5         US   R%                  [&        5        U R)                  US5        g)zY
When the command closes the channel, the protocol's C{connectionLost}
method is called.
rþ   r   FN)r`   rÇ   rp   r×   r   r   r½   r@   rà   r  r  ÚconnectionLostr—   r  r  r  ÚloseConnectionr´   rö   r   rÝ   )
rH   r÷   r˜   rø   r¶   rÛ   r´   r½   r!  r  s
             rI   Útest_connectionLostÚ6SSHCommandClientEndpointTestsMixin.test_connectionLostù  sÓ   € ô
 0Bˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜à×'Ñ'¨	Ó2ˆØˆØ"0×"7Ñ"7ˆÔð ×&Ñ&×)Ñ)ˆ	Ø�‰×Ñ 	Ñ*×9Ñ9Ô;à�	‰	ŒØ�qÑ×Ñœ~Ô.à×'Ñ'¨°Õ6rL   c                 ó  • [         U R                  R                  S'   U R                  5       n[	        5       n[
        Ul        UR                  U5      nU R                  5       u  pgnU R                  U5      n	/ n
U
R                  U	l        U	R                  R                  nUR                  R                  U   nUR                  R!                  XÁU5        UR#                  5         UR%                  5         U R'                  US5        U
S   $ )z:
Test handling of non-zero exit statuses or exit signals.
rþ   Fr   )r`   rÇ   rp   r×   r   r   r½   r@   rà   r  r  r!  r—   r  r  r  ÚsendRequestr"  r´   rÝ   )rH   ÚrequestÚ
requestArgr÷   r˜   rø   r¶   rÛ   r´   r½   r!  r  Úchannels                rI   Ú_exitStatusTestÚ2SSHCommandClientEndpointTestsMixin._exitStatusTest  sä   € ô 0Bˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜à×'Ñ'¨	Ó2ˆØˆØ"0×"7Ñ"7ˆÔð
 ×&Ñ&×)Ñ)ˆ	Ø—.‘.×)Ñ)¨)Ñ4ˆà�‰×"Ñ" 7°ZÔ@Ø×ÑÔ Ø�	‰	ŒØ×'Ñ'¨°Ô6Ø˜aÑ Ð rL   c                 ój   • SnU R                  S[        SU5      5      nUR                  [        5        g)úª
When the command exits with a non-zero status, the protocol's
C{connectionLost} method is called with a L{Failure} wrapping an
exception which encapsulates that status.
r   ó   exit-statusú>LN)r*  r   rö   r   )rH   ÚexitCodeÚexcs      rI   Útest_zeroExitCodeÚ4SSHCommandClientEndpointTestsMixin.test_zeroExitCode2  s.   € ð ˆØ×"Ñ" >´4¸¸hÓ3GÓHˆØ�‰”Õ rL   c                 ó  • SnSnU R                  S[        SU5      5      nUR                  [        5        U R	                  XR
                  R                  5        U R	                  X#R
                  R                  5        g)r-  é{   Nr.  r/  )r*  r   rö   r   ró   rò   r0  Úsignal)rH   r0  r6  r1  s       rI   Útest_nonZeroExitStatusÚ9SSHCommandClientEndpointTestsMixin.test_nonZeroExitStatus<  sd   € ð ˆØˆØ×"Ñ" >´4¸¸hÓ3GÓHˆØ�‰Ô"Ô#Ø×Ñ˜§9¡9×#5Ñ#5Ô6Ø×Ñ˜§¡×!1Ñ!1Õ2rL   c                 óä  • [        5       n[        R                  " U5        U R                  [        R                  U5        SnSnSR                  [        R                  " S5      S[        R                  " S5      [        R                  " S5      /5      nU R                  SU5      nUR                  [        5        U R                  X%R                  R                  5        U R                  X5R                  R                  5        S	n[        R                   " U[        R"                  " [        R$                  " [        R&                  " [(        R*                  5      USS
SSS.5      5      5        g)zç
When the command exits with a non-zero signal, the protocol's
C{connectionLost} method is called with a L{Failure} wrapping an
exception which encapsulates that status.

Additional packet contents are logged at the C{info} level.
Né   rL   s   TERMó   s   messages   en-USs   exit-signalz'twisted.conch.endpoints._CommandChannelTÚmessage)Ú	log_levelÚlog_namespaceÚshortSignalNameÚ
coreDumpedÚerrorMessageÚlanguageTag)r   r    ÚaddObserverrÍ   ÚremoveObserverr  r3   ÚNSr*  rö   r   ró   rò   r0  r6  ÚhamcrestÚassert_thatÚhas_itemÚhas_entriesÚequal_tor   Úinfo)rH   ÚlogObserverr0  r6  Úpacketr1  ÚlogNamespaces          rI   Útest_nonZeroExitSignalÚ9SSHCommandClientEndpointTestsMixin.test_nonZeroExitSignalI  s  € ô +Ó,ˆÜ×&Ò& {Ô3Ø�‰Ô*×9Ñ9¸;ÔGàˆØˆà—‘ä—	’	˜'Ó"àÜ—	’	˜*Ó%Ü—	’	˜(Ó#ðó
ˆð ×"Ñ" >°6Ó:ˆØ�‰Ô"Ô#Ø×Ñ˜§9¡9×#5Ñ#5Ô6Ø×Ñ˜§¡×!1Ñ!1Ô2à@ˆÜ×ÒØÜ×ÒÜ×$Ò$ä%-×%6Ò%6´x·}±}Ó%EØ)5Ø+2Ø&*Ø(1Ø'/ñó	óõ	
rL   c                 ó²   ^• UR                   R                  n/ mU(       a  U4S jnOTR                  n[        UR                  R
                  U   X65        T$ )zÞ
Hook into and record events which happen to C{protocol}.

@param server: The SSH server protocol over which C{protocol} is
    running.
@type server: L{IProtocol} provider

@param protocol:

@param event:

@param noArgs:
c                  ó&   >• T R                  S 5      $ rn   )r  )Úrecorders   €rI   ru   Ú;SSHCommandClientEndpointTestsMixin.record.<locals>.<lambda>‹  s   ø€ ˜Ÿ™¨Ô-rL   )r—   r  r  Úsetattrr  r  )rH   r¶   r½   ÚeventÚnoArgsr  rú   rS  s          @rI   ÚrecordÚ)SSHCommandClientEndpointTestsMixin.recordw  sJ   ø€ ð  ×&Ñ&×)Ñ)ˆ	àˆÞÜ-‰Aà—‘ˆAä�—‘×'Ñ'¨	Ñ2°EÔ=ØˆrL   c                 ó®  • [         U R                  R                  S'   U R                  5       n[	        5       n[
        Ul        UR                  U5      nU R                  5       u  pEnU R                  U5      nU R                  XGS5      nUR                  R                  S5        UR                  5         U R                  SSR                  U5      5        g)zŠ
The transport connected to the protocol has a C{write} method which
sends bytes to the input of the command executing on the SSH server.
rþ   r  r  rL   N)r`   rÇ   rp   r×   r   r   r½   r@   rà   r  rX  r—   r  r´   ró   r  ©	rH   r÷   r˜   rø   r¶   rÛ   r´   r½   r  s	            rI   Ú
test_writeÚ-SSHCommandClientEndpointTestsMixin.test_write’  s¬   € ô
 0Bˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜à×'Ñ'¨	Ó2ˆà—{‘{ 6°^ÓDˆØ×Ñ× Ñ  Ô1Ø�	‰	ŒØ×Ñ˜¨#¯(©(°<Ó*@ÕArL   c                 ó°  • [         U R                  R                  S'   U R                  5       n[	        5       n[
        Ul        UR                  U5      nU R                  5       u  pEnU R                  U5      nU R                  XGS5      nUR                  R                  S/5        UR                  5         U R                  SSR                  U5      5        g)z’
The transport connected to the protocol has a C{writeSequence} method which
sends bytes to the input of the command executing on the SSH server.
rþ   r  r  rL   N)r`   rÇ   rp   r×   r   r   r½   r@   rà   r  rX  r—   ÚwriteSequencer´   ró   r  r[  s	            rI   Útest_writeSequenceÚ5SSHCommandClientEndpointTestsMixin.test_writeSequence§  s¯   € ô
 0Bˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜à×'Ñ'¨	Ó2ˆà—{‘{ 6°^ÓDˆØ×Ñ×(Ñ(¨/Ð):Ô;Ø�	‰	ŒØ×Ñ˜¨#¯(©(°<Ó*@ÕArL   )rÏ   r˜   rÃ   rÉ   rÆ   rÄ   rÈ   rœ   rÇ   rÐ   rÅ   N)F)rM   rN   rO   rP   rQ   rÑ   r×   rÝ   rà   rë   rû   r   r  r  r  r  r#  r*  r2  r7  rO  rX  r\  r`  rR   rS   rL   rI   rÀ   rÀ     sl   † ñòJò(
ò
ò 
ò4ò:7ò47ò*6ò*Aò.1ò&Bò67ò8!ò:!ò3ò,
ô\ò6Bõ*BrL   rÀ   c                   ó¢   • \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rSrg)ÚNewConnectionTestsi½  zT
Tests for L{SSHCommandClientEndpoint} when using the C{newConnection}
constructor.
c                 óì  • [         R                  U 5        [        U R                  5       5      U l        [        U R                  5      U l        U R                  R                  U R                  U R                  R                  S   5        U R                  R                  [        U R                  R                  5      U R                  R                  S   5        U R                  R                  5         g)úg
Configure an SSH server with password authentication enabled for a
well-known (to the tests) account.
r¥   N)rÀ   rÑ   r#   ÚmktempÚhostKeyPathr,   Ú
knownHostsÚ
addHostKeyrÃ   r˜   r§   r!   rÐ   ÚhostÚsaverG   s    rI   rÑ   ÚNewConnectionTests.setUpÃ  s§   € ô
 	+×0Ñ0°Ô6ä# D§K¡K£MÓ2ˆÔÜ(¨×)9Ñ)9Ó:ˆŒØ�‰×"Ñ" 4§=¡=°$·,±,×2IÑ2IÈ*Ñ2UÔVØ�‰×"Ñ"Ü˜$×,Ñ,×1Ñ1Ó2°D·L±L×4KÑ4KÈJÑ4Wô	
ð 	�‰×ÑÕrL   c                 óÂ   • [         R                  " U R                  SU R                  U R                  U R
                  U R                  U R                  [        S5      S9$ )z]
Create and return a new L{SSHCommandClientEndpoint} using the
C{newConnection} constructor.
r  F©rÆ   rh  Úui)	r/   ÚnewConnectionrœ   rÅ   rÃ   rÄ   rÆ   rh  r…   rG   s    rI   r×   ÚNewConnectionTests.createÒ  sL   € ô
 (×5Ò5Ø�L‰LØØ�I‰IØ�M‰MØ�I‰IØ—]‘]Ø—‘Ü˜uÓ%ñ	
ð 		
rL   c                 ón   • U R                  U R                  U R                  R                  S   S   5      $ )ze
Establish the first attempted TCP connection using the SSH server which
C{self.factory} can create.
r   é   )rë   r˜   rœ   Ú
tcpClientsrG   s    rI   rà   Ú#NewConnectionTests.finishConnectionâ  s4   € ð
 ×,Ñ,Ø�L‰L˜$Ÿ,™,×1Ñ1°!Ñ4°QÑ7ó
ð 	
rL   c                 óô   • U R                  XSSS9nUR                  R                  5         UR                  5         U R	                  S/U5        UR                  5         UR                  R                  5         g)a_  
Lose the connection to a server and pump the L{IOPump} sufficiently for
the client to handle the lost connection. Asserts that the client
disconnects its transport.

@param server: The SSH server protocol over which C{protocol} is
    running.
@type server: L{IProtocol} provider

@param client: The SSH client protocol over which C{protocol} is
    running.
@type client: L{IProtocol} provider

@param protocol: The protocol created by calling connect on the ssh
    endpoint under test.
@type protocol: L{IProtocol} provider

@param pump: The L{IOPump} connecting client to server.
@type pump: L{IOPump}
ÚclosedT)rW  N)rX  r—   r"  r´   ró   ÚreportDisconnect)rH   r¶   rÛ   r½   r´   rw  s         rI   ÚloseConnectionToServerÚ)NewConnectionTests.loseConnectionToServerë  sd   € ð* —‘˜V¨xÀ�ÐEˆØ×Ñ×)Ñ)Ô+Ø�	‰	ŒØ×Ñ˜$˜ Ô(ð
 	�	‰	Œð 	×Ñ×)Ñ)Õ+rL   c                 ó¨   • U(       a&  U R                  UR                  R                  5        gU R                  UR                  R                  5        g)zÄ
Assert that the transport for the given protocol has been disconnected.
L{SSHCommandClientEndpoint.newConnection} creates a new dedicated SSH
connection and cleans it up after the command exits.
N)Ú
assertTruer—   rF   ÚdisconnectingrÚ   s      rI   rÝ   Ú-NewConnectionTests.assertClientTransportState  s7   € ö Ø�O‰O˜F×,Ñ,×4Ñ4Õ5à�O‰O˜F×,Ñ,×:Ñ:Õ;rL   c                 ó²   • [         R                  " U R                  SSU R                  U R                  5      nU R                  [        [        U5      5        g)zI
L{SSHCommandClientEndpoint} instances provide L{IStreamClientEndpoint}.
ó   dummy commandó
   dummy userN)r/   rp  rœ   rÃ   rÄ   r|  r   r   ©rH   r÷   s     rI   Útest_interfaceÚ!NewConnectionTests.test_interface  sB   € ô ,×9Ò9Ø�L‰LÐ*¨M¸4¿=¹=È$Ï)É)ó
ˆð 	�‰œÔ%:¸HÓEÕFrL   c                 óª   • [         R                  " U R                  SSU R                  5      nU R	                  SUR
                  R                  5        g)zn
L{SSHCommandClientEndpoint} uses the default port number for SSH when
the C{port} argument is not specified.
r€  r�  é   N©r/   rp  rœ   rÃ   ró   Ú_creatorrÄ   r‚  s     rI   Útest_defaultPortÚ#NewConnectionTests.test_defaultPort$  sD   € ô
 ,×9Ò9Ø�L‰LÐ*¨M¸4¿=¹=ó
ˆð 	×Ñ˜˜X×.Ñ.×3Ñ3Õ4rL   c                 ó¨   • [         R                  " U R                  SSU R                  SS9nU R	                  SUR
                  R                  5        g)zE
L{SSHCommandClientEndpoint} uses the C{port} argument if specified.
r€  r�  i®  )rÄ   Nr‡  r‚  s     rI   Útest_specifiedPortÚ%NewConnectionTests.test_specifiedPort.  sF   € ô ,×9Ò9Ø�L‰LÐ*¨M¸4¿=¹=Ètñ
ˆð 	×Ñ˜˜x×0Ñ0×5Ñ5Õ6rL   c                 ó*  • [         R                  " U R                  SU R                  U R                  U R
                  U R                  U R                  [        S5      S9n[        5       n[        Ul        UR                  U5        U R                  R                  S   u  p4p%nU R                  U R                  [        U5      5        U R                  U R
                  U5        U R                  S[!        U R                  R                  5      5        g)z†
L{SSHCommandClientEndpoint} uses the L{IReactorTCP} passed to it to
attempt a connection to the host/port address also passed to it.
r  Frn  r   rc   N)r/   rp  rœ   rÅ   rÃ   rÄ   rÆ   rh  r…   r   r   r½   r@   rt  ró   r!   rô   )rH   r÷   r˜   rj  rÄ   ÚtimeoutÚbindAddresss          rI   Útest_destinationÚ#NewConnectionTests.test_destination7  sÏ   € ô
 ,×9Ò9Ø�L‰LØØ�I‰IØ�M‰MØ�I‰IØ—]‘]Ø—‘Ü˜uÓ%ñ	
ˆô “)ˆÜ#ˆÔØ×Ñ˜Ô!à48·L±L×4KÑ4KÈAÑ4NÑ1ˆ�G kØ×Ñ˜Ÿ™¬°dÓ(;Ô<Ø×Ñ˜Ÿ™ DÔ)Ø×Ñ˜œC §¡× 7Ñ 7Ó8Õ9rL   c                 ó¬  • [         R                  " U R                  SSU R                  U R                  U R
                  [        S5      S9n[        5       n[        Ul	        UR                  U5      nU R                  R                  S   S   nUR                  S[        [        5       5      5        U R                  U5      R!                  [        5        g)zº
If a connection cannot be established, the L{Deferred} returned by
L{SSHCommandClientEndpoint.connect} fires with a L{Failure}
representing the reason for the connection setup failure.
r  r�  F©rh  ro  r   rs  N)r/   rp  rœ   rÃ   rÄ   rh  r…   r   r   r½   r@   rt  ÚclientConnectionFailedr"   r   rõ   rö   ©rH   r÷   r˜   Úds       rI   Útest_connectionFailedÚ(NewConnectionTests.test_connectionFailedO  s«   € ô ,×9Ò9Ø�L‰LØØØ�M‰MØ�I‰IØ—‘Ü˜uÓ%ñ
ˆô “)ˆÜ#ˆÔØ×Ñ˜WÓ%ˆà—,‘,×)Ñ)¨!Ñ,¨QÑ/ˆØ×&Ñ& t¬WÔ5KÓ5MÓ-NÔOà×Ñ˜QÓ×$Ñ$Ô%;Õ<rL   c                 ó¾  • [         R                  " U R                  SSU R                  U R                  [        U R                  5       5      [        S5      S9n[        5       n[        Ul
        UR                  U5      nU R                  U R                  U R                  R                  S   S   5      u  pEnU R                  U5      nUR!                  ["        5        g)zú
If the L{KnownHostsFile} instance used to construct
L{SSHCommandClientEndpoint} rejects the SSH public key presented by the
server, the L{Deferred} returned by L{SSHCommandClientEndpoint.connect}
fires with a L{Failure} wrapping L{UserRejectedKey}.
r  r�  Fr”  r   rs  N)r/   rp  rœ   rÃ   rÄ   r,   rf  r…   r   r   r½   r@   rë   r˜   rt  rõ   rö   r   rÿ   s           rI   Útest_userRejectedHostKeyÚ+NewConnectionTests.test_userRejectedHostKeyg  s¶   € ô ,×9Ò9Ø�L‰LØØØ�M‰MØ�I‰IÜ% d§k¡k£mÓ4Ü˜uÓ%ñ
ˆô “)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×<Ñ<Ø�L‰L˜$Ÿ,™,×1Ñ1°!Ñ4°QÑ7ó 
Ñˆ˜ð × Ñ  Ó+ˆØ	�‰ŒÕrL   c                 ó  • [         R                  " [        5      R                  5       n[	        [        U R                  5       5      5      nUR                  [        U R                  R                  5      U5        [         R                  " [        SS9R                  5       nUR                  U R                  U5        [        S5      n[        R                  " U R                   SSU R                  U R"                  SUUS9n[%        5       n[&        Ul        UR+                  U5      nU R-                  U R.                  U R                   R0                  S   S	   5      u  p‰n
U R3                  U5      nUR5                  [6        5        g
)a3  
If the SSH public key presented by the SSH server does not match the
previously remembered key, as reported by the L{KnownHostsFile}
instance use to construct the endpoint, for that server, the
L{Deferred} returned by L{SSHCommandClientEndpoint.connect} fires with
a L{Failure} wrapping L{HostKeyChanged}.
s   testxp)Ú
passphraseTr  r�  ó   dummy passwordrn  r   rs  N)r8   r¦   r<   Úpublicr,   r#   rf  ri  r!   rÐ   rj  r=   rÃ   r…   r/   rp  rœ   rÄ   r   r   r½   r@   rë   r˜   rt  rõ   rö   r
   )rH   ÚfirstKeyrh  ÚdifferentKeyro  r÷   r˜   rø   r¶   rÛ   r´   rú   s               rI   Útest_mismatchedHostKeyÚ)NewConnectionTests.test_mismatchedHostKeyƒ  s6  € ô —>’>Ô"4Ó5×<Ñ<Ó>ˆÜ#¤H¨T¯[©[«]Ó$;Ó<ˆ
Ø×Ñœm¨D×,>Ñ,>×,CÑ,CÓDÀhÔOä—~’~Ü,¸ñ
ç
‰&‹(ð 	ð 	×Ñ˜dŸm™m¨\Ô:ô
 ˜TÓ"ˆä+×9Ò9Ø�L‰LØØØ�M‰MØ�I‰IØ&Ø!Øñ	
ˆô “)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×<Ñ<Ø�L‰L˜$Ÿ,™,×1Ñ1°!Ñ4°QÑ7ó 
Ñˆ˜ð × Ñ  Ó+ˆØ	�‰Œ~ÕrL   c                 ó  • [         R                  " U R                  SSU R                  U R                  U R
                  [        S5      S9n[        5       n[        Ul	        UR                  U5      n[        5       nU R                  R                  S   S   nUR                  S5      nUR                  U5        UR                  [!        [#        5       5      5        U R%                  U5      R'                  ["        5        g)a%  
If the connection closes at any point before the SSH transport layer
has finished key exchange (ie, gotten to the point where we may attempt
to authenticate), the L{Deferred} returned by
L{SSHCommandClientEndpoint.connect} fires with a L{Failure} wrapping
the reason for the lost connection.
r  r�  Fr”  r   rs  N)r/   rp  rœ   rÃ   rÄ   rh  r…   r   r   r½   r@   r   rt  r‚   ÚmakeConnectionr!  r"   r   rõ   rö   ©rH   r÷   r˜   r—  r—   rÛ   s         rI   Ú!test_connectionClosedBeforeSecureÚ4NewConnectionTests.test_connectionClosedBeforeSecure¯  sÍ   € ô ,×9Ò9Ø�L‰LØØØ�M‰MØ�I‰IØ—‘Ü˜uÓ%ñ
ˆô “)ˆÜ#ˆÔØ×Ñ˜WÓ%ˆä#Ó%ˆ	Ø—,‘,×)Ñ)¨!Ñ,¨QÑ/ˆØ×&Ñ& tÓ,ˆØ×Ñ˜iÔ(à×Ñœg¤nÓ&6Ó7Ô8Ø×Ñ˜QÓ×$Ñ$¤^Õ4rL   c                 óX  • [         R                  " U R                  SSU R                  U R                  U R
                  [        S5      S9n[        5       n[        Ul	        UR                  U5      n[        SSS9nU R                  R                  S   S   nUR                  S5      nUR                  U5        UR                  5         U R!                  U5      R#                  [$        5        U R'                  UR(                  5        UR+                  [-        [/        5       5      5        g)	a+  
If the connection is cancelled before the SSH transport layer has
finished key exchange (ie, gotten to the point where we may attempt to
authenticate), the L{Deferred} returned by
L{SSHCommandClientEndpoint.connect} fires with a L{Failure} wrapping
L{CancelledError} and the connection is aborted.
r  r�  Fr”  Nr¹   r   rs  )r/   rp  rœ   rÃ   rÄ   rh  r…   r   r   r½   r@   rB   rt  r‚   r¦  r  rõ   rö   r   r|  rF   r!  r"   r   r§  s         rI   Ú$test_connectionCancelledBeforeSecureÚ7NewConnectionTests.test_connectionCancelledBeforeSecureÍ  sî   € ô ,×9Ò9Ø�L‰LØØØ�M‰MØ�I‰IØ—‘Ü˜uÓ%ñ
ˆô “)ˆÜ#ˆÔØ×Ñ˜WÓ%ˆä*¨4¸%Ñ@ˆ	Ø—,‘,×)Ñ)¨!Ñ,¨QÑ/ˆØ×&Ñ& tÓ,ˆØ×Ñ˜iÔ(Ø	�‰Œ
à×Ñ˜QÓ×$Ñ$¤^Ô4Ø�‰˜	×)Ñ)Ô*ð 	×Ñœg¤nÓ&6Ó7Õ8rL   c                 ó²  • [         R                  " U R                  SSU R                  U R                  U R
                  [        S5      S9n[        5       n[        Ul	        UR                  U5      nUR                  5         U R                  U5      R                  [        5        U R                  U R                  R                   S   R"                  5        g)zb
If the connection is cancelled before it finishes connecting, the
connection attempt is stopped.
r  r�  Fr”  r   N)r/   rp  rœ   rÃ   rÄ   rh  r…   r   r   r½   r@   r  rõ   rö   r   r|  Ú
connectorsÚstoppedConnectingr–  s       rI   Ú'test_connectionCancelledBeforeConnectedÚ:NewConnectionTests.test_connectionCancelledBeforeConnectedï  s£   € ô
 ,×9Ò9Ø�L‰LØØØ�M‰MØ�I‰IØ—‘Ü˜uÓ%ñ
ˆô “)ˆÜ#ˆÔØ×Ñ˜WÓ%ˆØ	�‰Œ
Ø×Ñ˜QÓ×$Ñ$Ô%=Ô>Ø�‰˜Ÿ™×/Ñ/°Ñ2×DÑDÕErL   c                 óH  • [         R                  " U R                  SSU R                  U R                  SU R
                  [        S5      S9n[        5       n[        Ul	        UR                  U5      nU R                  U R                  U R                  R                  S   S   5      u  pEnU R                  R                  UR                  R                   5        UR#                  5         U R%                  U5      nUR'                  [(        5        U R+                  US5        g)	zÃ
If the SSH server rejects the password presented during authentication,
the L{Deferred} returned by L{SSHCommandClientEndpoint.connect} fires
with a L{Failure} wrapping L{AuthenticationFailed}.
r  r�  rŸ  Frn  r   rs  N)r/   rp  rœ   rÃ   rÄ   rh  r…   r   r   r½   r@   rë   r˜   rt  Úadvancer  ÚpasswordDelayÚflushrõ   rö   r-   rÝ   rÿ   s           rI   Ú"test_passwordAuthenticationFailureÚ5NewConnectionTests.test_passwordAuthenticationFailure  sì   € ô ,×9Ò9Ø�L‰LØØØ�M‰MØ�I‰IØ&Ø—‘Ü˜uÓ%ñ	
ˆô “)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×<Ñ<Ø�L‰L˜$Ÿ,™,×1Ñ1°!Ñ4°QÑ7ó 
Ñˆ˜ð 	�‰×Ñ˜VŸ^™^×9Ñ9Ô:ð 	�
‰
Œà× Ñ  Ó+ˆØ	�‰Ô#Ô$ð 	×'Ñ'¨°Õ6rL   c                 óê   • UR                  5        VVs0 s H+  u  p4U[        R                  " U5      R                  5       /_M-     nnn[	        [        U5      5      nUR                  U5        gs  snnf )at  
Create an L{ISSHPrivateKey} checker which recognizes C{users} and add it
to C{portal}.

@param portal: A L{Portal} to which to add the checker.
@type portal: L{Portal}

@param users: The users and their keys the checker will recognize.  Keys
    are byte strings giving user names.  Values are byte strings giving
    OpenSSH-formatted private keys.
@type users: L{dict}
N)Úitemsr8   r¦   r   r*   r)   rË   )rH   rÈ   ÚusersÚkÚvÚmappingÚcheckers          rI   ÚsetupKeyCheckerÚ"NewConnectionTests.setupKeyChecker-  s`   € ð @E¿{¹{¼}ÔMº}±t°q�1”s—~’~ aÓ(×/Ñ/Ó1Ð2Ò2¹}ˆÑMÜ%Ô&6°wÓ&?Ó@ˆØ×Ñ˜wÕ'ùó Ns   ”2A/c                 ó’  • [         R                  " [        5      nU R                  U R                  U R
                  [        05        [        R                  " U R                  SU R
                  U R                  U R                  U/U R                  [        S5      S9n[        5       n[        Ul        UR#                  U5      nU R%                  U R&                  U R                  R(                  S   S   5      u  pVnU R+                  U5      nUR-                  [.        5        U R1                  UR2                  R4                  5        g)zÃ
If the SSH server rejects the key pair presented during authentication,
the L{Deferred} returned by L{SSHCommandClientEndpoint.connect} fires
with a L{Failure} wrapping L{AuthenticationFailed}.
r  F©Úkeysrh  ro  r   rs  N)r8   r¦   r<   r¿  rÈ   rÅ   r;   r/   rp  rœ   rÃ   rÄ   rh  r…   r   r   r½   r@   rë   r˜   rt  rõ   rö   r-   r|  r—   r}  )	rH   ÚbadKeyr÷   r˜   rø   r¶   rÛ   r´   rú   s	            rI   Ú#test_publicKeyAuthenticationFailureÚ6NewConnectionTests.test_publicKeyAuthenticationFailure>  s   € ô —’Ô 2Ó3ˆØ×Ñ˜TŸ[™[¨4¯9©9Ô6HÐ*IÔJä+×9Ò9Ø�L‰LØØ�I‰IØ�M‰MØ�I‰IØ�Ø—‘Ü˜uÓ%ñ	
ˆô “)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×<Ñ<Ø�L‰L˜$Ÿ,™,×1Ñ1°!Ñ4°QÑ7ó 
Ñˆ˜ð × Ñ  Ó+ˆØ	�‰Ô#Ô$ð 	�‰˜×(Ñ(×6Ñ6Õ7rL   c                 ó6  • [         R                  " [        5      nU R                  U R                  U R
                  [        05        [        R                  " U R                  SU R
                  U R                  U R                  U/U R                  U R                  [        S5      S9	n[        5       n[         Ul        UR%                  U5      nU R&                  =R(                  S-  sl        U R+                  U R&                  U R                  R,                  S   S   5      u  pVnUR/                  5         U R1                  [2        5      nU R5                  SUS   R6                  R8                  US   R6                  R6                  45        U R;                  S[=        U5      5        U R?                  U5      n	U	RA                  [2        5        U R;                  SU	R6                  R6                  5        U RC                  URD                  RF                  5        g	)
zc
If the SSH server does not accept any of the specified SSH keys, the
specified password is tried.
r  F)rÃ  rÆ   rh  ro  rc   r   rs  rî   rï   N)$r8   r¦   r<   r¿  rÈ   rÅ   r;   r/   rp  rœ   rÃ   rÄ   rÆ   rh  r…   r   r   r½   r@   r˜   r™   rë   rt  r´   rð   r	   rñ   rò   rY   ró   rô   rõ   rö   r|  r—   r}  )
rH   rÄ  r÷   r˜   rø   r¶   rÛ   r´   rù   rú   s
             rI   Útest_authenticationFallbackÚ.NewConnectionTests.test_authenticationFallbackc  s—  € ô
 —’Ô 2Ó3ˆØ×Ñ˜TŸ[™[¨4¯9©9Ô6HÐ*IÔJä+×9Ò9Ø�L‰LØØ�I‰IØ�M‰MØ�I‰IØ�Ø—]‘]Ø—‘Ü˜uÓ%ñ

ˆô “)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	ð 	�‰×-Ò-°Ñ2Õ-à#×<Ñ<Ø�L‰L˜$Ÿ,™,×1Ñ1°!Ñ4°QÑ7ó 
Ñˆ˜ð 	�	‰	Œð ×'Ñ'¬
Ó3ˆØ�‰Ð'¨&°©)¯/©/×*>Ñ*>ÀÀqÁ	ÇÁ×@UÑ@UÐ)VÔWØ×Ñ˜œC ›KÔ(ð × Ñ  Ó+ˆØ	�‰ŒzÔØ×ÑÐ+¨Q¯W©W¯]©]Ô;ð 	�‰˜×(Ñ(×6Ñ6Õ7rL   c                 óŽ  • [         R                  " [        5      nU R                  U R                  U R
                  [        05        [        U R                  R                  S'   [        R                  " U R                  SU R
                  U R                  U R                  U/U R                  [        S5      S9n[!        5       n["        Ul        UR'                  U5      nU R)                  U R*                  U R                  R,                  S   S   5      u  pVnU R/                  U5      nU R1                  UR2                  5        g)zƒ
If L{SSHCommandClientEndpoint} is initialized with any private keys, it
will try to use them to authenticate with the SSH server.
rþ   r  FrÂ  r   rs  N)r8   r¦   r;   r¿  rÈ   rÅ   r`   rÇ   rp   r/   rp  rœ   rÃ   rÄ   rh  r…   r   r   r½   r@   rë   r˜   rt  r  r  r—   )	rH   Úkeyr÷   r˜   rø   r¶   rÛ   r´   r½   s	            rI   Útest_publicKeyAuthenticationÚ/NewConnectionTests.test_publicKeyAuthentication“  s  € ô
 �nŠnÔ/Ó0ˆØ×Ñ˜TŸ[™[¨4¯9©9Ô6HÐ*IÔJä/Aˆ�
‰
× Ñ  Ñ,Ü+×9Ò9Ø�L‰LØØ�I‰IØ�M‰MØ�I‰IØ�Ø—‘Ü˜uÓ%ñ	
ˆô “)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×<Ñ<Ø�L‰L˜$Ÿ,™,×1Ñ1°!Ñ4°QÑ7ó 
Ñˆ˜ð ×'Ñ'¨	Ó2ˆØ×Ñ˜X×/Ñ/Õ0rL   c                 ó"  • [         R                  " U R                  SU R                  U R                  U R
                  U R                  [        S5      S9n[        5       n[        Ul
        UR                  U5      nU R                  U R                  U R                  R                  S   S   5      u  pEnUR                  5         U R!                  U5      nUR#                  [$        5        U R'                  UR(                  R*                  5        g)zn
If the password is not specified, L{SSHCommandClientEndpoint} doesn't
try it as an authentication mechanism.
r  Fr”  r   rs  N)r/   rp  rœ   rÅ   rÃ   rÄ   rh  r…   r   r   r½   r@   rë   r˜   rt  r´   rõ   rö   r-   r|  r—   r}  rÿ   s           rI   Útest_skipPasswordAuthenticationÚ2NewConnectionTests.test_skipPasswordAuthentication²  sÙ   € ô
 ,×9Ò9Ø�L‰LØØ�I‰IØ�M‰MØ�I‰IØ—‘Ü˜uÓ%ñ
ˆô “)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×<Ñ<Ø�L‰L˜$Ÿ,™,×1Ñ1°!Ñ4°QÑ7ó 
Ñˆ˜ð 	�	‰	Œð × Ñ  Ó+ˆØ	�‰Ô#Ô$ð 	�‰˜×(Ñ(×6Ñ6Õ7rL   c                 ó^  • [         R                  " [        5      n[        5       n[	        5       Ul        UR                  5       US40UR
                  l        U R                  U R                  U R                  [        05        [        U5      n[        R                  " U R                  SU R                  U R                  U R                   U R"                  [%        S5      US9n[&        U R(                  R*                  S'   [	        5       n[,        Ul        UR1                  U5      nU R3                  U R
                  U R                  R4                  S   S   5      u  pxn	[7        S5       H-  n
UR8                  R9                  5         U	R9                  5         M/     U R;                  U5      nU R=                  UR>                  5        U RA                  XxX¹5        U RC                  UR>                  RD                  5        U RC                  UR8                  RF                  RD                  5        g	)
zå
If L{SSHCommandClientEndpoint} is initialized with an
L{SSHAgentClient}, the agent is used to authenticate with the SSH
server. Once the connection with the SSH server has concluded, the
connection to the agent is disconnected.
rL   r  F)rh  ro  ÚagentEndpointrþ   r   rs  é   N)$r8   r¦   r<   r4   r   r˜   ÚblobrÃ  r¿  rÈ   rÅ   r±   r/   rp  rœ   rÃ   rÄ   rh  r…   r`   rÇ   rp   r   r½   r@   rë   rt  Úranger´   r  r  r—   ry  r|  r}  ÚclientIO)rH   rË  ÚagentServerrÒ  r÷   r˜   rø   r¶   rÛ   r´   Úir½   s               rI   Útest_agentAuthenticationÚ+NewConnectionTests.test_agentAuthenticationÓ  s¬  € ô �nŠnÔ/Ó0ˆÜ$Ó&ˆÜ%›iˆÔØ$'§H¡H£J°°c°
Ð#;ˆ×ÑÔ à×Ñ˜TŸ[™[¨4¯9©9Ô6HÐ*IÔJä/°Ó<ˆÜ+×9Ò9Ø�L‰LØØ�I‰IØ�M‰MØ�I‰IØ—‘Ü˜uÓ%Ø'ñ	
ˆô 0Bˆ�
‰
× Ñ  Ñ,ä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×<Ñ<Ø�L‰L˜$Ÿ,™,×1Ñ1°!Ñ4°QÑ7ó 
Ñˆ˜ô �r–ˆAØ×Ñ×#Ñ#Ô%Ø�I‰IŽKñ ð ×'Ñ'¨	Ó2ˆØ×Ñ˜X×/Ñ/Ô0ð 	×#Ñ# F°HÔCØ�‰˜×(Ñ(×6Ñ6Ô7Ø�‰˜×*Ñ*×3Ñ3×AÑAÕBrL   c                 ó`  • [         U R                  R                  S'   U R                  5       n[	        5       n[
        Ul        UR                  U5      nU R                  5       u  pEnU R                  U5      nU R                  XEXv5        U R                  UR                  R                  5        g)z³
The transport connected to the protocol has a C{loseConnection} method
which causes the channel in which the command is running to close and
the overall connection to be closed.
rþ   N)r`   rÇ   rp   r×   r   r   r½   r@   rà   r  ry  r|  r—   r}  r  s           rI   Útest_loseConnectionÚ&NewConnectionTests.test_loseConnection  s�   € ô 0Bˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜à×'Ñ'¨	Ó2ˆØ×#Ñ# F°HÔCð 	�‰˜×(Ñ(×6Ñ6Õ7rL   )rg  rh  N)rM   rN   rO   rP   rQ   rÑ   r×   rà   ry  rÝ   rƒ  r‰  rŒ  r‘  r˜  r›  r£  r¨  r«  r°  r¶  r¿  rÅ  rÈ  rÌ  rÏ  rÙ  rÜ  rR   rS   rL   rI   rc  rc  ½  s…   † ñò
ò
ò 
ò!,òF<òGò5ò7ò:ò0=ò0 ò8*òX5ò< 9òDFò,&7òP(ò"#8òJ.8ò`1ò>8òB1Cõf8rL   rc  c                   ó0   • \ rS rSrSrS rS rS rS rSr	g)	ÚExistingConnectionTestsi  zY
Tests for L{SSHCommandClientEndpoint} when using the C{existingConnection}
constructor.
c                 ó  • [         R                  U 5        [        [        U R	                  5       5      5      nUR                  U R                  U R                  R                  S   5        UR                  [        U R                  R                  5      U R                  R                  S   5        [        R                  " U R                  SU R                  U R                  U R                   U R"                  U[%        S5      S9U l        g)re  r¥   r  Frn  N)rÀ   rÑ   r,   r#   rf  ri  rÃ   r˜   r§   r!   rÐ   rj  r/   rp  rœ   rÅ   rÄ   rÆ   r…   r÷   )rH   rh  s     rI   rÑ   ÚExistingConnectionTests.setUp#  sÂ   € ô
 	+×0Ñ0°Ô6ä#¤H¨T¯[©[«]Ó$;Ó<ˆ
Ø×Ñ˜dŸm™m¨T¯\©\×-DÑ-DÀZÑ-PÔQØ×ÑÜ˜$×,Ñ,×1Ñ1Ó2°D·L±L×4KÑ4KÈJÑ4Wô	
ô 1×>Ò>Ø�L‰LØØ�I‰IØ�M‰MØ�I‰IØ—]‘]Ø!Ü˜uÓ%ñ	
ˆ�rL   c                 ó&  • [        5       n[        Ul        U R                  R	                  U5      nU R
                  R                  R                  5       n [        U R
                  R                  S'   U R                  U R                  U R                  R                  S   S   5      u  pEnU R
                  R                  R                  5         U R
                  R                  R                  U5        X@l        XPl        X`l        U R%                  U5      nUR&                  R(                  n[*        R,                  " US5      $ ! U R
                  R                  R                  5         U R
                  R                  R                  U5        f = f)zb
Create and return a new L{SSHCommandClientEndpoint} using the
C{existingConnection} constructor.
rþ   r   rs  r  )r   r   r½   r÷   r@   rÇ   rp   Úcopyr`   rë   r˜   rœ   rt  ÚclearÚupdaterµ   Ú_clientÚ_pumpr  r—   Úconnr/   ÚexistingConnection)	rH   r˜   rø   rp   r¶   rÛ   r´   r½   Ú
connections	            rI   r×   ÚExistingConnectionTests.create;  s1  € ô
 “)ˆÜ#ˆÔØ—M‘M×)Ñ)¨'Ó2ˆ	ð Ÿ
™
×0Ñ0×5Ñ5Ó7ˆð		;Ü3EˆD�J‰J×$Ñ$ ZÑ0à#'×#@Ñ#@Ø—‘˜dŸl™l×5Ñ5°aÑ8¸Ñ;ó$Ñ ˆF˜Dð
 �J‰J×$Ñ$×*Ñ*Ô,Ø�J‰J×$Ñ$×+Ñ+¨MÔ:àŒØŒØŒ
à×'Ñ'¨	Ó2ˆØ×'Ñ'×,Ñ,ˆ
Ü'×:Ò:¸:À}ÓUÐUøð �J‰J×$Ñ$×*Ñ*Ô,Ø�J‰J×$Ñ$×+Ñ+¨MÕ:ús   ÁAE ÅAFc                 ó  • U R                   R                  5         U R                   R                  5         U R                   R                  5         U R                   R                  5         U R                  U R                  U R                   4$ )zw
Give back the connection established in L{create} over which the new
command channel being tested will exchange data.
)rç  r´   rµ   ræ  rG   s    rI   rà   Ú(ExistingConnectionTests.finishConnectionY  sU   € ð 	�
‰
�‰ÔØ�
‰
�‰ÔØ�
‰
�‰ÔØ�
‰
�‰ÔØ�|‰|˜TŸ\™\¨4¯:©:Ð5Ð5rL   c                 ó˜   • U R                  UR                  R                  5        U R                  UR                  R                  5        g)zÛ
Assert that the transport for the given protocol is still connected.
L{SSHCommandClientEndpoint.existingConnection} re-uses an SSH connected
created by some other code, so other code is responsible for cleaning
it up.
N)ÚassertFalser—   r}  rF   rÚ   s      rI   rÝ   Ú2ExistingConnectionTests.assertClientTransportStateg  s8   € ð 	×Ñ˜×)Ñ)×7Ñ7Ô8Ø×Ñ˜×)Ñ)×1Ñ1Õ2rL   )ræ  rç  rµ   r÷   N)
rM   rN   rO   rP   rQ   rÑ   r×   rà   rÝ   rR   rS   rL   rI   rß  rß    s   † ñò

ò0Vò<6õ3rL   rß  c                   ó0   • \ rS rSrSrS rS rS rS rSr	g)	ÚExistingConnectionHelperTestsir  z)
Tests for L{_ExistingConnectionHelper}.
c                 óJ   • U R                  [        [        [        5      5        g)zD
L{_ExistingConnectionHelper} implements L{_ISSHConnectionCreator}.
N)r|  r   r1   r0   rG   s    rI   rƒ  Ú,ExistingConnectionHelperTests.test_interfacew  s   € ð 	�‰œÔ$:Ô<UÓVÕWrL   c                 óŠ   • [        5       n[        U5      nU R                  XR                  UR	                  5       5      5        g)z˜
L{_ExistingConnectionHelper.secureConnection} returns a L{Deferred}
which fires with whatever object was fed to
L{_ExistingConnectionHelper.__init__}.
N)Úobjectr0   ÚassertIsr  ÚsecureConnection)rH   r‰   Úhelpers      rI   Útest_secureConnectionÚ3ExistingConnectionHelperTests.test_secureConnection}  s5   € ô “ˆÜ*¨6Ó2ˆØ�‰�f×2Ñ2°6×3JÑ3JÓ3LÓMÕNrL   c                 ó^   • [        [        5       5      nUR                  [        5       S5        g)z…
L{_ExistingConnectionHelper.cleanupConnection} does nothing to the
existing connection if called with C{immediate} set to C{False}.
FN©r0   rö  ÚcleanupConnection©rH   rù  s     rI   Ú$test_cleanupConnectionNotImmediatelyÚBExistingConnectionHelperTests.test_cleanupConnectionNotImmediately‡  s$   € ô
 +¬6«8Ó4ˆð 	× Ñ ¤£¨5Õ1rL   c                 ó^   • [        [        5       5      nUR                  [        5       S5        g)z„
L{_ExistingConnectionHelper.cleanupConnection} does nothing to the
existing connection if called with C{immediate} set to C{True}.
TNrý  rÿ  s     rI   Ú!test_cleanupConnectionImmediatelyÚ?ExistingConnectionHelperTests.test_cleanupConnectionImmediately’  s$   € ô
 +¬6«8Ó4ˆð 	× Ñ ¤£¨4Õ0rL   rS   N)
rM   rN   rO   rP   rQ   rƒ  rú  r   r  rR   rS   rL   rI   rò  rò  r  s   † ñòXòOò	2õ	1rL   rò  c                   ó&   • \ rS rSrS\S\4S jrSrg)Ú_WriteDiscarderiž  rY   Úreturnc                ó   • g)z�
Discard writes because we are emulating a console object, where they'd
go to the screen, not back into the buffer to be read like an a+ file.
r   rS   rX   s     rI   r  Ú_WriteDiscarder.writeŸ  s   € ð
 rL   rS   N)rM   rN   rO   rP   rö  Úintr  rR   rS   rL   rI   r  r  ž  s   † ð˜&ð ¨÷ rL   r  c                   óB   • \ rS rSrSrS\SS4S jrS\S\\   4S jr	S	r
g)
Ú_PTYPathi§  z_
A L{FilePath}-like object which can be opened to create a L{_ReadFile} with
certain contents.
Úcontentsr  Nc                 ó   • Xl         g)zb
@param contents: L{bytes} which will be the contents of the
    L{_ReadFile} this path can open.
N©r  )rH   r  s     rI   rq   Ú_PTYPath.__init__­  s	   € ð
 !�rL   Úmodec                 ó<   • US:X  d   e[        U R                  5      $ )zž
If the mode is r+, return a file with the given contents as a line.

@return: a buffer of the given contents, which will discard any writes
    given to it.
zr+)r  r  )rH   r  s     rI   ÚopenÚ_PTYPath.open´  s   € ð �t‹|Ðˆ|Ü˜tŸ}™}Ó-Ð-rL   r  )rM   rN   rO   rP   rQ   Úbytesrq   Ústrr   r  rR   rS   rL   rI   r  r  §  s1   † ñð
! ð !¨4ô !ð.˜ð .  E¡÷ .rL   r  c                   óX   • \ rS rSrSrS rS rSS jrS rS r	S	 r
S
 rS rS rS rSrg)ÚNewConnectionHelperTestsi¿  z$
Tests for L{_NewConnectionHelper}.
c                 óJ   • U R                  [        [        [        5      5        g)z?
L{_NewConnectionHelper} implements L{_ISSHConnectionCreator}.
N)r|  r   r1   r2   rG   s    rI   rƒ  Ú'NewConnectionHelperTests.test_interfaceÄ  s   € ð 	�‰œÔ$:Ô<PÓQÕRrL   c                 óD   • U R                  S[        R                  5        g)z;
The default I{known_hosts} path is I{~/.ssh/known_hosts}.
z~/.ssh/known_hostsN)ró   r2   Ú_KNOWN_HOSTSrG   s    rI   Útest_defaultPathÚ)NewConnectionHelperTests.test_defaultPathÊ  s   € ð 	×ÑÐ-Ô/C×/PÑ/PÕQrL   Nc                 ó°   ^• [        5       mU R                  [        SU4S j5        [        SSSSSSSSSS5
      nU R                  TUR                  5        g)zt
L{_NewConnectionHelper._knownHosts} is used to create a
L{KnownHostsFile} if one is not passed to the initializer.
Ú_knownHostsc                 ó   >• T$ rn   rS   )ÚclsÚignoredr‰   s     €rI   ru   ÚANewConnectionHelperTests.test_defaultKnownHosts.<locals>.<lambda>Ö  s   ø€ ÉVrL   N)rö  Úpatchr2   r÷  rh  )rH   rù  r‰   s     @rI   Útest_defaultKnownHostsÚ/NewConnectionHelperTests.test_defaultKnownHostsÐ  s\   ø€ ô
 “ˆØ�
‰
Ô'¨Ô8SÔTä%ØØØØØØØØØØó
ˆð 	�‰�f˜f×/Ñ/Õ0rL   c                 ó  • [        5       R                  S   n[        U R                  5       5      n[	        U5      nUR                  SU5        UR                  5         [        SUR                  < 35        [        R                  R                  S5      nUR                  R                  US5      nU R                  [        SU5        [        SU< 35        [        R                  " 5       nU R                  UR!                  SU5      5        g)z”
Existing entries in the I{known_hosts} file are reflected by the
L{KnownHostsFile} created by L{_NewConnectionHelper} when none is
supplied to it.
r¥   s	   127.0.0.1zCreated known_hosts file at z~/r  zPatched _KNOWN_HOSTS with N)r¡   r§   r#   rf  r,   ri  rk  r$   ÚpathÚosÚ
expanduserÚreplacer%  r2   r   r|  Ú
hasHostKey)rH   rË  r)  rh  ÚhomeÚdefaultÚloadeds          rI   Útest_readExistingÚ*NewConnectionHelperTests.test_readExistingç  sÓ   € ô Ó×)Ñ)¨*Ñ5ˆÜ˜Ÿ™›Ó&ˆÜ# DÓ)ˆ
Ø×Ñ˜l¨CÔ0Ø�‰ÔäÐ*¨4¯9©9©-Ð8Ô9ô �w‰w×!Ñ! $Ó'ˆØ—)‘)×#Ñ# D¨$Ó/ˆØ�
‰
Ô'¨¸ÔAÜÐ(¨©Ð4Ô5ä%×1Ò1Ó3ˆØ�‰˜×)Ñ)¨,¸Ó<Õ=rL   c                 ól   • [        SSSSSSSSSS5
      nU R                  UR                  [        5        g)zb
If L{None} is passed for the C{ui} parameter to
L{_NewConnectionHelper}, a L{ConsoleUI} is used.
N)r2   r  ro  r+   rÿ  s     rI   Útest_defaultConsoleUIÚ.NewConnectionHelperTests.test_defaultConsoleUIþ  s9   € ô
 &Ø�$˜˜d D¨$°°d¸DÀ$ó
ˆð 	×Ñ˜fŸi™i¬Õ3rL   c                 óº   • [        S5      n[        SSSSSSSSSSU5      nU R                  UR                  R	                  S5      5      nU R                  U5        g)z—
If L{None} is passed for the C{ui} parameter to L{_NewConnectionHelper}
and /dev/tty is available, the L{ConsoleUI} used is associated with
/dev/tty.
s   yesNs   does this work?)r  r2   r  ro  rŽ   r|  ©rH   Úttyrù  r‰   s       rI   Útest_ttyConsoleUIÚ*NewConnectionHelperTests.test_ttyConsoleUI  s]   € ô �vÓˆÜ%Ø�$˜˜d D¨$°°d¸DÀ$Èó
ˆð ×%Ñ% f§i¡i×&6Ñ&6Ð7IÓ&JÓKˆØ�‰˜ÕrL   c                 óÖ   • [        U R                  5       5      n[        SSSSSSSSSSU5      nU R                  UR                  R                  S5      5      nU R                  U5        g)zÆ
If L{None} is passed for the C{ui} parameter to L{_NewConnectionHelper}
and /dev/tty is not available, the L{ConsoleUI} used is associated with
some file which always produces a C{b"no"} response.
Ns   did this break?)r#   rf  r2   r  ro  rŽ   rï  r7  s       rI   Útest_nottyUIÚ%NewConnectionHelperTests.test_nottyUI  se   € ô �t—{‘{“}Ó%ˆÜ%Ø�$˜˜d D¨$°°d¸DÀ$Èó
ˆð ×%Ñ% f§i¡i×&6Ñ&6Ð7IÓ&JÓKˆØ×Ñ˜Õ rL   c                 óv   • [        SSSSSSSSSS5
      nU R                  [        S5      UR                  5        g)za
If not passed the name of a tty in the filesystem,
L{_NewConnectionHelper} uses C{b"/dev/tty"}.
Ns   /dev/tty)r2   ró   r#   r8  rÿ  s     rI   Útest_defaultTTYFilenameÚ0NewConnectionHelperTests.test_defaultTTYFilename"  s>   € ô
 &Ø�$˜˜d D¨$°°d¸DÀ$ó
ˆð 	×Ñœ +Ó.°·
±
Õ;rL   c                 óÌ   • [        SSSSSSSSSS5
      n[        5       n[        5       Ul        UR	                  US5        U R                  UR                  R                  5        g)zu
L{_NewConnectionHelper.cleanupConnection} closes the transport cleanly
if called with C{immediate} set to C{False}.
NF)r2   r6   r   r—   rþ  r|  r}  )rH   rù  rê  s      rI   r   Ú=NewConnectionHelperTests.test_cleanupConnectionNotImmediately,  s_   € ô
 &Ø�$˜˜d D¨$°°d¸DÀ$ó
ˆô #“_ˆ
Ü.Ó0ˆ
ÔØ× Ñ  ¨UÔ3Ø�‰˜
×,Ñ,×:Ñ:Õ;rL   c                 ó   •  " S S5      n[        SSSSSSSSSS5
      n[        5       n[        5       Ul        U" 5       UR                  l        UR	                  US5        U R                  UR                  R                  R                  5        g)z„
L{_NewConnectionHelper.cleanupConnection} closes the transport with
C{abortConnection} if called with C{immediate} set to C{True}.
c                   ó   • \ rS rSrSrS rSrg)ÚMNewConnectionHelperTests.test_cleanupConnectionImmediately.<locals>.Abortablei?  Fc                 ó   • SU l         g)z
Abort the connection.
TNrE   rG   s    rI   rJ   Ú]NewConnectionHelperTests.test_cleanupConnectionImmediately.<locals>.Abortable.abortConnectionB  s   € ð  $�•rL   rE   N)rM   rN   rO   rP   rF   rJ   rR   rS   rL   rI   Ú	AbortablerE  ?  s   † ØˆGõ$rL   rH  NT)r2   r6   r9   r—   rþ  r|  rF   )rH   rH  rù  rê  s       rI   r  Ú:NewConnectionHelperTests.test_cleanupConnectionImmediately9  s   € ÷	$ñ 	$ô &Ø�$˜˜d D¨$°°d¸DÀ$ó
ˆô #“_ˆ
Ü1Ó3ˆ
ÔÙ)2«ˆ
×ÑÔ&Ø× Ñ  ¨TÔ2Ø�‰˜
×,Ñ,×6Ñ6×>Ñ>Õ?rL   rS   )r  N)rM   rN   rO   rP   rQ   rƒ  r  r&  r1  r4  r9  r<  r?  r   r  rR   rS   rL   rI   r  r  ¿  s<   † ñòSòRô1ò.>ò.4ò ò!ò<ò<õ@rL   r  )yrQ   Úos.pathr*  Úior   Ústructr   Útypingr   Úzope.interfacer   Úzope.interface.verifyr   r   rF  Útwisted.conch.errorr	   r
   r   Útwisted.conch.interfacesr   Útwisted.cred.checkersr   Útwisted.cred.portalr   Útwisted.internet.addressr   Útwisted.internet.deferr   r   r   r   Útwisted.internet.errorr   r   r   r   Útwisted.internet.interfacesr   r   Útwisted.internet.protocolr   r   Útwisted.internet.testingr   r   r   Útwisted.loggerr   r    Útwisted.python.compatr!   Útwisted.python.failurer"   Útwisted.python.filepathr#   Útwisted.python.logr$   Útwisted.python.reflectr%   Útwisted.trial.unittestr&   Útwisted.conch.avatarr(   Útwisted.conch.checkersr)   r*   Útwisted.conch.client.knownhostsr+   r,   Útwisted.conch.endpointsr-   r.   r/   r0   r1   r2   Útwisted.conch.sshr3   Útwisted.conch.ssh.agentr4   Útwisted.conch.ssh.channelr5   Útwisted.conch.ssh.connectionr6   Útwisted.conch.ssh.factoryr7   Útwisted.conch.ssh.keysr8   Útwisted.conch.ssh.transportr9   Útwisted.conch.ssh.userauthr:   Útwisted.conch.test.keydatar;   r<   r=   r>   Úskiprö  Útwisted.test.iosimr?   r@   rB   rU   r`   rf   rk   r~   r…   r”   r¡   r®   r±   rÀ   rc  rß  rò  r  r  r  rS   rL   rI   Ú<module>rp     sõ  ðñó Ý Ý Ý å &ß ;ã ç KÑ KÝ /Ý IÝ &Ý 0ß JÓ J÷ó ÷ Hß 7÷ñ ÷
 8Ý /Ý *Ý ,Ý "Ý 0Ý +á�× Ñ Ý.ßLßI÷÷ õ )Ý6Ý4Ý:Ý4Ý*Ý>Ý<÷ô ð (€DØ€JØÐØ€MØ
€CØ€JØ€NØ€NØ ÐØ€Iç 5ô˜]ô ô ˜
ô ô$˜ô ô$˜Zô ÷&2ñ 2ô4˜ô 4÷ñ ô.Ð!2ô .ô(!�Zô !ñ* ˆXÓ÷	ð 	ó ð	ñ Ð"Ó#÷#%ð #%ó $ð#%÷LkBñ kBô\]	8˜Ð#Eô ]	8ô@R3˜hÐ(Jô R3ôj)1 Hô )1ôX�gô ÷.ñ .ô0P@˜xõ P@rL   