+
    üÐj¦  ã                   ó(  € R t ^ RIHtHtHtHt ^ RIHtHt ^ RI	H
t
 ^ RIHt ^ RIHt  ! R R]P                  4      t ! R R	]P"                  4      t ! R
 R]P&                  4      t ! R R]P                  4      t ! R R]P                  4      tR# )z+
Test cases for twisted.protocols package.
)ÚaddressÚdeferÚprotocolÚreactor)ÚportforwardÚwire)Ú	iterbytes)Úproto_helpers)Úunittestc                   ó<   a € ] tR t^t o RtR tR tR tR tRt	V t
R# )Ú	WireTestsz
Test wire protocols.
c                óf  € \         P                  ! 4       p\        P                  ! 4       pVP	                  V4       VP                  R4       VP                  R4       VP                  R4       VP                  R4       VP                  R4       V P                  VP                  4       R4       R# )zD
Test wire.Echo protocol: send some data and check it send it back.
ó   helloó   worldó   howó   areó   yous   helloworldhowareyouN)r	   ÚStringTransportr   ÚEchoÚmakeConnectionÚdataReceivedÚassertEqualÚvalue©ÚselfÚtÚas   &  Ú=/usr/lib/python3/dist-packages/twisted/test/test_protocols.pyÚ	test_echoÚWireTests.test_echo   s~   € ô ×)Ò)Ó+ˆÜ�IŠI‹KˆØ	×Ñ˜ÔØ	�‰�xÔ Ø	�‰�xÔ Ø	�‰�vÔØ	�‰�vÔØ	�‰�vÔØ×Ñ˜Ÿ™›Ð$:Ö;ó    c                ó¼   € \         P                  ! 4       p\        P                  ! 4       pVP	                  V4       V P                  VP                  4       R4       R# )z
Test wire.Who protocol.
s   root
N)r	   r   r   ÚWhor   r   r   r   s   &  r   Útest_whoÚWireTests.test_who"   sA   € ô ×)Ò)Ó+ˆÜ�HŠH‹JˆØ	×Ñ˜ÔØ×Ñ˜Ÿ™› KÖ0r    c                ó¼   € \         P                  ! 4       p\        P                  ! 4       pVP	                  V4       V P                  VP                  4       R4       R# )z
Test wire.QOTD protocol.
s'   An apple a day keeps the doctor away.
N)r	   r   r   ÚQOTDr   r   r   r   s   &  r   Ú	test_QOTDÚWireTests.test_QOTD+   sB   € ô ×)Ò)Ó+ˆÜ�IŠI‹KˆØ	×Ñ˜ÔØ×Ñ˜Ÿ™›Ð$PÖQr    c                óf  € \         P                  ! 4       p\        P                  ! 4       pVP	                  V4       VP                  R4       VP                  R4       VP                  R4       VP                  R4       VP                  R4       V P                  VP                  4       R4       R# )z
Test wire.Discard protocol.
r   r   r   r   r   r    N)r	   r   r   ÚDiscardr   r   r   r   r   s   &  r   Útest_discardÚWireTests.test_discard4   s}   € ô ×)Ò)Ó+ˆÜ�LŠL‹NˆØ	×Ñ˜ÔØ	�‰�xÔ Ø	�‰�xÔ Ø	�‰�vÔØ	�‰�vÔØ	�‰�vÔØ×Ñ˜Ÿ™› CÖ(r    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r#   r'   r+   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r   r      s$   ø‡ € ñò<ò1òR÷)ð )r    r   c                   ó*   a € ] tR t^Ct o RtR tRtV tR# )ÚTestableProxyClientFactoryz³
Test proxy client factory that keeps the last created protocol instance.

@ivar protoInstance: the last instance of the protocol.
@type protoInstance: L{portforward.ProxyClient}
c                óP   € \         P                  P                  W4      pW n        V# )z5
Create the protocol instance and keeps track of it.
)r   ÚProxyClientFactoryÚbuildProtocolÚprotoInstance©r   ÚaddrÚprotos   && r   r;   Ú(TestableProxyClientFactory.buildProtocolK   s%   € ô ×.Ñ.×<Ñ<¸TÓHˆØ"ÔØˆr    )r<   N©r.   r/   r0   r1   r2   r;   r3   r4   r5   s   @r   r8   r8   C   s   ø‡ € ñ÷ð r    r8   c                   ó*   a € ] tR t^Tt o RtR tRtV tR# )ÚTestableProxyFactoryaP  
Test proxy factory that keeps the last created protocol instance.

@ivar protoInstance: the last instance of the protocol.
@type protoInstance: L{portforward.ProxyServer}

@ivar clientFactoryInstance: client factory used by C{protoInstance} to
    create forward connections.
@type clientFactoryInstance: L{TestableProxyClientFactory}
c                óŠ   a € \         P                  P                  S V4      p\        4       S n        V 3R lVn        VS n        V# )zo
Create the protocol instance, keeps track of it, and makes it use
C{clientFactoryInstance} as client factory.
c                  ó   <€ S P                   # ©N)ÚclientFactoryInstance©r   s   €r   Ú<lambda>Ú4TestableProxyFactory.buildProtocol.<locals>.<lambda>h   s   ø€ ¨d×.HÒ.Hr    )r   ÚProxyFactoryr;   r8   rG   ÚclientProtocolFactoryr<   r=   s   f& r   r;   Ú"TestableProxyFactory.buildProtocol`   s=   ø€ ô
 ×(Ñ(×6Ñ6°t¸TÓBˆÜ%?Ó%AˆÔ"ä&HˆÔ#Ø"ˆÔØˆr    )rG   r<   NrA   r5   s   @r   rC   rC   T   s   ø‡ € ñ	÷
ð 
r    rC   c                   ó<   a € ] tR t^mt o RtR tR tR tR tRt	V t
R# )ÚPortforwardingTestsz
Test port forwarding.
c                ó|   € \         P                  ! 4       V n        \        P                  ! 4       V n        . V n        R # rF   )r   r   ÚserverProtocolr   ÚProtocolÚclientProtocolÚ	openPortsrH   s   &r   ÚsetUpÚPortforwardingTests.setUpr   s(   € Ü"Ÿiši›kˆÔÜ&×/Ò/Ó1ˆÔØˆŽr    c                ó˜  €  V P                   P                  P                  P                  4         V P                   P
                  P                  pVP                  P                  4         V P                  P                  P                  4         V P                  P                  P                  4        \        P                  ! V P                   Uu. uF#  p\        P                  ! VP                  4      NK%  	  up4      #   \         d     Lài ; i  \         d     L¶i ; i  \         d     L¢i ; i  \         d     LŽi ; iu upi rF   )ÚproxyServerFactoryr<   Ú	transportÚloseConnectionÚAttributeErrorrG   rS   rQ   r   ÚgatherResultsrT   ÚmaybeDeferredÚstopListening)r   ÚpiÚps   &  r   ÚtearDownÚPortforwardingTests.tearDownw   s  € ð	Ø×#Ñ#×1Ñ1×;Ñ;×JÑJÔLð	Ø×(Ñ(×>Ñ>×LÑLˆBØ�L‰L×'Ñ'Ô)ð	Ø×Ñ×)Ñ)×8Ñ8Ô:ð	Ø×Ñ×)Ñ)×8Ñ8Ô:ô ×"Ò"Ø;?¿>º>ÓJ¹>°aŒU× Ò  §¡Ö1¹>ÑJó
ð 	
øô ô 	Ùð	ûô
 ô 	Ùð	ûô ô 	Ùð	ûô ô 	Ùð	üò KsL   ‚.D ±:D Á,$D% Â$D6 Ã)EÄDÄDÄD"Ä!D"Ä%D3Ä2D3Ä6EÅEc                óº  a aaa	€ \         P                  ! 4       pV 3R lVn         \        P                  ! ^ VRR7      pS P                  P                  V4       \        RVP                  4       P                  4      S n	        \        P                  ! ^ S P                  RR7      pS P                  P                  V4       Ro. o	\        P                  ! 4       oVVV	V 3R lpVS P                  n        VV 3R lpVS P                  n        \         P                  ! 4       pV 3R lVn         \        P                   ! RVP                  4       P                  V4       S# )z-
