
    Vhb                     V   d Z ddlZddlZddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZmZ ddlmZ dd	lmZmZmZ dd
lmZ ddlmZ ddlmZmZ  ed      Z eej:                        Zej>                  jA                  ejB                        ed<    G d de      Z"ddlm#Z# ddlm$Z$ ddl%m&Z&  G d dejN                        Z(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1ddl	m2Z2 	 dd l3m4Z4m5Z5m6Z6m7Z7m8Z8 dd!l9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z? d"Z@ G d# d$e:j                        ZB G d% d&e;j                        ZD G d' d(e?j                        ZF G d) d*e>j                        ZH G d+ d,e7      ZI G d- d.e6      ZJ G d/ d0e8      ZK ej                  eJeKe=j                          G d2 d3e$j                        ZP G d4 d5      ZQ G d6 d7eQ      ZRdd8lSmTZT  G d9 d:ej                  eTj                        ZW G d; d<ej                  eTj                        ZY G d= d>eQ      ZZ G d? d@eQ      Z[ G dA dB      Z\ G dC dDeZee\      Z] G dE dFeRee\      Z^ ee dG       G dH dIe[ee\             Z_ G dJ dK      Z` G dL dMeZee`      Za G dN dOeRee`      Zb ee dP       G dQ dRe[ee`             Zc G dS dTe      Zdy# eN$ r d1Z@Y w xY w)UzU
Tests for L{twisted.conch.recvline} and fixtures for testing related
functionality.
    N)skipIf)recvline)insults)portal)defererror)StringTransport)
componentsfilepathreflect)	iterbytes)requireModule)SkipTestTestCaseztwisted.conch.stdio
PYTHONPATHc                   T    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zy)ArrowsTestsc                     t                _        t        j                          _        t        j                          _         fd j                  _          j                  _	         j                  j                   j                         y )Nc                       j                   S N)pselfs   P/home/dcms/DCMS/lib/python3.12/site-packages/twisted/conch/test/test_recvline.py<lambda>z#ArrowsTests.setUp.<locals>.<lambda>"   s    $&&     )r	   underlyingTransportr   ServerProtocolptr   HistoricRecvLiner   protocolFactoryfactorymakeConnectionr   s   `r   setUpzArrowsTests.setUp   s]    #2#4 ((***,"0t778r   c                     | j                   j                  dd       | j                   j                  dd       | j                   j                  dd       | j                  | j                   j                         d       y)zy
        When L{HistoricRecvLine} receives a printable character,
        it adds it to the current line buffer.
           xN   y   z   xyzr   )r   keystrokeReceivedassertEqualcurrentLineBufferr   s    r   test_printableCharactersz$ArrowsTests.test_printableCharacters&   s]    
 	  t,  t,  t,113]Cr   c                      fd}t        d      D ]
  } ||         j                   j                  j                         d        | j                  j
                          j                   j                  j                         d        | j                  j                          j                   j                  j                         d        | j                  j                          j                   j                  j                         d        | j                  j                          j                   j                  j                         d        | j                  j                          j                   j                  j                         d        | j                  j
                          j                   j                  j                         d        | j                  j
                          j                   j                  j                         d        | j                  j
                          j                   j                  j                         d        | j                  j
                          j                   j                  j                         d       y)z
        When L{HistoricRecvLine} receives a LEFT_ARROW or
        RIGHT_ARROW keystroke it moves the cursor left or right
        in the current line buffer, respectively.
        c                 <    j                   j                  | d       S r   r   r+   chr   s    r   r   z3ArrowsTests.test_horizontalArrows.<locals>.<lambda>7       00T: r   r*   r)   )   xyr(   )r&   s   yz)r   r*   N)r   r,   r   r-   r   RIGHT_ARROW
