+
    Dfjh                     D   R t ^ RIHt ^ RIHt ^ RIHt ^ RIHt ^ RI	H
t
 ^ RIHt ^ RIHt ]! ]P                  4       ! R R	4      4       t ! R
 R]P"                  4      t ! R R]P"                  4      t ! R R]P(                  4      t ! R R]P"                  4      tR# )z$
Tests for L{twisted.conch.telnet}.
)implementer)verifyObject)telnet)defer)	iterbytes)proto_helpers)unittestc                   p   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RtV tR# )TestProtocolc                h    R V n         . V n        . V n        . V n        . V n        . V n        . V n        R# )    N)datasubcmdcallsenabledLocalenabledRemotedisabledLocaldisabledRemoteselfs   &@/usr/lib/python3/dist-packages/twisted/conch/test/test_telnet.py__init__TestProtocol.__init__   s7    	
 r   c                   a  / ;q!n         S P                  VR &   VP                  P                  4       ;q!n        R F  pV3V 3R llV\	        \
        V4      &   K  	  R# )   c                 :   < SP                   P                  V4      # N)r   append)argcmdr   s   &&r   <lambda>-TestProtocol.makeConnection.<locals>.<lambda>)   s    4::;L;LS;Qr   N)
EORNOPDMBRKIPAOAYTECELGA)negotiationMapneg_TEST_COMMAND
commandMapcopygetattrr   )r   	transportdr   s   f&  r   makeConnectionTestProtocol.makeConnection#   sV    '))$**'
#,#7#7#<#<#>> SC69&QAgfc"# Tr   c                8    V ;P                   V,          un         R # r   )r   r   r   s   &&r   dataReceivedTestProtocol.dataReceived+   s    		T	r   c                    R # r    )r   reasons   &&r   connectionLostTestProtocol.connectionLost.   s    r   c                    Wn         R # r   )r   )r   payloads   &&r   r-   TestProtocol.neg_TEST_COMMAND1   s    r   c                `    WP                   9   d   V P                  P                  V4       R # R# TF)localEnableabler   r   r   options   &&r   enableLocalTestProtocol.enableLocal4   s(    )))$$V,r   c                <    V P                   P                  V4       R # r   )r   r   rD   s   &&r   disableLocalTestProtocol.disableLocal:   s    !!&)r   c                `    WP                   9   d   V P                  P                  V4       R # R# rB   )remoteEnableabler   r   rD   s   &&r   enableRemoteTestProtocol.enableRemote=   s(    ***%%f-r   c                <    V P                   P                  V4       R # r   )r   r   rD   s   &&r   disableRemoteTestProtocol.disableRemoteC   s    ""6*r   c                    R # r   r:   r   s   &r   connectionMadeTestProtocol.connectionMadeF       r   c                    R # r   r:   )r   commandarguments   &&&r   unhandledCommandTestProtocol.unhandledCommandJ   rU   r   c                    R # r   r:   r   rW   r   s   &&&r   unhandledSubnegotiation$TestProtocol.unhandledSubnegotiationN   rU   r   )r   r   r   r   r   r   r   Nr:   )__name__
__module____qualname____firstlineno__rC   rL   r   r3   r7   r<   r-   rF   rI   rM   rP   rS   rY   r]   __static_attributes____classdictcell____classdict__s   @r   r
   r
      sR     O!R*+ r   r
   c                   &   a  ] tR t^St o R tRtV tR# )InterfacesTestsc                d    \         P                  ! 4       p\        \         P                  V4       R# )z?
