+
    üÐjÀÛ  ã                   ó$  € R t ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHtHt ^ RIt^ RIHtHtHt ^ RIHt ^ R	IHt ^ R
IHt ^ RIHt ^ RIHtHtHtHt ^ RI H!t!H"t"H#t#H$t$ ^ RI%H&t&H't' ^ RI(H)t)H*t* ^ RI+H,t,H-t-H.t. ^ RI/H0t0H1t1 ^ RI2H3t3 ^ RI4H5t5 ^ RI6H7t7 ^ RI8H9t9 ^ RI:H;t; ^ RI<H=t= ];! R4      '       dd   ^ RI>H?t? ^ RI@HAtAHBtB ^ RICHDtDHEtE ^ RIFHGtGHHtHHItIHJtJHKtKHLtL ^ RIMHNtN ^ RIOHPtP ^ RIQHRtR ^ R ISHTtT ^ R!IUHVtV ^ R"IWHXtX ^ R#IYHZtZ ^ R$I[H\t\ ^ R%I]H^t^H_t_H`t`Hata MR&tb]ctV]ct\]ctT]ctX]ctR]ctP]ctE]ctB]ct?^ R'IdHeteHftf  ! R( R)]e4      tg ! R* R+]R4      th ! R, R-]R4      ti ! R. R/]R4      tj ! R0 R14      tk ! R2 R3])4      tl ! R4 R54      tm ! R6 R7]\4      tn ! R8 R9]V4      to]
! ]&4       ! R: R;4      4       tp]
! ]'4       ! R< R=4      4       tq ! R> R?4      tr ! R@ RA]=]r4      ts ! RB RC]=]r4      tt ! RD RE]=4      tu ! RF RG]4      tv ! RH RI4      tw ! RJ RK]=4      txR# )Lz'
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                   ó.   a € ] tR t^Vt o RtRtR tRtV tR# )ÚAbortableFakeTransportz;
A L{FakeTransport} with added C{abortConnection} support.
Fc                ó   € RV n         R# )ze
Abort the connection in a fake manner.

