+
    Dfj                        R t ^ RIHt ^ RIHtHt ^ RIHt ^ RIH	t	 ^ RI
HtHtHtHt ^ RIHt  ^ RIHt ^ RIHt ]t^ R
IHt  ! R R]P0                  4      t ! R R4      t]! ]P6                  4       ! R R]4      4       t ! R R]]]4      t]! 4       P?                  ]PA                  4       4       R	#   ] d    R	t Li ; i)z(
Tests for L{twisted.internet._newtls}.
)
interfaces)ConnectableProtocolrunProtocolsWithReactor)ReactorBuilder)
TCPCreator)ContextGeneratingMixin
SSLCreatorStartTLSClientCreatorTLSMixin)unittest)_newtls)tlsN)implementerc                   >   a  ] tR t^"t o Rt]'       g   RtR tRtV t	R# )BypassTLSTestsz,
Tests for the L{_newtls._BypassTLS} class.
z<Couldn't import _newtls, perhaps pyOpenSSL is old or missingc                  aa \        4       o. o ! VV3R lR4      p\        P                  W! 4       4      pVP                  4        V P	                  SS.4       \        4       pVP                  V4       V P	                  SSV.4       R# )z
C{_BypassTLS.loseConnection} calls C{loseConnection} on the base
class, while preserving any default argument in the base class'
C{loseConnection} implementation.
c                   6   <a  ] tR t^3t o  Z3V3R lltRtV tR# )DBypassTLSTests.test_loseConnectionPassThrough.<locals>.FakeTransportc                *   < SP                  V4       R # N)append)self	_connDoneresults   &&C/usr/lib/python3/dist-packages/twisted/internet/test/test_newtls.pyloseConnectionSBypassTLSTests.test_loseConnectionPassThrough.<locals>.FakeTransport.loseConnection4   s    i(     N)__name__
__module____qualname____firstlineno__r   __static_attributes____classdictcell__)__classdict__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%   s   @r   r   r   "   s      M8 8r   r   c                   6   a  ] tR t^Ct o RtR tR tR tRtV t	R# )FakeProducerz
A producer that does nothing.
c                    R # r   r   r   s   &r   pauseProducingFakeProducer.pauseProducingH       r   c                    R # r   r   r5   s   &r   resumeProducingFakeProducer.resumeProducingK   r8   r   c                    R # r   r   r5   s   &r   stopProducingFakeProducer.stopProducingN   r8   r   r   N)
r   r    r!   r"   r/   r6   r:   r=   r#   r$   r1   s   @r   r3   r3   C   s      r   r3   c                   0   a  ] tR t^Rt o RtR tR tRtV tR# )ProducerProtocolzm
Register a producer, unregister it, and verify the producer hooks up to
innards of C{TLSMemoryBIOProtocol}.
c                    Wn         W n        R # r   producerr   )r   rC   r   s   &&&r   __init__ProducerProtocol.__init__Y   s     r   c                0   \        V P                  P                  \        P                  4      '       g   \        R 4      hV P                  P                  V P                  R4       V P                  P                  V P                  P                  P                  P                  4       V P                  P                  4        V P                  P                  V P                  P                  P                  4       V P                  P                  4        R# )z#TLSMemoryBIOProtocol not hooked up.TN)
isinstance	transportprotocolr   BufferingTLSTransportRuntimeErrorregisterProducerrC   r   r   	_producerunregisterProducerr   r5   s   &r   handshakeCompleted#ProducerProtocol.handshakeCompleted]   s    $..1133L3LMMDEE''t<4>>22<<FFG))+4>>22<<=%%'r   rB   N)	r   r    r!   r"   r/   rD   rO   r#   r$   r1   s   @r   r@   r@   R   s     
( (r   r@   c                   V   a  ] tR t^lt o Rt]'       g   RtR tR tR t	R t
R tRtV tR	# )
ProducerTestsMixinzE
Test the new TLS code integrates C{TLSMemoryBIOProtocol} correctly.
z)Could not import twisted.internet._newtlsc                    . p\        4       p\        V \        4       \        W!4      \	        4       4       V P                  WR.4       R# )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   r@   r   r*   r   r   rC   s   &  r   test_producerSSLFromStart,ProducerTestsMixin.test_producerSSLFromStartt   sC     >!X.L		
 	D!12r   c                    . p\        4       p\        V \        4       \        W!4      \	        4       4       V P                  WR.4       R# )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   r@   r	   r*   rT   s   &  r   test_producerAfterStartTLS-ProducerTestsMixin.test_producerAfterStartTLS   sD     >!X.!#		
 	D!12r   c                  aaaaa V P                  4       oV P                  4       o. o\        4       o ! VVVV3R lR\        4      p ! V3R lR\        4      p\	        W! 4       V! 4       \        4       4       V P                  SSS.4       R# )z}
