+
    üÐjHr  ã                   óP  € R t ^ RIt^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ]! R4      t
^ RIHt ]
'       d
   ^ RIHtHt M
 ! R	 R
4      t ! R R]P                  4      t ! R R4      t ! R R]P$                  4      t ! R R]	P(                  4      t ! R R]	P(                  4      tR# )z1
This module tests twisted.conch.ssh.connection.
N©Úchannel)Útest_userauth)ÚrequireModule)ÚunittestÚcryptography)Úerror)ÚcommonÚ
connectionc                   ó*   € ] tR t^t ! R R4      tRtR# )r
   c                   ó   € ] tR t^tRtR# )Úconnection.SSHConnection© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__static_attributes__r   ó    ÚD/usr/lib/python3/dist-packages/twisted/conch/test/test_connection.pyÚSSHConnectionr      s   † Ûr   r   r   N)r   r   r   r   r   r   r   r   r   r
   r
      s   † ÷	õ 	r   r
   c                   óf   a € ] tR t^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V tR# )ÚTestChannelaz  
A mocked-up version of twisted.conch.ssh.channel.SSHChannel.

@ivar gotOpen: True if channelOpen has been called.
@type gotOpen: L{bool}
@ivar specificData: the specific channel open data passed to channelOpen.
@type specificData: L{bytes}
@ivar openFailureReason: the reason passed to openFailed.
@type openFailed: C{error.ConchError}
@ivar inBuffer: a C{list} of strings received by the channel.
@type inBuffer: C{list}
@ivar extBuffer: a C{list} of 2-tuples (type, extended data) of received by
    the channel.
@type extBuffer: C{list}
@ivar numberRequests: the number of requests that have been made to this
    channel.
@type numberRequests: L{int}
@ivar gotEOF: True if the other side sent EOF.
@type gotEOF: L{bool}
@ivar gotOneClose: True if the other side closed the connection.
@type gotOneClose: L{bool}
@ivar gotClosed: True if the channel is closed.
@type gotClosed: L{bool}
ó   TestChannelFc                ó(   € R V P                   ,          # )zTestChannel %i)Úid©Úselfs   &r   Ú	logPrefixÚTestChannel.logPrefix:   s   € Ø $§'¡'Õ)Ð)r   c                ót   € RV n         Wn        . V n        . V n        ^ V n        RV n        RV n        RV n        R# )z6
The channel is open.  Set up the instance variables.
TFN)ÚgotOpenÚspecificDataÚinBufferÚ	extBufferÚnumberRequestsÚgotEOFÚgotOneCloseÚ	gotClosed)r   r"   s   &&r   ÚchannelOpenÚTestChannel.channelOpen=   s=   € ð ˆŒØ(ÔØˆŒØˆŒØˆÔØˆŒØ ˆÔØˆŽr   c                ó   € Wn         R# )z4
Opening the channel failed.  Store the reason why.
N)ÚopenFailureReason)r   Úreasons   &&r   Ú
openFailedÚTestChannel.openFailedJ   s
   € ð "(Ör   c                ó>   € V ;P                   ^,          un         VR8H  # )zG
A test request.  Return True if data is 'data'.

@type data: L{bytes}
ó   data)r%   ©r   Údatas   &&r   Úrequest_testÚTestChannel.request_testP   s   € ð 	×Ò˜qÕ ÕØ�w‰Ðr   c                ó<   € V P                   P                  V4       R# )z-
Data was received.  Store it in the buffer.
N)r#   Úappendr2   s   &&r   ÚdataReceivedÚTestChannel.dataReceivedY   s   € ð 	�‰×Ñ˜TÖ"r   c                ó>   € V P                   P                  W34       R# )z6
Extended data was received.  Store it in the buffer.
N)r$   r7   )r   Úcoder3   s   &&&r   ÚextReceivedÚTestChannel.extReceived_   s   € ð 	�‰×Ñ˜t˜lÖ+r   c                ó   € RV n         R# )z!
EOF was received.  Remember it.
TN)r&   r   s   &r   ÚeofReceivedÚTestChannel.eofReceivede   s   € ð ˆŽr   c                ó   € RV n         R# )z#
Close was received.  Remember it.
TN)r'   r   s   &r   ÚcloseReceivedÚTestChannel.closeReceivedk   s   € ð  ˆÖr   c                ó   € RV n         R# )z'
The channel is closed.  Rembember it.
TN)r(   r   s   &r   ÚclosedÚTestChannel.closedq   s   € ð ˆŽr   )	r$   r(   r&   r'   r!   r#   r%   r,   r"   N)r   r   r   r   Ú__doc__Únamer!   r(   r   r)   r.   r4   r8   r<   r?   rB   rE   r   Ú__classdictcell__©Ú__classdict__s   @r   r   r      sM   ø‡ € ñð2 €DØ€GØ€Iò*òò(òò#ò,òò ÷ð r   r   c                   ó4   a € ] tR t^xt o Rt^{tR tR tRtV t	R# )Ú
TestAvatarz7
A mocked-up version of twisted.conch.avatar.ConchUser
c                óž   € V\         P                  8X  d   \        VVVV R7      # VR8X  d"   \        P                  ! V P                  R4      hR# )zz
The server wants us to return a channel.  If the requested channel is
our TestChannel, return it, otherwise return None.
)ÚremoteWindowÚremoteMaxPacketr3   Úavataró   conch-error-argsúerror args in wrong orderN)r   rH   r   Ú
ConchErrorÚ_ARGS_ERROR_CODE)r   ÚchannelTypeÚ
windowSizeÚ	maxPacketr3   s   &&&&&r   ÚlookupChannelÚTestAvatar.lookupChannel   sW   € ð
 œ+×*Ñ*Ô*ÜØ'Ø )ØØô	ð ð Ð/Ô/ô
 ×"Ò" 4×#8Ñ#8Ð:UÓVÐVñ 0r   c                ó.   € VR8X  d   R# VR8X  d   RV3# R# )zÓ
The client has made a global request.  If the global request is
'TestGlobal', return True.  If the global request is 'TestData',
return True and the request-specific data we received.  Otherwise,
return False.
ó
   TestGlobalTó   TestDataFr   )r   ÚrequestTyper3   s   &&&r   ÚgotGlobalRequestÚTestAvatar.gotGlobalRequest’   s$   € ð ˜-Ô'ÙØ˜KÔ'Ø˜�:Ðár   r   N)