This should really be implemented in the underlying module.
TN©Úaborted©Úselfs   &ÚC/usr/lib/python3/dist-packages/twisted/conch/test/test_endpoints.pyÚabortConnectionÚ&AbortableFakeTransport.abortConnection]   s   € ð ˆŽó    rC   N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rD   rH   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @rG   rA   rA   V   s   ø‡ € ñð €G÷ð rJ   rA   c                   ó*   a € ] tR t^ft o RtR tRtV tR# )ÚBrokenExecSessionzG
L{BrokenExecSession} is a session on which exec requests always fail.
c                ó   € ^ # )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}
© ©rF   Údatas   &&rG   Úrequest_execÚBrokenExecSession.request_execk   ó   € ñ rJ   rW   N©rK   rL   rM   rN   rO   rZ   rP   rQ   rR   s   @rG   rU   rU   f   ó   ø‡ € ñ÷
ð 
rJ   rU   c                   ó*   a € ] tR t^xt o RtR tRtV tR# )ÚWorkingExecSessionzK
L{WorkingExecSession} is a session on which exec requests always succeed.
c                ó   € ^# )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}
rW   rX   s   &&rG   rZ   ÚWorkingExecSession.request_exec}   r\   rJ   rW   Nr]   rR   s   @rG   r`   r`   x   r^   rJ   r`   c                   ó*   a € ] tR t^Št o RtR tRtV tR# )ÚUnsatisfiedExecSessionz}
L{UnsatisfiedExecSession} is a session on which exec requests are always
delayed indefinitely, never succeeding or failing.
c                ó   € \        4       # )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   &&rG   rZ   Ú#UnsatisfiedExecSession.request_exec�   s   € ô ‹zÐrJ   rW   Nr]   rR   s   @rG   rd   rd   Š   s   ø‡ € ñ÷

ð 
rJ   rd   c                   ó,   a € ] tR t^�t o R tR tRtV tR# )ÚTrivialRealmc                ó   € / V n         R # ©N©ÚchannelLookuprE   s   &rG   Ú__init__ÚTrivialRealm.__init__ž   s
   € ØˆÖrJ   c                óL   € \        4       pV P                  Vn        \        VR  3# )c                  ó   € R # rj   rW   rW   rJ   rG   Ú<lambda>Ú,TrivialRealm.requestAvatar.<locals>.<lambda>¤   s   € ©DrJ   )r'   rl   r   )rF   ÚavatarIdÚmindÚ
interfacesÚavatars   &&&* rG   ÚrequestAvatarÚTrivialRealm.requestAvatar¡   s$   € Ü“ˆØ#×1Ñ1ˆÔÜ˜F¡LÐ1Ð1rJ   rk   N)rK   rL   rM   rN   rm   rw   rP   rQ   rR   s   @rG   rh   rh   �   s   ø‡ € ò ÷2ð 2rJ   rh   c                   ó*   a € ] tR t^§t o RtR tRtV tR# )ÚAddressSpyFactoryNc                ó:   € Wn         \        P                  ! W4      # rj   )Úaddressr   ÚbuildProtocol)rF   r|   s   &&rG   r}   ÚAddressSpyFactory.buildProtocolª   s   € ØŒÜ×$Ò$ TÓ3Ð3rJ   )r|   )rK   rL   rM   rN   r|   r}   rP   rQ   rR   s   @rG   rz   rz   §   s   ø‡ € Ø€G÷4ð 4rJ   rz   c                   ó2   a € ] tR t^¯t o R tR tR tRtV tR# )ÚFixedResponseUIc                ó   € Wn         R # rj   ©Úresult)rF   rƒ   s   &&rG   rm   ÚFixedResponseUI.__init__°   s   € ØŽrJ   c                ó,   € \        V P                  4      # rj   )r   rƒ   ©rF   Útexts   &&rG   ÚpromptÚFixedResponseUI.prompt³   s   € Ü�t—{‘{Ó#Ð#rJ   c                ó   € R # rj   rW   r†   s   &&rG   ÚwarnÚFixedResponseUI.warn¶   s   € ÙrJ   r‚   N)	rK   rL   rM   rN   rm   rˆ   r‹   rP   rQ   rR   s   @rG   r€   r€   ¯   s   ø‡ € òò$÷ð rJ   r€   c                   ó@   a € ] tR t^ºt o ]R 4       t]R 4       tRtV tR# )ÚFakeClockSSHUserAuthServerc                óB   € V P                   P                  P                  # )za
Use the C{attemptsBeforeDisconnect} value defined by the factory to make
it easier to override.
)Ú	transportÚfactoryÚattemptsBeforeDisconnectrE   s   &rG   r’   Ú3FakeClockSSHUserAuthServer.attemptsBeforeDisconnect¼   s   € ð �~‰~×%Ñ%×>Ñ>Ð>rJ   c                óB   € V P                   P                  P                  # )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‘   ÚreactorrE   s   &rG   ÚclockÚ FakeClockSSHUserAuthServer.clockÄ   s   € ð �~‰~×%Ñ%×-Ñ-Ð-rJ   rW   N)	rK   rL   rM   rN   Úpropertyr’   r–   rP   rQ   rR   s   @rG   rŽ   rŽ   º   s+   ø‡ € àñ?ó ð?ð ñ.ó ö.rJ   rŽ   c                   óP   a € ] tR t^Ît o ]R 4       t]R 4       tR]R]/t	^ t
RtV tR# )ÚCommandFactoryc                ó<   € R \         P                  ! \        R7      /# ©ó   ssh-rsa)rY   )r7   Ú
fromStringr=   rE   s   &rG   Ú
publicKeysÚCommandFactory.publicKeysÏ   s   € àœCŸNšNÔ0AÔBÐCÐCrJ   c                ó<   € R \         P                  ! \        R7      /# rœ   )r7   rž   r;   rE   s   &rG   ÚprivateKeysÚCommandFactory.privateKeysÓ   s   € àœCŸNšNÔ0BÔCÐDÐDrJ   s   ssh-userauths   ssh-connectionrW   N)rK   rL   rM   rN   r˜   rŸ   r¢   rŽ   r5   Úservicesr’   rP   rQ   rR   s   @rG   rš   rš   Î   sK   ø‡ € ØñDó ðDð ñEó ðEð 	Ð3Ø˜=ð€Hð  !ÖrJ   rš   c                   ó   € ] tR t^ãtRtR# )ÚMemoryAddressrW   N)rK   rL   rM   rN   rP   rW   rJ   rG   r¦   r¦   ã   s   † ãrJ   r¦   c                   ó0   a € ] tR t^èt o RtR tR tRtV tR# )ÚSingleUseMemoryEndpointaA  
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                ó    € RV n         Wn        R# )zx
@param server: An L{IProtocol} provider to which the client will be
    connected.
@type server: L{IProtocol} provider
N)ÚpumpÚ_server)rF   Úservers   &&rG   rm   Ú SingleUseMemoryEndpoint.__init__ô   s   € ð ˆŒ	ØŽrJ   c           
     ó.  € V P                   e   \        R4      h VP                  \        4       4      p\	        V P
                  \        V P
                  RR7      V\        VRR7      4      V n         \        V4      #   \         d    \        4       u # i ; i)Nz(SingleUseMemoryEndpoint was already usedT©ÚisServerF)
rª   Ú	Exceptionr}   r¦   r?   r«   rA   r   ÚBaseExceptionr   )rF   r‘   Úprotocols   && rG   r?   ÚSingleUseMemoryEndpoint.connectý   s„   € Ø�9‰9Ò ÜÐFÓGÐGð	%Ø×,Ñ,¬]«_Ó=ˆHô  Ø—‘Ü& t§|¡|¸dÔCØÜ& x¸%Ô@ó	ˆDŒIô ˜8Ó$Ð$øô ô 	Ü“6ŠMð	ús   ›A< Á<BÂB)r«   rª   N)	rK   rL   rM   rN   rO   rm   r?   rP   rQ   rR   s   @rG   r¨   r¨   è   s   ø‡ € ñò÷%ð %rJ   r¨   c                   óš   a € ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tR tRR ltR tR tRtV tR# )Ú"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                óÆ  € R V n         RV n        RV n        RV n        \	        4       V n        \        4       V n        \        V P                  4      V n	        \        4       V n        V P                  P                  V P                  V P                  4       V P                  P                  V P                  4       \        4       V n        V P
                  V P                  n        V P                  V P                  n	        V P                  P!                  4        V P#                  V P                  P$                  4       \'        RRR4      V n        \'        RRR4      V n        R	# )
s   ssh.example.comi&¤  s   users   passwordÚTCPz10.0.0.1i90  z192.168.100.200i1Ô  N)ÚhostnameÚportÚuserÚpasswordr   r•   rh   Úrealmr   Úportalr   ÚpasswdDBÚaddUserÚregisterCheckerrš   r‘   ÚdoStartÚ
addCleanupÚdoStopr   ÚclientAddressÚserverAddressrE   s   &rG   ÚsetUpÚ(SSHCommandClientEndpointTestsMixin.setUp  sð   € Ø*ˆŒØˆŒ	ØˆŒ	Ø#ˆŒÜ)Ó+ˆŒÜ!“^ˆŒ
Ü˜TŸZ™ZÓ(ˆŒÜ?ÓAˆŒØ�‰×Ñ˜dŸi™i¨¯©Ô7Ø�‰×#Ñ# D§M¡MÔ2Ü%Ó'ˆŒØ#Ÿ|™|ˆ�‰ÔØ"Ÿk™kˆ�‰ÔØ�‰×ÑÔØ�‰˜Ÿ™×+Ñ+Ô,ä(¨°
¸EÓBˆÔÜ(¨Ð0AÀ5ÓIˆÖrJ   c                óH   € \        V P                  P                  : R24      h)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__rK   rE   s   &rG   ÚcreateÚ)SSHCommandClientEndpointTestsMixin.create1  s'   € ô
 "Ø�~‰~×&Ñ&Ñ)Ð)BÐCó
ð 	
rJ   c                óH   € \        V P                  P                  : R24      h)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Ê   ©rF   ÚclientÚimmediateCloses   &&&rG   ÚassertClientTransportStateÚ=SSHCommandClientEndpointTestsMixin.assertClientTransportState:  s#   € ô "à�~‰~×&Ô&ð)ó
ð 	
rJ   c                óH   € \        V P                  P                  : R24      h)zp
Do any remaining work necessary to complete an in-memory connection
attempted initiated using C{self.reactor}.
z# did not implement finishConnectionrÊ   rE   s   &rG   ÚfinishConnectionÚ3SSHCommandClientEndpointTestsMixin.finishConnectionJ  s'   € ô
 "Ø�~‰~×&Ñ&Ñ)Ð)LÐMó
ð 	
rJ   c                óò   € VP                  R4      pVP                  R4      p\        VRV P                  V P                  R7      p\        VRV P                  V P                  R7      p\	        WFW54      pWCV3# )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}   rA   rÅ   rÆ   r?   )rF   ÚserverFactoryÚclientFactoryÚclientProtocolÚserverProtocolÚclientTransportÚserverTransportrª   s   &&&     rG   ÚconnectedServerAndClientÚ;SSHCommandClientEndpointTestsMixin.connectedServerAndClientS  sƒ   € ð '×4Ñ4°TÓ:ˆØ&×4Ñ4°TÓ:ˆä0ØØØ×*Ñ*Ø×*Ñ*ô	
ˆô 1ØØØ×*Ñ*Ø×*Ñ*ô	
ˆô �~¸ÓXˆØ¨tÐ3Ð3rJ   c                óH  € V P                  4       p\        4       p\        Vn        VP	                  V4      pV P                  4       w  rEpV P                  \        4      pV P                  RV^ ,          P                  P                  V^ ,          P                  P                  34       V P                  ^\        V4      4       V P                  V4      pVP                  \        4       V P                  RVP                  P                  4       V P                  VR4       R# )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 channeló   unknown channelFN)rÍ   r   r   r³   r?   rÖ   ÚflushLoggedErrorsr   ÚassertInÚvaluerY   ÚassertEqualÚlenÚfailureResultOfÚtraprÓ   )	rF   Úendpointr‘   Ú	connectedr¬   rÑ   rª   ÚerrorsÚfs	   &        rG   Útest_channelOpenFailureÚ:SSHCommandClientEndpointTestsMixin.test_channelOpenFailurep  sÞ   € ð —;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜ð ×'Ñ'¬
Ó3ˆØ�‰Ð'¨&°­)¯/©/×*>Ñ*>ÀÀqÅ	ÇÁ×@UÑ@UÐ)VÔWØ×Ñ˜œC ›KÔ(ð × Ñ  Ó+ˆØ	�‰ŒzÔØ×ÑÐ+¨Q¯W©W¯]©]Ô;à×'Ñ'¨°Ö6rJ   c                óŽ  € \         V P                  P                  R&   V P                  4       p\	        4       p\
        Vn        VP                  V4      pV P                  4       w  rEpV P                  V4      pVP                  \        4       V P                  RVP                  P                  4       V P                  VR4       R# )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½   rl   rÍ   r   r   r³   r?   rÖ   rë   rì   r   ré   rè   rÓ   ©rF   rí   r‘   rî   r¬   rÑ   rª   rð   s   &       rG   Útest_execFailureÚ3SSHCommandClientEndpointTestsMixin.test_execFailureŠ  s›   € ô 0Aˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜à× Ñ  Ó+ˆØ	�‰ŒzÔØ×ÑÐ1°1·7±7·=±=ÔAà×'Ñ'¨°Ö6rJ   c                ób  € \         V P                  P                  R&   V P                  4       p\	        4       p\
        Vn        VP                  V4      pV P                  4       w  rEpVP                  4        V P                  V4      pVP                  \        4       V P                  VR4       R# )z•
If execution of the command is cancelled via the L{Deferred} returned
by L{SSHCommandClientEndpoint.connect}, the connection is closed
immediately.
rô   TN)rd   r½   rl   rÍ   r   r   r³   r?   rÖ   Úcancelrë   rì   r   rÓ   rõ   s   &       rG   Útest_execCancelledÚ5SSHCommandClientEndpointTestsMixin.test_execCancelledŸ  sŽ   € ô 0Fˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	Ø#×4Ñ4Ó6Ñˆ˜à×ÑÔà× Ñ  Ó+ˆØ	�‰Œ~Ôà×'Ñ'¨°Ö5rJ   c                ó:  € \         V P                  P                  R&   V P                  4       p\	        4       p\
        Vn        VP                  V4       V P                  4       w  r4pV P                  VP                  \        4       V P                  VP                  P                  4       VP                  P                  4       V P                  V P                   VP                  P"                  4       V P                  RVP                  P$                  4       R# )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½   rl   rÍ   rz   r   r³   r?   rÖ   ÚassertIsInstancer|   r-   ré   r�   ÚgetHostr¬   r»   ÚusernameÚcommand)rF   rí   r‘   r¬   rÑ   rª   s   &     rG   Útest_buildProtocolÚ5SSHCommandClientEndpointTestsMixin.test_buildProtocol´  sË   € ô 0Bˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä#Ó%ˆÜ#ˆÔà×Ñ˜Ô!à#×4Ñ4Ó6Ñˆ˜à×Ñ˜gŸo™oÔ/@ÔAØ×Ñ˜×)Ñ)×1Ñ1Ó3°W·_±_×5KÑ5KÔLØ×Ñ˜Ÿ™ G§O¡O×$<Ñ$<Ô=Ø×Ñ˜¨¯©×(?Ñ(?Ö@rJ   c                ó*  € \         V P                  P                  R&   V P                  4       p\	        4       p\
        Vn        VP                  V4      pV P                  4       w  rEpV P                  V4      pV P                  VP                  4       R# )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½   rl   rÍ   r   r   r³   r?   rÖ   ÚsuccessResultOfÚassertIsNotNoner�   ©rF   rí   r‘   rî   r¬   rÑ   rª   r³   s   &       rG   Útest_makeConnectionÚ6SSHCommandClientEndpointTestsMixin.test_makeConnectionË  sz   € ô 0Bˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜à×'Ñ'¨	Ó2ˆØ×Ñ˜X×/Ñ/Ö0rJ   c                ó   € \         V P                  P                  R&   V P                  4       p\	        4       p\
        Vn        VP                  V4      pV P                  4       w  rEpV P                  V4      p. pVP                  Vn        VP                  P                  p	VP                  P                  V	,          P!                  R4       VP#                  4        V P%                  RRP'                  V4      4       R# )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, worldrJ   N)r`   r½   rl   rÍ   r   r   r³   r?   rÖ   r  ÚappendÚdataReceivedr�   ÚidÚserviceÚchannelsÚwriterª   ré   Újoin)
