%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/internet/test/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/internet/test/__pycache__/test_newtls.cpython-312.pyc

�

Ϫ�f����dZddlmZddlmZmZddlmZddlm	Z	ddl
mZmZm
Z
mZddlmZ	ddlmZdd	lmZeZddlmZGd�d
ej0�ZGd�d�Zeej6�Gd�de��ZGd�deee�Ze�j?ejA��y
#e$rd
ZY��wxYw)z(
Tests for L{twisted.internet._newtls}.
�)�
interfaces)�ConnectableProtocol�runProtocolsWithReactor)�ReactorBuilder)�
TCPCreator)�ContextGeneratingMixin�
SSLCreator�StartTLSClientCreator�TLSMixin)�unittest)�_newtls)�tlsN)�implementerc��eZdZdZesdZd�Zy)�BypassTLSTestsz4
    Tests for the L{_newtls._BypassTLS} class.
    z<Couldn't import _newtls, perhaps pyOpenSSL is old or missingc����t��g�G��fd�d�}tj||��}|j�|j	��g�t�}|j|�|j	��|g�y)z�
        C{_BypassTLS.loseConnection} calls C{loseConnection} on the base
        class, while preserving any default argument in the base class'
        C{loseConnection} implementation.
        c���eZdZW�f�fd�	Zy)�DBypassTLSTests.test_loseConnectionPassThrough.<locals>.FakeTransportc�(���j|�y�N)�append)�self�	_connDone�results  ��C/usr/lib/python3/dist-packages/twisted/internet/test/test_newtls.py�loseConnectionzSBypassTLSTests.test_loseConnectionPassThrough.<locals>.FakeTransport.loseConnection4s����
�
�i�(�N)�__name__�
__module__�__qualname__r)�defaultrs��r�
FakeTransportr3s���/6�
)rr"N)�objectr
�
_BypassTLSr�assertEqual)rr"�bypass�
notDefaultr!rs    @@r�test_loseConnectionPassThroughz-BypassTLSTests.test_loseConnectionPassThrough*s}����(����	)�	)��#�#�M�=�?�C��	��������'��+��X�
����j�)�����'�:�!6�7rN)rrr �__doc__r
�skipr(�rrrr"s����M��8rrc�"�eZdZdZd�Zd�Zd�Zy)�FakeProducerz'
    A producer that does nothing.
    c��yrr+�rs r�pauseProducingzFakeProducer.pauseProducingH���rc��yrr+r/s r�resumeProducingzFakeProducer.resumeProducingKr1rc��yrr+r/s r�
stopProducingzFakeProducer.stopProducingNr1rN)rrr r)r0r3r5r+rrr-r-Cs���
�
�
rr-c��eZdZdZd�Zd�Zy)�ProducerProtocolzy
    Register a producer, unregister it, and verify the producer hooks up to
    innards of C{TLSMemoryBIOProtocol}.
    c� �||_||_yr)�producerr)rr9rs   r�__init__zProducerProtocol.__init__Ys�� ��
���rc�"�t|jjtj�std��|jj
|jd�|jj|jjjj�|jj�|jj|jjj�|jj�y)Nz#TLSMemoryBIOProtocol not hooked up.T)
�
isinstance�	transport�protocolr�BufferingTLSTransport�RuntimeError�registerProducerr9rr�	_producer�unregisterProducerrr/s r�handshakeCompletedz#ProducerProtocol.handshakeCompleted]s����$�.�.�1�1�3�3L�3L�M��D�E�E����'�'��
�
�t�<������4�>�>�2�2�<�<�F�F�G����)�)�+������4�>�>�2�2�<�<�=����%�%�'rN)rrr r)r:rDr+rrr7r7Rs���
�(rr7c�6�eZdZdZesdZd�Zd�Zd�Zd�Z	d�Z
y)	�ProducerTestsMixinzM
    Test the new TLS code integrates C{TLSMemoryBIOProtocol} correctly.
    z)Could not import twisted.internet._newtlsc��g}t�}t|t�t||�t	��|j||dg�y)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-rrr7r	r%�rrr9s   r�test_producerSSLFromStartz,ProducerTestsMixin.test_producerSSLFromStarttsG�����>�����!��X�v�.��L�		
�	
����(�D�!1�2rc��g}t�}t|t�t||�t	��|j||dg�y)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-rrr7r
r%rHs   r�test_producerAfterStartTLSz-ProducerTestsMixin.test_producerAfterStartTLS�sH�����>�����!��X�v�.�!�#�		
�	
����(�D�!1�2rc�������|j��|j��g�t��G����fd�dt�}G�fd�dt�}t	||�|�t��|j
���g�y)z�
        When a producer is registered, and then startTLS is called,
        the producer is re-registered with the C{TLSMemoryBIOProtocol}.
        c���eZdZ����fd�Zy)�MProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.RegisterTLSProtocolc���|jj���|jj���ri�j|jjj
j
��j|jjj
�n|�j|jjj
j
j
��j|jjj
j
�|jj�|jj�yr)	r=rA�startTLSrr>rBr9rCr)rr9r�
serverContext�	streamings ����r�connectionMadez\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����-�-�/rN�rrr rS)r9rrQrRs����r�RegisterTLSProtocolrN�s
���
0�
0rrUc���eZdZ�fd�Zy)�JProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.StartTLSProtocolc�<��|jj��yr)r=rP)r�
clientContexts �rrSzYProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.StartTLSProtocol.connectionMade�s������'�'�
�6rNrT)rYs�r�StartTLSProtocolrW�s���
7rrZN)�getClientContext�getServerContextr-rrrr%)rrRrUrZrYr9rrQs `  @@@@r�startTLSAfterRegisterProducerz0ProducerTestsMixin.startTLSAfterRegisterProducer�s����
�-�-�/�
��-�-�/�
����>��	0�	0�"5�	0�"	7�2�	7�	 ��%�'�)9�);�Z�\�	
�	
����(�H�!5�6rc�&�|jd�y)z�
        When a streaming producer is registered, and then startTLS is called,
        the producer is re-registered with the C{TLSMemoryBIOProtocol}.
        TN�r]r/s r�+test_startTLSAfterRegisterProducerStreamingz>ProducerTestsMixin.test_startTLSAfterRegisterProducerStreaming�s��
	
�*�*�4�0rc�&�|jd�y)z�
        When a non-streaming producer is registered, and then startTLS is
        called, the producer is re-registered with the
        C{TLSMemoryBIOProtocol}.
        FNr_r/s r�.test_startTLSAfterRegisterProducerNonStreamingzAProducerTestsMixin.test_startTLSAfterRegisterProducerNonStreaming�s��	
�*�*�5�1rN)rrr r)r
r*rIrKr]r`rbr+rrrFrFls+����:��3�"3�""7�H1�2rrF)!r)�twisted.internetr�&twisted.internet.test.connectionmixinsrr�#twisted.internet.test.reactormixinsr�twisted.internet.test.test_tcpr�twisted.internet.test.test_tlsrr	r
r�
twisted.trialrr
�__newtls�twisted.protocolsr�ImportError�zope.interfacer�TestCaserr-�IHandshakeListenerr7rF�globals�update�makeTestCaseClassesr+rr�<module>rrs����
(��?�5���#��4�%��G�&�8�X�&�&�8�B
�
�
�Z�
*�
*�+�(�*�(�,�(�2[2���3I�[2�|�	���#�7�7�9�:��_���G��s�B5�5B?�>B?

Zerion Mini Shell 1.0