r   r   r   r   rG   rU   rY   r_   r   rI   rJ   s   @r   rM   rM   x   s"   ø‡ € ñð ÐòW÷&ð r   rM   c                   óV   a € ] tR t^¡t o Rt]'       g   RtR tR tR t	R t
R tRtV tR	# )
ÚTestConnectionzm
A subclass of SSHConnection for testing.

@ivar channel: the current channel.
@type channel. C{TestChannel}
úCannot run without cryptographyc                ó   € R # )rb   r   r   s   &r   r   ÚTestConnection.logPrefix¬   s   € Ùr   c                ó   € R# )zD
The other side made the 'TestGlobal' global request.  Return True.
Tr   r2   s   &&r   Úglobal_TestGlobalÚ TestConnection.global_TestGlobal¯   s   € ñ r   c                ó
   € RV3# )z\
The other side made the 'Test-Data' global request.  Return True and
the data we received.
Tr   r2   s   &&r   Úglobal_Test_DataÚTestConnection.global_Test_Dataµ   s   € ð
 �TˆzÐr   c                ó>   € \        WVR7      V n        V P                  # )zk
The other side is requesting the TestChannel.  Create a C{TestChannel}
instance, store it, and return it.
)rO   rP   r3   )r   r   ©r   rW   rX   r3   s   &&&&r   Úchannel_TestChannelÚ"TestConnection.channel_TestChannel¼   s!   € ô
 #Ø#ÀTô
ˆŒð �|‰|Ðr   c                ó   € \        R4      h)zE
The other side is requesting the ErrorChannel.  Raise an exception.
zno such thing)ÚAssertionErrorrm   s   &&&&r   Úchannel_ErrorChannelÚ#TestConnection.channel_ErrorChannelÆ   s   € ô ˜_Ó-Ð-r   r   N)r   r   r   r   rG   r   Úskipr   rg   rj   rn   rr   r   rI   rJ   s   @r   rb   rb   ¡   s2   ø‡ € ñ÷ Ø0ˆò òòò÷.ð .r   rb   c                   óú   a € ] tR t^Ít o ]'       g   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R tR tR t R t!R t"R t#R  t$R! t%R" t&R#t'V t(R$# )%ÚConnectionTestsrc   c                óö   € \         P                  ! R 4      V n        \        4       V P                  n        \        4       V n        V P                  V P                  n        V P                  P                  4        R # ©N)r   ÚFakeTransportÚ	transportrM   rQ   rb   ÚconnÚserviceStartedr   s   &r   ÚsetUpÚConnectionTests.setUpÑ   sL   € Ü&×4Ò4°TÓ:ˆŒÜ *£ˆ�‰ÔÜ"Ó$ˆŒ	Ø"Ÿn™nˆ�	‰	ÔØ�	‰	× Ñ Ö"r   c                ó  € V P                   P                  V4       V P                  P                  RR V P                  n        V P                   P	                  \
        P                  ! RVP                  ^ÿ4      R,           4       R# )z/
Open the channel with the default connection.
Nz>2Ls        € éÿÿÿÿ)r{   ÚopenChannelrz   ÚpacketsÚssh_CHANNEL_OPEN_CONFIRMATIONÚstructÚpackr   ©r   r   s   &&r   Ú_openChannelÚConnectionTests._openChannelØ   s_   € ð 	�	‰	×Ñ˜gÔ&Ø!%§¡×!7Ñ!7¸¸Ð!<ˆ�‰ÔØ�	‰	×/Ñ/Ü�KŠK˜˜wŸz™z¨3Ó/Ð2UÕUö	
r   c                ó:   € V P                   P                  4        R # rx   )r{   ÚserviceStoppedr   s   &r   ÚtearDownÚConnectionTests.tearDownâ   s   € Ø�	‰	× Ñ Ö"r   c                óz   € V P                  V P                  P                  P                  V P                  4       R# )zG
Test that the connection links itself to the avatar in the
transport.
N)ÚassertIsrz   rQ   r{   r   s   &r   Útest_linkAvatarÚConnectionTests.test_linkAvatarå   s&   € ð
 	�‰�d—n‘n×+Ñ+×0Ñ0°$·)±)Ö<r   c                óÂ  € \        4       p\        4       pV P                  P                  V4       V P                  P                  V4       V P                  P                  R4       V P	                  VP
                  4       V P                  VP                  4       V P                  VP
                  4       V P                  VP                  4       V P                  P                  4        V P	                  VP                  4       V P                  VP
                  4       V P                  VP                  4       ^ RI	H