rF   rí   r‘   rî   r¬   rÑ   rª   r³   r  Ú	channelIds
   &         rG   Útest_dataReceivedÚ4SSHCommandClientEndpointTestsMixin.test_dataReceivedÞ  sË   € ô 0Bˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜à×'Ñ'¨	Ó2ˆØˆØ ,× 3Ñ 3ˆÔð ×&Ñ&×)Ñ)ˆ	à�‰×Ñ 	Õ*×0Ñ0°ÔAØ�	‰	ŒØ×Ñ˜¨#¯(©(°<Ó*@ÖArJ   c                ó  € \         V P                  P                  R&   V P                  4       p\	        4       p\
        Vn        VP                  V4      pV P                  4       w  rEpV P                  V4      p. pVP                  Vn        VP                  P                  p	VP                  P                  V	,          P!                  4        VP#                  4        V^ ,          P%                  \&        4       V P)                  VR4       R# )zY
When the command closes the channel, the protocol's C{connectionLost}
method is called.
rô   FN)r`   r½   rl   rÍ   r   r   r³   r?   rÖ   r  r  ÚconnectionLostr�   r  r  r  ÚloseConnectionrª   rì   r   rÓ   )
rF   rí   r‘   rî   r¬   rÑ   rª   r³   r  r  s
   &         rG   Útest_connectionLostÚ6SSHCommandClientEndpointTestsMixin.test_connectionLostù  sÓ   € ô
 0Bˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜à×'Ñ'¨	Ó2ˆØˆØ"0×"7Ñ"7ˆÔð ×&Ñ&×)Ñ)ˆ	Ø�‰×Ñ 	Õ*×9Ñ9Ô;à�	‰	ŒØ�qÕ×Ñœ~Ô.à×'Ñ'¨°Ö6rJ   c                ó*  € \         V P                  P                  R&   V P                  4       p\	        4       p\
        Vn        VP                  V4      pV P                  4       w  rgpV P                  V4      p	. p
V
P                  V	n        V	P                  P                  pVP                  P                  V,          pVP                  P!                  WÁV4       VP#                  4        VP%                  4        V P'                  VR4       V
^ ,          # )z:
Test handling of non-zero exit statuses or exit signals.
rô   F)r`   r½   rl   rÍ   r   r   r³   r?   rÖ   r  r  r  r�   r  r  r  ÚsendRequestr  rª   rÓ   )rF   ÚrequestÚ
requestArgrí   r‘   rî   r¬   rÑ   rª   r³   r  r  Úchannels   &&&          rG   Ú_exitStatusTestÚ2SSHCommandClientEndpointTestsMixin._exitStatusTest  sä   € ô 0Bˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜à×'Ñ'¨	Ó2ˆØˆØ"0×"7Ñ"7ˆÔð
 ×&Ñ&×)Ñ)ˆ	Ø—.‘.×)Ñ)¨)Õ4ˆà�‰×"Ñ" 7°ZÔ@Ø×ÑÔ Ø�	‰	ŒØ×'Ñ'¨°Ô6Ø˜aÕ Ð rJ   c                ól   € ^ pV P                  R\        RV4      4      pVP                  \        4       R# )úª
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.
ó   exit-statusú>LN)r   r   rì   r   )rF   ÚexitCodeÚexcs   &  rG   Útest_zeroExitCodeÚ4SSHCommandClientEndpointTestsMixin.test_zeroExitCode2  s.   € ð ˆØ×"Ñ" >´4¸¸hÓ3GÓHˆØ�‰”Ö rJ   c                ó  € ^{pRpV P                  R\        RV4      4      pVP                  \        4       V P	                  WP
                  P                  4       V P	                  W#P
                  P                  4       R# )r#  Nr$  r%  )r   r   rì   r   ré   rè   r&  Úsignal)rF   r&  r+  r'  s   &   rG   Útest_nonZeroExitStatusÚ9SSHCommandClientEndpointTestsMixin.test_nonZeroExitStatus<  sd   € ð ˆØˆØ×"Ñ" >´4¸¸hÓ3GÓHˆØ�‰Ô"Ô#Ø×Ñ˜§9¡9×#5Ñ#5Ô6Ø×Ñ˜§¡×!1Ñ!1Ö2rJ   c                óð  € \        4       p\        P                  ! V4       V P                  \        P                  V4       Rp^pRP                  \        P                  ! R4      R\        P                  ! R4      \        P                  ! R4      .4      pV P                  RV4      pVP                  \        4       V P                  W%P                  P                  4       V P                  W5P                  P                  4       Rp\        P                   ! V\        P"                  ! \        P$                  ! R	\        P&                  ! \(        P*                  4      R
VRRRRRRRR/4      4      4       R# )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.
NrJ   s   TERMó   s   messages   en-USs   exit-signalz'twisted.conch.endpoints._CommandChannelÚ	log_levelÚlog_namespaceÚshortSignalNameÚ
coreDumpedTÚerrorMessageÚmessageÚlanguageTag)r   r   ÚaddObserverrÃ   ÚremoveObserverr  r2   ÚNSr   rì   r   ré   rè   r&  r+  ÚhamcrestÚassert_thatÚhas_itemÚhas_entriesÚequal_tor   Úinfo)rF   ÚlogObserverr&  r+  Úpacketr'  ÚlogNamespaces   &      rG   Útest_nonZeroExitSignalÚ9SSHCommandClientEndpointTestsMixin.test_nonZeroExitSignalI  s(  € ô +Ó,ˆÜ×&Ò& {Ô3Ø�‰Ô*×9Ñ9¸;ÔGàˆØˆà—‘ä—	’	˜'Ó"àÜ—	’	˜*Ó%Ü—	’	˜(Ó#ðó
ˆð ×"Ñ" >°6Ó:ˆØ�‰Ô"Ô#Ø×Ñ˜§9¡9×#5Ñ#5Ô6Ø×Ñ˜§¡×!1Ñ!1Ô2à@ˆÜ×ÒØÜ×ÒÜ×$Ò$à#¤X×%6Ò%6´x·}±}Ó%EØ'¨Ø)¨7Ø$ dØ&¨	Ø% xðó	óö	
rJ   c                ó¼   a€ VP                   P                  p. oV'       d   V3R lpMSP                  p\        VP                  P
                  V,          W64       S# )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                  ó&   <€ S P                  R 4      # rj   )r  )Úrecorders   €rG   rq   Ú;SSHCommandClientEndpointTestsMixin.record.<locals>.<lambda>‹  s   ø€ ˜Ÿ™¨Ô-rJ   )r�   r  r  Úsetattrr  r  )rF   r¬   r³   ÚeventÚnoArgsr  rð   rG  s   &&&&&  @rG   ÚrecordÚ)SSHCommandClientEndpointTestsMixin.recordw  sJ   ø€ ð  ×&Ñ&×)Ñ)ˆ	àˆßÜ-‰Aà—‘ˆAä�—‘×'Ñ'¨	Õ2°EÔ=ØˆrJ   c                ó°  € \         V P                  P                  R&   V P                  4       p\	        4       p\
        Vn        VP                  V4      pV P                  4       w  rEpV P                  V4      pV P                  WGR4      pVP                  P                  R4       VP                  4        V P                  RRP                  V4      4       R# )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  rJ   N)r`   r½   rl   rÍ   r   r   r³   r?   rÖ   r  rL  r�   r  rª   ré   r  ©	rF   rí   r‘   rî   r¬   rÑ   rª   r³   r  s	   &        rG   Ú