LEFT_ARROWr   kRr3   s   `  r   test_horizontalArrowsz!ArrowsTests.test_horizontalArrows1   s    ;F# 	BrF	 	113]C
477113]C
477113]C
477113]C
477113]C
477113]C
477113]C
477113]C
477113]C
477113]Cr   c                 |     fd}t        d      D ]
  } ||         j                   j                  j                         d        |d        |d        |d        j                   j                  j                         d        |d        j                   j                  j                         d       y	)
z
        When {HistoricRecvLine} receives a newline, it adds the current
        line buffer to the end of its history buffer.
        c                 <    j                   j                  | d       S r   r1   r2   s    r   r   z*ArrowsTests.test_newline.<locals>.<lambda>]   r4   r      xyz
abc
123
r*      abc   123    c   b   a   
))r*   r@   rA   s   cbarB   N)r   r,   r   currentHistoryBufferr8   s   `  r   test_newlinezArrowsTests.test_newlineX   s    
 ;./ 	BrF	 	4468VW
4
4
44468VW
5	FF'')+Q	
r   c                      fd}t        d      D ]
  } ||         j                   j                  j                         d        j                   j                  j	                         d        | j
                  j                          j                   j                  j                         d        j                   j                  j	                         d        | j
                  j                          j                   j                  j                         d        j                   j                  j	                         d        | j
                  j                          j                   j                  j                         d	        j                   j                  j	                         d
        | j
                  j                          j                   j                  j                         d	        j                   j                  j	                         d
       t        d      D ]  } | j
                  j                            j                   j                  j                         d       y)a  
        When L{HistoricRecvLine} receives UP_ARROW or DOWN_ARROW
        keystrokes it move the current index in the current history
        buffer up or down, and resets the current line buffer to the
        previous or next line in history, respectively for each.
        c                 <    j                   j                  | d       S r   r1   r2   s    r   r   z1ArrowsTests.test_verticalArrows.<locals>.<lambda>u   r4   r   r=   r>   r   r   ))r*   r@   )rA   )rA   r   ))r*   )r@   rA   )r@   r   )rB   r?   r)      N)	r   r,   r   rG   r-   r   UP_ARROWrange
DOWN_ARROW)r   r9   r3   is   `   r   test_verticalArrowszArrowsTests.test_verticalArrowsn   s    ;./ 	BrF	 	4468VW113Z@
4774468UV113]C
4774468UV113]C
4774468VW113]C
4774468VW113]Cq 	#Atww!!"	#4468VWr   c                       fd}t        d      D ]
  } ||         j                   j                  j                         d        | j                  j
                          j                   j                  j                         d       y)z
        When L{HistoricRecvLine} receives a HOME keystroke it moves the
        cursor to the beginning of the current line buffer.
        c                 <    j                   j                  | d       S r   r1   r2   s    r   r   z'ArrowsTests.test_home.<locals>.<lambda>   r4   r      hello, worldrT   r   )r   rT   N)r   r,   r   r-   r   HOMEr8   s   `  r   	test_homezArrowsTests.test_home   sq    
 ;O, 	BrF	1135KL
477<<1135KLr   c                 X     fd}t        d      D ]
  } ||         j                   j                  j                         d        | j                  j
                          | j                  j                          j                   j                  j                         d       y)z
        When L{HistoricRecvLine} receives an END keystroke it moves the cursor
        to the end of the current line buffer.
        c                 <    j                   j                  | d       S r   r1   r2   s    r   r   z&ArrowsTests.test_end.<locals>.<lambda>   r4   r   rT   rU   N)r   r,   r   r-   r   rV   ENDr8   s   `  r   test_endzArrowsTests.test_end   s    
 ;O, 	BrF	1135KL
477<<
477;;1135KLr   c                 p     fd}t        d      D ]
  } ||         j                   j                  j                         d        | j                  j
                          j                   j                  j                         d        | j                  j                          | j                  j
                          j                   j                  j                         d        | j                  j
                          j                   j                  j                         d       y)z
        When L{HistoricRecvLine} receives a BACKSPACE keystroke it deletes
        the character immediately before the cursor.
        c                 <    j                   j                  | d       S r   r1   r2   s    r   r   z,ArrowsTests.test_backspace.<locals>.<lambda>   r4   r   r*   r)   r5   r   )r   r'   N)r   r,   r   r-   r   	BACKSPACEr7   r8   s   `  r   test_backspacezArrowsTests.test_backspace   s    
 ;F# 	BrF	113]C