Test port forwarding through Echo protocol.
c                  ó   <€ S P                   # rF   )rQ   rH   s   €r   rI   Ú6PortforwardingTests.test_portforward.<locals>.<lambda>’   s   ø€ ¨T×-@Ò-@r    ú	127.0.0.1)Ú	interfaceiè  c                 óÒ   <€ SP                  \        V 4      4       \        S4      S8¼  d<   SP                  R P	                  S4      RS,          4       SP                  R4       R# R# )r    ó   xN)Úextendr   Úlenr   ÚjoinÚcallback)ÚdataÚdÚnBytesÚreceivedr   s   &€€€€r   ÚtestDataReceivedÚ>PortforwardingTests.test_portforward.<locals>.testDataReceived¡   sM   ø€ Ø�O‰OœI d›OÔ,Ü�8‹} Ô&Ø× Ñ  §¡¨(Ó!3°T¸Fµ]ÔCØ—
‘
˜4Ö ñ 'r    c                  ó`   <€ SP                   P                  P                  R S ,          4       R# )ri   N)rS   rY   Úwrite)rp   r   s   €€r   ÚtestConnectionMadeÚ@PortforwardingTests.test_portforward.<locals>.testConnectionMade©   s!   ø€ Ø×Ñ×)Ñ)×/Ñ/°°vµÖ>r    c                  ó   <€ S P                   # rF   )rS   rH   s   €r   rI   re   ¯   s   ø€ ¨×)<Ò)<r    )r   ÚServerFactoryr   Ú	listenTCPrT   ÚappendrC   ÚgetHostÚportrX   r   ÚDeferredrS   r   ÚconnectionMadeÚClientFactoryÚ
connectTCP)
r   ÚrealServerFactoryÚrealServerPortÚproxyServerPortrr   rv   ÚclientFactoryro   rp   rq   s
   f      @@@r   Útest_portforwardÚ$PortforwardingTests.test_portforward�   s  û€ ô %×2Ò2Ó4ÐÜ%@ÐÔ"Ü ×*Ò*¨1Ð.?È;ÔWˆØ�‰×Ñ˜nÔ-Ü"6Ø˜×/Ñ/Ó1×6Ñ6ó#