test_writeÚ-SSHCommandClientEndpointTestsMixin.test_write’  s¬   € ô
 0Bˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜à×'Ñ'¨	Ó2ˆà—{‘{ 6°^ÓDˆØ×Ñ× Ñ  Ô1Ø�	‰	ŒØ×Ñ˜¨#¯(©(°<Ó*@ÖArJ   c                ó²  € \         V P                  P                  R&   V P                  4       p\	        4       p\
        Vn        VP                  V4      pV P                  4       w  rEpV P                  V4      pV P                  WGR4      pVP                  P                  R.4       VP                  4        V P                  RRP                  V4      4       R# )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  rJ   N)r`   r½   rl   rÍ   r   r   r³   r?   rÖ   r  rL  r�   ÚwriteSequencerª   ré   r  rO  s	   &        rG   Útest_writeSequenceÚ5SSHCommandClientEndpointTestsMixin.test_writeSequence§  s¯   € ô
 0Bˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜à×'Ñ'¨	Ó2ˆà—{‘{ 6°^ÓDˆØ×Ñ×(Ñ(¨/Ð):Ô;Ø�	‰	ŒØ×Ñ˜¨#¯(©(°<Ó*@ÖArJ   )rÅ   r‘   r¹   r¿   r¼   rº   r¾   r•   r½   rÆ   r»   N)F)rK   rL   rM   rN   rO   rÇ   rÍ   rÓ   rÖ   rá   rñ   rö   rú   r  r  r  r  r   r(  r,  rC  rL  rP  rT  rP   rQ   rR   s   @rG   r¶   r¶     su   ø‡ € ñòJò(
ò
ò 
ò4ò:7ò47ò*6ò*Aò.1ò&Bò67ò8!ò:!ò3ò,
ô\ò6B÷*Bð BrJ   r¶   c                   ó®   a € ] tR tRt o RtR tR tR tR tR t	R t
R	 tR
 tR tR tR tR tR tR tR tR tR tR tR tR tR tR tR tRtV tR# )ÚNewConnectionTestsi½  zT
Tests for L{SSHCommandClientEndpoint} when using the C{newConnection}
constructor.
c                óþ  € \         P                  V 4       \        V P                  4       4      V n        \        V P                  4      V n        V P                  P                  V P                  V P                  P                  R,          4       V P                  P                  \        V P                  P                  4      V P                  P                  R,          4       V P                  P                  4        R# )ú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ÚsaverE   s   &rG   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ô	
ð 	�‰×ÑÖrJ   c                óÈ   € \         P                  ! V P                  RV P                  V P                  V P
                  V P                  V P                  \        R4      R7      # )z]
Create and return a new L{SSHCommandClientEndpoint} using the
C{newConnection} constructor.
rý   F©r¼   r\  Úui)	r.   ÚnewConnectionr•   r»   r¹   rº   r¼   r\  r€   rE   s   &rG   rÍ   ÚNewConnectionTests.createÒ  sL   € ô
 (×5Ò5Ø�L‰LØØ�I‰IØ�M‰MØ�I‰IØ—]‘]Ø—‘Ü˜uÓ%ô	
ð 		
rJ   c                ó~   € V P                  V P                  V P                  P                  ^ ,          ^,          4      # )ze
Establish the first attempted TCP connection using the SSH server which
C{self.factory} can create.
)rá   r‘   r•   Ú
tcpClientsrE   s   &rG   rÖ   Ú#NewConnectionTests.finishConnectionâ  s4   € ð
 ×,Ñ,Ø�L‰L˜$Ÿ,™,×1Ñ1°!Õ4°QÕ7ó
ð 	
rJ   c                óü   € V P                  WRRR7      pVP                  P                  4        VP                  4        V P	                  R.V4       VP                  4        VP                  P                  4        R# )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)rK  N)rL  r�   r  rª   ré   ÚreportDisconnect)rF   r¬   rÑ   r³   rª   rj  s   &&&&& rG   ÚloseConnectionToServerÚ)NewConnectionTests.loseConnectionToServerë  sd   € ð* —‘˜V¨xÀ�ÓEˆØ×Ñ×)Ñ)Ô+Ø�	‰	ŒØ×Ñ˜$˜ Ô(ð
 	�	‰	Œð 	×Ñ×)Ñ)Ö+rJ   c                ó®   € V'       d(   V P                  VP                  P                  4       R# V P                  VP                  P                  4       R# )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�   rD   ÚdisconnectingrÐ   s   &&&rG   rÓ   Ú-NewConnectionTests.assertClientTransportState  s7   € ÷ Ø�O‰O˜F×,Ñ,×4Ñ4Ö5à�O‰O˜F×,Ñ,×:Ñ:Ö;rJ   c                ó´   € \         P                  ! V P                  RRV P                  V P                  4      pV P                  \        \        V4      4       R# )zI
L{SSHCommandClientEndpoint} instances provide L{IStreamClientEndpoint}.
ó   dummy commandó
   dummy userN)r.   rd  r•   r¹   rº   ro  r   r   ©rF   rí   s   & rG   Útest_interfaceÚ!NewConnectionTests.test_interface  sB   € ô ,×9Ò9Ø�L‰LÐ*¨M¸4¿=¹=È$Ï)É)ó