p V P                  VP                  V4       R# )z6
Test that serviceStopped() closes any open channels.
)ÚConnectionLostNs                   )r   r{   r�   rƒ   Ú
assertTruer!   ÚassertFalser(   rŠ   Útwisted.internet.errorr’   ÚassertIsInstancer,   )r   Úchannel1Úchannel2r’   s   &   r   Útest_serviceStoppedÚ#ConnectionTests.test_serviceStoppedì   sú   € ô “=ˆÜ“=ˆØ�	‰	×Ñ˜hÔ'Ø�	‰	×Ñ˜hÔ'Ø�	‰	×/Ñ/Ð0GÔHØ�‰˜×(Ñ(Ô)Ø×Ñ˜×+Ñ+Ô,Ø×Ñ˜×)Ñ)Ô*Ø×Ñ˜×+Ñ+Ô,Ø�	‰	× Ñ Ô"Ø�‰˜×*Ñ*Ô+Ø×Ñ˜×)Ñ)Ô*Ø×Ñ˜×+Ñ+Ô,Ý9à×Ñ˜h×8Ñ8¸.ÖIr   c                óÀ  € V P                   P                  \        P                  ! R4      R,           4       V P	                  V P
                  P                  \        P                  R3.4       . V P
                  n        V P                   P                  \        P                  ! R4      R,           R,           4       V P	                  V P
                  P                  \        P                  R3.4       . V P
                  n        V P                   P                  \        P                  ! R4      R,           4       V P	                  V P
                  P                  \        P                  R3.4       . V P
                  n        V P                   P                  \        P                  ! R4      R,           4       V P	                  V P
                  P                  . 4       R# )	z�
Test that global request packets are dispatched to the global_*
methods and the return values are translated into success or failure
messages.
r\   ó   ÿr   r]   s	   test datas   TestBadó    N)
r{   Ússh_GLOBAL_REQUESTr	   ÚNSÚassertEqualrz   r‚   r
   ÚMSG_REQUEST_SUCCESSÚMSG_REQUEST_FAILUREr   s   &r   Útest_GLOBAL_REQUESTÚ#ConnectionTests.test_GLOBAL_REQUEST  sN  € ð 	�	‰	×$Ñ$¤V§Y¢Y¨}Ó%=ÀÕ%GÔHØ×ÑØ�N‰N×"Ñ"¤j×&DÑ&DÀcÐ%JÐ$Kô	
ð "$ˆ�‰ÔØ�	‰	×$Ñ$¤V§Y¢Y¨{Ó%;¸gÕ%EÈÕ%TÔUØ×ÑØ�N‰N×"Ñ"¤j×&DÑ&DÀlÐ%SÐ$Tô	
ð "$ˆ�‰ÔØ�	‰	×$Ñ$¤V§Y¢Y¨zÓ%:¸WÕ%DÔEØ×ÑØ�N‰N×"Ñ"¤j×&DÑ&DÀcÐ%JÐ$Kô	
ð "$ˆ�‰ÔØ�	‰	×$Ñ$¤V§Y¢Y¨}Ó%=ÀÕ%GÔHØ×Ñ˜Ÿ™×/Ñ/°Ö4r   c                óÜ   a € S P                   P                  RRR4      pS P                   P                  R4       V 3R lpVP                  V4       VP	                  S P
                  4       V# )zP
Test that global request success packets cause the Deferred to be
called back.
ó   requestr1   Tc                 ó,   <€ SP                  V R 4       R# ©r1   N)r    )r3   r   s   &€r   ÚcheckÚ3ConnectionTests.test_REQUEST_SUCCESS.<locals>.check!  s   ø€ Ø×Ñ˜T 7Ö+r   )r{   ÚsendGlobalRequestÚssh_REQUEST_SUCCESSÚaddCallbackÚ
addErrbackÚfail©r   Údr©   s   f  r   Útest_REQUEST_SUCCESSÚ$ConnectionTests.test_REQUEST_SUCCESS  sW   ø€ ð
 �I‰I×'Ñ'¨
°G¸TÓBˆØ�	‰	×%Ñ% gÔ.õ	,ð 	
�‰�eÔØ	�‰�T—Y‘YÔØˆr   c                óÜ   a € S P                   P                  RRR4      pS P                   P                  R4       V 3R lpVP                  S P                  4       VP                  V4       V# )zO
Test that global request failure packets cause the Deferred to be
erred back.
r¦   r1   Tc                 óT   <€ SP                  V P                  P                  R 4       R# r¨   )r    Úvaluer3   )Úfr   s   &€r   r©   Ú3ConnectionTests.test_REQUEST_FAILURE.<locals>.check0  s   ø€ Ø×Ñ˜QŸW™WŸ\™\¨7Ö3r   )r{   r«   Ússh_REQUEST_FAILUREr­   r¯   r®   r°   s   f  r   Útest_REQUEST_FAILUREÚ$ConnectionTests.test_REQUEST_FAILURE(  sW   ø€ ð
 �I‰I×'Ñ'¨
°G¸TÓBˆØ�	‰	×%Ñ% gÔ.õ	4ð 	
�‰�d—i‘iÔ Ø	�‰�UÔØˆr   c                óZ  € V P                   =V P                  P                  \        P
                  ! R4      R,           4       V P                  V P                  P                  P                  4       V P                  V P                  P                  P                  V P                  4       V P                  V P                  P                  P                  R4       V P                  V P                  P                  P                  R4       V P                  V P                  P                  P                  ^4       V P                  V P                  P                  P                  ^4       V P                  V P                   P                  \        P                   R3.4       . V P                   n        V P                  P                  \        P
                  ! R4      R,           4       V P#                  4        V P                  V P                   P                  \        P$                  R\        P
                  ! R4      ,           \        P
                  ! R4      ,           3.4       . V P                   n        V P                  P                  \        P
                  ! R4      R,           4       V P#                  4        V P                  V P                   P                  \        P$                  R	\        P
                  ! R
4      ,           \        P
                  ! R4      ,           3.4       R# )zn
Test that open channel packets cause a channel to be created and
opened or a failure message to be returned.
r   ó      s               € ó
   BadChannels         s   unknown channelr   s   ErrorChannels         s   unknown failureNó               s               )rz   rQ   r{   Ússh_CHANNEL_OPENr	   rŸ   r“   r   r!   r    r3   r"   ÚremoteWindowLeftrP   r‚   r
   ÚMSG_CHANNEL_OPEN_CONFIRMATIONÚflushLoggedErrorsÚMSG_CHANNEL_OPEN_FAILUREr   s   &r   Útest_CHANNEL_OPENÚ!ConnectionTests.test_CHANNEL_OPEN7  sF  € ð
 �N‰NÐ!Ø�	‰	×"Ñ"¤6§9¢9¨^Ó#<Ð?VÕ#VÔWØ�‰˜Ÿ	™	×)Ñ)×1Ñ1Ô2Ø×Ñ˜Ÿ™×*Ñ*×/Ñ/°·±Ô;Ø×Ñ˜Ÿ™×*Ñ*×/Ñ/Ð1DÔEØ×Ñ˜Ÿ™×*Ñ*×7Ñ7Ð9LÔMØ×Ñ˜Ÿ™×*Ñ*×;Ñ;¸QÔ?Ø×Ñ˜Ÿ™×*Ñ*×:Ñ:¸AÔ>Ø×ÑØ�N‰N×"Ñ"ô ×<Ñ<ð(ððô		
ð "$ˆ�‰ÔØ�	‰	×"Ñ"¤6§9¢9¨]Ó#;Ð>UÕ#UÔVØ×ÑÔ Ø×ÑØ�N‰N×"Ñ"ô ×7Ñ7Ø7Ü—i’iÐ 2Ó3õ4ä—i’i “nõ%ððô
	
ð "$ˆ�‰ÔØ�	‰	×"Ñ"¤6§9¢9¨_Ó#=Ð@WÕ#WÔXØ×ÑÔ Ø×ÑØ�N‰N×"Ñ"ô ×7Ñ7Ø7Ü—i’iÐ 2Ó3õ4ä—i’i “nõ%ððö
	
r   c                óX  € WP                   P                  n        V P                  P	                  \
        P                  ! R4      R,           4       V P                  \        P                  4      pV P                  \        V4      ^RV: 24       V P                  V^ ,          P                  P                  R4       V P                  V P                   P                  \        P                   R\
        P                  ! R4      ,           \
        P                  ! R4      ,           3.4       R# )	z¥
Deliver a request for a channel open which will result in an exception
being raised during channel lookup.  Assert that an error response is
delivered as a result.
rR   zExpected one error, got: s         {s   error args in wrong orderr   Nr¿   )é{   rS   )rz   rQ   rU   r{   rÀ   r	   rŸ   rÃ   r   rT   r    Úlenr¶   Úargsr‚   r
   rÄ   )r   r;   Úerrorss   && r   Ú_lookupChannelErrorTestÚ'ConnectionTests._lookupChannelErrorTestk  så   € ð 26�‰×ÑÔ.Ø�	‰	×"Ñ"Ü�IŠIÐ)Ó*Ð-DÕDô	
ð ×'Ñ'¬×(8Ñ(8Ó9ˆØ×Ñœ˜V› aÐ+DÀVÁJÐ)OÔPØ×Ñ˜ �Ÿ™×-Ñ-Ð/QÔRØ×ÑØ�N‰N×"Ñ"ô ×7Ñ7ð 8Ü—i’iÐ <Ó=õ>ä—i’i “nõ%ðð
ö	
r   c                ó(   € V P                  ^{4       R# )a”  
If a C{lookupChannel} implementation raises L{error.ConchError} with the
arguments in the wrong order, a C{MSG_CHANNEL_OPEN} failure is still
sent in response to the message.

This is a temporary work-around until L{error.ConchError} is given
better attributes and all of the Conch code starts constructing
instances of it properly.  Eventually this functionality should be
deprecated and then removed.
N)rÌ   r   s   &r   Útest_lookupChannelErrorÚ'ConnectionTests.test_lookupChannelError‡  s   € ð 	×$Ñ$ SÖ)r   c                óâ  € \        4       pV P                  P                  V4       V P                  P                  R4       V P	                  VP
                  ^ 4       V P	                  VP                  ^ 4       V P	                  VP                  R4       V P	                  V P                  P                  V,          ^ 4       V P	                  V P                  P                  ^ ,          ^ 4       R# )z^
Test that channel open confirmation packets cause the channel to be
notified that it's open.
ó       Ns                       )
r   r{   r�   rƒ   r    rÁ   rP   r"   ÚchannelsToRemoteChannelÚlocalToRemoteChannelr†   s   & r   Útest_CHANNEL_OPEN_CONFIRMATIONÚ.ConnectionTests.test_CHANNEL_OPEN_CONFIRMATION”  s±   € ô
 “-ˆØ�	‰	×Ñ˜gÔ&Ø�	‰	×/Ñ/Ð0GÔHØ×Ñ˜×1Ñ1°1Ô5Ø×Ñ˜×0Ñ0°!Ô4Ø×Ñ˜×-Ñ-Ð/BÔCØ×Ñ˜Ÿ™×:Ñ:¸7ÕCÀQÔGØ×Ñ˜Ÿ™×7Ñ7¸Õ:¸AÖ>r   c                óp  € \        4       pV P                  P                  V4       V P                  P                  R\        P
                  ! R4      ,           4       V P                  VP                  P                  R4       V P                  V P                  P                  P                  V4      4       R# )zb
Test that channel open failure packets cause the channel to be
notified that its opening failed.
ó          ó   failure!N)rÙ   é   )r   r{   r�   Ússh_CHANNEL_OPEN_FAILUREr	   rŸ   r    r,   rÊ   ÚassertIsNoneÚchannelsÚgetr†   s   & r   Útest_CHANNEL_OPEN_FAILUREÚ)ConnectionTests.test_CHANNEL_OPEN_FAILURE¢  s‚   € ô
 “-ˆØ�	‰	×Ñ˜gÔ&Ø�	‰	×*Ñ*Ø3´f·i²iÀÓ6LÕLô	
ð 	×Ñ˜×2Ñ2×7Ñ7Ð9IÔJØ×Ñ˜$Ÿ)™)×,Ñ,×0Ñ0°Ó9Ö:r   c                óÐ   € \        4       pV P                  V4       VP                  pV P                  P	                  R4       V P                  VP                  V^,           4       R# )zK
Test that channel window adjust messages add bytes to the channel
window.
rØ   N)r   r‡   rÁ   r{   Ússh_CHANNEL_WINDOW_ADJUSTr    )r   r   ÚoldWindowSizes   &  r   Útest_CHANNEL_WINDOW_ADJUSTÚ*ConnectionTests.test_CHANNEL_WINDOW_ADJUST¯  sR   € ô
 “-ˆØ×Ñ˜'Ô"Ø×0Ñ0ˆØ�	‰	×+Ñ+Ð,SÔTØ×Ñ˜×1Ñ1°=À1Õ3DÖEr   c                ó^  € \        ^^R7      pV P                  V4       V P                  P                  R\        P
                  ! R4      ,           4       V P                  VP                  R.4       V P                  V P                  P                  \        P                  R3.4       . V P                  n	        RVP                  ^,           ,          pV P                  P                  R\        P
                  ! V4      ,           4       V P                  VP                  R.4       V P                  V P                  P                  \        P                  R3.4       \        4       pV P                  V4       RVP                  ^,           ,          p. V P                  n	        V P                  P                  R\        P
                  ! V4      ,           4       V P                  VP                  . 4       V P                  V P                  P                  \        P                  R3.4       R# )	z{