L{telnet.TelnetProtocol} implements L{telnet.ITelnetProtocol}
N)r   TelnetProtocolr   ITelnetProtocol)r   ps   & r   test_interfaceInterfacesTests.test_interfaceT   s"     !!#V++Q/r   r:   N)r_   r`   ra   rb   rm   rc   rd   re   s   @r   rh   rh   S   s     0 0r   rh   c                     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R tR tR tR tR t. . . . 3R l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(# ))TelnetTransportTestsz&
Tests for L{telnet.TelnetTransport}.
c                    \         P                  ! \        4      V n        \        P
                  ! 4       V n        V P                  P                  V P                  4       R # r   )r   TelnetTransportr
   rl   r   StringTransporttr3   r   s   &r   setUpTelnetTransportTests.setUpa   s:    ''5..0dff%r   c                    V P                   P                  p. ROpV F  pV P                   P                  V4       K   	  V P                  VP                  RP                  V4      4       R# )   here are some bytes la la lar   N)rx   s   some more arrive heres   lots of bytes to play withs   la la las   ta de das   dum)rl   protocolr7   assertEqualr   joinr   hLbs   &   r   testRegularBytes%TelnetTransportTests.testRegularBytesf   sT     FFOO
 AFF"  	!-r   c                l   V P                   P                  p. ROpV F  pV P                   P                  V4       K   	  V P                  VP                  V^ ,          RR R,           V^,          RR ,           R,           V^,          RR ,           R,           V^,          RR ,           R,           4       R# )   here is the first line
N   
   )r   s   here is the second line s   here is the third line