ˆð 	�‰œÔ%:¸HÓEÖFrJ   c                ó¬   € \         P                  ! V P                  RRV P                  4      pV P	                  ^VP
                  P                  4       R# )zn
L{SSHCommandClientEndpoint} uses the default port number for SSH when
the C{port} argument is not specified.
rs  rt  N©r.   rd  r•   r¹   ré   Ú_creatorrº   ru  s   & rG   Útest_defaultPortÚ#NewConnectionTests.test_defaultPort$  sD   € ô
 ,×9Ò9Ø�L‰LÐ*¨M¸4¿=¹=ó
ˆð 	×Ñ˜˜X×.Ñ.×3Ñ3Ö4rJ   c                ó°   € \         P                  ! V P                  RRV P                  RR7      pV P	                  RVP
                  P                  4       R# )zE
L{SSHCommandClientEndpoint} uses the C{port} argument if specified.
rs  rt  i®  )rº   Nry  ru  s   & rG   Útest_specifiedPortÚ%NewConnectionTests.test_specifiedPort.  sF   € ô ,×9Ò9Ø�L‰LÐ*¨M¸4¿=¹=Ètô
ˆð 	×Ñ˜˜x×0Ñ0×5Ñ5Ö6rJ   c                ó:  € \         P                  ! V P                  RV P                  V P                  V P
                  V P                  V P                  \        R4      R7      p\        4       p\        Vn        VP                  V4       V P                  P                  ^ ,          w  r4r%pV P                  V P                  \        V4      4       V P                  V P
                  V4       V P                  ^\!        V P                  P                  4      4       R# )z†
L{SSHCommandClientEndpoint} uses the L{IReactorTCP} passed to it to
attempt a connection to the host/port address also passed to it.
rý   Frb  N)r.   rd  r•   r»   r¹   rº   r¼   r\  r€   r   r   r³   r?   rg  ré   r    rê   )rF   rí   r‘   r^  rº   ÚtimeoutÚbindAddresss   &      rG   Ú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Ö9rJ   c                óÄ  € \         P                  ! V P                  RRV P                  V P                  V P
                  \        R4      R7      p\        4       p\        Vn	        VP                  V4      pV P                  P                  ^ ,          ^,          pVP                  R\        \        4       4      4       V P                  V4      P!                  \        4       R# )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ý   rt  F©r\  rc  N)r.   rd  r•   r¹   rº   r\  r€   r   r   r³   r?   rg  ÚclientConnectionFailedr!   r   rë   rì   ©rF   rí   r‘   Úds   &   rG   Útest_connectionFailedÚ(NewConnectionTests.test_connectionFailedO  s«   € ô ,×9Ò9Ø�L‰LØØØ�M‰MØ�I‰IØ—‘Ü˜uÓ%ô
ˆô “)ˆÜ#ˆÔØ×Ñ˜WÓ%ˆà—,‘,×)Ñ)¨!Õ,¨QÕ/ˆØ×&Ñ& t¬WÔ5KÓ5MÓ-NÔOà×Ñ˜QÓ×$Ñ$Ô%;Ö<rJ   c                óÖ  € \         P                  ! V P                  RRV P                  V P                  \        V P                  4       4      \        R4      R7      p\        4       p\        Vn
        VP                  V4      pV P                  V P                  V P                  P                  ^ ,          ^,          4      w  rEpV P                  V4      pVP!                  \"        4       R# )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ý   rt  Fr†  N)r.   rd  r•   r¹   rº   r+   rZ  r€   r   r   r³   r?   rá   r‘   rg  rë   rì   r
   rõ   s   &       rG   Ú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ó 
Ñˆ˜ð × Ñ  Ó+ˆØ	�‰ŒÖrJ   c                ó,  € \         P                  ! \        4      P                  4       p\	        \        V P                  4       4      4      pVP                  \        V P                  P                  4      V4       \         P                  ! \        RR7      P                  4       pVP                  V P                  V4       \        R4      p\        P                  ! V P                   RRV P                  V P"                  RVVR7      p\%        4       p\&        Vn        VP+                  V4      pV P-                  V P.                  V P                   P0                  ^ ,          ^,          4      w  r‰p
V P3                  V4      pVP5                  \6        4       R# )	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ý   rt  ó   dummy passwordrb  N)r7   rž   r;   Úpublicr+   r"   rZ  r]  r    rÆ   r^  r<   r¹   r€   r.   rd  r•   rº   r   r   r³   r?   rá   r‘   rg  rë   rì   r	   )rF   ÚfirstKeyr\  ÚdifferentKeyrc  rí   r‘   rî   r¬   rÑ   rª   rð   s   &           rG   Ú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ó 
Ñˆ˜ð × Ñ  Ó+ˆØ	�‰Œ~ÖrJ   c                ó  € \         P                  ! V P                  RRV P                  V P                  V P
                  \        R4      R7      p\        4       p\        Vn	        VP                  V4      p\        4       pV P                  P                  ^ ,          ^,          pVP                  R4      pVP                  V4       VP                  \!        \#        4       4      4       V P%                  V4      P'                  \"        4       R# )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ý   rt  Fr†  N)r.   rd  r•   r¹   rº   r\  r€   r   r   r³   r?   r   rg  r}   ÚmakeConnectionr  r!   r   rë   rì   ©rF   rí   r‘   r‰  r�   rÑ   s   &     rG   Ú!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Ó×$Ñ$¤^Ö4rJ   c                óv  € \         P                  ! V P                  RRV P                  V P                  V P
                  \        R4      R7      p\        4       p\        Vn	        VP                  V4      p\        RRR7      pV P                  P                  ^ ,          ^,          pVP                  R4      pVP                  V4       VP                  4        V P!                  V4      P#                  \$        4       V P'                  VP(                  4       VP+                  \-        \/        4       4      4       R# )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ý   rt  Fr†  Nr¯   )r.   rd  r•   r¹   rº   r\  r€   r   r   r³   r?   rA   rg  r}   r˜  rù   rë   rì   r   ro  rD   r  r!   r   r™  s   &     rG   Ú$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Ö8rJ   c                óÂ  € \         P                  ! V P                  RRV P                  V P                  V P
                  \        R4      R7      p\        4       p\        Vn	        VP                  V4      pVP                  4        V P                  V4      P                  \        4       V P                  V P                  P                   ^ ,          P"                  4       R# )zb
If the connection is cancelled before it finishes connecting, the
connection attempt is stopped.
rý   rt  Fr†  N)r.   rd  r•   r¹   rº   r\  r€   r   r   r³   r?   rù   rë   rì   r   ro  Ú
connectorsÚstoppedConnectingrˆ  s   &   rG   Ú'test_connectionCancelledBeforeConnectedÚ:NewConnectionTests.test_connectionCancelledBeforeConnectedï  s£   € ô
 ,×9Ò9Ø�L‰LØØØ�M‰MØ�I‰IØ—‘Ü˜uÓ%ô