Test that channel data messages are passed up to the channel, or
cause the channel to be closed if the data is too large.
©ÚlocalWindowÚlocalMaxPacketrÒ   r1   ó      ÿ   ó   aó      ÿr½   N)r   r‡   r{   Ússh_CHANNEL_DATAr	   rŸ   r    r#   rz   r‚   r
   ÚMSG_CHANNEL_WINDOW_ADJUSTÚlocalWindowLeftÚMSG_CHANNEL_CLOSEré   ©r   r   ÚlongDataÚbigDatas   &   r   Útest_CHANNEL_DATAÚ!ConnectionTests.test_CHANNEL_DATAº  s¯  € ô
 ¨!¸AÔ>ˆØ×Ñ˜'Ô"Ø�	‰	×"Ñ"Ð#6¼¿ºÀ7Ó9KÕ#KÔLØ×Ñ˜×)Ñ)¨G¨9Ô5Ø×ÑØ�N‰N×"Ñ"ô ×8Ñ8Ø;ððô	
ð "$ˆ�‰ÔØ˜7×2Ñ2°QÕ6Õ7ˆØ�	‰	×"Ñ"Ð#6¼¿ºÀ8Ó9LÕ#LÔMØ×Ñ˜×)Ñ)¨G¨9Ô5Ø×ÑØ�N‰N×"Ñ"Ü×*Ñ*Ð,?Ð@ÐAô	
ô “-ˆØ×Ñ˜'Ô"Ø˜'×0Ñ0°1Õ4Õ5ˆØ!#ˆ�‰ÔØ�	‰	×"Ñ"Ð#6¼¿ºÀ7Ó9KÕ#KÔLØ×Ñ˜×)Ñ)¨2Ô.Ø×ÑØ�N‰N×"Ñ"Ü×*Ñ*Ð,?Ð@ÐAö	
r   c                ó^  € \        ^^R7      pV P                  V4       V P                  P                  R\        P
                  ! R4      ,           4       V P                  VP                  R	.4       V P                  V P                  P                  \        P                  R3.4       . V P                  n	        RVP                  ^,           ,          pV P                  P                  R\        P
                  ! V4      ,           4       V P                  VP                  R	.4       V P                  V P                  P                  \        P                  R3.4       \        4       pV P                  V4       RVP                  ^,           ,          p. V P                  n	        V P                  P                  R\        P
                  ! V4      ,           4       V P                  VP                  . 4       V P                  V P                  P                  \        P                  R3.4       R# )
z~
Test that channel extended data messages are passed up to the channel,
or cause the channel to be closed if they're too big.
rç   s           r1   rê   rë   rì   s          N)é    r1   )r   r‡   r{   Ússh_CHANNEL_EXTENDED_DATAr	   rŸ   r    r$   rz   r‚   r
   rî   rï   rð   ré   rñ   s   &   r   Útest_CHANNEL_EXTENDED_DATAÚ*ConnectionTests.test_CHANNEL_EXTENDED_DATAß  s»  € ô
 ¨!¸AÔ>ˆØ×Ñ˜'Ô"Ø�	‰	×+Ñ+Ø3´f·i²iÀÓ6HÕHô	
ð 	×Ñ˜×*Ñ*¨\¨NÔ;Ø×ÑØ�N‰N×"Ñ"ô ×8Ñ8Ø;ððô	
ð "$ˆ�‰ÔØ˜7×2Ñ2°QÕ6Õ7ˆØ�	‰	×+Ñ+Ø3´f·i²iÀÓ6IÕIô	
ð 	×Ñ˜×*Ñ*¨\¨NÔ;Ø×ÑØ�N‰N×"Ñ"Ü×*Ñ*Ð,?Ð@ÐAô	
ô “-ˆØ×Ñ˜'Ô"Ø˜'×0Ñ0°1Õ4Õ5ˆØ!#ˆ�‰ÔØ�	‰	×+Ñ+Ø3´f·i²iÀÓ6HÕHô	
ð 	×Ñ˜×*Ñ*¨BÔ/Ø×ÑØ�N‰N×"Ñ"Ü×*Ñ*Ð,?Ð@ÐAö	
r   c                ó¨   € \        4       pV P                  V4       V P                  P                  R4       V P	                  VP
                  4       R# )z>
Test that channel eof messages are passed up to the channel.
rÒ   N)r   r‡   r{   Ússh_CHANNEL_EOFr“   r&   r†   s   & r   Útest_CHANNEL_EOFÚ ConnectionTests.test_CHANNEL_EOF
  s<   € ô “-ˆØ×Ñ˜'Ô"Ø�	‰	×!Ñ!Ð"5Ô6Ø�‰˜Ÿ™Ö'r   c                ó¶  € \        4       pV P                  V4       V P                  VP                  4       V P	                  VP
                  4       V P	                  VP                  4       V P                  P                  V4       V P                  P                  R4       V P                  VP
                  4       V P                  VP                  4       R# )z£
Test that channel close messages are passed up to the channel.  Also,
test that channel.close() is called if both sides are closed when this
message is received.
rÒ   N)
r   r‡   r“   r!   r”   r'   r(   r{   Ú	sendCloseÚssh_CHANNEL_CLOSEr†   s   & r   Útest_CHANNEL_CLOSEÚ"ConnectionTests.test_CHANNEL_CLOSE  sš   € ô “-ˆØ×Ñ˜'Ô"Ø�‰˜Ÿ™Ô(Ø×Ñ˜×,Ñ,Ô-Ø×Ñ˜×*Ñ*Ô+Ø�	‰	×Ñ˜GÔ$Ø�	‰	×#Ñ#Ð$7Ô8Ø�‰˜×+Ñ+Ô,Ø�‰˜×)Ñ)Ö*r   c                ó¦  a € \        4       pS P                  V4       S P                  P                  R\        P
                  ! R4      ,           R,           4       S P                  VP                  ^4       S P                  P                  R\        P
                  ! R4      ,           R,           R,           4      pV 3R lpVP                  V4       V# )zC