s   here is the last line )rl   ry   r7   rz   r   r|   s   &   r   testNewlineHandling(TelnetTransportTests.testNewlineHandlingy   s     FFOO
 AFF"  	FFaD"Id3Bi  d3Bi	
  d3Bi 
	
r   c                    V P                   P                  p. ROpV F  pV P                   P                  V4       K   	  V P                  VP                  RP                  V4      P                  RR4      4       R# )*   here are some bytes with an embedded IACr   s      N)r   s&   and here is a test of a border escapes    did you get that IAC?)rl   ry   r7   rz   r   r{   replacer|   s   &   r   testIACEscape"TelnetTransportTests.testIACEscape   sa     FFOO
 AFF"  	!!4!4['!JKr   c                   V P                   P                  p\        P                  \	        \        V4      ,           pR RV,           R,           .pV F  pV P                   P                  V4       K   	  V P                  VP                  V.4       V P                  VP                  RP                  V4      P                  VR4      4       R# )s   Here's some bytes, tra la las   But ono!s    an interruptr   N)rl   ry   r   IACr0   r7   rz   r   r   r{   r   )r   cmdNamer}   r   r~   r   s   &&    r   _simpleCommandTest'TelnetTransportTests._simpleCommandTest   s     FFOOjj76733,kC.?BR.RSAFF"  	7),!!4!4S#!>?r   c                (    V P                  R 4       R# )r&   Nr   r   s   &r   testInterrupt"TelnetTransportTests.testInterrupt       %r   c                (    V P                  R 4       R# )r"   Nr   r   s   &r   testEndOfRecord$TelnetTransportTests.testEndOfRecord       &r   c                (    V P                  R 4       R# )r#   Nr   r   s   &r   testNoOperation$TelnetTransportTests.testNoOperation   r   r   c                (    V P                  R 4       R# )r$   Nr   r   s   &r   testDataMark!TelnetTransportTests.testDataMark   r   r   c                (    V P                  R 4       R# )r%   Nr   r   s   &r   	testBreakTelnetTransportTests.testBreak   r   r   c                (    V P                  R 4       R# )r'   Nr   r   s   &r   testAbortOutput$TelnetTransportTests.testAbortOutput   r   r   c                (    V P                  R 4       R# )r(   Nr   r   s   &r   testAreYouThere$TelnetTransportTests.testAreYouThere   r   r   c                (    V P                  R 4       R# )r)   Nr   r   s   &r   testEraseCharacter'TelnetTransportTests.testEraseCharacter   r   r   c                (    V P                  R 4       R# )r*   Nr   r   s   &r   testEraseLine"TelnetTransportTests.testEraseLine   r   r   c                (    V P                  R 4       R# )r+   Nr   r   s   &r   testGoAhead TelnetTransportTests.testGoAhead   r   r   c                   V P                   P                  p\        P                  \        P                  ,           R ,           \        P                  ,           \        P
                  ,           pRV,           R.pV F  pV P                   P                  V4       K   	  V P                  VP                  RP                  V4      P                  VR4      4       V P                  VP                  \        \        R4      4      4       R# )s   hello worlds   These are some bytes but soons   there will be some morer   s   hello worldN)rl   ry   r   r   SBSEr7   rz   r   r{   r   r   listr   r   r}   r   r~   r   s   &    r   testSubnegotiation'TelnetTransportTests.testSubnegotiation   s     FFOOjj699$'99FJJFR-35OPAFF"  	!!4!4S#!>?4	.(A#BCr   c                @   V P                   P                  p\        P                  \        P                  ,           R ,           \        P
                  ,           \        P                  ,           \        P
                  ,           pRV,           R,           R.pV F  pV P                   P                  V4       K   	  V P                  VP                  RP                  V4      P                  VR4      4       V P                  VP                  \        P
                  .4       R# )r   s   Some bytes are heres   and herer   N)rl   ry   r   r   r   r   r7   rz   r   r{   r   r   r   s   &    r    testSubnegotiationWithEmbeddedSE5TelnetTransportTests.testSubnegotiationWithEmbeddedSE   s     FFOOjj699$w.:VZZG&))S#c)K7EAFF"  	!!4!4S#!>?FII;/r   c           
        \         P                  \         P                  ,           R ,           \         P                  ,           R,           \         P                  ,           \         P                  ,           p\	        \        V4      4       F  p\        4       ;q0P                  n        VP                  V P                  4       VRV WR rTRV,           VR,           .pV F  pV P                  P                  V4       K   	  V P                  VP                  RP                  V4      P                  VR4      4       V P                  VP                  \         P                  .\!        \#        R4      4      ,           4       K  	  R# )r   s   helloNs
   first parts	   last partr   )r   r   r   r   rangelenr
   rl   ry   r3   r7   rz   r   r{   r   r   r   r   )r   r   ir}   ar   r~   r   s   &       r   testBoundarySubnegotiation/TelnetTransportTests.testBoundarySubnegotiation   s#   
 JJii ii 	
 jj ii 	 s3xA"..0ATVV$r7CGq"A$45A##D)  QVVSXXa[%8%8c%BCQXX		{T)H:M5N'NO !r   c                    V P                  VP                  V4       V P                  VP                  V4       V P                  VP                  V4       V P                  VP                  V4       R # r   )rz   r   r   r   r   )r   oeLeRdLdRs   &&&&&&r   _enabledHelper#TelnetTransportTests._enabledHelper
  sT    ,"-"-))2.r   c                &   \         P                  \         P                  ,           R ,           pRV,           R,           pV P                  P	                  V4       V P                  V P                  P                  P                  VP                  VR4      4       V P                  V P                  P                  4       \         P                  \         P                  ,           R ,           4       V P                  V P                  P                  4       R# r   s   surrounding bytess   to spice things upr   N)r   r   WILLrl   r7   rz   ry   r   r   rt   valueDONTr   r   r   r   s   &  r   testRefuseWill#TelnetTransportTests.testRefuseWill  s    jj6;;&0#c),AAD!--t||C/EFfkk)AG)KLDFFOO,r   c                &   \         P                  \         P                  ,           R ,           pRV,           R,           pV P                  P	                  V4       V P                  V P                  P                  P                  VP                  VR4      4       V P                  V P                  P                  4       \         P                  \         P                  ,           R ,           4       V P                  V P                  P                  4       R# r   )r   r   DOrl   r7   rz   ry   r   r   rt   r   WONTr   r   s   &  r   testRefuseDo!TelnetTransportTests.testRefuseDo  s    jj699$w.#c),AAD!--t||C/EFfkk)AG)KLDFFOO,r   c                   \         P                  \         P                  ,           R ,           pRV,           R,           pV P                  P                  pRVn        V P                  P                  V4       V P                  V P                  P                  4       \         P                  \         P                  ,           R ,           4       V P                  VR .R7       R# )      paddings   trailer)r   N)r   )r   r   r   rl   ry   rC   r7   rz   rt   r   r   r   r   r   r   r}   s   &   r   testAcceptDo!TelnetTransportTests.testAcceptDo&  s     jj699$w.C*,FFOO&D!fkk)AG)KLA7),r   c                   \         P                  \         P                  ,           R ,           pRV,           R,           pV P                  P                  pRVn        V P                  P                  V4       V P                  V P                  P                  4       \         P                  \         P                  ,           R ,           4       V P                  VR .R7       R# )   s   headerr   r   N)r   )r   r   r   rl   ry   rL   r7   rz   rt   r   r   r   r   s   &   r   testAcceptWill#TelnetTransportTests.testAcceptWill3  s    jj6;;&03+FFOO'D!fii)?')IJA7),r   c                   \         P                  \         P                  ,           R ,           pV P                  P	                  R 4      pRVP
                  n        RV,           pV P                  P                  V4       V P                  V P                  P                  P                  VP                  VR4      4       V P                  V P                  P                  4       \         P                  \         P                  ,           R ,           4       V P                  VP
                  P                  R4       V P                  V P                  P                  R .R7       R# )   )yess
   fiddle deer   nor   N)r   r   r   rl   getOptionStatehimstater7   rz   ry   r   r   rt   r   r   r   r   r   sr   s   &   r   testAcceptWont#TelnetTransportTests.testAcceptWont?  s     jj6;;&0
 FF!!'*s"D!--t||C/EFfkk)AG)KLd+DFFOO	:r   c                   \         P                  \         P                  ,           R ,           pV P                  P	                  R 4      pRVP
                  n        RV,           pV P                  P                  V4       V P                  V P                  P                  P                  VP                  VR4      4       V P                  V P                  P                  4       \         P                  \         P                  ,           R ,           4       V P                  VP
                  P                  R4       V P                  V P                  P                  R .R7       R# )r   r   s   fiddle dum r   r   )r   N)r   r   r   rl   r   usr   r7   rz   ry   r   r   rt   r   r   r   r   s   &   r   testAcceptDont#TelnetTransportTests.testAcceptDontS  s     jj6;;&0
 FF!!'*