When a producer is registered, and then startTLS is called,
the producer is re-registered with the C{TLSMemoryBIOProtocol}.
c                   4   <a  ] tR t^t o VVVV3R ltRtV tR# )MProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.RegisterTLSProtocolc                  < V P                   P                  SS4       V P                   P                  S4       S'       dj   SP                  V P                   P                  P
                  P
                  4       SP                  V P                   P                  P
                  4       M|SP                  V P                   P                  P
                  P
                  P
                  4       SP                  V P                   P                  P
                  P
                  4       V P                   P                  4        V P                   P                  4        R # r   )	rH   rL   startTLSr   rI   rM   rC   rN   r   )r   rC   r   serverContext	streamings   &r   connectionMade\ProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.RegisterTLSProtocol.connectionMade   s    //)D''6 MM$.."9"9"C"C"M"MNMM$.."9"9"C"CD MM$.."9"9"C"C"M"M"W"WXMM$.."9"9"C"C"M"MN113--/r   r   Nr   r    r!   r"   ra   r#   r$   )r%   rC   r   r_   r`   s   @r   RegisterTLSProtocolr\      s     0 0r   rd   c                   .   <a  ] tR t^t o V3R ltRtV tR# )JProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.StartTLSProtocolc                >   < V P                   P                  S4       R # r   )rH   r^   )r   clientContexts   &r   ra   YProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.StartTLSProtocol.connectionMade   s    ''6r   r   Nrc   )r%   rh   s   @r   StartTLSProtocolrf      s     7 7r   rj   N)getClientContextgetServerContextr3   r   r   r   r*   )r   r`   rd   rj   rh   rC   r   r_   s   &f  @@@@r   startTLSAfterRegisterProducer0ProducerTestsMixin.startTLSAfterRegisterProducer   s    
 --/--/>	0 	0"5 	0"	72 	7 	 %')9);Z\	
 	(H!56r   c                (    V P                  R4       R# )z
When a streaming producer is registered, and then startTLS is called,
the producer is re-registered with the C{TLSMemoryBIOProtocol}.
TNrm   r5   s   &r   +test_startTLSAfterRegisterProducerStreaming>ProducerTestsMixin.test_startTLSAfterRegisterProducerStreaming   s    
 	**40r   c                (    V P                  R4       R# )z
When a non-streaming producer is registered, and then startTLS is
called, the producer is re-registered with the
C{TLSMemoryBIOProtocol}.
FNrp   r5   s   &r   .test_startTLSAfterRegisterProducerNonStreamingAProducerTestsMixin.test_startTLSAfterRegisterProducerNonStreaming   s     	**51r   r   N)r   r    r!   r"   r/   r   r0   rU   rX   rm   rq   rt   r#   r$   r1   s   @r   rR   rR   l   s3      :3"3""7H12 2r   rR   )!r/   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   IHandshakeListenerr@   rR   globalsupdatemakeTestCaseClassesr   r   r   <module>r      s   
 ( ? 5  #4% G &8X&& 8B  Z**+(* ( ,(2[23I [2| 	  #779 :_  Gs   B6 6	CC