ó
    ×›‘h¦  ã                   ó&  • S r SSKJrJrJrJr  SSKJrJr  SSK	J
r
  SSKJr  SSKJr   " S S\R                  5      r " S	 S
\R"                  5      r " S S\R&                  5      r " S S\R                  5      r " S S\R                  5      rg)z+
Test cases for twisted.protocols package.
é    )ÚaddressÚdeferÚprotocolÚreactor)ÚportforwardÚwire)Ú	iterbytes)Úproto_helpers)Úunittestc                   ó0   • \ rS rSrSrS rS rS rS rSr	g)	Ú	WireTestsé   z
Test wire protocols.
c                 ód  • [         R                  " 5       n[        R                  " 5       nUR	                  U5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        U R                  UR                  5       S5        g)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      Ú_C:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/test/test_protocols.pyÚ	test_echoÚWireTests.test_echo   s~   € ô ×)Ò)Ó+ˆÜ�IŠI‹KˆØ	×Ñ˜ÔØ	�‰�xÔ Ø	�‰�xÔ Ø	�‰�vÔØ	�‰�vÔØ	�‰�vÔØ×Ñ˜Ÿ™›Ð$:Õ;ó    c                 óº   • [         R                  " 5       n[        R                  " 5       nUR	                  U5        U R                  UR                  5       S5        g)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                 óº   • [         R                  " 5       n[        R                  " 5       nUR	                  U5        U R                  UR                  5       S5        g)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                 ód  • [         R                  " 5       n[        R                  " 5       nUR	                  U5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        UR                  S5        U R                  UR                  5       S5        g)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__r/   r"   r   r   r      s   † ñò<ò1òRõ)r"   r   c                   ó   • \ rS rSrSrS rSrg)ÚTestableProxyClientFactoryéC   z³
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   • [         R                  R                  X5      nX l        U$ )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©r0   r1   r2   r3   r4   r;   r5   r/   r"   r   r7   r7   C   s   † ñõr"   r7   c                   ó   • \ rS rSrSrS rSrg)ÚTestableProxyFactoryéT   aP  
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                 óŠ   ^ • [         R                  R                  T U5      n[        5       T l        U 4S jUl        UT l        U$ )zo
Create the protocol instance, keeps track of it, and makes it use
C{clientFactoryInstance} as client factory.
c                  ó   >• T R                   $ ©N)ÚclientFactoryInstance©r   s   €r   Ú<lambda>Ú4TestableProxyFactory.buildProtocol.<locals>.<lambda>h   s   ø€ ¨d×.HÒ.Hr"   )r   ÚProxyFactoryr;   r7   rH   ÚclientProtocolFactoryr<   r=   s   `  r   r;   Ú"TestableProxyFactory.buildProtocol`   s=   ø€ ô
 ×(Ñ(×6Ñ6°t¸TÓBˆÜ%?Ó%AˆÔ"ä&HˆÔ#Ø"ˆÔØˆr"   )rH   r<   NrA   r/   r"   r   rC   rC   T   s   † ñ	õ
r"   rC   c                   ó0   • \ rS rSrSrS rS rS rS rSr	g)	ÚPortforwardingTestsém   z
Test port forwarding.
c                 óz   • [         R                  " 5       U l        [        R                  " 5       U l        / U l        g rG   )r   r   ÚserverProtocolr   ÚProtocolÚclientProtocolÚ	openPortsrI   s    r   ÚsetUpÚPortforwardingTests.setUpr   s(   € Ü"Ÿiši›kˆÔÜ&×/Ò/Ó1ˆÔØˆ�r"   c                 ó’  •  U R                   R                  R                  R                  5          U R                   R
                  R                  nUR                  R                  5          U R                  R                  R                  5          U R                  R                  R                  5         [        R                  " U R                   Vs/ s H#  n[        R                  " UR                  5      PM%     sn5      $ ! [         a     Nàf = f! [         a     Nµf = f! [         a     N f = f! [         a     N‹f = fs  snf rG   )ÚproxyServerFactoryr<   Ú	transportÚloseConnectionÚAttributeErrorrH   rU   rS   r   ÚgatherResultsrV   Ú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$ Â$D4 Ã*EÄ
DÄDÄ
D!Ä D!Ä$
D1Ä0D1Ä4
EÅ Ec                 ó®  ^ ^^^	• [         R                  " 5       nU 4S jUl         [        R                  " SUSS9nT R                  R                  U5        [        SUR                  5       R                  5      T l	        [        R                  " ST R                  SS9nT R                  R                  U5        Sm/ m	[        R                  " 5       mUUU	U 4S jnUT R                  l        UU 4S jnUT R                  l        [         R                  " 5       nU 4S jUl         [        R                   " SUR                  5       R                  U5        T$ )	z-
Test port forwarding through Echo protocol.
c                  ó   >• T R                   $ rG   )rS   rI   s   €r   rJ   Ú6PortforwardingTests.test_portforward.<locals>.<lambda>’   s   ø€ ¨T×-@Ò-@r"   r   ú	127.0.0.1)Ú	interfaceiè  c                 óÄ   >• TR                  [        U 5      5        [        T5      T:¼  a6  TR                  SR	                  T5      ST-  5        TR                  S 5        g g )Nr"   ó   x)Ú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                  óV   >• TR                   R                  R                  ST -  5        g )Nrk   )rU   r[   Úwrite)rr   r   s   €€r   ÚtestConnectionMadeÚ@PortforwardingTests.test_portforward.<locals>.testConnectionMade©   s!   ø€ Ø×Ñ×)Ñ)×/Ñ/°°v±Õ>r"   c                  ó   >• T R                   $ rG   )rU   rI   s   €r   rJ   rg   ¯   s   ø€ ¨×)<Ò)<r"   )r   ÚServerFactoryr   Ú	listenTCPrV   ÚappendrC   ÚgetHostÚportrZ   r   ÚDeferredrU   r   ÚconnectionMadeÚClientFactoryÚ
connectTCP)
r   ÚrealServerFactoryÚrealServerPortÚproxyServerPortrt   rx   ÚclientFactoryrq   rr   rs   s
   `      @@@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                 óü  • [         R                  " SSS5      n[        R                  " SS5      R	                  U5      n[
        R                  " 5       nX2l        [
        R                  " 5       nUR                  U5        U R                  [        UR                  5      S5        UR                  S   u  pVpxn	U R                  U[        R                  5        UR	                  U5      n
[
        R                  " 5       nU
R                  U5        U R                  UR                   U5        U R                  UR                   U5        U R#                  UR$                  5        U R#                  UR$                  5        g)zU
The proxy client registers itself as a producer of the proxy server and
vice versa.
ÚTCPrh   r   é   N)r   ÚIPv4Addressr   rL   r;   r
   ÚMemoryReactorr   r   r   r   rm   Ú
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"   )rU   rV   rZ   rS   N)
r0   r1   r2   r3   r4   rW   rc   rˆ   rœ   r5   r/   r"   r   rP   rP   m   s   † ñòò

ò,&õP!3r"   rP   c                   ó   • \ rS rSrSrS rSrg)ÚStringTransportTestséÙ   z9
Test L{proto_helpers.StringTransport} helper behaviour.
c                 óp   • [         R                  " 5       nU R                  [        UR                  S5        g)zI
Test that L{proto_helpers.StringTransport} doesn't accept unicode data.
ÚfooN)r
   r   ÚassertRaisesÚ	TypeErrorrw   )r   Úss     r   Útest_noUnicodeÚ#StringTransportTests.test_noUnicodeÞ   s(   € ô ×)Ò)Ó+ˆØ×Ñœ) Q§W¡W¨eÕ4r"   r/   N)r0   r1   r2   r3   r4   r¦   r5   r/   r"   r   rŸ   rŸ   Ù   s   † ñõ5r"   rŸ   N)r4   Útwisted.internetr   r   r   r   Útwisted.protocolsr   r   Útwisted.python.compatr	   Útwisted.testr
   Útwisted.trialr   ÚTestCaser   r:   r7   rL   rC   rP   rŸ   r/   r"   r   Ú<module>r®      s|   ðñ÷ ?Ó >ß /Ý +Ý &Ý "ô1)�×!Ñ!ô 1)ôh ×!?Ñ!?ô ô"˜;×3Ñ3ô ô2i3˜(×+Ñ+ô i3ôX
5˜8×,Ñ,õ 
5r"   