477113\B
477
477113[A
477113[Ar   c                      fd}t        d      D ]
  } ||         j                   j                  j                         d        | j                  j
                          j                   j                  j                         d        | j                  j                          | j                  j
                          j                   j                  j                         d        | j                  j                          | j                  j
                          j                   j                  j                         d        | j                  j                          | j                  j
                          j                   j                  j                         d        | j                  j
                          j                   j                  j                         d       y)z
        When L{HistoricRecvLine} receives a DELETE keystroke, it
        delets the character immediately after the cursor.
        c                 <    j                   j                  | d       S r   r1   r2   s    r   r   z)ArrowsTests.test_delete.<locals>.<lambda>   r4   r   r*   r)   r^   )r&   r   rK   N)r   r,   r   r-   r   DELETEr7   r8   s   `  r   test_deletezArrowsTests.test_delete   sY   
 ;F# 	BrF	113]C
477>>113]C
477
477>>113\B
477
477>>113[A
477
477>>113Z@
477>>113Z@r   c                 x     fd}t        d      D ]
  } ||         | j                  j                          |d        j                   j                  j                         d        | j                  j                          |d        j                   j                  j                         d       y)z
        When not in INSERT mode, L{HistoricRecvLine} inserts the typed
        character at the cursor before the next character.
        c                 <    j                   j                  | d       S r   r1   r2   s    r   r   z)ArrowsTests.test_insert.<locals>.<lambda>   r4   r   r*      A)   xyAr(      B)   xyBs   AzN)r   r   r7   r,   r   r-   r8   s   `  r   test_insertzArrowsTests.test_insert   s    
 ;F# 	BrF	 	477
4113^D
477
4113_Er   c                      fd}t        d      D ]
  } ||         | j                  j                          | j                  j                          |d        j	                   j
                  j                         d        | j                  j                          |d        j	                   j
                  j                         d       y)a  
        When in INSERT mode and upon receiving a keystroke with a printable
        character, L{HistoricRecvLine} replaces the character at
        the cursor with the typed character rather than inserting before.
        Ah, the ironies of INSERT mode.
        c                 <    j                   j                  | d       S r   r1   r2   s    r   r   z+ArrowsTests.test_typeover.<locals>.<lambda>   r4   r   r*   rg   )rh   r   ri   )rj   r   N)r   r   INSERTr7   r,   r   r-   r8   s   `  r   test_typeoverzArrowsTests.test_typeover   s     ;F# 	BrF	 	477>>
477
4113]C
477
4113]Cr   c                      fd} j                   }|j                  |j                  |j                  |j                  |j
                  |j                  |j                  |j                  |j                  |j                  |j                  |j                  |j                  |j                  fD ]4  } ||        j                   j                   j#                         d       6 y)z
        When L{HistoricRecvLine} receives a keystroke for an unprintable
        function key with no assigned behavior, the line buffer is unmodified.
        c                 <    j                   j                  | d       S r   r1   r2   s    r   r   z8ArrowsTests.test_unprintableCharacters.<locals>.<lambda>  r4   r   rK   N)r   F1F2F3F4F5F6F7F8F9F10F11F12PGUPPGDNr,   r   r-   )r   r9   r   r3   s   `   r   test_unprintableCharactersz&ArrowsTests.test_unprintableCharacters  s    
 ;WW EEEEEEEEEEEEEEEEEEFFFFFFGGGG
 	EB  rFTVV557D#	Er   N)__name__