Test that channel requests that succeed send MSG_CHANNEL_SUCCESS.
rÒ   ó   testr�   rœ   r1   c                 óv   <€ SP                  SP                  P                  \        P                  R 3.4       R# ©rì   N)r    rz   r‚   r
   ÚMSG_CHANNEL_SUCCESS©Úresultr   s   &€r   r©   Ú;ConnectionTests.test_CHANNEL_REQUEST_success.<locals>.check1  ó0   ø€ Ø×ÑØ—‘×&Ñ&Ü×0Ñ0Ð2EÐFÐGör   )	r   r‡   r{   Ússh_CHANNEL_REQUESTr	   rŸ   r    r%   r­   ©r   r   r±   r©   s   f   r   Útest_CHANNEL_REQUEST_successÚ,ConnectionTests.test_CHANNEL_REQUEST_success#  s¡   ø€ ô “-ˆØ×Ñ˜'Ô"Ø�	‰	×%Ñ%Ø¤&§)¢)¨GÓ"4Õ4°wÕ>ô	
ð 	×Ñ˜×/Ñ/°Ô3Ø�I‰I×)Ñ)Ø¤&§)¢)¨GÓ"4Õ4°wÕ>ÀÕHó
ˆõ	ð 	
�‰�eÔØˆr   c                ó  a € \        4       pS P                  V4       S P                  P                  R\        P
                  ! R4      ,           R,           4      pV 3R lpVP                  S P                  4       VP                  V4       V# )z@