ˆô “)ˆÜ#ˆÔØ×Ñ˜WÓ%ˆØ	�‰Œ
Ø×Ñ˜QÓ×$Ñ$Ô%=Ô>Ø�‰˜Ÿ™×/Ñ/°Õ2×DÑDÖErJ   c                ó`  € \         P                  ! V P                  RRV P                  V P                  RV P
                  \        R4      R7      p\        4       p\        Vn	        VP                  V4      pV P                  V P                  V P                  P                  ^ ,          ^,          4      w  rEpV P                  P                  VP                  P                   4       VP#                  4        V P%                  V4      pVP'                  \(        4       V P+                  VR4       R# )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ý   rt  r‘  Frb  N)r.   rd  r•   r¹   rº   r\  r€   r   r   r³   r?   rá   r‘   rg  Úadvancer  ÚpasswordDelayÚflushrë   rì   r,   rÓ   rõ   s   &       rG   Ú"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Ô:ð 	�
‰
Œà× Ñ  Ó+ˆØ	�‰Ô#Ô$ð 	×'Ñ'¨°Ö6rJ   c                óê   € VP                  4        UUu/ uF+  w  r4V\        P                  ! V4      P                  4       .bK-  	  ppp\	        \        V4      4      pVP                  V4       R# u uppi )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)Úitemsr7   rž   r’  r)   r(   rÁ   )rF   r¾   ÚusersÚkÚvÚmappingÚcheckers   &&&    rG   ÚsetupKeyCheckerÚ"NewConnectionTests.setupKeyChecker-  s`   € ð @E¿{¹{¼}ÔM¹}±t°q�1”s—~’~ aÓ(×/Ñ/Ó1Ð2Ò2¹}ˆÑMÜ%Ô&6°wÓ&?Ó@ˆØ×Ñ˜wÖ'ùó Ns   ”1A/c                óª  € \         P                  ! \        4      pV P                  V P                  V P
                  \        /4       \        P                  ! V P                  RV P
                  V P                  V P                  V.V P                  \        R4      R7      p\        4       p\        Vn        VP#                  V4      pV P%                  V P&                  V P                  P(                  ^ ,          ^,          4      w  rVpV P+                  V4      pVP-                  \.        4       V P1                  VP2                  P4                  4       R# )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©Úkeysr\  rc  N)r7   rž   r;   r±  r¾   r»   r:   r.   rd  r•   r¹   rº   r\  r€   r   r   r³   r?   rá   r‘   rg  rë   rì   r,   ro  r�   rp  )	rF   ÚbadKeyrí   r‘   rî   r¬   rÑ   rª   rð   s	   &        rG   Ú#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Ö7rJ   c                óf  € \         P                  ! \        4      pV P                  V P                  V P
                  \        /4       \        P                  ! V P                  RV P
                  V P                  V P                  V.V P                  V P                  \        R4      R7	      p\        4       p\         Vn        VP%                  V4      pV P&                  ;P(                  ^,          un        V P+                  V P&                  V P                  P,                  ^ ,          ^,          4      w  rVpVP/                  4        V P1                  \2        4      pV P5                  RV^ ,          P6                  P8                  V^ ,          P6                  P6                  34       V P;                  ^\=        V4      4       V P?                  V4      p	V	PA                  \2        4       V P;                  RV	P6                  P6                  4       V PC                  VPD                  PF                  4       R# )zc
If the SSH server does not accept any of the specified SSH keys, the
specified password is tried.
rý   F)rµ  r¼   r\  rc  rä   rå   N)$r7   rž   r;   r±  r¾   r»   r:   r.   rd  r•   r¹   rº   r¼   r\  r€   r   r   r³   r?   r‘   r’   rá   rg  rª   ræ   r   rç   rè   rY   ré   rê   rë   rì   ro  r�   rp  )
rF   r¶  rí   r‘   rî   r¬   rÑ   rª   rï   rð   s
   &         rG   Ú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Ö7rJ   c                ó¦  € \         P                  ! \        4      pV P                  V P                  V P
                  \        /4       \        V P                  P                  R&   \        P                  ! V P                  RV P
                  V P                  V P                  V.V P                  \        R4      R7      p\!        4       p\"        Vn        VP'                  V4      pV P)                  V P*                  V P                  P,                  ^ ,          ^,          4      w  rVpV P/                  V4      pV P1                  VP2                  4       R# )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´  N)r7   rž   r:   r±  r¾   r»   r`   r½   rl   r.   rd  r•   r¹   rº   r\  r€   r   r   r³   r?   rá   r‘   rg  r  r  r�   )	rF   Úkeyrí   r‘   rî   r¬   rÑ   rª   r³   s	   &        rG   Ú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×/Ñ/Ö0rJ   c                ó:  € \         P                  ! V P                  RV P                  V P                  V P
                  V P                  \        R4      R7      p\        4       p\        Vn
        VP                  V4      pV P                  V P                  V P                  P                  ^ ,          ^,          4      w  rEpVP                  4        V P!                  V4      pVP#                  \$        4       V P'                  VP(                  P*                  4       R# )zn
If the password is not specified, L{SSHCommandClientEndpoint} doesn't
try it as an authentication mechanism.
rý   Fr†  N)r.   rd  r•   r»   r¹   rº   r\  r€   r   r   r³   r?   rá   r‘   rg  rª   rë   rì   r,   ro  r�   rp  rõ   s   &       rG   Ú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Ö7rJ   c                óv  € \         P                  ! \        4      p\        4       p\	        4       Vn        VP                  4       VR3/VP
                  n        V P                  V P                  V P                  \        /4       \        V4      p\        P                  ! V P                  RV P                  V P                  V P                   V P"                  \%        R4      VR7      p\&        V P(                  P*                  R&   \	        4       p\,        Vn        VP1                  V4      pV P3                  V P
                  V P                  P4                  ^ ,          ^,          4      w  rxp	\7        ^4       F-  p