__module____qualname__r$   r.   r:   rH   rQ   rW   r[   r`   rd   rk   ro   r   rB   r   r   r   r      sJ    9	D%DN
,!XFMMB*A:F$D,Er   r   )telnet)helper)LoopbackRelayc                       e Zd Zd Zy)
EchoServerc                 t    | j                   j                  |dz   | j                  | j                     z          y )NrF   )terminalwritepspn)r   lines     r   lineReceivedzEchoServer.lineReceived*  s*    D5L477477+;;<r   N)r   r   r   r   rB   r   r   r   r   )  s    =r   r   s   [Ds   [Cs   [As   [Bs   [2~s   [1~s   [3~s   [4~   )checkers)ConchFactoryTerminalRealmTerminalSessionTerminalSessionTransportTerminalUser)channel
connectionkeyssession	transportuserauthTc                   (    e Zd ZdZd Zd Zd Zd Zy)SessionChannels   sessionc                     t        j                  j                  | g|i | || _        || _        || _        || _        || _        y r   )r   
SSHChannel__init__r!   protocolArgsprotocolKwArgswidthheightr   r!   r   r   r   r   akws           r   r   zSessionChannel.__init__S  sH     ''7q7B7#2D  ,D"0DDJ DKr   c                    t        j                  d| j                  | j                  ddfd      }| j                  j                  | d|       | j                  j                  | dd        | j                  | j                  i | j                  | _	        | | j                  _
        | j                  j                  |        y )Ns   vt102r   r   s   pty-reqs   shell)r   packRequest_pty_reqr   r   connsendRequestr!   r   r   _protocolInstancer"   r#   )r   dataterms      r   channelOpenzSessionChannel.channelOpen_  s    ..4;;

Aq93D II!!$
D9II!!$#6%9T%9%9""&&*&9&9&D" .2D""*""11$7r   c                 ^    | j                   j                  t        j                                y r   )r   connectionLostr   ConnectionDoner   s    r   closedzSessionChannel.closedl  s    ""11%2F2F2HIr   c                 :    | j                   j                  |       y r   )r   dataReceivedr   r   s     r   r   zSessionChannel.dataReceivedo  s    ""//5r   N)r   r   r   namer   r   r   r   rB   r   r   r   r   P  s    
	!	8	J	6r   r   c                       e Zd Zd Zd Zd Zy)TestConnectionc                     t        j                  j                  | g|i | || _        || _        || _        || _        || _        y r   )r   SSHConnectionr   r!   r   r   r   r   r   s           r   r   zTestConnection.__init__s  sH     $$--d=Q="=#2D  ,D"0DDJ DKr   c                     t        | j                  | j                  | j                  | j                  | j
                        | _        | j                  | j                         y r   )r   r!   r   r   r   r   _TestConnection__channelopenChannelr   s    r   serviceStartedzTestConnection.serviceStarted  sK    +$$!!##

DN T^^,r   c                 8    | j                   j                  |      S r   )r   r   r   s     r   r   zTestConnection.write  s    >>''--r   N)r   r   r   r   r   r   rB   r   r   r   r   r  s    
	!	-	.r   r   c                       e Zd Zd Zd Zy)TestAuthc                 Z    t        j                  j                  | |g|i | || _        y r   )r   SSHUserAuthClientr   password)r   usernamer   r   r   s        r   r   zTestAuth.__init__  s)    &&//hIIbI$DMr   c                 @    t        j                  | j                        S r   )r   succeedr   r   s    r   getPasswordzTestAuth.getPassword  s    ==//r   N)r   r   r   r   r   rB   r   r   r   r     s    	%	0r   r   c                   $    e Zd Zd Zd Zd Zd Zy)TestTransportc                 f    || _         || _        || _        || _        || _        || _        || _        y r   )r!   r   r   r   r   r   r   )
r   r!   r   r   r   r   r   r   r   r   s
             r   r   zTestTransport.__init__  s8     $3D  ,D"0D$DM$DMDJ DKr   c                 ,    t        j                  d      S )NT)r   r   )r   hostKeyfingerprints      r   verifyHostKeyzTestTransport.verifyHostKey  s    ==&&r   c                    t        | j                  | j                  | j                  | j                  | j
                        | _        | j                  t        | j                  | j                  | j                               y r   )r   r!   r   r   r   r   _TestTransport__connectionrequestServicer   r   r   r   s    r   connectionSecurezTestTransport.connectionSecure  sb     .$$!!##

!D t7H7HIr   c                 8    | j                   j                  |      S r   )r   r   r   s     r   r   zTestTransport.write  s    $$**400r   N)r   r   r   r   r   r   r   rB   r   r   r   r     s    	!(	'
		1r   r   c                       e Zd Zd Zy)TestSessionTransportc                 r    | j                   j                  j                  j                  j	                         S r   )avatarr   r   r"   serverProtocolr   s    r   r!   z$TestSessionTransport.protocolFactory  s'    ;;##--55DDFFr   N)r   r   r   r!   rB   r   r   r   r     s    	Gr   r   c                       e Zd ZeZy)TestSessionN)r   r   r   r   transportFactoryrB   r   r   r   r     s    /r   r   c                       e Zd Zy)TestUserNr   r   r   rB   r   r   r   r     s    r   r   Fc                       e Zd Zd Zd Zd Zy)NotifyingExpectableBufferc                 h    t        j                         | _        t        j                         | _        y r   )r   DeferredonConnectiononDisconnectionr   s    r   r   z"NotifyingExpectableBuffer.__init__  s     !NN,$~~/r   c                 x    t         j                  j                  |        | j                  j	                  |        y r   )r   ExpectableBufferconnectionMader   callbackr   s    r   r   z(NotifyingExpectableBuffer.connectionMade  s*    ..t4""4(r   c                 :    | j                   j                  |       y r   )r   errback)r   reasons     r   r   z(NotifyingExpectableBuffer.connectionLost  s    $$V,r   N)r   r   r   r   r   r   rB   r   r   r   r     s    0)-r   r   c                        e Zd ZdZdZd Zd Zy)
_BaseMixinP      c                     | j                   j                         j                         }|dg| j                  t	        |      z
  dz
  z  z   }| j                  ||       y )Nr      )recvlineClient	__bytes__
splitlinesHEIGHTlenr,   )r   linesreceivedLinesexpectedLiness       r   _assertBufferz_BaseMixin._assertBuffer  sR    ++557BBD#$++E
*BQ*F!GH6r   c                       j                   j                  d      } j                  |        fd}|j                  |      S )Ns   donec                 (    j                         y r   )r   )ignoutputr   s    r   finishedz)_BaseMixin._trivialTest.<locals>.finished  s    v&r   )r   expect
_testwriteaddCallback)r   	inputLiner  doner  s   ` `  r   _trivialTestz_BaseMixin._trivialTest  s=    ""))'2	"	' ))r   N)r   r   r   WIDTHr   r   r  rB   r   r   r   r     s    EF7
*r   r   c                       e Zd Zd Zd Zy)	_SSHMixinc           	         t         st        d      d\  }}t               }t        |_        fd|_        t        j                         }|j                  ||       t        j                  |      }|j                  |       t        |      }t        j                  t        j                   | j#                               d      }||j$                  d<   ||j&                  d<   | j(                  |_        |j+                          | j)                         t-        j.                  fd      |j1                  d       }t3        |      }	t5               t-        j6                  fd      t9        fd	d
i ||| j:                  | j<                        }
t3        |
      }|
j?                  |	       |j?                  |       | _         |
| _!        || _"        |	| _#        || _$        jJ                  S )NzMcryptography requirements missing, can't run historic recvline tests over ssh)s   testusers   testpassc                       S r   rB   insultsServers   r   r   z!_SSHMixin.setUp.<locals>.<lambda>  s    ] r   i   )keySizes   ssh-rsac                       S r   rB   recvlineServers   r   r   z!_SSHMixin.setUp.<locals>.<lambda>      ~ r   c                       S r   rB   r   s   r   r   z!_SSHMixin.setUp.<locals>.<lambda>  r  r   c                       S r   rB   insultsClients   r   r   z!_SSHMixin.setUp.<locals>.<lambda>  s    M r   rB   )&sshr   r   r   userFactorychainedProtocolFactoryr   'InMemoryUsernamePasswordDatabaseDontUseaddUserr   PortalregisterCheckerr   r   _getPersistentRSAKeyr   FilePathmktemp
publicKeysprivateKeysr   startFactoryr   r   buildProtocolr   r   ClientProtocolr   r	  r   r#   r   	sshClient	sshServerclientTransportserverTransportr   )r   ur   rlmcheckerptl
sshFactorysshKeyr*  r+  r)  r,  r  r  r   r  s               @@@@r   r$   z_SSHMixin.setUp  s   * 
 (1o"%:"BBD1mmC G$!#&
**dkkm,d
 -3
j)-3
z*$($7$7
!!,,.../EF,,T2	'	224../EF!!2r1aT[[
	 (	2  1  1,""..***r   c                 :    | j                   j                  |       y r   )r)  r   r   s     r   r  z_SSHMixin._testwrite  s    T"r   Nr   r   r   r$   r  rB   r   r   r  r    s    0+d#r   r  )test_telnetc                       e Zd Zy)TestInsultsClientProtocolNr   rB   r   r   r7  r7  #      r   r7  c                       e Zd Zy)TestInsultsServerProtocolNr   rB   r   r   r:  r:  '  r8  r   r:  c                       e Zd Zd Zd Zy)_TelnetMixinc                    | j                         t        fd      t        j                  fd      }t	        |      }t               t        fd      t        j                  fd      }t	        |      }|j                  |       |j                  |       |j                          |j                          | _	        || _
        || _        || _        j                  S )Nc                       S r   rB   r  s   r   r   z$_TelnetMixin.setUp.<locals>.<lambda>.      . r   c                       S r   rB   r  s   r   r   z$_TelnetMixin.setUp.<locals>.<lambda>/      m r   c                       S r   rB   r  s   r   r   z$_TelnetMixin.setUp.<locals>.<lambda>3  r?  r   c                       S r   rB   r  s   r   r   z$_TelnetMixin.setUp.<locals>.<lambda>4  rA  r   )r   r:  r   TelnetTransportr   r   r7  r#   clearBufferr   telnetClientr+  r,  r   )	r   telnetServerr+  rF  r,  r  r  r   r  s	        @@@@r   r$   z_TelnetMixin.setUp,  s    ,,.12HI--.CD'52412HI--.CD'5##O4##O4##%##%,(..***r   c                 :    | j                   j                  |       y r   )rF  r   r   s     r   r  z_TelnetMixin._testwriteD  s    %r   Nr4  rB   r   r   r<  r<  +  s    +0&r   r<  c                       e Zd Zd Zd Zd Zy)_StdioMixinc           	      0   t               t        j                  fd      }t        j	                  |      }t
        j                  }t        j                  }|j                  d      s|j                  d      r|d d }||t        j                  | j                        g}ddlm} |j                  |||t        d      }x| _        | _        || _        || _        t)        j*                  t-        d |j.                  j1                  d	      g            S )
Nc                       S r   rB   )testTerminals   r   r   z#_StdioMixin.setUp.<locals>.<lambda>S  s    | r   z.pycz.pyor   )reactorT)envusePTYs   >>> )r   r   r(  stdioTerminalProcessProtocolsys
executable__file__endswithr   qualr   twisted.internetrO  spawnProcess	properEnvr   rM  processClientr+  r   gatherResultsfilterr   r  )	r   r  r\  exemoduleargsrO  r+  rM  s	           @r   r$   z_StdioMixin.setUpI  s    
 12
  ../CD
 55mD
 nn??6"foof&=CR[FVW\\$*=*=>?,!..3)D / 
 3?>d/*.
 ""4-44l6I6I'6RST
 	
r   c                      	  j                   j                  d        fd} j
                  j                  j                  |      S # t        j                  t        f$ r Y Ew xY w)NKILLc                     | j                  t        j                         j                  | j                  j
                         j                  | j                  j                  d       y )N	   )trapr   ProcessTerminatedassertIsNonevalueexitCoder,   status)failurer   s    r   rf  z"_StdioMixin.tearDown.<locals>.trap{  sG    LL001gmm445W]]1115r   )r+  signalProcessr   ProcessExitedAlreadyOSErrorrM  r   
addErrback)r   rf  s   ` r   tearDownz_StdioMixin.tearDownt  s_    	  ..v6	6
   00;;DAA **G4 		s   A A$#A$c                 :    | j                   j                  |       y r   )r+  r   r   s     r   r  z_StdioMixin._testwrite  s    ""4(r   N)r   r   r   r$   rq  r  rB   r   r   rJ  rJ  H  s    )
VB)r   rJ  c                   F    e Zd ZeZd Zd Zd Zd Zd Z	d Z
d Zd Zd	 Zy
)RecvlineLoopbackMixinc                 *    | j                  dg d      S )Ns   first line
done)   >>> first line
   first line   >>> done)r  r   s    r   
