§
    Ètºf…  ã                   ó®  — d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 ddl
mZmZmZmZ ddlmZ 	 ddlmZ dd	lmZ eZn# e$ r d
ZY nw xY wddlmZ  G d„ dej        ¦  «        Z G d„ d¦  «        Z eej        ¦  «         G d„ de¦  «        ¦   «         Z G d„ deee¦  «        Z e¦   «                              e                      ¦   «         ¦  «         d
S )z(
Tests for L{twisted.internet._newtls}.
é    )Ú
interfaces)ÚConnectableProtocolÚrunProtocolsWithReactor)ÚReactorBuilder)Ú
TCPCreator)ÚContextGeneratingMixinÚ
SSLCreatorÚStartTLSClientCreatorÚTLSMixin)Úunittest)Ú_newtls)ÚtlsN)Úimplementerc                   ó    — e Zd ZdZesdZd„ ZdS )ÚBypassTLSTestsz4
    Tests for the L{_newtls._BypassTLS} class.
    z<Couldn't import _newtls, perhaps pyOpenSSL is old or missingc                 ó\  ‡‡— t          ¦   «         Šg Š G ˆˆfd„d¦  «        }t                               | |¦   «         ¦  «        }|                     ¦   «          |                      ‰‰g¦  «         t          ¦   «         }|                     |¦  «         |                      ‰‰|g¦  «         dS )zÄ
        C{_BypassTLS.loseConnection} calls C{loseConnection} on the base
        class, while preserving any default argument in the base class'
        C{loseConnection} implementation.
        c                   ó   •— e Zd Z” fˆfd„	ZdS )úDBypassTLSTests.test_loseConnectionPassThrough.<locals>.FakeTransportc                 ó2   •— ‰                      |¦  «         d S ©N)Úappend)ÚselfÚ	_connDoneÚresults     €ú`/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/internet/test/test_newtls.pyÚloseConnectionzSBypassTLSTests.test_loseConnectionPassThrough.<locals>.FakeTransport.loseConnection4   s   ø€ Ø—’˜iÑ(Ô(Ð(Ð(Ð(ó    N)Ú__name__Ú
__module__Ú__qualname__r   )Údefaultr   s   €€r   ÚFakeTransportr   3   s6   ø€ € € € € Ø/6ð )ð )ð )ð )ð )ð )ð )ð )r   r"   N)Úobjectr   Ú
_BypassTLSr   ÚassertEqual)r   r"   ÚbypassÚ
notDefaultr!   r   s       @@r   Útest_loseConnectionPassThroughz-BypassTLSTests.test_loseConnectionPassThrough*   sÔ   øø€ õ ‘(”(ˆØˆð	)ð 	)ð 	)ð 	)ð 	)ð 	)ð 	)ð 	)ñ 	)ô 	)ð 	)õ ×#Ò# M°=°=±?´?ÑCÔCˆð 	×ÒÑÔÐØ×Ò˜ ' Ñ+Ô+Ð+õ ‘X”Xˆ
Ø×Ò˜jÑ)Ô)Ð)Ø×Ò˜ '¨:Ð!6Ñ7Ô7Ð7Ð7Ð7r   N)r   r   r    Ú__doc__r   Úskipr(   © r   r   r   r   "   s=   € € € € € ðð ð ð NØMˆð8ð 8ð 8ð 8ð 8r   r   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚFakeProducerz'
    A producer that does nothing.
    c                 ó   — d S r   r+   ©r   s    r   ÚpauseProducingzFakeProducer.pauseProducingH   ó   € Øˆr   c                 ó   — d S r   r+   r/   s    r   ÚresumeProducingzFakeProducer.resumeProducingK   r1   r   c                 ó   — d S r   r+   r/   s    r   ÚstopProducingzFakeProducer.stopProducingN   r1   r   N)r   r   r    r)   r0   r3   r5   r+   r   r   r-   r-   C   sK   € € € € € ðð ðð ð ðð ð ðð ð ð ð r   r-   c                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚProducerProtocolzy
    Register a producer, unregister it, and verify the producer hooks up to
    innards of C{TLSMemoryBIOProtocol}.
    c                 ó"   — || _         || _        d S r   )Úproducerr   )r   r9   r   s      r   Ú__init__zProducerProtocol.__init__Y   s   € Ø ˆŒØˆŒˆˆr   c                 ó¾  — t          | j        j        t          j        ¦  «        st          d¦  «        ‚| j                             | j        d¦  «         | j         	                    | j        j        j
        j
        ¦  «         | j                             ¦   «          | j         	                    | j        j        j
        ¦  «         | j                             ¦   «          d S )Nz#TLSMemoryBIOProtocol not hooked up.T)Ú
isinstanceÚ	transportÚprotocolr   ÚBufferingTLSTransportÚRuntimeErrorÚregisterProducerr9   r   r   Ú	_producerÚunregisterProducerr   r/   s    r   ÚhandshakeCompletedz#ProducerProtocol.handshakeCompleted]   s³   € Ý˜$œ.Ô1µ3Ô3LÑMÔMð 	FåÐDÑEÔEÐEàŒ×'Ò'¨¬°tÑ<Ô<Ð<àŒ×Ò˜4œ>Ô2Ô<ÔFÑGÔGÐGàŒ×)Ò)Ñ+Ô+Ð+àŒ×Ò˜4œ>Ô2Ô<Ñ=Ô=Ð=ØŒ×%Ò%Ñ'Ô'Ð'Ð'Ð'r   N)r   r   r    r)   r:   rD   r+   r   r   r7   r7   R   s<   € € € € € ðð ð
ð ð ð(ð (ð (ð (ð (r   r7   c                   ó8   — e Zd ZdZesdZd„ Zd„ Zd„ Zd„ Z	d„ Z
dS )	ÚProducerTestsMixinzM
    Test the new TLS code integrates C{TLSMemoryBIOProtocol} correctly.
    z)Could not import twisted.internet._newtlsc                 óÆ   — g }t          ¦   «         }t          | t          ¦   «         t          ||¦  «        t	          ¦   «         ¦  «         |                      ||dg¦  «         dS )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-   r   r   r7   r	   r%   ©r   r   r9   s      r   Útest_producerSSLFromStartz,ProducerTestsMixin.test_producerSSLFromStartt   sg   € ð ˆÝ‘>”>ˆåØÝÑ!Ô!Ý˜X vÑ.Ô.Ý‰LŒLñ		
ô 	
ð 	
ð 	×Ò˜ (¨DÐ!1Ñ2Ô2Ð2Ð2Ð2r   c                 óÆ   — g }t          ¦   «         }t          | t          ¦   «         t          ||¦  «        t	          ¦   «         ¦  «         |                      ||dg¦  «         dS )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-   r   r   r7   r
   r%   rH   s      r   Útest_producerAfterStartTLSz-ProducerTestsMixin.test_producerAfterStartTLS…   si   € ð ˆÝ‘>”>ˆåØÝÑ!Ô!Ý˜X vÑ.Ô.Ý!Ñ#Ô#ñ		
ô 	
ð 	
ð 	×Ò˜ (¨DÐ!1Ñ2Ô2Ð2Ð2Ð2r   c                 óf  ‡‡‡‡‡— |                       ¦   «         Š|                      ¦   «         Šg Št          ¦   «         Š G ˆˆˆˆfd„dt          ¦  «        } G ˆfd„dt          ¦  «        }t	          |  |¦   «          |¦   «         t          ¦   «         ¦  «         |                      ‰‰‰g¦  «         dS )z•
        When a producer is registered, and then startTLS is called,
        the producer is re-registered with the C{TLSMemoryBIOProtocol}.
        c                   ó    •— e Zd Zˆ ˆˆˆfd„ZdS )úMProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.RegisterTLSProtocolc                 ó$  •— | j                              ‰‰¦  «         | j                              ‰¦  «         ‰rN‰                     | j         j        j        j        ¦  «         ‰                     | j         j        j        ¦  «         nW‰                     | j         j        j        j        j        ¦  «         ‰                     | j         j        j        j        ¦  «         | j                              ¦   «          | j                              ¦   «          d S r   )	r=   rA   ÚstartTLSr   r>   rB   r9   rC   r   )r   r9   r   ÚserverContextÚ	streamings    €€€€r   ÚconnectionMadez\ProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.RegisterTLSProtocol.connectionMade¡   sã   ø€ Ø”×/Ò/°¸)ÑDÔDÐDØ”×'Ò'¨Ñ6Ô6Ð6ð ð Oà—M’M $¤.Ô"9Ô"CÔ"MÑNÔNÐNØ—M’M $¤.Ô"9Ô"CÑDÔDÐDÐDð —M’M $¤.Ô"9Ô"CÔ"MÔ"WÑXÔXÐXØ—M’M $¤.Ô"9Ô"CÔ"MÑNÔNÐNØ”×1Ò1Ñ3Ô3Ð3Ø”×-Ò-Ñ/Ô/Ð/Ð/Ð/r   N©r   r   r    rS   )r9   r   rQ   rR   s   €€€€r   ÚRegisterTLSProtocolrN       s=   ø€ € € € € ð0ð 0ð 0ð 0ð 0ð 0ð 0ð 0ð 0ð 0r   rU   c                   ó   •— e Zd Zˆ fd„ZdS )úJProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.StartTLSProtocolc                 ó<   •— | j                              ‰¦  «         d S r   )r=   rP   )r   ÚclientContexts    €r   rS   zYProducerTestsMixin.startTLSAfterRegisterProducer.<locals>.StartTLSProtocol.connectionMade²   s   ø€ Ø”×'Ò'¨Ñ6Ô6Ð6Ð6Ð6r   NrT   )rY   s   €r   ÚStartTLSProtocolrW   ±   s.   ø€ € € € € ð7ð 7ð 7ð 7ð 7ð 7ð 7r   rZ   N)ÚgetClientContextÚgetServerContextr-   r   r   r   r%   )r   rR   rU   rZ   rY   r9   r   rQ   s    `  @@@@r   ÚstartTLSAfterRegisterProducerz0ProducerTestsMixin.startTLSAfterRegisterProducer–   s
  øøøøø€ ð
 ×-Ò-Ñ/Ô/ˆØ×-Ò-Ñ/Ô/ˆØˆÝ‘>”>ˆð	0ð 	0ð 	0ð 	0ð 	0ð 	0ð 	0ð 	0ð 	0ð 	0Õ"5ñ 	0ô 	0ð 	0ð"	7ð 	7ð 	7ð 	7ð 	7ð 	7ð 	7Õ2ñ 	7ô 	7ð 	7õ 	 ØÐ%Ð%Ñ'Ô'Ð)9Ð)9Ñ);Ô);½Z¹\¼\ñ	