#D!--t||C/EFfkk)AG)KLT*DFFOO	:r   c                   \         P                  \         P                  ,           R ,           pRV,           R,           pV P                  P	                  V4       V P                  V P                  P                  P                  VP                  VR4      4       V P                  V P                  P                  4       R4       V P                  V P                  P                  4       R#    G
   dum de dum	   tra la lar   N)r   r   r   rl   r7   rz   ry   r   r   rt   r   r   r   s   &  r   testIgnoreWont#TelnetTransportTests.testIgnoreWontg  s     jj6;;&0s"\1D!--t||C/EF-DFFOO,r   c                   \         P                  \         P                  ,           R ,           pRV,           R,           pV P                  P	                  V4       V P                  V P                  P                  P                  VP                  VR4      4       V P                  V P                  P                  4       R4       V P                  V P                  P                  4       R# r   )r   r   r   rl   r7   rz   ry   r   r   rt   r   r   r   s   &  r   testIgnoreDont#TelnetTransportTests.testIgnoreDonts  s     jj6;;&0s"\1D!--t||C/EF-DFFOO,r   c                *   \         P                  \         P                  ,           R ,           pV P                  P	                  R 4      pRVP
                  n        RV,           R,           pV P                  P                  V4       V P                  V P                  P                  P                  VP                  VR4      4       V P                  V P                  P                  4       R4       V P                  V P                  P                  4       R#    Vr   r   r   r   N)r   r   r   rl   r   r   r   r7   rz   ry   r   r   rt   r   r   r   s   &   r   testIgnoreWill#TelnetTransportTests.testIgnoreWill  s     jj6;;&0
 FF!!'*c!M1D!--t||C/EF-DFFOO,r   c                *   \         P                  \         P                  ,           R ,           pV P                  P	                  R 4      pRVP
                  n        RV,           R,           pV P                  P                  V4       V P                  V P                  P                  P                  VP                  VR4      4       V P                  V P                  P                  4       R4       V P                  V P                  P                  4       R# r  )r   r   r   rl   r   r   r   r7   rz   ry   r   r   rt   r   r   r   s   &   r   testIgnoreDo!TelnetTransportTests.testIgnoreDo  s     jj699$w.
 FF!!'*
