%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f�Z���dZddlZddlZddlmZmZmZmZddlm	Z	ddl
mZddlm
Z
ddlmZddlmZdd	lmZdd
lmZ	ddlmamZddlmadd
lmZmZddlm Z Gd�de
jB�Z"Gd�de
jB�Z#Gd�dejH�Z%Gd�dejH�Z&e ejN�Gd�dejH��Z(d�Z)d�Z*Gd�d�Z+t.�Gd�dt2jX�Z-Gd �d!ee�Z.Gd"�d#e�Z/Gd$�d%e/�Z0Gd&�d'e�Z1Gd(�d)ee+�Z2Gd*�d+�Z3Gd,�d-e�Z4Gd.�d/e�Z5y#e$rd�Ze�Y��wxYw)0z 
Tests for twisted SSL support.
�N)�defer�
interfaces�protocol�reactor)�ConnectionDone)�waitUntilAllDisconnected)�basic)�FilePath)�platform)�ProperlyCloseFilesMixin)�TestCase)�SSL�crypto)�ssl)�ClientTLSContext�certPathc��dxaay�N)rr���7/usr/lib/python3/dist-packages/twisted/test/test_ssl.py�_noSSLrs�����cr)�implementerc�8�eZdZdZgd�ZddgZd�Zd�Zd�Zd�Z	y	)
�UnintelligentProtocola
    @ivar deferred: a deferred that will fire at connection lost.
    @type deferred: L{defer.Deferred}

    @cvar pretext: text sent before TLS is set up.
    @type pretext: C{bytes}

    @cvar posttext: text sent after TLS is set up.
    @type posttext: C{bytes}
    )s
first lineslast thing before tls starts�STARTTLSsfirst thing after tls startedslast thing everc�6�tj�|_yr�r�Deferred�deferred��selfs r�__init__zUnintelligentProtocol.__init__7������(��
rc�H�|jD]}|j|��yr)�pretext�sendLine)r"�ls  r�connectionMadez$UnintelligentProtocol.connectionMade:s!�����	�A��M�M�!��	rc��|dk(ru|jjt�|jj�|j
D]}|j
|��|jj�yy)N�READY)�	transport�startTLSr�factory�client�posttextr'�loseConnection)r"�liner(s   r�lineReceivedz"UnintelligentProtocol.lineReceived>s`���8���N�N�#�#�$4�$6����8K�8K�L��]�]�
!���
�
�a� �
!��N�N�)�)�+�	rc�:�|jjd�yr�r �callback�r"�reasons  r�connectionLostz$UnintelligentProtocol.connectionLostE����
�
���t�$rN)
�__name__�
__module__�__qualname__�__doc__r&r0r#r)r3r9rrrrr's.��	�L�G�0�2D�E�H�)��,�%rrc�0�eZdZdZdd�Zd�Zd�Zd�Zd�Zy)	�
LineCollectoraJ
    @ivar deferred: a deferred that will fire at connection lost.
    @type deferred: L{defer.Deferred}

    @ivar doTLS: whether the protocol is initiate TLS or not.
    @type doTLS: C{bool}

    @ivar fillBuffer: if set to True, it will send lots of data once
        C{STARTTLS} is received.
    @type fillBuffer: C{bool}
    c�R�||_||_tj�|_yr)�doTLS�
fillBufferrrr )r"rBrCs   rr#zLineCollector.__init__Vs����
�$������(��
rc�H�d|j_g|j_y)Nr)r.�rawdata�linesr!s rr)zLineCollector.connectionMade[s��"���������rc��|jjj|�|dk(r�|jr!t	d�D]}|jd��|jd�|jrFttt��}|jj||jj�y|j�yy)Nri�s�XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXr+)�privateKeyFileName�certificateFileName)
r.rF�appendrC�ranger'rB�ServerTLSContextrr,r-�server�
setRawMode)r"r2�x�ctxs    rr3zLineCollector.lineReceived_s��������!�!�$�'��;������s��/�A��M�M�+�.�/��M�M�(�#��z�z�&�'/�(0������'�'��T�\�\�-@�-@�A����!�rc�v�|jxj|z
c_|jj�yr)r.rEr,r1�r"�datas  r�rawDataReceivedzLineCollector.rawDataReceivedos'��������$�����%�%�'rc�:�|jjd�yrr5r7s  rr9zLineCollector.connectionLostsr:rN�F)	r;r<r=r>r#r)r3rTr9rrrr@r@Is ��
�)�
 �"� (�%rr@c��eZdZdZd�Zy)�SingleLineServerProtocolzK
    A protocol that sends a single line of data at C{connectionMade}.
    c�n�|jjd�|jj�y)N�+OK <some crap>
)r,�write�getPeerCertificater!s rr)z'SingleLineServerProtocol.connectionMade|s%�������3�4����)�)�+rN)r;r<r=r>r)rrrrXrXws���,rrXc�"�eZdZdZd�Zd�Zd�Zy)�RecordingClientProtocolzv
    @ivar deferred: a deferred that will fire with first received content.
    @type deferred: L{defer.Deferred}
    c�6�tj�|_yrrr!s rr#z RecordingClientProtocol.__init__�r$rc�8�|jj�yr)r,r\r!s rr)z&RecordingClientProtocol.connectionMade�s�����)�)�+rc�:�|jj|�yrr5rRs  r�dataReceivedz$RecordingClientProtocol.dataReceived�r:rN)r;r<r=r>r#r)rbrrrr^r^�s���
)�,�%rr^c��eZdZdZd�Zd�Zy)� ImmediatelyDisconnectingProtocolz�
    A protocol that disconnect immediately on connection. It fires the
    C{connectionDisconnected} deferred of its factory on connetion lost.
    c�8�|jj�yr�r,r1r!s r�handshakeCompletedz3ImmediatelyDisconnectingProtocol.handshakeCompleted�s�����%�%�'rc�N�|jjjd�yr)r.�connectionDisconnectedr6r7s  rr9z/ImmediatelyDisconnectingProtocol.connectionLost�s�����+�+�4�4�T�:rN)r;r<r=r>rgr9rrrrdrd�s���
(�;rrdc��tj�}|jtjd�tj�}|j�}||_||_|j|�|j|d�tj�}|jd�|jd�|jd�|j|j��|j|j��|j|j!��|j|d�|||fS)z�
    Create a certificate for given C{organization} and C{organizationalUnit}.

    @return: a tuple of (key, request, certificate) objects.
    i�md5�r�<)r�PKey�generate_key�TYPE_RSA�X509Req�get_subject�O�OU�
set_pubkey�sign�X509�set_serial_number�gmtime_adj_notBefore�gmtime_adj_notAfter�
set_issuer�set_subject�
get_pubkey)�organization�organizationalUnit�pkey�req�subject�certs      r�generateCertificateObjectsr��s����;�;�=�D����f�o�o�t�,�
�.�.�
�C��o�o��G��G�I�#�G�J��N�N�4���H�H�T�5���;�;�=�D����1�����a� ����R� ��O�O�C�O�O�%�&����S�_�_�&�'��O�O�C�N�N�$�%��I�I�d�E����d�?�rc�d�t||�\}}}d|tjfd|tjfd|tjffD]e\}}}t
jj||f�jd�}	t|	�j|tj|���gy)z�
    Create certificate files key, req and cert prefixed by C{basename} for
    given C{organization} and C{organizationalUnit}.
    �keyr�r�zutf-8N)r�r�dump_privatekey�dump_certificate_request�dump_certificate�os�extsep�join�encoder
�
setContent�FILETYPE_PEM)
�basenamer~rr�r�r��ext�obj�dumpFunc�fNames
          r�generateCertificateFilesr��s���
1��?Q�R�O�D�#�t�
��f�,�,�-�	��V�4�4�5�	��v�.�.�/��G���S�(�
�	�	����#��/�6�6�w�?�����"�"�8�F�,?�,?��#E�F�
Grc��eZdZdZd�Zd�Zy)�ContextGeneratingMixinah
    Offer methods to create L{ssl.DefaultOpenSSLContextFactory} for both client
    and server.

    @ivar clientBase: prefix of client certificate files.
    @type clientBase: C{str}

    @ivar serverBase: prefix of server certificate files.
    @type serverBase: C{str}

    @ivar clientCtxFactory: a generated context factory to be used in
        L{IReactorSSL.connectSSL}.
    @type clientCtxFactory: L{ssl.DefaultOpenSSLContextFactory}

    @ivar serverCtxFactory: a generated context factory to be used in
        L{IReactorSSL.listenSSL}.
    @type serverCtxFactory: L{ssl.DefaultOpenSSLContextFactory}
    c���|j�}t|||�tjtj