testSimplez RecvlineLoopbackMixin.testSimple  s      !P
 	
r   c                 R    | j                  t        dz   t        dz  z   dz   g d      S )Nrw  rL   	   xxxx
done)s   >>> first xxxxs
   first xxxxrx  )r  insertleftr   s    r   testLeftArrowz#RecvlineLoopbackMixin.testLeftArrow  s.      ]"TAX-=;
 	
r   c                 f    | j                  t        dz   t        dz  z   t        dz  z   dz   g d      S )Ns
   right linerL      s   xx
done)s   >>> right lixxs
   right lixxrx  )r  r|  r}  rightr   s    r   testRightArrowz$RecvlineLoopbackMixin.testRightArrow  s7      ]"TAX-	9KG;
 	
r   c                 D    | j                  dt        dz  z   dz   g d      S )N   second linerL   r{  )s   >>> second xxxxs   second xxxxrx  )r  	backspacer   s    r   testBackspacez#RecvlineLoopbackMixin.testBackspace  s)      Y]*]:=
 	
r   c                 X    | j                  dt        dz  z   t        dz  z   dz   g d      S )Ns   delete xxxxrL   	   line
done)s   >>> delete lines   delete linerx  )r  r}  deleter   s    r   
testDeletez RecvlineLoopbackMixin.testDelete  s2      TAX%
2]B=
 	