ô 	
ð 	
ð 	×Ò˜ (¨HÐ!5Ñ6Ô6Ð6Ð6Ð6r   c                 ó0   — |                       d¦  «         dS )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Ñ0Ô0Ð0Ð0Ð0r   c                 ó0   — |                       d¦  «         dS )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Ñ1Ô1Ð1Ð1Ð1r   N)r   r   r    r)   r   r*   rI   rK   r]   r`   rb   r+   r   r   rF   rF   l   sy   € € € € € ðð ð ð ;Ø:ˆð3ð 3ð 3ð"3ð 3ð 3ð""7ð "7ð "7ðH1ð 1ð 1ð2ð 2ð 2ð 2ð 2r   rF   )!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   r-   ÚIHandshakeListenerr7   rF   ÚglobalsÚupdateÚmakeTestCaseClassesr+   r   r   ú<module>rr      s/  ððð ð
 (Ð 'Ð 'Ð 'Ð 'Ð 'ðð ð ð ð ð ð ð ð ?Ð >Ð >Ð >Ð >Ð >Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5ðð ð ð ð ð ð ð ð ð ð ð ð #Ð "Ð "Ð "Ð "Ð "ðØ4Ð4Ð4Ð4Ð4Ð4Ø%Ð%Ð%Ð%Ð%Ð%ð €G€Gøð ð ð ð Ø€G€G€Gðøøøð 'Ð &Ð &Ð &Ð &Ð &ð8ð 8ð 8ð 8ð 8�XÔ&ñ 8ô 8ð 8ðBð ð ð ð ñ ô ð ð €ˆZÔ*Ñ+Ô+ð(ð (ð (ð (ð (Ð*ñ (ô (ñ ,Ô+ð(ð2[2ð [2ð [2ð [2ð [2˜¨Ð3Iñ [2ô [2ð [2ð| €�	„	× Ò Ð#×7Ò7Ñ9Ô9Ñ :Ô :Ð :Ð :Ð :s   °? ¿A	ÁA	