j
|df�tj
j
|df�g|��i|��}||fS)Nr�r�)�mktempr�r�DefaultOpenSSLContextFactoryr�r�r�)r"�org�orgUnit�args�kwArgs�base�serverCtxFactorys       r�makeContextFactoryz)ContextGeneratingMixin.makeContextFactory�st���{�{�}�� ��s�G�4��;�;��I�I�N�N�D�%�=�)��I�I�N�N�D�&�>�*�
��
��	
���%�%�%rc��|j|i|��\|_|_|j|i|��\|_|_yr)r��
clientBase�clientCtxFactory�
serverBaser�)r"�
clientArgs�clientKwArgs�
serverArgs�serverKwArgss     r�setupServerAndClientz+ContextGeneratingMixin.setupServerAndClient�sS��1H��1H�1H�
�2
�'�2
�.����.�2I��1H�1H�
�2
�'�2
�.����.rN)r;r<r=r>r�r�rrrr�r��s���&
&�
rr�c��eZdZdZdZd�Zy)rLzf
        A context factory with a default method set to
        L{OpenSSL.SSL.SSLv23_METHOD}.
        Fc�p�tj|d<tjj|g|��i|��y)N�	sslmethod)r�
SSLv23_METHODrr�r#)r"r��kws   rr#zServerTLSContext.__init__�s/��!�/�/�B�{�O��,�,�5�5�d�H�T�H�R�HrN)r;r<r=r>�isClientr#rrrrLrL�s��	�
��	IrrLc�R�eZdZdZej
ed��dZd�Zd�Z	d�Z
d�Zy)�StolenTCPTestszc
    For SSL transports, test many of the same things which are tested for
    TCP transports.
    N�2Reactor does not support SSL, cannot run SSL testsc���tjjtt�j��}|j
�}tj||||��S)zY
        Create an SSL server with a certificate using L{IReactorSSL.listenSSL}.
        ��	interface)	r�PrivateCertificate�loadPEMr
r�
getContent�optionsr�	listenSSL)r"�address�
portNumberr.r��contextFactorys      r�createServerzStolenTCPTests.createServersK���%�%�-�-�h�x�.@�.K�.K�.M�N�������� � ��W�n�PW�X�Xrc�P�tj�}|j|||�S)zG
        Create an SSL client using L{IReactorSSL.connectSSL}.
        )r�CertificateOptions�
connectSSL)r"r�r��
clientCreatorr�s     r�
connectClientzStolenTCPTests.connectClients'���/�/�1���'�'���^�L�Lrc�"�tjS)z�
        Return L{OpenSSL.SSL.Error} as the expected error type which will be
        raised by a write to the L{OpenSSL.SSL.Connection} object after it has
        been closed.
        )r�Errorr!s r�getHandleExceptionTypez%StolenTCPTests.getHandleExceptionTypes���y�y�rc�>�tjtjtjd�tjtjd�tjd�tjd��tjd���S)a4
        Return a L{hamcrest.core.matcher.Matcher} for the argument
        L{OpenSSL.SSL.Error} will be constructed with for this case.
        This is basically just a random OpenSSL implementation detail.
        It would be better if this test worked in a way which did not
        require this.
        zSSL routines�	SSL_write�ssl_write_internal�zprotocol is shutdown)�hamcrest�contains�equal_to�any_ofr!s r�getHandleErrorCodeMatcherz(StolenTCPTests.getHandleErrorCodeMatcher#s{��� � �����!�!�.�1�����%�%�k�2��%�%�&:�;��%�%�b�)��
�!�!�"8�9�
�

�
	
r)r;r<r=r>r�IReactorSSLr�skipr�r�r�r�rrrr�r�s9���
�z���g�t�,�4�C��Y�M��
rr�c�f�eZdZdZej
ed��dZdZdZ	dZ
d�Zd
d�Zd�Z
d�Zd	�Zy)�TLSTestsz�
    Tests for startTLS support.

    @ivar fillBuffer: forwarded to L{LineCollector.fillBuffer}
    @type fillBuffer: C{bool}
    Nr�Fc���|jj�$|jjj�|jj�%|jjj�yyr)�clientProtor,r1�serverProtor!s r�tearDownzTLSTests.tearDownJs[�����%�%�1����&�&�5�5�7����%�%�1����&�&�5�5�7�2rc�����|_tj�x}|_�fd�|_|rd|_nd|_�|_tj�x}|_�fd�|_|rd|_nd|_tjd|d��}|j|j�tjd|j�j|�t!j"�j$�j$g�S)a�
        Helper method to run TLS tests.

        @param clientProto: protocol instance attached to the client
            connection.
        @param serverProto: protocol instance attached to the server
            connection.
        @param clientIsServer: flag indicated if client should initiate
            startTLS instead of server.

        @return: a L{defer.Deferred} that will fire when both connections are
            lost.
        c����Srr�r�s�r�<lambda>z#TLSTests._runTest.<locals>.<lambda>`����k�rFTc����Srr�r�s�rr�z#TLSTests._runTest.<locals>.<lambda>hr�rr�	127.0.0.1r�)r�r�
ClientFactory�
clientFactoryrMr/r��
ServerFactory�
serverFactoryr�	listenTCP�
addCleanup�
stopListening�
connectTCP�getHost�portr�
gatherResultsr )r"r�r��clientIsServer�cf�sfr�s ``    r�_runTestzTLSTests._runTestPs����'���"*�"8�"8�":�:��T�
�)�����B�I��B�I�&���"*�"8�"8�":�:��T�
�)�����B�I��B�I�� � ��B�+�>������*�*�+����;�����(;�(;�R�@��"�"�K�$8�$8�+�:N�:N�#O�P�Prc����fd�}�jt�td�j��}|j	|�S)z~
        Test for server and client startTLS: client should received data both
        before and after the startTLS.
        c����j�jjtjtj
z�yr)�assertEqualr�rFrr&r0)�ignorer"s �r�checkz TLSTests.test_TLS.<locals>.check{�5�������"�"�(�(�%�-�-�0E�0N�0N�N�
rT�r�rr@rC�addCallback�r"r��ds`  r�test_TLSzTLSTests.test_TLSus8���	�
�M�M�/�1�=��t���3W�X���}�}�U�#�#rc����fd�}�jt�td�j��}|j	|�S)z�
        Test for server startTLS not followed by a startTLS in client: the data
        received after server startTLS should be received as raw.
        c����j�jjtj��j�jjd�y)NzNo encrypted bytes received)r�r�rFrr&�
assertTruerE��ignoredr"s �rr�z"TLSTests.test_unTLS.<locals>.check�sA������T�/�/�5�5�7L�7T�7T�U��O�O�D�.�.�6�6�8U�VrFr�r�s`  r�
test_unTLSzTLSTests.test_unTLS�s=���	W�
�M�M�!�#�]�5�$�/�/�%J�
���}�}�U�#�#rc����fd�}�jtd�j�t�d�}|j	|�S)z:
        Test startTLS first initiated by client.
        c����j�jjtjtj
z�yr)r�r�rFrr&r0r�s �rr�z)TLSTests.test_backwardsTLS.<locals>.check�r�rT)r�r@rCrr�r�s`  r�test_backwardsTLSzTLSTests.test_backwardsTLS�s?���
	�
�M�M��$����0�2G�2I�4�
���}�}�U�#�#rrV)r;r<r=r>rr�rr�rCr�r�r�r�r�rrrrrr�r�:sM����z���g�t�,�4�C���J��K��K�8�#Q�J
$�
$�$rr�c�>�eZdZdZej
ed��dZdZy)�SpammyTLSTestszA
    Test TLS features with bytes sitting in the out buffer.
    Nr�T)	r;r<r=r>rr�rr�rCrrrrr�s(����z���g�t�,�4�C���Jrrc�J�eZdZejed��dZdZdZd�Z	d�Z
y)�BufferingTestsNr�c�6�|jj�$|jjj�|jj�$|jjj�t	t
|j|jg�Sr)r�r,r1r�rrr!s rr�zBufferingTests.tearDown�st�����%�%�1����&�&�5�5�7����%�%�1����&�&�5�5�7�'��$�2B�2B�D�DT�DT�1U�V�Vrc�~���t�x�|_t�x�|_t	j
�}t	j�x}|_�fd�|_�fd�|_tjtt�}tj�}tjd||d��}|j|j�tj d|j#�j$||�}|j|j&��j(j+|j,d�S)Nc����Srrr�s�rr�z6BufferingTests.test_openSSLBuffering.<locals>.<lambda>�����+�rc����Srrr�s�rr�z6BufferingTests.test_openSSLBuffering.<locals>.<lambda>�rrrr�r�rZ)rXr�r^r�rr�r�r/rr�r�ClientContextFactoryrr�r�r�r�r�r��
disconnectr r�r�)	r"rMr/�sCTX�cCTXr��clientConnectorr�r�s	       @@r�test_openSSLBufferingz$BufferingTests.test_openSSLBuffering�s����)A�)C�C��d�&�)@�)B�B��d�&��'�'�)��'�5�5�7�7����-���-����/�/��(�C���'�'�)��� � ��F�D�K�H������*�*�+�!�,�,������,�,�f�d�
��	
����2�2�3��#�#�/�/����4�
�	
r)r;r<r=rr�rr�r�r�r�rrrrrr�s1���z���g�t�,�4�C���K��K�W�
rrc�R�eZdZdZej
ed��dZd�Zd�Z	d�Z
d�Zy)�ConnectionLostTestsz'
    SSL connection closing tests.
    Nr�c���d}�j||dzfi||dzfi�tj�}tj|_t	j
d|�j�x�_}tj�}t|_tj�|_t	jd|j�j|�j �|jj#�fd��S)N�twisted.test.test_ssl�, client�, serverrr�c�8���jj�Sr)�
serverPortr�)�
ignoredResultr"s �rr�z=ConnectionLostTests.testImmediateDisconnect.<locals>.<lambda>�s���$�/�/�"?�"?�"A�r)r�rr��Protocolrr�r�rr�rdrrrir�r�r�r�r�)r"r��serverProtocolFactoryr�clientProtocolFactorys`    r�testImmediateDisconnectz+ConnectionLostTests.testImmediateDisconnect�s����%���!�!�
�#�
�"�#�R�#�s�Z�/?�)@�"�	
�!)� 6� 6� 8��)1�):�):��&�'.�'8�'8�
�$�d�&;�&;�(
�	
���*�!)� 6� 6� 8��)I��&�7<�~�~�7G��4�������� �%�%�!��!�!�		
�%�;�;�G�G�A�
�	
rc�����ttj�Gd�dtj��}d}|j||dzfi||dzfi�|��tj�}�fd�|_tjd||j�}|j|j�|��tj�}�fd�|_tjd	|j�j||j �d
�}t#j$�j&j)|��j&j)|�g�S)z�
        Both sides of SSL connection close connection; the connections should
        close cleanly, and only after the underlying TCP connection has
        disconnected.
        c�"�eZdZdZd�Zd�Zd�Zy)�MConnectionLostTests.test_bothSidesLoseConnection.<locals>.CloseAfterHandshakeFc�6�tj�|_yr)rr�doner!s rr#zVConnectionLostTests.test_bothSidesLoseConnection.<locals>.CloseAfterHandshake.__init__s��!�N�N�,��	rc�8�|jj�yrrfr!s rrgz`ConnectionLostTests.test_bothSidesLoseConnection.<locals>.CloseAfterHandshake.handshakeCompleted
