HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/twisted/internet/test/__pycache__/test_newtls.cpython-38.pyc
U


W[%�@s"dZddlmZmZddlmZddlmZddlm	Z	ddl
mZmZddl
mZmZddl
mZdd	l
mZdd
lmZzddlmZddlmZWnek
r�d
ZYnXddlmZGdd�dej�ZGdd�de�Zeej�Gdd�de��ZGdd�de	ee�Z e!��"e �#��d
S)z(
Tests for L{twisted.internet._newtls}.
�)�division�absolute_import)�unittest)�
interfaces)�ReactorBuilder)�ConnectableProtocol�runProtocolsWithReactor)�
SSLCreator�TLSMixin)�StartTLSClientCreator)�ContextGeneratingMixin)�
TCPCreator)�tls)�_newtlsN)�implementerc@s eZdZdZesdZdd�ZdS)�BypassTLSTestsz4
    Tests for the L{_newtls._BypassTLS} class.
    z<Couldn't import _newtls, perhaps pyOpenSSL is old or missingcsht��g�G��fdd�dt�}t�||��}|��|���g�t�}|�|�|���|g�dS)z�
        C{_BypassTLS.loseConnection} calls C{loseConnection} on the base
        class, while preserving any default argument in the base class'
        C{loseConnection} implementation.
        cseZdZ�f�fdd�	ZdS)zDBypassTLSTests.test_loseConnectionPassThrough.<locals>.FakeTransportcs��|�dS�N)�append)�selfZ	_connDone)�result��C/usr/lib/python3/dist-packages/twisted/internet/test/test_newtls.py�loseConnection-szSBypassTLSTests.test_loseConnectionPassThrough.<locals>.FakeTransport.loseConnectionN)�__name__�
__module__�__qualname__rr��defaultrrr�
FakeTransport,srN)�objectrZ
_BypassTLSr�assertEqual)rrZbypassZ
notDefaultrrr�test_loseConnectionPassThrough#s
z-BypassTLSTests.test_loseConnectionPassThroughN)rrr�__doc__r�skipr!rrrrrsrc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�FakeProducerz'
    A producer that does nothing.
    cCsdSrr�rrrr�pauseProducingBszFakeProducer.pauseProducingcCsdSrrr%rrr�resumeProducingFszFakeProducer.resumeProducingcCsdSrrr%rrr�
stopProducingJszFakeProducer.stopProducingN)rrrr"r&r'r(rrrrr$=sr$c@s eZdZdZdd�Zdd�ZdS)�ProducerProtocolzy
    Register a producer, unregister it, and verify the producer hooks up to
    innards of C{TLSMemoryBIOProtocol}.
    cCs||_||_dSr)�producerr)rr*rrrr�__init__VszProducerProtocol.__init__cCsft|jjtj�std��|j�|jd�|j�	|jjj
j
�|j��|j�	|jjj
�|j��dS)Nz#TLSMemoryBIOProtocol not hooked up.T)
�
isinstance�	transport�protocolrZTLSMemoryBIOProtocol�RuntimeError�registerProducerr*rr�	_producer�unregisterProducerrr%rrr�handshakeCompleted[s�
z#ProducerProtocol.handshakeCompletedN)rrrr"r+r3rrrrr)Osr)c@s@eZdZdZesdZdd�Zdd�Zdd�Zd	d
�Z	dd�Z
d
S)�ProducerTestsMixinzM
    Test the new TLS code integrates C{TLSMemoryBIOProtocol} correctly.
    z)Could not import twisted.internet._newtlscCs6g}t�}t|t�t||�t��|�||dg�dS)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)r$rrr)r	r �rrr*rrr�test_producerSSLFromStartts�z,ProducerTestsMixin.test_producerSSLFromStartcCs6g}t�}t|t�t||�t��|�||dg�dS)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)r$rrr)rr r5rrr�test_producerAfterStartTLS�s�z-ProducerTestsMixin.test_producerAfterStartTLScsp|���|���g�t��G����fdd�dt�}G�fdd�dt�}t||�|�t��|����g�dS)z�
        When a producer is registered, and then startTLS is called,
        the producer is re-registered with the C{TLSMemoryBIOProtocol}.
        cseZdZ����fdd�ZdS)zMProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.RegisterTLSProtocolcs�|j����|j����rB��|jjjj���|jjj�n&��|jjjjj���|jjjj�|j��|j��dSr)	r-r0�startTLSrr.r1r*r2rr%�r*r�
serverContext�	streamingrr�connectionMade�s�
z\ProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.RegisterTLSProtocol.connectionMadeN�rrrr<rr9rr�RegisterTLSProtocol�sr>cseZdZ�fdd�ZdS)zJProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.StartTLSProtocolcs|j���dSr)r-r8r%��
clientContextrrr<�szYProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.StartTLSProtocol.connectionMadeNr=rr?rr�StartTLSProtocol�srAN)ZgetClientContextZgetServerContextr$rrr
r )rr;r>rAr)r@r*rr:r;r�startTLSAfterRegisterProducer�s�z0ProducerTestsMixin.startTLSAfterRegisterProducercCs|�d�dS)z�
        When a streaming producer is registered, and then startTLS is called,
        the producer is re-registered with the C{TLSMemoryBIOProtocol}.
        TN�rBr%rrr�+test_startTLSAfterRegisterProducerStreaming�sz>ProducerTestsMixin.test_startTLSAfterRegisterProducerStreamingcCs|�d�dS)z�
        When a non-streaming producer is registered, and then startTLS is
        called, the producer is re-registered with the
        C{TLSMemoryBIOProtocol}.
        FNrCr%rrr�.test_startTLSAfterRegisterProducerNonStreaming�szAProducerTestsMixin.test_startTLSAfterRegisterProducerNonStreamingN)rrrr"rr#r6r7rBrDrErrrrr4ls%r4)$r"Z
__future__rrZ
twisted.trialrZtwisted.internetrZ#twisted.internet.test.reactormixinsrZ&twisted.internet.test.connectionmixinsrrZtwisted.internet.test.test_tlsr	r
rrZtwisted.internet.test.test_tcpr
Ztwisted.protocolsrr�ImportErrorZzope.interfacerZTestCaserrr$ZIHandshakeListenerr)r4�globals�updateZmakeTestCaseClassesrrrr�<module>s*
"\