ˆÔô "×+Ò+Øˆt×&Ñ&°+ô
ˆð 	�‰×Ñ˜oÔ.àˆØˆÜ�NŠNÓˆ÷	!ð 	!ð ,<ˆ×ÑÔ(ö	?ð .@ˆ×ÑÔ*ä ×.Ò.Ó0ˆÜ!<ˆÔä×Ò˜;¨×(?Ñ(?Ó(A×(FÑ(FÈÔVàˆr    c                ó  € \         P                  ! RR^ 4      p\        P                  ! R^ 4      P	                  V4      p\
        P                  ! 4       pW2n        \
        P                  ! 4       pVP                  V4       V P                  \        VP                  4      ^4       VP                  ^ ,          w  rVrxp	V P                  V\        P                  4       VP	                  V4      p
\
        P                  ! 4       pV
P                  V4       V P                  VP                   V4       V P                  VP                   V4       V P#                  VP$                  4       V P#                  VP$                  4       R# )zU
The proxy client registers itself as a producer of the proxy server and
vice versa.
ÚTCPrf   N)r   ÚIPv4Addressr   rK   r;   r	   ÚMemoryReactorr   r   r   r   rk   Ú
tcpClientsÚassertIsInstancer:   ÚassertIsÚproducerÚ
assertTrueÚ	streaming)r   r>   Úserverr   ÚserverTransportÚhostr}   r…   ÚtimeoutÚ_ÚclientÚclientTransports   &           r   Útest_registerProducersÚ*PortforwardingTests.test_registerProducersµ   s.  € ô ×"Ò" 5¨+°qÓ9ˆÜ×)Ò)¨+°qÓ9×GÑGÈÓMˆô  ×-Ò-Ó/ˆØ Œô (×7Ò7Ó9ˆØ×Ñ˜oÔ.ð 	×Ñœ˜W×/Ñ/Ó0°!Ô4à07×0BÑ0BÀ1Õ0EÑ-ˆ�M¨AØ×Ñ˜m¬[×-KÑ-KÔLð ×,Ñ,¨TÓ2ˆÜ'×7Ò7Ó9ˆØ×Ñ˜oÔ.ð 	�‰�o×.Ñ.°Ô@Ø�‰�o×.Ñ.°Ô@à�‰˜×1Ñ1Ô2Ø�‰˜×1Ñ1Ö2r    )rS   rT   rX   rQ   N)r.   r/   r0   r1   r2   rU   ra   r†   r™   r3   r4   r5   s   @r   rO   rO   m   s$   ø‡ € ñòò

ò,&÷P!3ð !3r    rO   c                   ó*   a € ] tR t^Ùt o RtR tRtV tR# )ÚStringTransportTestsz9
Test L{proto_helpers.StringTransport} helper behaviour.
c                ór   € \         P                  ! 4       pV P                  \        VP                  R4       R# )zI
Test that L{proto_helpers.StringTransport} doesn't accept unicode data.
ÚfooN)r	   r   ÚassertRaisesÚ	TypeErrorru   )r   Úss   & r   Útest_noUnicodeÚ#StringTransportTests.test_noUnicodeÞ   s(   € ô ×)Ò)Ó+ˆØ×Ñœ) Q§W¡W¨eÖ4r    r-   N)r.   r/   r0   r1   r2   r¢   r3   r4   r5   s   @r   rœ   rœ   Ù   s   ø‡ € ñ÷5ð 5r    rœ   N)r2   Útwisted.internetr   r   r   r   Útwisted.protocolsr   r   Útwisted.python.compatr   Útwisted.testr	   Útwisted.trialr
   ÚTestCaser   r:   r8   rK   rC   rO   rœ   r-   r    r   Ú<module>rª      s|   ðñ÷ ?Ó >ß /Ý +Ý &Ý "ô1)�×!Ñ!ô 1)ôh ×!?Ñ!?ô ô"˜;×3Ñ3ô ô2i3˜(×+Ñ+ô i3ôX
5˜8×,Ñ,ö 
5r    