ó
    Ö›‘h…  ã                   ó†  • S r SSKJr  SSKJrJr  SSKJr  SSKJ	r	  SSK
JrJrJrJr  SSKJr   SSKJr  SS	KJr  \rSSKJr   " S S\R0                  5      r " S S5      r\" \R6                  5       " S S\5      5       r " S S\\\5      r\" 5       R?                  \RA                  5       5        g
! \ a    S
r N�f = f)z(
Tests for L{twisted.internet._newtls}.
é    )Ú
interfaces)ÚConnectableProtocolÚrunProtocolsWithReactor)ÚReactorBuilder)Ú
TCPCreator)ÚContextGeneratingMixinÚ
SSLCreatorÚStartTLSClientCreatorÚTLSMixin)Úunittest)Ú_newtls)ÚtlsN)Úimplementerc                   ó0   • \ rS rSrSr\(       d  SrS rSrg)ÚBypassTLSTestsé"   z,
Tests for the L{_newtls._BypassTLS} class.
z<Couldn't import _newtls, perhaps pyOpenSSL is old or missingc                 ó  ^^• [        5       m/ m " UU4S jS5      n[        R                  X" 5       5      nUR                  5         U R	                  TT/5        [        5       nUR                  U5        U R	                  TTU/5        g)z¤
C{_BypassTLS.loseConnection} calls C{loseConnection} on the base
class, while preserving any default argument in the base class'
C{loseConnection} implementation.
c                   ó*   >• \ rS rSr Y 4U4S jjrSrg)ÚDBypassTLSTests.test_loseConnectionPassThrough.<locals>.FakeTransporté3   c                 ó(   >• TR                  U5        g ©N)Úappend)ÚselfÚ	_connDoneÚresults     €ÚeC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/internet/test/test_newtls.pyÚloseConnectionÚSBypassTLSTests.test_loseConnectionPassThrough.<locals>.FakeTransport.loseConnection4   s   ø€ Ø—‘˜iÕ(ó    © N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__r   Ú__static_attributes__)Údefaultr   s   €€r   ÚFakeTransportr   3   s   ø† Ù/6÷ )ò )r    r(   N)Úobjectr   Ú
_BypassTLSr   ÚassertEqual)r   r(   ÚbypassÚ
notDefaultr'   r   s       @@r   Útest_loseConnectionPassThroughÚ-BypassTLSTests.test_loseConnectionPassThrough*   s}   ù€ ô “(ˆØˆ÷	)õ 	)ô ×#Ñ# M°=³?ÓCˆð 	×ÑÔØ×Ñ˜ ' Ô+ô “Xˆ
Ø×Ñ˜jÔ)Ø×Ñ˜ '¨:Ð!6Õ7r    r!   N)	r"   r#   r$   r%   Ú__doc__r   Úskipr.   r&   r!   r    r   r   r   "   s   † ñö ØMˆõ8r    r   c                   ó*   • \ rS rSrSrS rS rS rSrg)ÚFakeProduceréC   z
A producer that does nothing.
c                 ó   • g r   r!   ©r   s    r   ÚpauseProducingÚFakeProducer.pauseProducingH   ó   € Ør    c                 ó   • g r   r!   r6   s    r   ÚresumeProducingÚFakeProducer.resumeProducingK   r9   r    c                 ó   • g r   r!   r6   s    r   ÚstopProducingÚFakeProducer.stopProducingN   r9   r    r!   N)	r"   r#   r$   r%   r0   r7   r;   r>   r&   r!   r    r   r3   r3   C   s   † ñòòõr    r3   c                   ó$   • \ rS rSrSrS rS rSrg)ÚProducerProtocoléR   zm
Register a producer, unregister it, and verify the producer hooks up to
innards of C{TLSMemoryBIOProtocol}.
c                 ó   • Xl         X l        g r   ©Úproducerr   )r   rE   r   s      r   Ú__init__ÚProducerProtocol.__init__Y   s   € Ø ŒØ�r    c                 ó,  • [        U R                  R                  [        R                  5      (       d  [        S5      eU R                  R                  U R                  S5        U R                  R                  U R                  R                  R                  R                  5        U R                  R                  5         U R                  R                  U R                  R                  R                  5        U R                  R                  5         g )Nz#TLSMemoryBIOProtocol not hooked up.T)Ú
isinstanceÚ	transportÚprotocolr   ÚBufferingTLSTransportÚRuntimeErrorÚregisterProducerrE   r   r   Ú	_producerÚunregisterProducerr   r6   s    r   ÚhandshakeCompletedÚ#ProducerProtocol.handshakeCompleted]   s­   € Ü˜$Ÿ.™.×1Ñ1´3×3LÑ3L×MÑMäÐDÓEÐEà�‰×'Ñ'¨¯©°tÔ<à�‰×Ñ˜4Ÿ>™>×2Ñ2×<Ñ<×FÑFÔGà�‰×)Ñ)Ô+à�‰×Ñ˜4Ÿ>™>×2Ñ2×<Ñ<Ô=Ø�‰×%Ñ%Õ'r    rD   N)r"   r#   r$   r%   r0   rF   rQ   r&   r!   r    r   rA   rA   R   s   † ñò
õ(r    rA   c                   óH   • \ rS rSrSr\(       d  SrS rS rS r	S r
S rS	rg
)ÚProducerTestsMixinél   zE
Test the new TLS code integrates C{TLSMemoryBIOProtocol} correctly.
z)Could not import twisted.internet._newtlsc                 ó�   • / n[        5       n[        U [        5       [        X!5      [	        5       5        U R                  XS/5        g)z²
C{registerProducer} and C{unregisterProducer} on TLS transports
created as SSL from the get go are passed to the
C{TLSMemoryBIOProtocol}, not the underlying transport directly.
N)r3   r   r   rA   r	   r+   ©r   r   rE   s      r   Útest_producerSSLFromStartÚ,ProducerTestsMixin.test_producerSSLFromStartt   sC   € ð ˆÜ“>ˆäØÜÓ!Ü˜XÓ.Ü‹Lô		
ð 	×Ñ˜¨DÐ!1Õ2r    c                 ó�   • / n[        5       n[        U [        5       [        X!5      [	        5       5        U R                  XS/5        g)zª
C{registerProducer} and C{unregisterProducer} on TLS transports
created by C{startTLS} are passed to the C{TLSMemoryBIOProtocol}, not
the underlying transport directly.
N)r3   r   r   rA   r
   r+   rW   s      r   Útest_producerAfterStartTLSÚ-ProducerTestsMixin.test_producerAfterStartTLS…   sD   € ð ˆÜ“>ˆäØÜÓ!Ü˜XÓ.Ü!Ó#ô		
ð 	×Ñ˜¨DÐ!1Õ2r    c                 ó  ^^^^^• U R                  5       mU R                  5       m/ m[        5       m " UUUU4S jS[        5      n " U4S jS[        5      n[	        X" 5       U" 5       [        5       5        U R                  TTT/5        g)z}
When a producer is registered, and then startTLS is called,
the producer is re-registered with the C{TLSMemoryBIOProtocol}.
c                   ó(   >• \ rS rSrU UUU4S jrSrg)ÚMProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.RegisterTLSProtocolé    c                 ó´  >• U R                   R                  TT5        U R                   R                  T5        T(       ai  TR                  U R                   R                  R
                  R
                  5        TR                  U R                   R                  R
                  5        O|TR                  U R                   R                  R
                  R
                  R
                  5        TR                  U R                   R                  R
                  R
                  5        U R                   R                  5         U R                   R                  5         g r   )	rJ   rN   ÚstartTLSr   rK   rO   rE   rP   r   )r   rE   r   ÚserverContextÚ	streamings    €€€€r   ÚconnectionMadeÚ\ProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.RegisterTLSProtocol.connectionMade¡   sØ   ø€ Ø—‘×/Ñ/°¸)ÔDØ—‘×'Ñ'¨Ô6ö à—M‘M $§.¡.×"9Ñ"9×"CÑ"C×"MÑ"MÔNØ—M‘M $§.¡.×"9Ñ"9×"CÑ"CÕDð —M‘M $§.¡.×"9Ñ"9×"CÑ"C×"MÑ"M×"WÑ"WÔXØ—M‘M $§.¡.×"9Ñ"9×"CÑ"C×"MÑ"MÔNØ—‘×1Ñ1Ô3Ø—‘×-Ñ-Õ/r    r!   N©r"   r#   r$   r%   re   r&   )rE   r   rc   rd   s   €€€€r   ÚRegisterTLSProtocolr_       s   ø† ÷0ó 0r    rh   c                   ó"   >• \ rS rSrU 4S jrSrg)ÚJProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.StartTLSProtocolé±   c                 ó<   >• U R                   R                  T5        g r   )rJ   rb   )r   ÚclientContexts    €r   re   ÚYProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.StartTLSProtocol.connectionMade²   s   ø€ Ø—‘×'Ñ'¨Õ6r    r!   Nrg   )rm   s   €r   ÚStartTLSProtocolrj   ±   s   ø† ÷7ð 7r    ro   N)ÚgetClientContextÚgetServerContextr3   r   r   r   r+   )r   rd   rh   ro   rm   rE   r   rc   s    `  @@@@r   ÚstartTLSAfterRegisterProducerÚ0ProducerTestsMixin.startTLSAfterRegisterProducer–   s€   ü€ ð
 ×-Ñ-Ó/ˆØ×-Ñ-Ó/ˆØˆÜ“>ˆ÷	0ò 	0Ô"5ô 	0÷"	7Ô2ô 	7ô 	 ØÐ%Ó'Ñ)9Ó);¼Z»\ô	
ð 	×Ñ˜ (¨HÐ!5Õ6r    c                 ó&   • U R                  S5        g)z‡
When a streaming producer is registered, and then startTLS is called,
the producer is re-registered with the C{TLSMemoryBIOProtocol}.
TN©rr   r6   s    r   Ú+test_startTLSAfterRegisterProducerStreamingÚ>ProducerTestsMixin.test_startTLSAfterRegisterProducerStreamingº   s   € ð
 	×*Ñ*¨4Õ0r    c                 ó&   • U R                  S5        g)z‹
When a non-streaming producer is registered, and then startTLS is
called, the producer is re-registered with the
C{TLSMemoryBIOProtocol}.
FNru   r6   s    r   Ú.test_startTLSAfterRegisterProducerNonStreamingÚAProducerTestsMixin.test_startTLSAfterRegisterProducerNonStreamingÁ   s   € ð 	×*Ñ*¨5Õ1r    r!   N)r"   r#   r$   r%   r0   r   r1   rX   r[   rr   rv   ry   r&   r!   r    r   rT   rT   l   s+   † ñö Ø:ˆò3ò"3ò""7òH1õ2r    rT   )!r0   Útwisted.internetr   Ú&twisted.internet.test.connectionmixinsr   r   Ú#twisted.internet.test.reactormixinsr   Útwisted.internet.test.test_tcpr   Útwisted.internet.test.test_tlsr   r	   r
   r   Útwisted.trialr   r   Ú__newtlsÚtwisted.protocolsr   ÚImportErrorÚzope.interfacer   ÚTestCaser   r3   ÚIHandshakeListenerrA   rT   ÚglobalsÚupdateÚmakeTestCaseClassesr!   r    r   Ú<module>rŠ      sË   ðñõ
 (÷õ ?Ý 5÷ó õ #ðÝ4Ý%ð €GÝ &ô8�X×&Ñ&ô 8÷Bñ ñ ˆZ×*Ñ*Ó+ô(Ð*ó (ó ,ð(ô2[2˜¨Ð3Iô [2ñ| ƒ	× Ñ Ð#×7Ñ7Ó9Õ :øð_ ó Ø‚Gðús   °B5 Â5C Â?C 