c!M1D!--t||C/EF-DFFOO,r   c                  a a S P                   P                  R 4      pS P                   P                  oRSn        S P	                  S P
                  P                  4       \        P                  \        P                  ,           R ,           4       S P                   P                  \        P                  \        P                  ,           R ,           4       VP                  S P                  R4       VP                  VV 3R l4       V# )   BTc                 ,   < SP                  SR .R7      # )r	  r   )r   )_r}   r   s   &r   r    @TelnetTransportTests.testAcceptedEnableRequest.<locals>.<lambda>  s     3 3A7) 3 Dr   r	  )rl   dory   rL   rz   rt   r   r   r   r   r7   r   addCallback)r   r2   r}   s   f @r   testAcceptedEnableRequest.TelnetTransportTests.testAcceptedEnableRequest  s    
 FFIIgFFOO'fii)?')IJFJJ4w>?	d&&-	DEr   c                  a a RS P                   P                  n        S P                   P                  R4      pS P	                  S P
                  P                  4       \        P                  \        P                  ,           R,           4       S P                   P                  R4      oS P	                  SP                  P                  R4       S P	                  SP                  P                  R4       S P                  SP                  P                  4       S P!                  SP                  P                  4       S P                   P#                  \        P                  \        P$                  ,           R,           4       S P'                  V\        P(                  4      pVP+                  V 3R l4       VP+                  VV 3R l4       V# )z
If the peer refuses to enable an option we request it to enable, the
L{Deferred} returned by L{TelnetProtocol.do} fires with an
L{OptionRefused} L{Failure}.
r	  r   c                 N   < SP                  SP                  P                  4      # r   r   rl   ry   ignoredr   s   &r   r    @TelnetTransportTests.test_refusedEnableRequest.<locals>.<lambda>      d&9&9$&&//&Jr   c                 N   < SP                  SP                  P                  4      # r   )assertFalser   negotiatingr  r   r   s   &r   r    r    s    d&6&6quu7H7H&Ir   r  )rl   ry   rL   r  rz   rt   r   r   r   r   r   r   r   r   
assertTruer  r  r7   r   assertFailureOptionRefusedr  r   r2   r   s   f @r   test_refusedEnableRequest.TelnetTransportTests.test_refusedEnableRequest  s     ,6(FFIIgfii)?')IJFF!!'*d+T*))*))*FJJ4w>?q&"6"67	JK	IJr   c                  a a RS P                   P                  n        S P                   P                  R4      pS P	                  S P
                  P                  4       \        P                  \        P                  ,           R,           4       S P                   P                  R4      oS P	                  SP                  P                  R4       S P	                  SP                  P                  R4       S P                  SP                  P                  4       S P!                  SP                  P                  4       S P                   P#                  \        P                  \        P$                  ,           R,           4       S P'                  V\        P(                  4      pVP+                  V 3R l4       VP+                  VV 3R l4       V# )z