Test that channel requests that fail send MSG_CHANNEL_FAILURE.
rÒ   r  rœ   c                 óv   <€ SP                  SP                  P                  \        P                  R 3.4       R# r  )r    rz   r‚   r
   ÚMSG_CHANNEL_FAILUREr	  s   &€r   r©   Ú;ConnectionTests.test_CHANNEL_REQUEST_failure.<locals>.checkD  r  r   )	r   r‡   r{   r  r	   rŸ   r­   r¯   r®   r  s   f   r   Útest_CHANNEL_REQUEST_failureÚ,ConnectionTests.test_CHANNEL_REQUEST_failure:  sl   ø€ ô “-ˆØ×Ñ˜'Ô"Ø�I‰I×)Ñ)Ø¤&§)¢)¨GÓ"4Õ4°wÕ>ó
ˆõ	ð 	
�‰�d—i‘iÔ Ø	�‰�UÔØˆr   c                ó¼   a € \        4       pS P                  V4       S P                  P                  VRRR4      pS P                  P	                  R4       V 3R lpV# )zR
Test that channel request success messages cause the Deferred to be
called back.
r  r1   TrÒ   c                 ó*   <€ SP                  V 4       R # rx   )r“   r	  s   &€r   r©   Ú;ConnectionTests.test_CHANNEL_REQUEST_SUCCESS.<locals>.checkX  s   ø€ Ø�O‰O˜FÖ#r   )r   r‡   r{   ÚsendRequestÚssh_CHANNEL_SUCCESSr  s   f   r   Útest_CHANNEL_REQUEST_SUCCESSÚ,ConnectionTests.test_CHANNEL_REQUEST_SUCCESSN  sS   ø€ ô
 “-ˆØ×Ñ˜'Ô"Ø�I‰I×!Ñ! '¨7°G¸TÓBˆØ�	‰	×%Ñ%Ð&9Ô:õ	$ð ˆr   c                ó  a € \        4       pS P                  V4       S P                  P                  VRRR4      pS P                  P	                  R4       V 3R lpVP                  S P                  4       VP                  V4       V# )zQ
Test that channel request failure messages cause the Deferred to be
erred back.
r  r   TrÒ   c                 óT   <€ SP                  V P                  P                  R 4       R# )zchannel request failedN)r    r¶   r	  s   &€r   r©   Ú;ConnectionTests.test_CHANNEL_REQUEST_FAILURE.<locals>.checkg  s   ø€ Ø×Ñ˜VŸ\™\×/Ñ/Ð1IÖJr   )r   r‡   r{   r  Ússh_CHANNEL_FAILUREr­   r¯   r®   r  s   f   r   Útest_CHANNEL_REQUEST_FAILUREÚ,ConnectionTests.test_CHANNEL_REQUEST_FAILURE]  sp   ø€ ô
 “-ˆØ×Ñ˜'Ô"Ø�I‰I×!Ñ! '¨7°C¸Ó>ˆØ�	‰	×%Ñ%Ð&9Ô:õ	Kð 	
�‰�d—i‘iÔ Ø	�‰�UÔØˆr   c                óì  € V P                   P                  RRR4      pVP                  R 4       V P                   P                  RRR4       V P                  V P                  P
                  \        P                  \        P                  ! R4      R,           3\        P                  \        P                  ! R4      R	,           3.4       V P                  V P                   P                  R
V./4       R# )zA
Test that global request messages are sent in the right format.
s	   wantReplyr1   Tc                 ó   € R # rx   r   ©Úfailures   &r   Ú<lambda>Ú8ConnectionTests.test_sendGlobalRequest.<locals>.<lambda>t  ó   € ¡Tr   s   noReplyr   Fs   ÿdatar�   ÚglobalN)r{   r«   r®   r    rz   r‚   r
   ÚMSG_GLOBAL_REQUESTr	   rŸ   Ú	deferreds©r   r±   s   & r   Útest_sendGlobalRequestÚ&ConnectionTests.test_sendGlobalRequestn  s¹   € ð �I‰I×'Ñ'¨°g¸tÓDˆà	�‰Ñ)Ô*Ø�	‰	×#Ñ# J°°UÔ;Ø×ÑØ�N‰N×"Ñ"ä×.Ñ.´·	²	¸,Ó0GÈ+Õ0UÐVÜ×.Ñ.´·	²	¸*Ó0EÈÕ0OÐPðô	
ð 	×Ñ˜Ÿ™×,Ñ,¨x¸!¸¨oÖ>r   c                óz  € \        4       pV P                  P                  VR4       V P                  V P                  P
                  \        P                  \        P                  ! R4      R,           3.4       V P                  VP                  ^ 4       V P                  V P                  P                  ^4       R# )z?
