
    tfh                     <   d 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
 ddlmZ ddlmZ  eej                   G d	 d
                      Z G d dej                  Z G d dej                  Z G d dej                  Z G d dej                  ZdS )z$
Tests for L{twisted.conch.telnet}.
    )implementer)verifyObject)telnet)defer)	iterbytes)proto_helpers)unittestc                   ^    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d Zd ZdS )TestProtocol c                 h    d| _         g | _        g | _        g | _        g | _        g | _        g | _        d S )N    )datasubcmdcallsenabledLocalenabledRemotedisabledLocaldisabledRemoteselfs    ]/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/conch/test/test_telnet.py__init__zTestProtocol.__init__   s=    	
 r   c                      i x}|_          j        |d<   |j                                        x}|_        dD ]}|f fd	|t	          t
          |          <    d S )N   )
EORNOPDMBRKIPAOAYTECELGAc                 8    j                             |          S N)r   append)argcmdr   s     r   <lambda>z-TestProtocol.makeConnection.<locals>.<lambda>)   s    4:;L;LS;Q;Q r   )negotiationMapneg_TEST_COMMAND
commandMapcopygetattrr   )r   	transportdr*   s   `   r   makeConnectionzTestProtocol.makeConnection#   s{    '))I$*'
#,#7#<#<#>#>>I S 	R 	RC69&Q&Q&Q&Q&QAgfc""##	R 	Rr   c                 &    | xj         |z  c_         d S r'   )r   r   r   s     r   dataReceivedzTestProtocol.dataReceived+   s    		T				r   c                     d S r'   r   )r   reasons     r   connectionLostzTestProtocol.connectionLost.   s    r   c                     || _         d S r'   )r   )r   payloads     r   r-   zTestProtocol.neg_TEST_COMMAND1   s    r   c                 P    || j         v r| j                            |           dS dS NTF)localEnableabler   r(   r   options     r   enableLocalzTestProtocol.enableLocal4   s1    T)))$$V,,,4ur   c                 :    | j                             |           d S r'   )r   r(   r?   s     r   disableLocalzTestProtocol.disableLocal:   s    !!&)))))r   c                 P    || j         v r| j                            |           dS dS r=   )remoteEnableabler   r(   r?   s     r   enableRemotezTestProtocol.enableRemote=   s1    T***%%f---4ur   c                 :    | j                             |           d S r'   )r   r(   r?   s     r   disableRemotezTestProtocol.disableRemoteC   s    ""6*****r   c                     d S r'   r   r   s    r   connectionMadezTestProtocol.connectionMadeF       r   c                     d S r'   r   )r   commandarguments      r   unhandledCommandzTestProtocol.unhandledCommandJ   rK   r   c                     d S r'   r   r   rM   r   s      r   unhandledSubnegotiationz$TestProtocol.unhandledSubnegotiationN   rK   r   N)__name__
__module____qualname__r>   rE   r   r3   r6   r9   r-   rA   rC   rF   rH   rJ   rO   rR   r   r   r   r   r      s        O! ! !R R R        * * *  + + +        r   r   c                       e Zd Zd ZdS )InterfacesTestsc                 `    t          j                    }t          t           j        |           dS )zO
        L{telnet.TelnetProtocol} implements L{telnet.ITelnetProtocol}
        N)r   TelnetProtocolr   ITelnetProtocol)r   ps     r   test_interfacezInterfacesTests.test_interfaceT   s+     !##V+Q/////r   N)rS   rT   rU   r\   r   r   r   rW   rW   S   s#        0 0 0 0 0r   rW   c                       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d Zd Zd Zd Zd Zd Zd Zg g g g f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"d! Z#d" Z$d# Z%d$ Z&d% Z'd& Z(d'S )(TelnetTransportTestsz.
    Tests for L{telnet.TelnetTransport}.
    c                     t          j        t                    | _        t	          j                    | _        | j                            | j                   d S r'   )r   TelnetTransportr   r[   r   StringTransporttr3   r   s    r   setUpzTelnetTransportTests.setUpa   sB    '55.00df%%%%%r   c                     | j         j        }g d}|D ]}| j                             |           |                     |j        d                    |                     d S )N)s   here are some bytes la la las   some more arrive heres   lots of bytes to play withs   la la las   ta de das   dumr   )r[   protocolr6   assertEqualr   joinr   hLbs       r   testRegularBytesz%TelnetTransportTests.testRegularBytesf   sp     FO
 
 
  	# 	#AF""""!-----r   c                 4   | j         j        }g d}|D ]}| j                             |           |                     |j        |d         d d         dz   |d         d d         z   dz   |d         d d         z   dz   |d         d d         z   dz              d S )	N)s   here is the first line
s   here is the second line s   here is the third line
s   here is the last line r      
            )r[   re   r6   rf   r   rh   s       r   testNewlineHandlingz(TelnetTransportTests.testNewlineHandlingy   s     FO
 
 
  	# 	#AF""""FaD"Id3B3i  d3B3i	
  d3B3i 
	
 
	
 
	
 
	
 
	
r   c                     | j         j        }g d}|D ]}| j                             |           |                     |j        d                    |                              dd                     d S )N)s*   here are some bytes with an embedded IACs&   and here is a test of a border escapes    did you get that IAC?r   s      )r[   re   r6   rf   r   rg   replacerh   s       r   testIACEscapez"TelnetTransportTests.testIACEscape   s     FO
 
 
  	# 	#AF""""!!4!4['!J!JKKKKKr   c                 p   | j         j        }t          j        t	          t          |          z   }dd|z   dz   g}|D ]}| j                             |           |                     |j        |g           |                     |j        d	                    |          
                    |d                     d S )Ns   Here's some bytes, tra la las   But ono!s    an interruptr   )r[   re   r   IACr0   r6   rf   r   r   rg   rw   )r   cmdNameri   r*   rj   rk   s         r   _simpleCommandTestz'TelnetTransportTests._simpleCommandTest   s     FOj767333,kC.?BR.RS 	# 	#AF""""7),,,!!4!4S#!>!>?????r   c                 0    |                      d           d S )Nr    r|   r   s    r   testInterruptz"TelnetTransportTests.testInterrupt       %%%%%r   c                 0    |                      d           d S )Nr   r~   r   s    r   testEndOfRecordz$TelnetTransportTests.testEndOfRecord       &&&&&r   c                 0    |                      d           d S )Nr   r~   r   s    r   testNoOperationz$TelnetTransportTests.testNoOperation   r   r   c                 0    |                      d           d S )Nr   r~   r   s    r   testDataMarkz!TelnetTransportTests.testDataMark   r   r   c                 0    |                      d           d S )Nr   r~   r   s    r   	testBreakzTelnetTransportTests.testBreak   r   r   c                 0    |                      d           d S )Nr!   r~   r   s    r   testAbortOutputz$TelnetTransportTests.testAbortOutput   r   r   c                 0    |                      d           d S )Nr"   r~   r   s    r   testAreYouTherez$TelnetTransportTests.testAreYouThere   r   r   c                 0    |                      d           d S )Nr#   r~   r   s    r   testEraseCharacterz'TelnetTransportTests.testEraseCharacter   r   r   c                 0    |                      d           d S )Nr$   r~   r   s    r   testEraseLinez"TelnetTransportTests.testEraseLine   r   r   c                 0    |                      d           d S )Nr%   r~   r   s    r   testGoAheadz TelnetTransportTests.testGoAhead   r   r   c                    | j         j        }t          j        t          j        z   dz   t          j        z   t          j        z   }d|z   dg}|D ]}| j                             |           |                     |j        d	                    |          
                    |d                     |                     |j        t          t          d                               d S )Ns   hello worlds   These are some bytes but soons   there will be some morer   s   hello world)r[   re   r   rz   SBSEr6   rf   r   rg   rw   r   listr   r   ri   r*   rj   rk   s        r   testSubnegotiationz'TelnetTransportTests.testSubnegotiation   s     FOj69$'99FJFR-35OP 	# 	#AF""""!!4!4S#!>!>???4	.(A(A#B#BCCCCCr   c                    | j         j        }t          j        t          j        z   dz   t          j        z   t          j        z   t          j        z   }d|z   dz   dg}|D ]}| j                             |           |                     |j        d	                    |          
                    |d                     |                     |j        t          j        g           d S )Nr   s   Some bytes are heres   and herer   )r[   re   r   rz   r   r   r6   rf   r   rg   rw   r   r   s        r    testSubnegotiationWithEmbeddedSEz5TelnetTransportTests.testSubnegotiationWithEmbeddedSE   s     FOj69$w.:VZG&)S#c)K7E 	# 	#AF""""!!4!4S#!>!>???FI;/////r   c           
         t           j        t           j        z   dz   t           j        z   dz   t           j        z   t           j        z   }t	          t          |                    D ]}t                      x}| j        _        |	                    | j                   |d |         ||d          }}d|z   |dz   g}|D ]}| j        
                    |           |                     |j        d                    |                              |d                     |                     |j        t           j        gt!          t#          d                    z              d S )Nr   s   hellos
   first parts	   last partr   )r   rz   r   r   rangelenr   r[   re   r3   r6   rf   r   rg   rw   r   r   r   )r   r*   iri   ark   rj   r   s           r   testBoundarySubnegotiationz/TelnetTransportTests.testBoundarySubnegotiation   s\   
 Ji i 	
 j i 	 s3xx 	P 	PA"...0ATV$$$rr7CGqA"A$45A * *##D))))QVSXXa[[%8%8c%B%BCCCQX	{T)H:M:M5N5N'NOOOO	P 	Pr   c                     |                      |j        |           |                      |j        |           |                      |j        |           |                      |j        |           d S r'   )rf   r   r   r   r   )r   oeLeRdLdRs         r   _enabledHelperz#TelnetTransportTests._enabledHelper
  si    ,,,"---"---)2.....r   c                    t           j        t           j        z   dz   }d|z   dz   }| j                            |           |                     | j        j        j        |                    |d                     |                     | j	        
                                t           j        t           j        z   dz              |                     | j        j                   d S Nr   s   surrounding bytess   to spice things upr   )r   rz   WILLr[   r6   rf   re   r   rw   rb   valueDONTr   r   r*   r   s      r   testRefuseWillz#TelnetTransportTests.testRefuseWill  s    j6;&0#c),AAD!!!-t||C/E/EFFFfk)AG)KLLLDFO,,,,,r   c                    t           j        t           j        z   dz   }d|z   dz   }| j                            |           |                     | j        j        j        |                    |d                     |                     | j	        
                                t           j        t           j        z   dz              |                     | j        j                   d S r   )r   rz   DOr[   r6   rf   re   r   rw   rb   r   WONTr   r   s      r   testRefuseDoz!TelnetTransportTests.testRefuseDo  s    j69$w.#c),AAD!!!-t||C/E/EFFFfk)AG)KLLLDFO,,,,,r   c                 f   t           j        t           j        z   dz   }d|z   dz   }| j        j        }d|_        | j                            |           |                     | j        	                                t           j        t           j
        z   dz              |                     |dg           d S )N      paddings   trailer)r   )r   )r   rz   r   r[   re   r>   r6   rf   rb   r   r   r   r   r*   r   ri   s       r   testAcceptDoz!TelnetTransportTests.testAcceptDo&  s     j69$w.C*,FO&D!!!fk)AG)KLLLA7),,,,,r   c                 f   t           j        t           j        z   dz   }d|z   dz   }| j        j        }d|_        | j                            |           |                     | j        	                                t           j        t           j
        z   dz              |                     |dg           d S )N   s   headerr   )r   r   )r   rz   r   r[   re   rE   r6   rf   rb   r   r   r   r   s       r   testAcceptWillz#TelnetTransportTests.testAcceptWill3  s    j6;&03+FO'D!!!fi)?')IJJJA7),,,,,r   c                 L   t           j        t           j        z   dz   }| j                            d          }d|j        _        d|z   }| j                            |           |                     | j        j	        j
        |                    |d                     |                     | j                                        t           j        t           j        z   dz              |                     |j        j        d           |                     | j        j	        dg           d S )N   )yess
   fiddle deer   nor   )r   rz   r   r[   getOptionStatehimstater6   rf   re   r   rw   rb   r   r   r   r   r*   sr   s       r   testAcceptWontz#TelnetTransportTests.testAcceptWont?  s     j6;&0
 F!!'**s"D!!!-t||C/E/EFFFfk)AG)KLLLd+++DFO	:::::r   c                 L   t           j        t           j        z   dz   }| j                            d          }d|j        _        d|z   }| j                            |           |                     | j        j	        j
        |                    |d                     |                     | j                                        t           j        t           j        z   dz              |                     |j        j        d           |                     | j        j	        dg           d S )Nr   r   s   fiddle dum r   r   )r   )r   rz   r   r[   r   usr   r6   rf   re   r   rw   rb   r   r   r   r   s       r   testAcceptDontz#TelnetTransportTests.testAcceptDontS  s     j6;&0
 F!!'**
#D!!!-t||C/E/EFFFfk)AG)KLLLT***DFO	:::::r   c                    t           j        t           j        z   dz   }d|z   dz   }| j                            |           |                     | j        j        j        |                    |d                     |                     | j	        
                                d           |                     | j        j                   d S N   G
   dum de dum	   tra la lar   )r   rz   r   r[   r6   rf   re   r   rw   rb   r   r   r   s      r   testIgnoreWontz#TelnetTransportTests.testIgnoreWontg  s     j6;&0s"\1D!!!-t||C/E/EFFF---DFO,,,,,r   c                    t           j        t           j        z   dz   }d|z   dz   }| j                            |           |                     | j        j        j        |                    |d                     |                     | j	        
                                d           |                     | j        j                   d S r   )r   rz   r   r[   r6   rf   re   r   rw   rb   r   r   r   s      r   testIgnoreDontz#TelnetTransportTests.testIgnoreDonts  s     j6;&0s"\1D!!!-t||C/E/EFFF---DFO,,,,,r   c                    t           j        t           j        z   dz   }| j                            d          }d|j        _        d|z   dz   }| j                            |           |                     | j        j	        j
        |                    |d                     |                     | j                                        d           |                     | j        j	                   d S N   Vr   r   r   r   )r   rz   r   r[   r   r   r   r6   rf   re   r   rw   rb   r   r   r   s       r   testIgnoreWillz#TelnetTransportTests.testIgnoreWill  s     j6;&0
 F!!'**c!M1D!!!-t||C/E/EFFF---DFO,,,,,r   c                    t           j        t           j        z   dz   }| j                            d          }d|j        _        d|z   dz   }| j                            |           |                     | j        j	        j
        |                    |d                     |                     | j                                        d           |                     | j        j	                   d S r   )r   rz   r   r[   r   r   r   r6   rf   re   r   rw   rb   r   r   r   s       r   testIgnoreDoz!TelnetTransportTests.testIgnoreDo  s     j69$w.
 F!!'**
c!M1D!!!-t||C/E/EFFF---DFO,,,,,r   c                      j                             d          } j         j        d_                              j                                        t          j        t          j	        z   dz               j         
                    t          j        t          j        z   dz              |                     j        d           |                     fd           |S )N   Br   Tc                 4                         dg          S )Nr   r   )r   )_ri   r   s    r   r+   z@TelnetTransportTests.testAcceptedEnableRequest.<locals>.<lambda>  s     3 3A7) 3 D D r   )r[   dore   rE   rf   rb   r   r   rz   r   r6   r   addCallback)r   r2   ri   s   ` @r   testAcceptedEnableRequestz.TelnetTransportTests.testAcceptedEnableRequest  s    
 FIIgFO'fi)?')IJJJFJ4w>???	d&---	DDDDDEEEr   c                 (    d j         j        _         j                             d          }                      j                                        t          j        t          j	        z   dz               j         
                    d                               j        j        d                                j        j        d                                j        j                                        j        j                    j                             t          j        t          j        z   dz                                   |t          j                  }|                     fd           |                     fd           |S )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   r   c                 B                         j        j                  S r'   r   r[   re   ignoredr   s    r   r+   z@TelnetTransportTests.test_refusedEnableRequest.<locals>.<lambda>      d&9&9$&/&J&J r   c                 B                         j        j                  S r'   )assertFalser   negotiatingr   r   r   s    r   r+   z@TelnetTransportTests.test_refusedEnableRequest.<locals>.<lambda>  s    d&6&6qu7H&I&I r   )r[   re   rE   r   rf   rb   r   r   rz   r   r   r   r   r   
assertTruer   r   r6   r   assertFailureOptionRefusedr   r   r2   r   s   ` @r   test_refusedEnableRequestz.TelnetTransportTests.test_refusedEnableRequest  sH    ,6(FIIgfi)?')IJJJF!!'**d+++T***)***)***FJ4w>???q&"677	JJJJKKK	IIIIIJJJr   c                 (    d j         j        _         j                             d          }                      j                                        t          j        t          j	        z   dz               j         
                    d                               j        j        d                                j        j        d                                j        j                                        j        j                    j                             t          j        t          j        z   dz                                   |t          j                  }|                     fd           |                     fd           |S )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   r   c                 B                         j        j                  S r'   r   r   s    r   r+   z>TelnetTransportTests.test_refusedEnableOffer.<locals>.<lambda>  r   r   c                 B                         j        j                  S r'   )r   r   r   r   s    r   r+   z>TelnetTransportTests.test_refusedEnableOffer.<locals>.<lambda>  s    d&6&6qt7G&H&H r   )r[   re   r>   willrf   rb   r   r   rz   r   r   r   r   r   r   r   r   r6   r   r   r   r   r   s   ` @r   test_refusedEnableOfferz,TelnetTransportTests.test_refusedEnableOffer  sH    +5'FKK  fk)AG)KLLLF!!'**d+++T****+++()))FJ4w>???q&"677	JJJJKKK	HHHHHIIIr   c                      j                             d          }d|j        _         j                             d          }                      j                                        t          j	        t          j
        z   dz               j                             t          j	        t          j        z   dz              |                     j        d           |                     fd           |S )Nr   r   Tc                 H                         j        j        dg          S )Nr   r   r   r   r   s    r   r+   zATelnetTransportTests.testAcceptedDisableRequest.<locals>.<lambda>  s      3 3DFO	 3 R R r   )r[   r   r   r   dontrf   rb   r   r   rz   r   r6   r   r   r   r   r2   s   `  r   testAcceptedDisableRequestz/TelnetTransportTests.testAcceptedDisableRequest  s    
 F!!'**FKK  fk)AG)KLLLFJ4w>???	d&---	RRRRSSSr   c                      j                             d          }d|j        _         j                             d            fd} fd} fd} |d           }|                    |           |                    |           |S )N   $r   c                 x    j                             d          }                    |t          j                  S Nr   )r[   r   r   r   AlreadyNegotiatingxr2   r   s     r   _dozITelnetTransportTests.testNegotiationBlocksFurtherNegotiation.<locals>._do
  s/    		'""A%%a)BCCCr   c                 x    j                             d          }                    |t          j                  S r   )r[   r   r   r   r   r   s     r   _dontzKTelnetTransportTests.testNegotiationBlocksFurtherNegotiation.<locals>._dont  s/    G$$A%%a)BCCCr   c                    j                             t          j        t          j        z   dz                                  j         j        dg           dj         j        _        j                             d          }j                             t          j        t          j	        z   dz              |
                    j        d           |
                    fd           |S )Nr   r   )r   Tc                 L                         j        j        dgdg          S )Nr   )r   r   r   r   s    r   r+   z^TelnetTransportTests.testNegotiationBlocksFurtherNegotiation.<locals>._final.<locals>.<lambda>  s+    $--FO	wi .   r   )r[   r6   r   rz   r   r   re   rE   r   r   r   rf   r   s     r   _finalzLTelnetTransportTests.testNegotiationBlocksFurtherNegotiation.<locals>._final  s    F
V[ 87 BCCCWI>>>/9DFO,		'""AF
V[ 87 BCCCMM$*D111MM     
 Hr   )r[   r   r   r   r   r   )r   r   r  r  r  r2   s   `     r   'testNegotiationBlocksFurtherNegotiationz<TelnetTransportTests.testNegotiationBlocksFurtherNegotiation  s     F!!'**G	D 	D 	D 	D 	D	D 	D 	D 	D 	D	 	 	 	 	  CII	e	fr   c                 v    | j                             d          }|                     |t          j                  S )N   )r[   r   r   r   AlreadyDisabled)r   r2   s     r   #testSuperfluousDisableRequestRaisesz8TelnetTransportTests.testSuperfluousDisableRequestRaises'  s.    FKK  !!!V%;<<<r   c                     | j                             d          }d|j        _        | j                             d          }|                     |t          j                  S )Nr
  r   )r[   r   r   r   r   r   r   AlreadyEnabledr   s      r   "testSuperfluousEnableRequestRaisesz7TelnetTransportTests.testSuperfluousEnableRequestRaises,  sL    F!!'**FIIg!!!V%:;;;r   c                    | j                             d          }| j                             d          }| j                             d          } G d dt                    }| j                              |d                     |                     ||          }|                     ||          }|                     ||          }t          j        |||g          S )Nr      #   4c                       e Zd ZdS )LTelnetTransportTests.testLostConnectionFailsDeferreds.<locals>.TestExceptionN)rS   rT   rU   r   r   r   TestExceptionr  8  s        Dr   r  zTotal failure!)r[   r   	Exceptionr9   r   r   gatherResults)r   d1d2d3r  s        r    testLostConnectionFailsDeferredsz5TelnetTransportTests.testLostConnectionFailsDeferreds3  s    VYYwVYYwVYYw	 	 	 	 	I 	 	 	 	mm,<==>>>M22M22M22"BB<000r   N))rS   rT   rU   __doc__rc   rl   rt   rx   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  r  r  r   r   r   r^   r^   \   sf        & & &
. . .&
 
 
6L L L"@ @ @& & &' ' '' ' '& & &' ' '& & &' ' '& & && & && & &D D D0 0 0P P P6 $&" / / / /	- 	- 	-	- 	- 	-- - -
- 
- 
-; ; ;(; ; ;(
- 
- 
-- - -- - -&- - -&  $  8  8  $# # #J= = =
< < <1 1 1 1 1r   r^   c                   *    e Zd ZdZd Zd Zd Zd ZdS )
TestTelnetzP
    A trivial extension of the telnet protocol class useful to unit tests.
    c                 R    t           j                            |            g | _        d S r'   )r   Telnetr   eventsr   s    r   r   zTestTelnet.__init__H  s#    t$$$r   c                 >    | j                             d|f           dS )z:
        Record the given data in C{self.events}.
        bytesNr!  r(   r5   s     r   applicationDataReceivedz"TestTelnet.applicationDataReceivedL  s$     	GT?+++++r   c                 @    | j                             d||f           dS )z=
        Record the given command in C{self.events}.
        rM   Nr$  rQ   s      r   rO   zTestTelnet.unhandledCommandR  s'     	Iw566666r   c                 @    | j                             d||f           dS )zL
        Record the given subnegotiation command in C{self.events}.
        	negotiateNr$  rQ   s      r   rR   z"TestTelnet.unhandledSubnegotiationX  s'     	K$788888r   N)rS   rT   rU   r  r   r%  rO   rR   r   r   r   r  r  C  sZ           , , ,7 7 79 9 9 9 9r   r  c                   r    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d Zd Zd Zd Zd ZdS )TelnetTestsz
    Tests for L{telnet.Telnet}.

    L{telnet.Telnet} implements the TELNET protocol (RFC 854), including option
    and suboption negotiation, and option state tracking.
    c                 ,    t                      | _        dS )zM
        Create an unconnected L{telnet.Telnet} to be used by tests.
        N)r  re   r   s    r   rc   zTelnetTests.setUpg  s     #r   c                 `    |                      | j                            d                     dS )z
        L{telnet.Telnet.enableLocal} should reject all options, since
        L{telnet.Telnet} does not know how to implement any options.
            N)r   re   rA   r   s    r   test_enableLocalzTelnetTests.test_enableLocalm  s.    
 	22599:::::r   c                 `    |                      | j                            d                     dS )z
        L{telnet.Telnet.enableRemote} should reject all options, since
        L{telnet.Telnet} does not know how to implement any options.
        r-  N)r   re   rF   r   s    r   test_enableRemotezTelnetTests.test_enableRemotet  s.    
 	33E::;;;;;r   c                 R    |                      t          | j        j        d           dS )a	  
        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.
        r-  N)assertRaisesNotImplementedErrorre   rC   r   s    r   test_disableLocalzTelnetTests.test_disableLocal{  s(     	-t}/I5QQQQQr   c                 R    |                      t          | j        j        d           dS )a  
        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.
        r-  N)r2  r3  re   rH   r   s    r   test_disableRemotezTelnetTests.test_disableRemote  s(     	-t}/JERRRRRr   c                     t          j                    }| j                            |           | j                            dd           |                     |                                d           dS )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   ra   re   r3   requestNegotiationrf   r   r   r1   s     r   test_requestNegotiationz#TelnetTests.test_requestNegotiation  sr     "133	$$Y///((+>>>OO+	
 	
 	
 	
 	
r   c                     t          j                    }| j                            |           | j                            dd           |                     |                                d           dS )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.
        r8  rv   s   Nr9  r;  s     r   !test_requestNegotiationEscapesIACz-TelnetTests.test_requestNegotiationEscapesIAC  sg     "133	$$Y///((':::**,KLLLLLr   c                     g x}| j         _        | j                             |           |                     |t	          |                     dS )z
        Pass the given bytes to the protocol's C{dataReceived} method and
        assert that the given events occur.
        N)re   r!  r6   rf   r   )r   r   expectedreceiveds       r   _deliverzTelnetTests._deliver  sK    
 +-,4='""4(((4>>22222r   c                 2    |                      dd           dS )zc
        One application-data byte in the default state gets delivered right
        away.
           a)r#  rD  NrB  r   s    r   test_oneApplicationDataBytez'TelnetTests.test_oneApplicationDataByte  s    
 	dO,,,,,r   c                 2    |                      dd           dS )za
        Two application-data bytes in the default state get delivered
        together.
           bc)r#  rH  NrE  r   s    r   test_twoApplicationDataBytesz(TelnetTests.test_twoApplicationDataBytes  s    
 	e-.....r   c                 L    |                      dt          j        z   d           dS )z~
        Three application-data bytes followed by a control byte get
        delivered, but the control byte doesn't.
           def)r#  rK  NrB  r   rz   r   s    r   test_threeApplicationDataBytesz*TelnetTests.test_threeApplicationDataBytes  s&    
 	fvz)+<=====r   c                     |                      t          j                   |                      t          j        dz   dt          j        dz   f           dS )zy
        IAC in the escaped state gets delivered and so does another
        application-data byte following it.
           gr#  NrL  r   s    r   test_escapedControlzTelnetTests.test_escapedControl  sE    
 	fj!!!fj4''6:3D)EFFFFFr   c                 :   |                      d           |                      dd           |                      dd           |                      d           |                      dd           |                      dd           |                      d           |                      dd	           |                      d
d	           |                      d           |                      t          j        t          j        z   dz   ddt          j        z   dz   f           dS )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.
        rq   ro   )r#  ro   s   
r-  )r#  rq   s    rD  )r#     arR     xr#  NrL  r   s    r   test_carriageReturnzTelnetTests.test_carriageReturn  s    	ee-...g/000ee-...g/000ed-...f/000eJ#d*Wefj6H46O,P	
 	
 	
 	
 	
r   c                     |                      dt          j        z   t          j        z   ddt          j        df           dS )zt
        Application bytes received before a command are delivered before the
        command is processed.
        rS  )r#  rS  rM   N)rB  r   rz   r   r   s    r   'test_applicationDataBeforeSimpleCommandz3TelnetTests.test_applicationDataBeforeSimpleCommand  sD    
 	6:
*
D)	
 	
 	
 	
 	
r   c                     i | j         _        |                     dt          j        z   t          j        z   dz   ddt          j        df           dS )z~
        Application bytes received before a WILL/WONT/DO/DONT are delivered
        before the command is processed.
           yr-  )r#  rX  rM   N)re   r.   rB  r   rz   r   r   s    r   !test_applicationDataBeforeCommandz-TelnetTests.test_applicationDataBeforeCommand  sS    
 $& 6:+g5W-	
 	
 	
 	
 	
r   c                     |                      dt          j        z   t          j        z   dz   t          j        z   t          j        z   ddddgf           dS )z
        Application bytes received before a subnegotiation command are
        delivered before the negotiation is processed.
           zs   Qx)r#  r[  r(     QrS  N)rB  r   rz   r   r   r   s    r   (test_applicationDataBeforeSubnegotiationz4TelnetTests.test_applicationDataBeforeSubnegotiation  sW    
 	6:	)E1FJ>J$'	
 	
 	
 	
 	
r   N)rS   rT   rU   r  rc   r.  r0  r4  r6  r<  r>  rB  rF  rI  rM  rP  rT  rV  rY  r]  r   r   r   r*  r*  _  s        % % %; ; ;< < <R R RS S S
 
 
 
M 
M 
M3 3 3- - -/ / /> > >G G G
 
 
6	
 	
 	


 

 

	
 	
 	
 	
 	
r   r*  N)r  zope.interfacer   zope.interface.verifyr   twisted.conchr   twisted.internetr   twisted.python.compatr   twisted.testr   twisted.trialr	   rZ   r   TestCaserW   r^   r   r  r*  r   r   r   <module>rf     s  
 
 ' & & & & & . . . . . .             " " " " " " + + + + + + & & & & & & " " " " " " V#$$; ; ; ; ; ; ; %$;|0 0 0 0 0h' 0 0 0d1 d1 d1 d1 d18, d1 d1 d1N9 9 9 9 9 9 9 98k
 k
 k
 k
 k
(# k
 k
 k
 k
 k
r   