If the peer refuses to allow us to enable an option, the L{Deferred}
returned by L{TelnetProtocol.will} fires with an L{OptionRefused}
L{Failure}.
r	  r   c                 N   < SP                  SP                  P                  4      # r   r  r  s   &r   r    >TelnetTransportTests.test_refusedEnableOffer.<locals>.<lambda>  r  r   c                 N   < SP                  SP                  P                  4      # r   )r  r   r  r  s   &r   r    r%    s    d&6&6qtt7G7G&Hr   r  )rl   ry   rC   willrz   rt   r   r   r   r   r   r   r   r   r  r  r  r7   r   r  r  r  r   s   f @r   test_refusedEnableOffer,TelnetTransportTests.test_refusedEnableOffer  s     +5'FFKK fkk)AG)KLFF!!'*d+T***+(()FJJ4w>?q&"6"67	JK	HIr   c                *  a  S P                   P                  R 4      pRVP                  n        S P                   P	                  R 4      pS P                  S P                  P                  4       \        P                  \        P                  ,           R ,           4       S P                   P                  \        P                  \        P                  ,           R ,           4       VP                  S P
                  R4       VP                  V 3R l4       V# )r	  r   Tc                 T   < SP                  SP                  P                  R .R7      # )r	  r   r  r  r   s   &r   r    ATelnetTransportTests.testAcceptedDisableRequest.<locals>.<lambda>  s     3 3DFFOO	 3 Rr   )rl   r   r   r   dontrz   rt   r   r   r   r   r7   r   r  r   r   r2   s   f  r   testAcceptedDisableRequest/TelnetTransportTests.testAcceptedDisableRequest  s    
 FF!!'*FFKK fkk)AG)KLFJJ4w>?	d&&-	RSr   c                  a  S P                   P                  R 4      pRVP                  n        S P                   P	                  R 4       V 3R lpV 3R lpV 3R lpV! R4      pVP                  V4       VP                  V4       V# )   $r   c                 z   < SP                   P                  R 4      pSP                  V\        P                  4      # r3  )rl   r  r  r   AlreadyNegotiatingxr2   r   s   & r   _doITelnetTransportTests.testNegotiationBlocksFurtherNegotiation.<locals>._do
  s.    		'"A%%a)B)BCCr   c                 z   < SP                   P                  R 4      pSP                  V\        P                  4      # r5  )rl   r.  r  r   r6  r7  s   & r   _dontKTelnetTransportTests.testNegotiationBlocksFurtherNegotiation.<locals>._dont  s.    G$A%%a)B)BCCr   c                 :  < SP                   P                  \        P                  \        P                  ,           R ,           4       SP                  SP                   P                  R .R7       RSP                   P                  n        SP                   P                  R 4      pSP                   P                  \        P                  \        P                  ,           R ,           4       VP                  SP                  R4       VP                  V3R l4       V# )r3  r   Tc                 X   < SP                  SP                  P                  R .R .R7      # )r3  )r   r   r  r,  s   &r   r    ^TelnetTransportTests.testNegotiationBlocksFurtherNegotiation.<locals>._final.<locals>.<lambda>  s(    $--FFOO	wi . r   r5  )rl   r7   r   r   r   r   ry   rL   r  r   r  rz   r7  s   & r   _finalLTelnetTransportTests.testNegotiationBlocksFurtherNegotiation.<locals>._final  s    FF