Test that open channel messages are sent in the right format.
s   aaaar   s            € aaaaN)r   r{   r�   r    rz   r‚   r
   ÚMSG_CHANNEL_OPENr	   rŸ   r   ÚlocalChannelIDr†   s   & r   Útest_openChannelÚ ConnectionTests.test_openChannel  s”   € ô “-ˆØ�	‰	×Ñ˜g wÔ/Ø×ÑØ�N‰N×"Ñ"ô ×/Ñ/Ü—I’I˜nÓ-ØMõNððô		
ð 	×Ñ˜Ÿ™ QÔ'Ø×Ñ˜Ÿ™×1Ñ1°1Ö5r   c           	     ó–  € \        4       pV P                  V4       V P                  P                  VRRR4      pVP	                  R 4       V P                  P                  VRRR4       RVn        V P                  P                  VRRR4       V P                  V P                  P                  \        P                  R\        P                  ! R4      ,           R	,           3\        P                  R\        P                  ! R4      ,           R
,           3.4       V P                  V P                  P                  ^ ,          V.4       R# )zB
Test that channel request messages are sent in the right format.
r  Tc                 ó   € R # rx   r   r&  s   &r   r(  Ú2ConnectionTests.test_sendRequest.<locals>.<lambda>š  r*  r   ó   test2r   Fs   test3rì   s   testr�   N)r   r‡   r{   r  r®   ÚlocalClosedr    rz   r‚   r
   ÚMSG_CHANNEL_REQUESTr	   rŸ   r-  ©r   r   r±   s   &  r   Útest_sendRequestÚ ConnectionTests.test_sendRequest’  s  € ô “-ˆØ×Ñ˜'Ô"Ø�I‰I×!Ñ! '¨7°G¸TÓBˆà	�‰Ñ)Ô*Ø�	‰	×Ñ˜g x°°eÔ<Ø"ˆÔØ�	‰	×Ñ˜g x°°dÔ;Ø×ÑØ�N‰N×"Ñ"ô ×2Ñ2Ø'¬&¯)ª)°GÓ*<Õ<¸{ÕJðô
 ×2Ñ2Ø'¬&¯)ª)°HÓ*=Õ=ÀÕGðð	ô	
ð 	×Ñ˜Ÿ™×,Ñ,¨QÕ/°!°Ö5r   c                óª  € \        ^R7      pV P                  V4       ^ Vn        V P                  P	                  V^4       V P                  VP                  ^4       RVn        V P                  P	                  V^4       V P                  VP                  ^4       V P                  V P                  P                  \        P                  R3.4       R# )zQ
Test that channel window adjust messages cause bytes to be added
to the window.
)rè   Tó      ÿ   N)r   r‡   rï   r{   ÚadjustWindowr    r:  rz   r‚   r
   rî   r†   s   & r   Útest_adjustWindowÚ!ConnectionTests.test_adjustWindow­  s³   € ô
 ¨!Ô,ˆØ×Ñ˜'Ô"Ø"#ˆÔØ�	‰	×Ñ˜w¨Ô*Ø×Ñ˜×0Ñ0°!Ô4Ø"ˆÔØ�	‰	×Ñ˜w¨Ô*Ø×Ñ˜×0Ñ0°!Ô4Ø×ÑØ�N‰N×"Ñ"ô ×8Ñ8Ø;ððö	
r   c                ó^  € \        4       pV P                  V4       V P                  P                  VR4       RVn        V P                  P                  VR4       V P                  V P                  P                  \        P                  R\        P                  ! R4      ,           3.4       R# )z?
Test that channel data messages are sent in the right format.
rë   Tó   brì   N)r   r‡   r{   ÚsendDatar:  r    rz   r‚   r
   ÚMSG_CHANNEL_DATAr	   rŸ   r†   s   & r   Útest_sendDataÚConnectionTests.test_sendDataÄ  sƒ   € ô “-ˆØ×Ñ˜'Ô"Ø�	‰	×Ñ˜7 DÔ)Ø"ˆÔØ�	‰	×Ñ˜7 DÔ)Ø×ÑØ�N‰N×"Ñ"Ü×)Ñ)Ð+>ÄÇÂÈ4ÃÕ+PÐQÐRö	
r   c                ób  € \        4       pV P                  V4       V P                  P                  V^R4       RVn        V P                  P                  V^R4       V P                  V P                  P                  \        P                  R\        P                  ! R4      ,           3.4       R# )zH
Test that channel extended data messages are sent in the right format.
r  Tr9  Nr@  )r   r‡   r{   ÚsendExtendedDatar:  r    rz   r‚   r
   ÚMSG_CHANNEL_EXTENDED_DATAr	   rŸ   r†   s   & r   Útest_sendExtendedDataÚ%ConnectionTests.test_sendExtendedDataÒ  sŽ   € ô “-ˆØ×Ñ˜'Ô"Ø�	‰	×"Ñ" 7¨A¨wÔ7Ø"ˆÔØ�	‰	×"Ñ" 7¨A¨xÔ8Ø×ÑØ�N‰N×"Ñ"ô ×8Ñ8Ø=ÄÇ	Â	È'Ó@RÕRððö	
r   c                ó’  € \        4       pV P                  V4       V P                  P                  V4       V P	                  V P
                  P                  \        P                  R3.4       RVn	        V P                  P                  V4       V P	                  V P
                  P                  \        P                  R3.4       R# )z>
Test that channel EOF messages are sent in the right format.
rì   TN)
r   r‡   r{   ÚsendEOFr    rz   r‚   r
   ÚMSG_CHANNEL_EOFr:  r†   s   & r   Útest_sendEOFÚConnectionTests.test_sendEOFå  sŸ   € ô “-ˆØ×Ñ˜'Ô"Ø�	‰	×Ñ˜'Ô"Ø×ÑØ�N‰N×"Ñ"¤j×&@Ñ&@ÐBUÐ%VÐ$Wô	
ð #ˆÔØ�	‰	×Ñ˜'Ô"Ø×ÑØ�N‰N×"Ñ"¤j×&@Ñ&@ÐBUÐ%VÐ$Wö	
r   c                óÖ  € \        4       pV P                  V4       V P                  P                  V4       V P	                  VP
                  4       V P                  V P                  P                  \        P                  R3.4       V P                  P                  V4       V P                  V P                  P                  \        P                  R3.4       \        4       pV P                  V4       V P	                  VP                  4       V P                  VP                  4       RVn        V P                  P                  V4       V P	                  VP                  4       R# )z@
Test that channel close messages are sent in the right format.
rì   TN)r   r‡   r{   r   r“   r:  r    rz   r‚   r
   rð   r!   r”   r(   ÚremoteClosed)r   r   r˜   s   &  r   Útest_sendCloseÚConnectionTests.test_sendCloseõ  s  € ô “-ˆØ×Ñ˜'Ô"Ø�	‰	×Ñ˜GÔ$Ø�‰˜×+Ñ+Ô,Ø×ÑØ�N‰N×"Ñ"Ü×*Ñ*Ð,?Ð@ÐAô	
ð 	�	‰	×Ñ˜GÔ$Ø×ÑØ�N‰N×"Ñ"Ü×*Ñ*Ð,?Ð@ÐAô	
ô
 “=ˆØ×Ñ˜(Ô#Ø�‰˜×(Ñ(Ô)Ø×Ñ˜×+Ñ+Ô,Ø $ˆÔØ�	‰	×Ñ˜HÔ%Ø�‰˜×*Ñ*Ö+r   c                óZ  € V P                   P                  R^2^R4      pV P                  VP                  R4       V P                  VP                  ^24       V P                  VP
                  ^4       V P                  \        P                  V P                   P                  R^2^R4       R# )z“
Test that getChannel dispatches to the avatar when an avatar is
present. Correct functioning without the avatar is verified in
test_CHANNEL_OPEN.
r   r1   r¾   N)	r{   Ú
getChannelr    r3   rÁ   rP   ÚassertRaisesr   rT   r†   s   & r   Útest_getChannelWithAvatarÚ)ConnectionTests.test_getChannelWithAvatar  s‰   € ð —)‘)×&Ñ& ~°r¸2¸wÓGˆØ×Ñ˜Ÿ™ wÔ/Ø×Ñ˜×1Ñ1°2Ô6Ø×Ñ˜×0Ñ0°"Ô5Ø×ÑÜ×Ñ˜dŸi™i×2Ñ2°MÀ2ÀrÈ7ö	
r   c                ó"  € V P                   =V P                  V P                  P	                  RR4      4       V P                  V P                  P	                  RR4      R4       V P                  V P                  P	                  RR4      4       R# )zG
Test that gotGlobalRequests dispatches to global_* without an avatar.
r\   r1   s	   Test-Datas	   BadGlobalN)Tr1   )rz   rQ   r“   r{   r_   r    r”   r   s   &r   Ú"test_gotGlobalRequestWithoutAvatarÚ2ConnectionTests.test_gotGlobalRequestWithoutAvatar  sp   € ð �N‰NÐ!Ø�‰˜Ÿ	™	×2Ñ2°=À'ÓJÔKØ×ÑØ�I‰I×&Ñ& |°WÓ=¸ô	
ð 	×Ñ˜Ÿ™×3Ñ3°LÀ'ÓJÖKr   c                óð   € \        4       pV P                  V4       V P                  P                  VRR^R7      pV P	                  V\
        P                  4      pV P                  P                  V4       V# )zƒ
Whenever an SSH channel gets closed any Deferred that was returned by a
sendRequest() on its parent connection must be errbacked.
ó   dummyrequestó	   dummydata©Ú	wantReply)r   r‡   r{   r  ÚassertFailurer   rT   ÚchannelClosedr<  s   &  r   Ú9test_channelClosedCausesLeftoverChannelDeferredsToErrbackÚIConnectionTests.test_channelClosedCausesLeftoverChannelDeferredsToErrback(  sf   € ô
 “-ˆØ×Ñ˜'Ô"à�I‰I×!Ñ! '¨?¸LÐTUÐ!ÓVˆØ×Ñ˜q¤%×"2Ñ"2Ó3ˆØ�	‰	×Ñ Ô(Øˆr   ©r{   rz   N))r   r   r   r   r   rt   r}   r‡   r‹   r�   r™   r£   r²   rº   rÅ   rÌ   rÏ   rÕ   rß   rä   rô   rù   rý   r  r  r  r  r"  r/  r4  r=  rB  rH  rM  rR  rV  r[  r^  rg  r   rI   rJ   s   @r   rv   rv   Í   s½   ø‡ € ßØ0ˆò#ò
ò#ò=òJò*5ò0òò2
òh
ò8*ò?ò;ò	Fò#
òJ)
òV(ò+ò ò.ò(òò"?ò"6ò&6ò6
ò.
ò
ò&
ò ,ò4
ò	L÷ð r   rv   c                   óD   a € ] tR tRt o Rt]'       g   RtR tR tRt	V t
R# )ÚCleanConnectionShutdownTestsi6  zD
Check whether correct cleanup is performed on connection shutdown.
rc   c                óÂ   € \         P                  ! R 4      V n        \        4       V P                  n        \        4       V n        V P                  V P                  n        R # rx   )r   ry   rz   rM   rQ   rb   r{   r   s   &r   r}   Ú"CleanConnectionShutdownTests.setUp>  s<   € Ü&×4Ò4°TÓ:ˆŒÜ *£ˆ�‰ÔÜ"Ó$ˆŒ	Ø"Ÿn™nˆ�	‰	Ör   c                óê   € V P                   P                  4        V P                   P                  RR^R7      pV P                  V\        P
                  4      pV P                   P                  4        V# )zt