VP8                  P9                  4        V	P9                  4        K/  	  V P;                  V4      pV P=                  VP>                  4       V PA                  WxW¹4       V PC                  VP>                  PD                  4       V PC                  VP8                  PF                  PD                  4       R# )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.
rJ   rý   F)r\  rc  ÚagentEndpointrô   N)$r7   rž   r;   r3   r   r‘   Úblobrµ  r±  r¾   r»   r¨   r.   rd  r•   r¹   rº   r\  r€   r`   r½   rl   r   r³   r?   rá   rg  Úrangerª   r  r  r�   rl  ro  rp  ÚclientIO)rF   r½  ÚagentServerrÄ  rí   r‘   rî   r¬   rÑ   rª   Úir³   s   &           rG   Ú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ÖBrJ   c                ób  € \         V P                  P                  R&   V P                  4       p\	        4       p\
        Vn        VP                  V4      pV P                  4       w  rEpV P                  V4      pV P                  WEWv4       V P                  VP                  P                  4       R# )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½   rl   rÍ   r   r   r³   r?   rÖ   r  rl  ro  r�   rp  r  s   &       rG   Útest_loseConnectionÚ&NewConnectionTests.test_loseConnection  s�   € ô 0Bˆ�
‰
× Ñ  Ñ,Ø—;‘;“=ˆä“)ˆÜ#ˆÔØ×$Ñ$ WÓ-ˆ	à#×4Ñ4Ó6Ñˆ˜à×'Ñ'¨	Ó2ˆØ×#Ñ# F°HÔCð 	�‰˜×(Ñ(×6Ñ6Ö7rJ   )r[  r\  N)rK   rL   rM   rN   rO   rÇ   rÍ   rÖ   rl  rÓ   rv  r{  r~  rƒ  rŠ  r�  r•  rš  r�  r¢  r¨  r±  r·  rº  r¾  rÁ  rÊ  rÍ  rP   rQ   rR   s   @rG   rW  rW  ½  s�   ø‡ € ñò
ò
ò 
ò!,òF<òGò5ò7ò:ò0=ò0 ò8*òX5ò< 9òDFò,&7òP(ò"#8òJ.8ò`1ò>8òB1C÷f8ð 8rJ   rW  c                   ó<   a € ] tR tRt o RtR tR tR tR tRt	V t
R# )	ÚExistingConnectionTestsi  zY
Tests for L{SSHCommandClientEndpoint} when using the C{existingConnection}
constructor.
c                ó2  € \         P                  V 4       \        \        V P	                  4       4      4      pVP                  V P                  V P                  P                  R,          4       VP                  \        V P                  P                  4      V P                  P                  R,          4       \        P                  ! V P                  RV P                  V P                  V P                   V P"                  V\%        R4      R7      V n        R# )rY  r�   rý   Frb  N)r¶   rÇ   r+   r"   rZ  r]  r¹   r‘   rŸ   r    rÆ   r^  r.   rd  r•   r»   rº   r¼   r€   rí   )rF   r\  s   & rG   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Ó%ô	
ˆŽrJ   c                ó6  € \        4       p\        Vn        V P                  P	                  V4      pV P
                  P                  P                  4       p \        V P
                  P                  R&   V P                  V P                  V P                  P                  ^ ,          ^,          4      w  rEpV P
                  P                  P                  4        V P
                  P                  P                  V4       W@n        WPn        W`n        V P%                  V4      pVP&                  P(                  p\*        P,                  ! VR4      #   T P
                  P                  P                  4        T P
                  P                  P                  T4       i ; i)zb
Create and return a new L{SSHCommandClientEndpoint} using the
C{existingConnection} constructor.
rô   rý   )r   r   r³   rí   r?   r½   rl   Úcopyr`   rá   r‘   r•   rg  ÚclearÚupdater«   Ú_clientÚ_pumpr  r�   Úconnr.   ÚexistingConnection)	rF   r‘   rî   rl   r¬   rÑ   rª   r³   Ú
connections	   &        rG   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                ó  € V P                   P                  4        V P                   P                  4        V P                   P                  4        V P                   P                  4        V P                  V P                  V P                   3# )zw
Give back the connection established in L{create} over which the new
command channel being tested will exchange data.
)rØ  rª   r«   r×  rE   s   &rG   rÖ   Ú(ExistingConnectionTests.finishConnectionY  sU   € ð 	�
‰
�‰ÔØ�
‰
�‰ÔØ�
‰
�‰ÔØ�
‰
�‰ÔØ�|‰|˜TŸ\™\¨4¯:©:Ð5Ð5rJ   c                óš   € V P                  VP                  P                  4       V P                  VP                  P                  4       R# )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�   rp  rD   rÐ   s   &&&rG   rÓ   Ú2ExistingConnectionTests.assertClientTransportStateg  s8   € ð 	×Ñ˜×)Ñ)×7Ñ7Ô8Ø×Ñ˜×)Ñ)×1Ñ1Ö2rJ   )r×  rØ  r«   rí   N)rK   rL   rM   rN   rO   rÇ   rÍ   rÖ   rÓ   rP   rQ   rR   s   @rG   rÐ  rÐ    s$   ø‡ € ñò

ò0Vò<6÷3ð 3rJ   rÐ  c                   ó<   a € ] tR tRt o RtR tR tR tR tRt	V t
R# )	ÚExistingConnectionHelperTestsir  z)
Tests for L{_ExistingConnectionHelper}.
c                óL   € V P                  \        \        \        4      4       R# )zD
L{_ExistingConnectionHelper} implements L{_ISSHConnectionCreator}.
N)ro  r   r0   r/   rE   s   &rG   rv  Ú,ExistingConnectionHelperTests.test_interfacew  s   € ð 	�‰œÔ$:Ô<UÓVÖWrJ   c                óŒ   € \        4       p\        V4      pV P                  WP                  VP	                  4       4      4       R# )z˜
L{_ExistingConnectionHelper.secureConnection} returns a L{Deferred}
which fires with whatever object was fed to
L{_ExistingConnectionHelper.__init__}.
N)Úobjectr/   ÚassertIsr  ÚsecureConnection)rF   rƒ   Úhelpers   &  rG   Útest_secureConnectionÚ3ExistingConnectionHelperTests.test_secureConnection}  s5   € ô “ˆÜ*¨6Ó2ˆØ�‰�f×2Ñ2°6×3JÑ3JÓ3LÓMÖNrJ   c                ó`   € \        \        4       4      pVP                  \        4       R4       R# )z…
L{_ExistingConnectionHelper.cleanupConnection} does nothing to the
existing connection if called with C{immediate} set to C{False}.
FN©r/   rç  ÚcleanupConnection©rF   rê  s   & rG   Ú$test_cleanupConnectionNotImmediatelyÚBExistingConnectionHelperTests.test_cleanupConnectionNotImmediately‡  s$   € ô
 +¬6«8Ó4ˆð 	× Ñ ¤£¨5Ö1rJ   c                ó`   € \        \        4       4      pVP                  \        4       R4       R# )z„
L{_ExistingConnectionHelper.cleanupConnection} does nothing to the
existing connection if called with C{immediate} set to C{True}.
TNrî  rð  s   & rG   Ú!test_cleanupConnectionImmediatelyÚ?ExistingConnectionHelperTests.test_cleanupConnectionImmediately’  s$   € ô
 +¬6«8Ó4ˆð 	× Ñ ¤£¨4Ö0rJ   rW   N)rK   rL   rM   rN   rO   rv  rë  rñ  rô  rP   rQ   rR   s   @rG   rã  rã  r  s%   ø‡ € ñòXòOò	2÷	1ð 	1rJ   rã  c                   ó2   a € ] tR tRt o V 3R lR ltRtV tR# )Ú_WriteDiscarderiž  c                ó&   <€ V ^8„  d   QhRS[ RS[/# )é   rY   Úreturn)rç  Úint)ÚformatrS   s   "€rG   Ú__annotate__Ú_WriteDiscarder.__annotate__Ÿ  s   ø€ ÷ ñ ™&ð ©ñ rJ   c               ó   € ^ # )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.
rW   rX   s   ""rG   r  Ú_WriteDiscarder.writeŸ  s   € ñ
 rJ   rW   N)rK   rL   rM   rN   r  rP   rQ   rR   s   @rG   r÷  r÷  ž  s   ø‡ € ÷ö rJ   r÷  c                   óH   a € ] tR tRt o RtV 3R lR ltV 3R lR ltRtV tR# )	Ú_PTYPathi§  z_
A L{FilePath}-like object which can be opened to create a L{_ReadFile} with
certain contents.
c                ó$   <€ V ^8„  d   QhRS[ RR/# )rù  Úcontentsrú  N)Úbytes)rü  rS   s   "€rG   rý  Ú_PTYPath.__annotate__­  s   ø€ ÷ !ñ !¡ð !¨4ñ !rJ   c                ó   € Wn         R# )zb
@param contents: L{bytes} which will be the contents of the
    L{_ReadFile} this path can open.
N©r  )rF   r  s   &&rG   rm   Ú_PTYPath.__init__­  s	   € ð
 !ŽrJ   c                ó6   <€ V ^8„  d   QhRS[ RS[S[,          /# )rù  Úmoderú  )Ústrr   r  )rü  rS   s   "€rG   rý  r  ´  s   ø€ ÷ .ñ .™ð .¡¡E¥ñ .rJ   c                ó>   € VR8X  g   Q h\        V P                  4      # )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  )rF   r  s   &&rG   ÚopenÚ_PTYPath.open´  s   € ð �tŒ|Ðˆ|Ü˜tŸ}™}Ó-Ð-rJ   r  N)	rK   rL   rM   rN   rO   rm   r  rP   rQ   rR   s   @rG   r  r  §  s   ø‡ € ñ÷
!ð !÷.ö .rJ   r  c                   ól   a € ] tR tRt o RtR tR tV 3R lR ltR tR t	R	 t
R
 tR tR tR tRtV tR# )ÚNewConnectionHelperTestsi¿  z$
Tests for L{_NewConnectionHelper}.
c                óL   € V P                  \        \        \        4      4       R# )z?
L{_NewConnectionHelper} implements L{_ISSHConnectionCreator}.
N)ro  r   r0   r1   rE   s   &rG   rv  Ú'NewConnectionHelperTests.test_interfaceÄ  s   € ð 	�‰œÔ$:Ô<PÓQÖRrJ   c                óF   € V P                  R\        P                  4       R# )z;
The default I{known_hosts} path is I{~/.ssh/known_hosts}.
z~/.ssh/known_hostsN)ré   r1   Ú_KNOWN_HOSTSrE   s   &rG   Útest_defaultPathÚ)NewConnectionHelperTests.test_defaultPathÊ  s   € ð 	×ÑÐ-Ô/C×/PÑ/PÖQrJ   c                ó   <€ V ^8„  d   QhRR/# )rù  rú  NrW   )rü  rS   s   "€rG   rý  Ú%NewConnectionHelperTests.__annotate__Ð  s   ø€ ÷ 1ñ 1¨ñ 1rJ   c                ó²   a€ \        4       oV P                  \        RV3R l4       \        RRRRRRRRRR4
      pV P                  SVP                  4       R# )zt