V[[ 87 BCWI>/9DFFOO,		'"AFF

V[[ 87 BCMM$**D1MM
 Hr   N)rl   r   r   r   r.  r  )r   r   r9  r<  rA  r2   s   f     r   'testNegotiationBlocksFurtherNegotiation<TelnetTransportTests.testNegotiationBlocksFurtherNegotiation  sm     FF!!'*G	D	D	  I	e	fr   c                x    V P                   P                  R 4      pV P                  V\        P                  4      # )   )rl   r.  r  r   AlreadyDisabled)r   r2   s   & r   #testSuperfluousDisableRequestRaises8TelnetTransportTests.testSuperfluousDisableRequestRaises'  s-    FFKK !!!V%;%;<<r   c                    V P                   P                  R 4      pRVP                  n        V P                   P	                  R 4      pV P                  V\        P                  4      # )rF  r   )rl   r   r   r   r  r  r   AlreadyEnabledr/  s   &  r   "testSuperfluousEnableRequestRaises7TelnetTransportTests.testSuperfluousEnableRequestRaises,  sL    FF!!'*FFIIg!!!V%:%:;;r   c                   V P                   P                  R 4      pV P                   P                  R4      pV P                   P                  R4      p ! R R\        4      pV P                   P                  V! R4      4       V P	                  W4      pV P	                  W$4      pV P	                  W44      p\
        P                  ! WV.4      # )r      #   4c                       ] tR tRtRtR# )LTelnetTransportTests.testLostConnectionFailsDeferreds.<locals>.TestExceptioni8  r:   N)r_   r`   ra   rb   rc   r:   r   r   TestExceptionrR  8  s    r   rS  zTotal failure!)rl   r  	Exceptionr<   r  r   gatherResults)r   d1d2d3rS  s   &    r    testLostConnectionFailsDeferreds5TelnetTransportTests.testLostConnectionFailsDeferreds3  s    VVYYwVVYYwVVYYw	I 	 	m,<=>222""BB<00r   )rl   rt   N),r_   r`   ra   rb   __doc__ru   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r!  r(  r0  rC  rH  rL  rY  rc   rd   re   s   @r   rp   rp   \   s     &
.&
6L"@&''&'&'&&&D0P6 $&" /	-	--
-;(;(
---&-&$88$#J=
<1 1r   rp   c                   <   a  ] tR tRt o RtR tR tR tR tRt	V t
R# )	
TestTelnetiC  zH
A trivial extension of the telnet protocol class useful to unit tests.
c                R    \         P                  P                  V 4       . V n        R # r   )r   Telnetr   eventsr   s   &r   r   TestTelnet.__init__H  s    t$r   c                @    V P                   P                  RV34       R# )z*
Record the given data in C{self.events}.
bytesNr`  r   r6   s   &&r   applicationDataReceived"TestTelnet.applicationDataReceivedL  s     	GT?+r   c                @    V P                   P                  RW34       R# )z-
Record the given command in C{self.events}.
rW   Nrd  r\   s   &&&r   rY   TestTelnet.unhandledCommandR  s     	Iw56r   c                @    V P                   P                  RW34       R# )z<
Record the given subnegotiation command in C{self.events}.
	negotiateNrd  r\   s   &&&r   r]   "TestTelnet.unhandledSubnegotiationX  s     	K78r   )r`  N)r_   r`   ra   rb   r[  r   re  rY   r]   rc   rd   re   s   @r   r]  r]  C  s#     ,79 9r   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V tR# )TelnetTestsi_  z
Tests for L{telnet.Telnet}.

L{telnet.Telnet} implements the TELNET protocol (RFC 854), including option
and suboption negotiation, and option state tracking.
c                $    \        4       V n        R# )z=
Create an unconnected L{telnet.Telnet} to be used by tests.
N)r]  ry   r   s   &r   ru   TelnetTests.setUpg  s     #r   c                Z    V P                  V P                  P                  R4      4       R# )z|
L{telnet.Telnet.enableLocal} should reject all options, since
L{telnet.Telnet} does not know how to implement any options.
    N)r  ry   rF   r   s   &r   test_enableLocalTelnetTests.test_enableLocalm  s!    
 	2259:r   c                Z    V P                  V P                  P                  R4      4       R# )z}
L{telnet.Telnet.enableRemote} should reject all options, since
L{telnet.Telnet} does not know how to implement any options.
rq  N)r  ry   rM   r   s   &r   test_enableRemoteTelnetTests.test_enableRemotet  s!    
 	33E:;r   c                \    V P                  \        V P                  P                  R4       R# )z
It is an error for L{telnet.Telnet.disableLocal} to be called, since
L{telnet.Telnet.enableLocal} will never allow any options to be enabled
locally.  If a subclass overrides enableLocal, it must also override
disableLocal.
rq  N)assertRaisesNotImplementedErrorry   rI   r   s   &r   test_disableLocalTelnetTests.test_disableLocal{  s!     	-t}}/I/I5Qr   c                \    V P                  \        V P                  P                  R4       R# )z
It is an error for L{telnet.Telnet.disableRemote} to be called, since
L{telnet.Telnet.enableRemote} will never allow any options to be
enabled remotely.  If a subclass overrides enableRemote, it must also
override disableRemote.
rq  N)rx  ry  ry   rP   r   s   &r   test_disableRemoteTelnetTests.test_disableRemote  s!     	-t}}/J/JERr   c                    \         P                  ! 4       pV P                  P                  V4       V P                  P	                  RR4       V P                  VP                  4       R4       R# )z
L{telnet.Telnet.requestNegotiation} formats the feature byte and the
payload bytes into the subnegotiation format and sends them.

See RFC 855.
   s   s   Nr   rs   ry   r3   requestNegotiationrz   r   r   r1   s   & r   test_requestNegotiation#TelnetTests.test_requestNegotiation  sS     "113	$$Y/((+>OO+	
r   c                    \         P                  ! 4       pV P                  P                  V4       V P                  P	                  RR4       V P                  VP                  4       R4       R# )z
If the payload for a subnegotiation includes I{IAC}, it is escaped by
L{telnet.Telnet.requestNegotiation} with another I{IAC}.

See RFC 855.
r  r   s   Nr  r  s   & r   !test_requestNegotiationEscapesIAC-TelnetTests.test_requestNegotiationEscapesIAC  sP     "113	$$Y/((':*,KLr   c                    . ;q0P                   n        V P                   P                  V4       V P                  V\	        V4      4       R# )zg
Pass the given bytes to the protocol's C{dataReceived} method and
assert that the given events occur.
N)ry   r`  r7   rz   r   )r   r   expectedreceiveds   &&* r   _deliverTelnetTests._deliver  s9    
 +-,=='""4(4>2r   c                *    V P                  RR4       R# )zK
One application-data byte in the default state gets delivered right
away.
   aN)rc  r  r  r   s   &r   test_oneApplicationDataByte'TelnetTests.test_oneApplicationDataByte  s    
 	dO,r   c                *    V P                  RR4       R# )zI