r   c                 D    | j                  dt        dz  z   dz   g d      S )Ns	   third ine      l
done)s   >>> third lines
   third linerx  )r  r}  r   s    r   
testInsertz RecvlineLoopbackMixin.testInsert  s)      4!8#j0;
 	
r   c                 R    | j                  dt        dz  z   t        z   dz   g d      S )Ns   fourth xinerL   r  )s   >>> fourth lines   fourth linerx  )r  r}  r|  r   s    r   testTypeoverz"RecvlineLoopbackMixin.testTypeover  s.      TAX%.;=
 	
r   c                 L    | j                  t        dz   t        z   dz   g d      S )Ns	   blah lines	   home
done)s   >>> home lines	   home linerx  )r  r|  homer   s    r   testHomezRecvlineLoopbackMixin.testHome  s*      \!D(=89
 	
r   c                 R    | j                  dt        dz  z   t        z   dz   g d      S )Ns   end rL   r  )s   >>> end lines   end linerx  )r  r}  endr   s    r   testEndzRecvlineLoopbackMixin.testEnd  s.      dQh$}47
 	
r   N)r   r   r   r   r   ry  r~  r  r  r  r  r  r  r  rB   r   r   rt  rt    s4    N









r   rt  c                       e Zd Zy)RecvlineLoopbackTelnetTestsNr   rB   r   r   r  r    r8  r   r  c                       e Zd Zy)RecvlineLoopbackSSHTestsNr   rB   r   r   r  r    r8  r   r  zBTerminal requirements missing, can't run recvline tests over stdioc                       e Zd Zy)RecvlineLoopbackStdioTestsNr   rB   r   r   r  r    s    r   r  c                   "    e Zd ZeZd Zd Zd Zy)HistoricRecvlineLoopbackMixinc                 >    | j                  dt        z   dz   g d      S )Ns   first line
   