s�����-�-�/rc�>�|jj|�|`yr)r$�errbackr7s  rr9z\ConnectionLostTests.test_bothSidesLoseConnection.<locals>.CloseAfterHandshake.connectionLost
s���	�	�!�!�&�)��IrN)r;r<r=�gotDatar#rgr9rrr�CloseAfterHandshaker"s���G�
-�
0�
rr)rrrc����Srr��serverProtocols�rr�zBConnectionLostTests.test_bothSidesLoseConnection.<locals>.<lambda>�����rrc����Srr��clientProtocols�rr�zBConnectionLostTests.test_bothSidesLoseConnection.<locals>.<lambda>r-rr�c�.�|jt�yr)�trapr)�failures r�checkResultzEConnectionLostTests.test_bothSidesLoseConnection.<locals>.checkResult&s���L�L��(r)rr�IHandshakeListenerrrr�r�rr�r�r�r�r�r�r�r�r�rr�r$�
addErrback)	r"r)r�rrrr4r0r,s	       @@r�test_bothSidesLoseConnectionz0ConnectionLostTests.test_bothSidesLoseConnection�sF���
�Z�2�2�	3�	�(�"3�"3�	�
4�	�&���!�!�
�#�
�"�#�R�#�s�Z�/?�)@�"�	
�-�.�� (� 6� 6� 8��)?��&��&�&�q�*?��AV�AV�W�
����
�0�0�1�,�.�� (� 6� 6� 8��)?��&�������� �%�%�!��!�!�		
�	)��"�"��#�#�.�.�{�;��#�#�.�.�{�;�
�
�	
rc�D�	�
�d}|j||dzfi||dzfi�d�}|jj�jtj
|�t
j�}tj��
|j�
_tj�}�
fd�|_tjd||j�x|_}t
j�}tj��	|j�	_tj"�}�	fd�|_tj$d|j'�j(||j�t
j*||gd	�
�}|j-|j.�S)Nrrrc��y)NFr)�as r�verifyz4ConnectionLostTests.testFailedVerify.<locals>.verify6s��rc����Srrr+s�rr�z6ConnectionLostTests.testFailedVerify.<locals>.<lambda>?r-rrc����Srrr/s�rr�z6ConnectionLostTests.testFailedVerify.<locals>.<lambda>Hr-rr�T)�
consumeErrors)r�r��
getContext�
set_verifyr�VERIFY_PEERrrrrr6r9r�rr�r�rr�r�r�r��DeferredListr��_cbLostConns)r"r�r;�serverConnLostrr�clientConnLostr�dlr0r,s         @@r�testFailedVerifyz$ConnectionLostTests.testFailedVerify0sd���%���!�!�
�#�
�"�#�R�#�s�Z�/?�)@�"�	
�	�	
���(�(�*�5�5�c�o�o�v�N����)��!�*�*�,��(6�(?�(?��%� (� 6� 6� 8��)?��&�'.�'8�'8�
�$�d�&;�&;�(
�	
���*����)��!�*�*�,��(6�(?�(?��%� (� 6� 6� 8��)?��&�������� �%�%�!��!�!�		
��
�
��� @�PT�
U���~�~�d�/�/�0�0rc�D�|\\}}\}}|j|�|j|�tjg}tj�rddlm}|j|�|j|�|j|�|jj�S)Nr)�ConnectionLost)�assertFalserr�r�	isWindows�twisted.internet.errorrIrJr2rr�)r"�results�sSuccess�sResult�cSuccess�cResult�acceptableErrorsrIs        rrCz ConnectionLostTests._cbLostConnsSs���3:�0���7�0�h������"�����"��I�I�;������=��#�#�N�3�����&�'�����&�'����,�,�.�.r)r;r<r=r>rr�rr�rr7rGrCrrrrr�s9����z���g�t�,�4�C��
�82
�h!1�F/rrc�(�eZdZdZd�Zd�Zd�Zd�Zy)�FakeContextzK
    L{OpenSSL.SSL.Context} double which can more easily be inspected.
    c� �||_d|_y)Nr)�_method�_options)r"�methods  rr#zFakeContext.__init__ss�������
rc�.�|xj|zc_yr)rW)r"r�s  r�set_optionszFakeContext.set_optionsws���
�
�� �
rc��yrr�r"�fileNames  r�use_certificate_filez FakeContext.use_certificate_filez���rc��yrrr\s  r�use_privatekey_filezFakeContext.use_privatekey_file}r_rN)r;r<r=r>r#rZr^rarrrrTrTns����!�
�
rrTc�R�eZdZdZej
ed��dZd�Zd�Z	d�Z
d�Zy)�!DefaultOpenSSLContextFactoryTestsz8
    Tests for L{ssl.DefaultOpenSSLContextFactory}.
    Nr�c��tjttt��|_|jj�|_y)N)�_contextFactory)rr�rrTr�r?�contextr!s r�setUpz'DefaultOpenSSLContextFactoryTests.setUp�s6��"�>�>��h��
����*�*�5�5�7��rc�b�|j|jjtj�|j|jj
tjztj�|j|jj
tjz�y)z�
        L{ssl.DefaultOpenSSLContextFactory.getContext} returns an SSL context
        which can use SSLv3 or TLSv1 but not SSLv2.
        N)	r�rfrVr�
TLS_METHODrW�OP_NO_SSLv2rJ�
OP_NO_TLSv1_2r!s r�test_methodz-DefaultOpenSSLContextFactoryTests.test_method�sp��	
������-�-�s�~�~�>�	
������.�.����@�#�/�/�R�	
������.�.��1B�1B�B�Crc��|jtjtjt
|j
��y)z�
        Instantiating L{ssl.DefaultOpenSSLContextFactory} with a certificate
        filename which does not identify an existing file results in the
        initializer raising L{OpenSSL.SSL.Error}.
        N)�assertRaisesrr�rr�rr�r!s r�test_missingCertificateFilez=DefaultOpenSSLContextFactoryTests.test_missingCertificateFile�s+��	
����I�I�s�7�7��4�;�;�=�	
rc��|jtjtj|j�t�y)z�
        Instantiating L{ssl.DefaultOpenSSLContextFactory} with a private key
        filename which does not identify an existing file results in the
        initializer raising L{OpenSSL.SSL.Error}.
        N)rnrr�rr�r�rr!s r�test_missingPrivateKeyFilez<DefaultOpenSSLContextFactoryTests.test_missingPrivateKeyFile�s+��	
����I�I�s�7�7������	
r)r;r<r=r>rr�rr�rgrlrorqrrrrcrc�s8����z���g�t�,�4�C��8�D�
�
rrcc�F�eZdZdZej
ed��dZd�Zd�Z	y)�ClientContextFactoryTestsz0
    Tests for L{ssl.ClientContextFactory}.
    Nr�c��tj�|_t|j_|jj�|_yr)rr
r�rTrer?rfr!s rrgzClientContextFactoryTests.setUp�s7��!�6�6�8���.9����+��*�*�5�5�7��rc���|j|jjtj�|j|jj
tjztj�|j|jj
tjz�|j|jj
tjz�y)z�
        L{ssl.ClientContextFactory.getContext} returns a context which can use
        TLSv1.2 or 1.3 but nothing earlier.
        N)
r�rfrVrrirWrjr��OP_NO_SSLv3�OP_NO_TLSv1r!s rrlz%ClientContextFactoryTests.test_method�s���
	
������-�-�s�~�~�>�������.�.����@�#�/�/�R�������-�-����?�@�������-�-����?�@r)
r;r<r=r>rr�rr�rgrlrrrrsrs�s.����z���g�t�,�4�C��8�
Arrs)6r>r�r��twisted.internetrrrrrLr�twisted.internet.testingr�twisted.protocolsr	�twisted.python.filepathr
�twisted.python.runtimer�twisted.test.test_tcpr�twisted.trial.unittestr
�OpenSSLrrr�twisted.test.ssl_helpersrr�ImportErrorr�zope.interfacer�LineReceiverrr@rrXr^r5rdr�r�r�r�rLr�r�rrrrTrcrsrrr�<module>r�st���
��A�A�1�=�#�,�+�9�+�

�#�$�C�'�%�E�.�.�%�D+%�E�&�&�+%�\,�x�0�0�,�
%�h�/�/�
%� 
�Z�
*�
*�+�
;�x�'8�'8�
;�,�
;��8
G� &
�&
�R�?�
I�3�;�;�
I�4
�,�h�4
�ng$�x�g$�T�X��&
�X�&
�RS/�(�$:�S/�l
�
�&0
��0
�fA��A��u�
���H�
�s�E%�%E8�7E8

Zerion Mini Shell 1.0