Two application-data bytes in the default state get delivered
together.
   bcN)rc  r  r  r   s   &r   test_twoApplicationDataBytes(TelnetTests.test_twoApplicationDataBytes  s    
 	e-.r   c                T    V P                  R\        P                  ,           R4       R# )zf
Three application-data bytes followed by a control byte get
delivered, but the control byte doesn't.
   defN)rc  r  r  r   r   r   s   &r   test_threeApplicationDataBytes*TelnetTests.test_threeApplicationDataBytes  s    
 	fvzz)+<=r   c                    V P                  \        P                  4       V P                  \        P                  R,           R\        P                  R,           34       R# )za
IAC in the escaped state gets delivered and so does another
application-data byte following it.
   grc  Nr  r   s   &r   test_escapedControlTelnetTests.test_escapedControl  s9    
 	fjj!fjj4''6::3D)EFr   c                   V P                  R4       V P                  RR4       V P                  RR4       V P                  R4       V P                  RR4       V P                  RR4       V P                  R4       V P                  RR4       V P                  RR4       V P                  R4       V P                  \        P                  \        P                  ,           R	,           RR\        P                  ,           R	,           34       R
# )a  
A carriage return only puts the protocol into the newline state.  A
linefeed in the newline state causes just the newline to be
delivered.  A nul in the newline state causes a carriage return to
be delivered.  An IAC in the newline state causes a carriage return
to be delivered and puts the protocol into the escaped state.
Anything else causes a carriage return and that thing to be
delivered.
r   r   rc  s   
rq  s    r     a   xN)rc  r   )rc  r   )rc  r  r  r   s   &r   test_carriageReturnTelnetTests.test_carriageReturn  s     	ee-.g/0ee-.g/0ed-.f/0eJJ#d*Wefjj6H46O,P	
r   c                    V P                  R\        P                  ,           \        P                  ,           RR\        P                  R34       R# )z\
Application bytes received before a command are delivered before the
command is processed.
r  rW   N)rc  r  )r  r   r   r#   r   s   &r   'test_applicationDataBeforeSimpleCommand3TelnetTests.test_applicationDataBeforeSimpleCommand  s6    
 	6::

*

D)	
r   c                    / V P                   n        V P                  R\        P                  ,           \        P
                  ,           R,           RR\        P
                  R34       R# )zf
Application bytes received before a WILL/WONT/DO/DONT are delivered
before the command is processed.
   yrq  rW   N)rc  r  )ry   r.   r  r   r   r   r   s   &r   !test_applicationDataBeforeCommand-TelnetTests.test_applicationDataBeforeCommand  sG    
 $& 6::+g5W-	
r   c                    V P                  R\        P                  ,           \        P                  ,           R,           \        P                  ,           \        P                  ,           RRRR.34       R# )zo
Application bytes received before a subnegotiation command are
delivered before the negotiation is processed.
   zs   Qxrj     Qr  N)rc  r  )r  r   r   r   r   r   s   &r   (test_applicationDataBeforeSubnegotiation4TelnetTests.test_applicationDataBeforeSubnegotiation  sK    
 	6::		)E1FJJ>J$'	
r   )ry   N)r_   r`   ra   rb   r[  ru   rr  ru  rz  r}  r  r  r  r  r  r  r  r  r  r  r  rc   rd   re   s   @r   rm  rm  _  sc     %;<RS
 
M3-/>G
6	


	
 	
r   rm  N)r[  zope.interfacer   zope.interface.verifyr   twisted.conchr   twisted.internetr   twisted.python.compatr   twisted.testr   twisted.trialr   rk   r
   TestCaserh   rp   r_  r]  rm  r:   r   r   <module>r     s   

 ' .   " + & " V##$; ; %;|0h'' 0d18,, d1N9 98k
(## k
r   