L{_NewConnectionHelper._knownHosts} is used to create a
L{KnownHostsFile} if one is not passed to the initializer.
Ú_knownHostsc                 ó   <€ S# rj   rW   )ÚclsÚignoredrƒ   s   &&€rG   rq   ÚANewConnectionHelperTests.test_defaultKnownHosts.<locals>.<lambda>Ö  s   ø€ ÉVrJ   N)rç  Úpatchr1   rè  r\  )rF   rê  rƒ   s   & @rG   Útest_defaultKnownHostsÚ/NewConnectionHelperTests.test_defaultKnownHostsÐ  s\   ø€ ô
 “ˆØ�
‰
Ô'¨Ô8SÔTä%ØØØØØØØØØØó
ˆð 	�‰�f˜f×/Ñ/Ö0rJ   c                ó(  € \        4       P                  R,          p\        V P                  4       4      p\	        V4      pVP                  RV4       VP                  4        \        RVP                  : 24       \        P                  P                  R4      pVP                  P                  VR4      pV P                  \        RV4       \        RV: 24       \        P                  ! 4       pV P                  VP!                  RV4      4       R# )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"   rZ  r+   r]  r_  r#   ÚpathÚosÚ
expanduserÚreplacer   r1   r  ro  Ú
hasHostKey)rF   r½  r$  r\  ÚhomeÚdefaultÚloadeds   &      rG   Ú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ˆØ�‰˜×)Ñ)¨,¸Ó<Ö=rJ   c                ón   € \        RRRRRRRRRR4
      pV P                  VP                  \        4       R# )zb
If L{None} is passed for the C{ui} parameter to
L{_NewConnectionHelper}, a L{ConsoleUI} is used.
N)r1   rþ   rc  r*   rð  s   & rG   Útest_defaultConsoleUIÚ.NewConnectionHelperTests.test_defaultConsoleUIþ  s9   € ô
 &Ø�$˜˜d D¨$°°d¸DÀ$ó
ˆð 	×Ñ˜fŸi™i¬Ö3rJ   c                ó¼   € \        R4      p\        RRRRRRRRRRV4      pV P                  VP                  P	                  R4      4      pV P                  V4       R# )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  r1   r  rc  rˆ   ro  ©rF   Úttyrê  rƒ   s   &   rG   Útest_ttyConsoleUIÚ*NewConnectionHelperTests.test_ttyConsoleUI  s]   € ô �vÓˆÜ%Ø�$˜˜d D¨$°°d¸DÀ$Èó
ˆð ×%Ñ% f§i¡i×&6Ñ&6Ð7IÓ&JÓKˆØ�‰˜ÖrJ   c                óØ   € \        V P                  4       4      p\        RRRRRRRRRRV4      pV P                  VP                  P                  R4      4      pV P                  V4       R# )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"   rZ  r1   r  rc  rˆ   rà  r2  s   &   rG   Útest_nottyUIÚ%NewConnectionHelperTests.test_nottyUI  se   € ô �t—{‘{“}Ó%ˆÜ%Ø�$˜˜d D¨$°°d¸DÀ$Èó
ˆð ×%Ñ% f§i¡i×&6Ñ&6Ð7IÓ&JÓKˆØ×Ñ˜Ö rJ   c                óx   € \        RRRRRRRRRR4
      pV P                  \        R4      VP                  4       R# )za
If not passed the name of a tty in the filesystem,
L{_NewConnectionHelper} uses C{b"/dev/tty"}.
Ns   /dev/tty)r1   ré   r"   r3  rð  s   & rG   Útest_defaultTTYFilenameÚ0NewConnectionHelperTests.test_defaultTTYFilename"  s>   € ô
 &Ø�$˜˜d D¨$°°d¸DÀ$ó
ˆð 	×Ñœ +Ó.°·
±
Ö;rJ   c                óÎ   € \        RRRRRRRRRR4
      p\        4       p\        4       Vn        VP	                  VR4       V P                  VP                  P                  4       R# )zu
L{_NewConnectionHelper.cleanupConnection} closes the transport cleanly
if called with C{immediate} set to C{False}.
NF)r1   r5   r   r�   rï  ro  rp  )rF   rê  rÛ  s   &  rG   rñ  Ú=NewConnectionHelperTests.test_cleanupConnectionNotImmediately,  s_   € ô
 &Ø�$˜˜d D¨$°°d¸DÀ$ó
ˆô #“_ˆ
Ü.Ó0ˆ
ÔØ× Ñ  ¨UÔ3Ø�‰˜
×,Ñ,×:Ñ:Ö;rJ   c                ó"  €  ! R R4      p\        RRRRRRRRRR4
      p\        4       p\        4       Vn        V! 4       VP                  n        VP	                  VR4       V P                  VP                  P                  P                  4       R# )z„
L{_NewConnectionHelper.cleanupConnection} closes the transport with
C{abortConnection} if called with C{immediate} set to C{True}.
c                   ó*   a € ] tR tRt o RtR tRtV tR# )ÚMNewConnectionHelperTests.test_cleanupConnectionImmediately.<locals>.Abortablei?  Fc                ó   € RV n         R# )z
Abort the connection.
TNrC   rE   s   &rG   rH   Ú]NewConnectionHelperTests.test_cleanupConnectionImmediately.<locals>.Abortable.abortConnectionB  s   € ð  $�–rJ   rC   N)rK   rL   rM   rN   rD   rH   rP   rQ   rR   s   @rG   Ú	Abortabler@  ?  s   ø‡ € ØˆG÷$ð $rJ   rC  NT)r1   r5   r8   r�   rï  ro  rD   )rF   rC  rê  rÛ  s   &   rG   rô  Ú:NewConnectionHelperTests.test_cleanupConnectionImmediately9  s   € ÷	$ñ 	$ô &Ø�$˜˜d D¨$°°d¸DÀ$ó
ˆô #“_ˆ
Ü1Ó3ˆ
ÔÙ)2«ˆ
×ÑÔ&Ø× Ñ  ¨TÔ2Ø�‰˜
×,Ñ,×6Ñ6×>Ñ>Ö?rJ   rW   N)rK   rL   rM   rN   rO   rv  r  r!  r,  r/  r4  r7  r:  rñ  rô  rP   rQ   rR   s   @rG   r  r  ¿  sJ   ø‡ € ñòSòR÷1ð 1ò.>ò.4ò ò!ò<ò<÷@ð @rJ   r  )yrO   Úos.pathr%  Úior   Ústructr   Útypingr   Úzope.interfacer   Úzope.interface.verifyr   r   r:  Ú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.   r/   r0   r1   Útwisted.conch.sshr2   Útwisted.conch.ssh.agentr3   Útwisted.conch.ssh.channelr4   Útwisted.conch.ssh.connectionr5   Útwisted.conch.ssh.factoryr6   Útwisted.conch.ssh.keysr7   Útwisted.conch.ssh.transportr8   Útwisted.conch.ssh.userauthr9   Útwisted.conch.test.keydatar:   r;   r<   r=   Úskiprç  Útwisted.test.iosimr>   r?   rA   rU   r`   rd   rh   rz   r€   rŽ   rš   r¦   r¨   r¶   rW  rÐ  rã  r÷  r  r  rW   rJ   rG   Ú<module>rk     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@rJ   