done)rv  rw  rv  rw  rx  )r  upr   s    r   testUpArrowz)HistoricRecvlineLoopbackMixin.testUpArrow  s'      b 9,	
 		
r   c                 L    | j                  dt        z   t        z   dz   g d      S )aH  
        Pressing down arrow to visit an entry that was added to the
        history by pressing the up arrow instead of return does not
        raise a L{TypeError}.

        @see: U{http://twistedmatrix.com/trac/ticket/9031}

        @return: A L{defer.Deferred} that fires when C{b"done"} is
            echoed back.
        s   first line
partial liner  )rv  rw  s   >>> partial lines   partial linerx  r  r  downr   s    r   $test_DownArrowToPartialLineInHistoryzBHistoricRecvlineLoopbackMixin.test_DownArrowToPartialLineInHistory  s.       -2T9IE	
 		
r   c                 R    | j                  dt        dz  z   t        z   dz   g d      S )Ns   first line
second line
r  r  )rv  rw     >>> second liner  r  r  rx  r  r   s    r   testDownArrowz+HistoricRecvlineLoopbackMixin.testDownArrow  s0      (261D89D
 	
r   N)r   r   r   r   r   r  r  r  rB   r   r   r  r    s    N


.
r   r  c                       e Zd Zy)#HistoricRecvlineLoopbackTelnetTestsNr   rB   r   r   r  r         	r   r  c                       e Zd Zy) HistoricRecvlineLoopbackSSHTestsNr   rB   r   r   r  r    r  r   r  zKTerminal requirements missing, can't run historic recvline tests over stdioc                       e Zd Zy)"HistoricRecvlineLoopbackStdioTestsNr   rB   r   r   r  r    s     	r   r  c                       e Zd ZdZd Zy)TransportSequenceTestsz5
    L{twisted.conch.recvline.TransportSequence}
    c                 L    | j                  t        t        j                         y)zh
        Initializing a L{recvline.TransportSequence} with no args
        raises an assertion.
        N)assertRaisesAssertionErrorr   TransportSequencer   s    r   test_invalidSequencez+TransportSequenceTests.test_invalidSequence  s    
 	.(*D*DEr   N)r   r   r   __doc__r  rB   r   r   r  r    s    Fr   r  )er  osrT  unittestr   twisted.conchr   twisted.conch.insultsr   twisted.credr   rY  r   r   twisted.internet.testingr	   twisted.pythonr
   r   r   twisted.python.compatr   twisted.python.reflectr   twisted.trial.unittestr   r   rR  dictenvironr[  pathsepjoinpathr   r   r   twisted.conch.test.loopbackr   r    r   r}  r  r  r  r|  r  r  r  r  r   twisted.conch.manhole_sshr   r   r   r   r   twisted.conch.sshr   r   r   r   r   r   r  r   r   r   r   r   r   SSHClientTransportr   r   r   r   registerAdapterISessionImportErrorr   r   r   r  twisted.conch.testr5  r(  TestProtocolr7  r   r:  r<  rJ  rt  r  r  r  r  r  r  r  r  rB   r   r   <module>r     s  

 
 
  " )  ) 4 8 8 + 0 5+,	**//#((3	, DE( DEN ! ( 5=** = 			 !JH   C 6++  6D.11 .408-- 0%1	44 %1NG7 G0o 0<  J{Hg6F6FG
- 7 7 
-* *(4#
 4#n +	 6 68P8P 		 6 68P8P 	&: &:;)* ;)|6
 6
r	,:O 		y(4I 	 E	WX	h8M 	 Y	2
 2
j	(9		x6	 IT	8			
FX 
FY  
Cs   J J('J(