Once the service is stopped any leftover global deferred returned by
a sendGlobalRequest() call must be errbacked.
ra  rb  rc  )r{   r|   r«   re  r   rT   rŠ   r.  s   & r   Ú9test_serviceStoppedCausesLeftoverGlobalDeferredsToErrbackÚVCleanConnectionShutdownTests.test_serviceStoppedCausesLeftoverGlobalDeferredsToErrbackD  s]   € ð
 	�	‰	× Ñ Ô"à�I‰I×'Ñ'¨¸ÐQRÐ'ÓSˆØ×Ñ˜q¤%×"2Ñ"2Ó3ˆØ�	‰	× Ñ Ô"Øˆr   ri  N)r   r   r   r   rG   r   rt   r}   ro  r   rI   rJ   s   @r   rk  rk  6  s#   ø‡ € ñ÷ Ø0ˆò-÷
ð 
r   rk  )rG   r„   Útwisted.conch.sshr   Útwisted.conch.testr   Útwisted.python.reflectr   Útwisted.trialr   r   Útwisted.conchr   r	   r
   Ú
SSHChannelr   rM   r   rb   ÚTestCaserv   rk  r   r   r   Ú<module>rx     s•   ðñó å %Ý ,Ý 0Ý "á˜^Ó,€å çß4Ð4÷ñ ô
Y�'×$Ñ$ô Y÷x&ñ &ôR).�Z×-Ñ-ô ).ôXf	�h×'Ñ'ô f	ôR 8×#4Ñ#4ö r   