%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f'����dZddlmZddlmZddlmZmZddlm	Z	ddl
mZddlm
Z
ddlmZdd	lmZdd
lmZmZmZmZddlmZddlmZ	dd
lmZeZdZddlmZddlm Z dZ"Gd�dejF�Z$Gd�dejF�Z%Gd�dejF�Z&Gd�de'�Z(Gd�dejF�Z)Gd�dejF�Z*Gd �d!ejF�Z+Gd"�d#ejF�Z,Gd$�d%ejZ�Z.Gd&�d'ejF�Z/Gd(�d)ejF�Z0Gd*�d+�Z1Gd,�d-ejd�Z3Gd.�d/ejd�Z4Gd0�d1ejF�Z5Gd2�d3ejF�Z6Gd4�d5ejF�Z7Gd6�d7e�Z8y#e!$rdZdZY��jwxYw)8z8
Tests for L{twisted.words.protocols.jabber.xmlstream}.
�)�skipIf)�verifyObject)�defer�task)�ConnectionLost)�IProtocolFactory)�failure)�
proto_helpers)�unittest)�error�ijabber�jid�	xmlstream)�!GenericXmlStreamFactoryTestsMixin)�domish)�ssl)F�)�ClientTLSOptions)�CertificateOptionsN)TzSSL not available�urn:ietf:params:xml:ns:xmpp-tlsc�(�eZdZdZd�Zd�Zd�Zd�Zy)�HashPasswordTestsz.
    Tests for L{xmlstream.hashPassword}.
    c�T�tjdd�}|jd|�y)zS
        The sid and secret are concatenated to calculate sha1 hex digest.
        �12345�secret�(99567ee91b2c7cabf607f10cb9f4a3634fa820e0N�r�hashPassword�assertEqual��self�hashs  �I/usr/lib/python3/dist-packages/twisted/words/test/test_jabberxmlstream.py�
test_basiczHashPasswordTests.test_basic)s'���%�%�g�x�8�����C�T�J�c�P�|jttjdd�y)zB
        The session identifier must be a unicode object.
        s¹2345rN��assertRaises�	TypeErrorrr�r!s r#�test_sidNotUnicodez$HashPasswordTests.test_sidNotUnicode0s��	
���)�Y�%;�%;�_�h�Wr%c�P�|jttjdd�y)z8
        The password must be a unicode object.
        rssecrétNr'r*s r#�test_passwordNotUnicodez)HashPasswordTests.test_passwordNotUnicode6s��	
���)�Y�%;�%;�W�FV�Wr%c�T�tjdd�}|jd|�y)z\
        The concatenated sid and password must be encoded to UTF-8 before hashing.
        rusecrét�(659bf88d8f8e179081f7f3b4a8e7d224652d2853Nrr s  r#�test_unicodeSecretz$HashPasswordTests.test_unicodeSecret<s'���%�%�g�}�=�����C�T�Jr%N)�__name__�
__module__�__qualname__�__doc__r$r+r-r0�r%r#rr$s���K�X�X�Kr%rc�X�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zy)�IQTestszG
    Tests both IQ and the associated IIQResponseTracker callback.
    c���tjd�}d|_tj|�|_t	j
�|_|jj|j_|jjtj��|jjd�tj|jd�|_y)N�	otherhost�testnszm<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='testns' from='otherhost' version='1.0'>�get)r�ConnectAuthenticator�	namespace�	XmlStreamr�Clock�clock�	callLater�
_callLater�makeConnectionr
�StringTransport�dataReceived�IQ�iq)r!�
authenticators  r#�setUpz
IQTests.setUpIs���!�6�6�{�C�
�"*�
��"�,�,�]�;����Z�Z�\��
�$(�J�J�$8�$8����!����%�%�m�&C�&C�&E�F����#�#�
=�	
��,�,�t�~�~�u�5��r%c�~�|j|jdd�|j|jd�y)N�typer;�id)rrG�
assertTruer*s r#�	testBasiczIQTests.testBasicVs.����������%�0��������
�&r%c�@�|jjj�|jj	�|jdjd�}|j
|jjj�d|zdzd|zdzg�y)NrLzutf-8s<iq type='get' id='s'/>s<iq id='s' type='get'/>)r�	transport�clearrG�send�encode�assertIn�value)r!�idBytess  r#�testSendzIQTests.testSendZs����� � �&�&�(��������'�'�$�-�&�&�w�/���
�
��N�N�$�$�*�*�,�&��0�6�9��g�%�(9�9�
�	
r%c�����fd�}�jj�}|j|��j}|j	d�jdz�|S)Nc�0���j|dd�y)NrK�result)r)rZr!s �r#�cbz&IQTests.testResultResponse.<locals>.cbgs������V�F�^�X�6r%�<iq type='result' id='%s'/>rL)rGrR�addCallbackrrE)r!r[�d�xss`   r#�testResultResponsezIQTests.testResultResponsefsM���	7�
�G�G�L�L�N��	�
�
�b��
�^�^��
���5�����
�E�F��r%c���|jj�}|j|tj�|j
}|j
d|jdz�|S)Nz<iq type='error' id='%s'/>rL)rGrR�
assertFailurer�StanzaErrorrrE�r!r^r_s   r#�testErrorResponsezIQTests.testErrorResponseqsO���G�G�L�L�N�����1�e�/�/�0�
�^�^��
���4�t�w�w�t�}�D�E��r%c�����j}tj|��j|j��fd�}|j	d|d�|jd�y)z�
        Test that untracked iq responses don't trigger any action.

        Untracked means that the id of the incoming response iq is not
        in the stream's C{iqDeferreds} dictionary.
        c�>���jt|dd��y)N�handledF)�assertFalse�getattr)rGr!s �r#r[z*IQTests.testNonTrackedResponse.<locals>.cb�s������W�R��E�:�;r%z/iq���z<iq type='result' id='test'/>N)r�upgradeWithIQResponseTrackerri�iqDeferreds�addObserverrE)r!r_r[s`  r#�testNonTrackedResponsezIQTests.testNonTrackedResponseysV����^�^���.�.�r�2�	
������(�
	<�	���u�b�"�%�	���7�8r%c���|jj�}|j}|jd|jdz�|j	|jd|j
�|S)z�
        Test if the deferred associated with an iq request is removed
        from the list kept in the L{XmlStream} object after it has
        been fired.
        r\rL)rGrRrrE�assertNotInrmrds   r#�testCleanupzIQTests.testCleanup�sW��
�G�G�L�L�N��
�^�^��
���5�����
�E�F������������7��r%c��|jj�}|j}|jd�|j	|t
�|S)z�
        Test if deferreds for iq's that haven't yet received a response
        have their errback called on stream disconnect.
        �Closed by peer)rGrRr�connectionLostrbrrds   r#�testDisconnectCleanupzIQTests.testDisconnectCleanup�s@��
�G�G�L�L�N��
�^�^��
���*�+����1�n�-��r%c������fd���jj�}|j���jj	d�|S)z~
        Test to make sure the errbacks cannot cause the iteration of the
        iqDeferreds to blow up in our face.
        c���tj�j�j�}|j��y�N)rrFrR�
addErrback)r	r^�ebr!s  ��r#r{z'IQTests.testNoModifyingDict.<locals>.eb�s*������T�^�^�,�1�1�3�A�
�L�L��r%rt)rGrRrzrru)r!r^r{s` @r#�testNoModifyingDictzIQTests.testNoModifyingDict�s=���	�
�G�G�L�L�N��	���R�����%�%�&6�7��r%c�j�d|j_|jj�}|j|tj
�|jjddg�|j|jj�|j|jj�|S)zK
        Test that an iq request with a defined timeout times out.
        �<�)rG�timeoutrRrbr�TimeoutErrorr@�pumpri�callsrm�r!r^s  r#�testRequestTimingOutzIQTests.testRequestTimingOut�s}��������G�G�L�L�N�����1�i�4�4�5��
�
����B�� �������)�)�*�������3�3�4��r%c�b�d|j_|jj�}|jj	d|j
jd|jdz�|jjddg�|j|jj�|S)z�
        Test that an iq request with a defined timeout does not time out
        when a response was received before the timeout period elapsed.
        r~rr\rL)
rGr�rRr@rArrEr�rir�r�s  r#�testRequestNotTimingOutzIQTests.testRequestNotTimingOut�s���
������G�G�L�L�N���
�
���
��N�N�'�'�)�D�G�G�D�M�9�	
�
	
�
�
����A���������)�)�*��r%c��d|j_|jj�}|j}|j	d�|j|t�|j|jj�|S)z|
        Test if timeouts for iq's that haven't yet received a response
        are cancelled on stream disconnect.
        r~rt)
rGr�rRrrurbrrir@r�rds   r#�!testDisconnectTimeoutCancellationz)IQTests.testDisconnectTimeoutCancellation�sc��������G�G�L�L�N��
�^�^��
���*�+����1�n�-�������)�)�*��r%N)r1r2r3r4rIrNrWr`rerorrrvr|r�r�r�r5r%r#r7r7DsC���6�'�

�	��9�0�
�
��� 
r%r7c�l�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zy)�XmlStreamTestsc��d|_y�NT)�gotStreamStart�r!�objs  r#�
onStreamStartzXmlStreamTests.onStreamStart��
��"��r%c��d|_yr�)�gotStreamEndr�s  r#�onStreamEndzXmlStreamTests.onStreamEnd�s
�� ��r%c��d|_yr�)�gotStreamErrorr�s  r#�
onStreamErrorzXmlStreamTests.onStreamError�r�r%c��d|_d|_d|_tjtj
��}|j
d|j�|j
d|j�|j
d|j�|jtj��||j_d|_d|_||_y)z9
        Set up XmlStream and several observers.
        Fz//event/stream/start�//event/stream/endz//event/stream/errorr:�rrN)r�r�r�rr>�
Authenticatorrnr�r�r�rCr
� StringTransportWithDisconnectionrP�protocolr=�version�r!r_s  r#rIzXmlStreamTests.setUp�s���$���!���#���
�
 �
 ��!8�!8�!:�
;��
���-�t�/A�/A�B�
���+�T�-=�-=�>�
���-�t�/A�/A�B�
���-�H�H�J�K� "����������
���r%c�n�|j}|j�|jjj�ddj	d�}|jd|�|jd|�|jd|�|jd|�|j
|j�y)	z>
        Basic test on the header sent by sendHeader.
        rrk� �<stream:stream�/xmlns:stream='http://etherx.jabber.org/streams'�xmlns='testns'�
version='1.0'N)r�
sendHeaderrPrU�splitrTrM�_headerSent�r!r_�splitHeaders   r#�test_sendHeaderBasicz#XmlStreamTests.test_sendHeaderBasics����^�^��
�
�
���n�n�.�.�4�4�6�q��<�B�B�4�H���
�
�'��5��
�
�H�+�V��
�
�'��5��
�
�&��4�������'r%c��|j}d|jd<|j�|jjj	�ddjd�}|j
d|�|j
d|�|j
d|�|j
d	|�|j
d
|�|j|j�y)z=
        Test for additional namespace declarations.
        �dbzjabber:server:dialbackrrkr�r�r�s!xmlns:db='jabber:server:dialback'r�r�N)	r�prefixesr�rPrUr�rTrMr�r�s   r#�#test_sendHeaderAdditionalNamespacesz2XmlStreamTests.test_sendHeaderAdditionalNamespacess����^�^��04����,�-�
�
�
���n�n�.�.�4�4�6�q��<�B�B�4�H���
�
�'��5��
�
�H�+�V��
�
�:�K�H��
�
�'��5��
�
�&��4�������'r%c�R�|j}tjd�|_tjd�|_d|_|j
�|jj�ddjd�}|jd|�|jd|�y	)
z;
        Test addressing when initiating a stream.
        �thisHost�	otherHostTrrkr��to='otherhost'�from='thishost'N)rr�JID�
thisEntity�otherEntity�
initiatingr�rPrUr�rTr�s   r#�test_sendHeaderInitiatingz(XmlStreamTests.test_sendHeaderInitiatings���^�^�����
�+��
�����-�����
�
�
�
���l�l�(�(�*�1�R�0�6�6�t�<���
�
�'��5��
�
�(�+�6r%c��|j}tjd�|_tjd�|_d|_d|_|j�|jj�ddjd�}|jd|�|jd	|�|jd
|�y)z:
        Test addressing when receiving a stream.
        r�r�F�	session01rrkr�r�r�sid='session01'N)rrr�r�r�r��sidr�rPrUr�rTr�s   r#�test_sendHeaderReceivingz'XmlStreamTests.test_sendHeaderReceiving*s����^�^�����
�+��
�����-�����
����
�
�
���l�l�(�(�*�1�R�0�6�6�t�<���
�
�'��5��
�
�(�+�6��
�
�'��5r%c���|j}|jd�|jd�|j|j�|j|j�y)z>
        Test events when a stream error is received.
        ��<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='example.com' id='12345' version='1.0'>z<stream:error/>N)rrErMr�r�r�s  r#�test_receiveStreamErrorz&XmlStreamTests.test_receiveStreamError9sQ���^�^��
���
;�	
�
	���)�*�����+�+�,�����)�)�*r%c�P�|j}d|_|j�|jj	�|jt
jd��|jd|jj��|j|j�y)z�
        Test sendStreamError on an initiating xmlstream with a header sent.

        An error should be sent out and the connection lost.
        T�version-unsupportedr%N�rr�r�rPrQ�sendStreamErrorr�StreamError�assertNotEqualrUrMr�r�s  r#�test_sendStreamErrorInitiatingz-XmlStreamTests.test_sendStreamErrorInitiatingGsv���^�^����
�
�
�
��
������
���5�,�,�-B�C�D����C����!3�!3�!5�6�����)�)�*r%c�f�|j}d|_|jj�|j	tjd��|j|j�|jd|jj��|j|j�y)z�
        Test sendStreamError on an initiating xmlstream without having sent a
        header.

        In this case, no header should be generated. Also, the error should
        not be sent out on the stream. Just closing the connection.
        Tr�r%N)
rr�rPrQr�rr��	assertNotr�rrUrMr�r�s  r#�&test_sendStreamErrorInitiatingNoHeaderz5XmlStreamTests.test_sendStreamErrorInitiatingNoHeaderUs}���^�^����
�
������
���5�,�,�-B�C�D����r�~�~�&�����b�l�l�0�0�2�3�����)�)�*r%c�P�|j}d|_|j�|jj	�|jt
jd��|jd|jj��|j|j�y)z�
        Test sendStreamError on a receiving xmlstream with a header sent.

        An error should be sent out and the connection lost.
        Fr�r%Nr�r�s  r#�test_sendStreamErrorReceivingz,XmlStreamTests.test_sendStreamErrorReceivingesv���^�^����
�
�
�
��
������
���5�,�,�-B�C�D����C����!3�!3�!5�6�����)�)�*r%c�f�|j}d|_|jj�|j	tjd��|j|j�|jd|jj��|j|j�y)z�
        Test sendStreamError on a receiving xmlstream without having sent a
        header.

        In this case, a header should be generated. Then, the error should
        be sent out on the stream followed by closing the connection.
        Fr�r%N)rr�rPrQr�rr�rMr�r�rUr�r�s  r#�%test_sendStreamErrorReceivingNoHeaderz4XmlStreamTests.test_sendStreamErrorReceivingNoHeaderss}���^�^����
�
������
���5�,�,�-B�C�D�������'����C����!3�!3�!5�6�����)�)�*r%c���|j}|j�|j}|j�|j	||j�|j|j�y)zE
        Test resetting the XML stream to start a new layer.
        N)rr��stream�resetr�r�r�)r!r_r�s   r#�
test_resetzXmlStreamTests.test_reset�sL���^�^��
�
�
������
���
����F�B�I�I�.����r�~�~�&r%c�:�|j}|jd�|j|jj	�d�|jj�t
jd�}|j|�|j|jj	�d�|jj�t
jd�}|j|�|j|jj	�d�y)z:
        Test send with various types of objects.
        �<presence/>�<presence/>)r:�presence)z http://etherx.jabber.org/streams�featuress<stream:features/>N)rrRrrPrUrQr�Element)r!r_�els   r#�	test_sendzXmlStreamTests.test_send�s����^�^��
���
��������+�+�-�~�>�
������
�^�^�2�
3��
�����������+�+�-�~�>�
������
�^�^�L�
M��
�����������+�+�-�/D�Er%c�t����g�g�g�G���fd�d�}|�}tj|�}|j|g��|j�|jdg��|j	d�|jdt���|j
�|jdg��y)zM
        Test that the associated authenticator is correctly called.
        c�,��eZdZ�fd�Z�fd�Z�fd�Zy)�<XmlStreamTests.test_authenticator.<locals>.TestAuthenticatorc�(���jd�yry��append)r!�connectionMadeCallss �r#�connectionMadezKXmlStreamTests.test_authenticator.<locals>.TestAuthenticator.connectionMade�s���#�*�*�4�0r%c�(���j|�yryr�)r!�rootElement�streamStartedCallss  �r#�
streamStartedzJXmlStreamTests.test_authenticator.<locals>.TestAuthenticator.streamStarted�s���"�)�)�+�6r%c�(���j|�yryr�)r!r_�associateWithStreamCallss  �r#�associateWithStreamzPXmlStreamTests.test_authenticator.<locals>.TestAuthenticator.associateWithStream�s���(�/�/��3r%N)r1r2r3r�r�r�)r�r�r�s���r#�TestAuthenticatorr��s���
1�
7�
4r%r�N�s<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='example.com' id='12345'>r)rr>rr�rE�lenr�)r!r��ar_r�r�r�s    @@@r#�test_authenticatorz!XmlStreamTests.test_authenticator�s����!����#%� �	4�	4�
���
�
 �
 ��
#�����"��7�8�
�������$��!4�5�
���
-�	
�
	
����C� 2�3�4�
���
����$��!4�5r%N)r1r2r3r�r�r�rIr�r�r�r�r�r�r�r�r�r�r�r�r5r%r#r�r��sS��#�!�#��"(�
(�7�
6�+�+�+� +�+� 	'�F�$6r%r�c��eZdZy)�	TestErrorN)r1r2r3r5r%r#r�r��s��r%r�c�*�eZdZd�Zd�Zd�Zd�Zd�Zy)�AuthenticatorTestsc�~�tj�|_tj|j�|_yry)rr�rHr>r*s r#rIzAuthenticatorTests.setUp�s+��&�4�4�6���"�,�,�T�-?�-?�@��r%c��|j}|jtj��|j	d�|jd|j�|jd|j�|jd|j�|jd|j�|jd|j�y)�e
        Test streamStart to fill the appropriate attributes from the
        stream header.
        ��<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='example.org' to='example.com' id='12345' version='1.0'>r�N�invalid)rrCr
rDrErr��assertIdenticalr�r=r�r�r�s  r#�test_streamStartz#AuthenticatorTests.test_streamStart�s���
�^�^��
���-�7�7�9�:�
���
�	
�	
�������,����T�2�6�6�*�����B�L�L�1����T�2�>�>�2�����r�}�}�-r%c��|j}|jtj��|j	d�|jd|j�y)z
        Test streamStart to fill the appropriate attributes from the
        stream header for a pre-XMPP-1.0 header.
        r��rrN�rrCr
rDrErr�r�s  r#�test_streamStartLegacyz)AuthenticatorTests.test_streamStartLegacy�sK��
�^�^��
���-�7�7�9�:�
���
-�	
�
	
�������,r%c��|j}|jtj��|j	d�|jd|j�y)z�
        Test streamStart to fill the appropriate attributes from the
        stream header for a version with only one digit.
        z<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='example.com' id='12345' version='1'>r�Nr�r�s  r#�test_streamBadVersionOneDigitz0AuthenticatorTests.test_streamBadVersionOneDigit�sK��
�^�^��
���-�7�7�9�:�
���
9�	
�
	
�������,r%c��|j}|jtj��|j	d�|jd|j�y)z}
        Test streamStart to fill the appropriate attributes from the
        stream header for a malformed version.
        z�<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='example.com' id='12345' version='blah'>r�Nr�r�s  r#�test_streamBadVersionNoNumberz0AuthenticatorTests.test_streamBadVersionNoNumber�sK��
�^�^��
���-�7�7�9�:�
���
<�	
�
	
�������,r%N)r1r2r3rIr�r�rrr5r%r#r�r��s��A�.�&-�-�-r%r�c�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�ConnectAuthenticatorTestsc�4�d|_d|_tjd�|_tj
|j�|_|jj
d|j�|jj
d|j�y)NFr��//event/stream/authd�//event/xmpp/initfailed)	�gotAuthenticated�initFailurerr<rHr>rn�onAuthenticated�onInitFailedr*s r#rIzConnectAuthenticatorTests.setUp	ss�� %������&�;�;�K�H���"�,�,�T�-?�-?�@������"�"�#9�4�;O�;O�P����"�"�#<�d�>O�>O�Pr%c��d|_yr�)rr�s  r#r
z)ConnectAuthenticatorTests.onAuthenticateds
�� $��r%c��||_yry)r	)r!r	s  r#rz&ConnectAuthenticatorTests.onInitFaileds
��"��r%c��Gd�d�}|�}|g|j_|jj�|j	g|jj�|j|j�y)zG
        Test successful completion of an initialization step.
        c��eZdZd�Zy)�9ConnectAuthenticatorTests.testSucces.<locals>.Initializerc��yryr5r*s r#�
initializezDConnectAuthenticatorTests.testSucces.<locals>.Initializer.initializes��r%N�r1r2r3rr5r%r#�Initializerrs��
r%rN)r�initializersrH�initializeStreamrrMr�r!r�inits   r#�
testSuccesz$ConnectAuthenticatorTests.testSuccessa��
	�	��}��'+�f����#����+�+�-�����T�^�^�8�8�9�����-�-�.r%c��Gd�d�}|�}|g|j_|jj�|j	|g|jj�|j|j�|jd|j�|j|jjt��y)z9
        Test failure of an initialization step.
        c��eZdZd�Zy)�:ConnectAuthenticatorTests.testFailure.<locals>.Initializerc��t�ry)r�r*s r#rzEConnectAuthenticatorTests.testFailure.<locals>.Initializer.initialize-s���r%Nrr5r%r#rr,s��
 r%rN)rrrHrrrir�assertNotIdenticalr	rM�checkr�rs   r#�testFailurez%ConnectAuthenticatorTests.testFailure's���
	 �	 ��}��'+�f����#����+�+�-����$�����!<�!<�=�����.�.�/�����d�&6�&6�7�����(�(�.�.�y�9�:r%c��d|j_|j}|jt	j
��|j
d�|jd|j�|jd|j�|jd|j�|jd|jj�|jd|j�|j|j�|j
d�|j!d|j"�|j%|j�y)	r�r:z�<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='example.com' to='example.org' id='12345' version='1.0'>r�r�example.comNz9<stream:features><test xmlns='testns'/></stream:features>�r:�test)rHr=rrCr
rDrErr�r�r��hostr�r�r�rrTr�rMr�s  r#r�z*ConnectAuthenticatorTests.test_streamStart9s���
(0����$�
�^�^��
���-�7�7�9�:�
���
�	
�	
�������,�����"�&�&�)�����2�<�<�0��������(;�(;�<����T�2�=�=�1����t�,�,�-�
���M�	
�	
�
�
�(�"�+�+�6�����-�-�.r%N)	r1r2r3rIr
rrr r�r5r%r#rrs!��Q�%�#�/� ;�$/r%rc�"�eZdZdZd�Zd�Zd�Zy)�ListenAuthenticatorTestsz4
    Tests for L{xmlstream.ListenAuthenticator}
    c�~�tj�|_tj|j�|_yry)r�ListenAuthenticatorrHr>r*s r#rIzListenAuthenticatorTests.setUpYs+��&�:�:�<���"�,�,�T�-?�-?�@��r%c� �|j}|jtj��|j	d|j
�|j
d�|jd|j�|jd|j
�|jd|j
�|jd|j�|j	d|j�|jd|jj�y)r�Nr�r�r�
jabber:clientr")rrCr
rDr�r�rErr�rr�r=r�r�r%r�s  r#r�z)ListenAuthenticatorTests.test_streamStart]s���
�^�^��
���-�7�7�9�:����T�2�6�6�*�
���
�	
�	
�������,�����b�f�f�-����G�R�V�V�,�����"�,�,�7����T�2�>�>�2������
�
�(:�(:�;r%c���|j}|jtj��|j	d�|j|jt�y)zD
        The generated session id must be a unicode object.
        r�N)rrCr
rDrE�assertIsInstancer��strr�s  r#� test_streamStartUnicodeSessionIDz9ListenAuthenticatorTests.test_streamStartUnicodeSessionIDrsK���^�^��
���-�7�7�9�:�
���
�	
�	
���b�f�f�c�*r%N)r1r2r3r4rIr�r/r5r%r#r'r'Ts���A�<�*+r%r'c�~�eZdZd�Zd�Zd�Zee�d��Zee�d��Z	ee�d��Z
d�Zd�Zd	�Z
d
�Zd�Zy)
�TLSInitiatingInitializerTestsc���g|_g|_tj|_tj
d�|_tj|j�|_|jj|j_	|jj�|jjd�tj|j�|_
y)Nr"r�)�output�donerr�savedSSLr<rHr>r�rRr�rE�TLSInitiatingInitializerrr*s r#rIz#TLSInitiatingInitializerTests.setUp�s��������	�!�
�
��
�&�;�;�M�J���"�,�,�T�-?�-?�@���"�k�k�0�0��������%�%�'����#�#�
;�	
�
�6�6�t�~�~�F��	r%c�.�|jt_yry)r5rrr*s r#�tearDownz&TLSInitiatingInitializerTests.tearDown�s
���
�
�	�
r%c��tj|jd��|_|j|jj�y)z>
        Passing required sets the instance variable.
        T)�requiredN)rr6rrMr:r*s r#�test_initRequiredz/TLSInitiatingInitializerTests.test_initRequired�s3���6�6�t�~�~�PT�U��	�����	�	�*�*�+r%c����tj��j_�fd��jj_�fd��j_�fd��j_�jj�}|j�jtj��jdt�j���jd}�jd|j��jt|j ��jj#dtz��jgd��j$�|S)	zN
        When TLS is wanted and SSL available, StartTLS is initiated.
        c�:���jjd�S�N�TLS�r4r�)�ctxr!s �r#�<lambda>zDTLSInitiatingInitializerTests.test_wantedSupported.<locals>.<lambda>�s����	�	�8H�8H��8O�r%c�:���jjd�S�Nr�r@r*s�r#rBzDTLSInitiatingInitializerTests.test_wantedSupported.<locals>.<lambda>�����t�y�y�'7�'7��'@�r%c�:���jjd�S�N�headerr@r*s�r#rBzDTLSInitiatingInitializerTests.test_wantedSupported.<locals>.<lambda>�����D�I�I�,<�,<�X�,F�r%�r�starttls�<proceed xmlns='%s'/>�r?r�rH)r
rDrrP�startTLSr�r�r�startr]r�Resetr�r3�name�NS_XMPP_TLS�urirEr4)r!r^rKs`  r#�test_wantedSupportedz2TLSInitiatingInitializerTests.test_wantedSupported�s����
$1�#@�#@�#B���� �,O���� � �)�@�����$F����!��I�I�O�O���	�
�
�d�&�&�	���8�����C����,�-��;�;�q�>������X�]�]�3�����h�l�l�3����#�#�$;�k�$I�J����3�T�Y�Y�?��r%c����fd�}tj��j_|�jj_�fd��j_�fd��j_�jj�}�jjdtz��jgd��j�|S)z:
        The server certificate will be verified.
        c����j|t��j|jd��jjd�y)Nr"r?)r-rr�	_hostnamer4r�)�contextFactoryr!s �r#�fakeStartTLSzJTLSInitiatingInitializerTests.test_certificateVerify.<locals>.fakeStartTLS�s<����!�!�.�2B�C����^�5�5�}�E��I�I���U�#r%c�:���jjd�SrDr@r*s�r#rBzFTLSInitiatingInitializerTests.test_certificateVerify.<locals>.<lambda>�rEr%c�:���jjd�SrGr@r*s�r#rBzFTLSInitiatingInitializerTests.test_certificateVerify.<locals>.<lambda>�rIr%rLrM)
r
rDrrPrNr�r�rrOrErRrr4)r!rYr^s`  r#�test_certificateVerifyz4TLSInitiatingInitializerTests.test_certificateVerify�s����	$�
$1�#@�#@�#B���� �,8���� � �)�@�����$F����!��I�I�O�O������#�#�$;�k�$I�J����3�T�Y�Y�?��r%c����t��tj�j����_��j_��fd�}tj��j_|�jj_�fd��j_	�fd��j_
�jj�}�jjdtz��jgd��j�|S)zH
        A custom contextFactory is passed through to startTLS.
        )�configurationForTLSc�`���j�|��jjd�yr>)�assertIsr4r�)rXrAr!s ��r#rYzQTLSInitiatingInitializerTests.test_certificateVerifyContext.<locals>.fakeStartTLS�s#����M�M�#�~�.��I�I���U�#r%c�:���jjd�SrDr@r*s�r#rBzMTLSInitiatingInitializerTests.test_certificateVerifyContext.<locals>.<lambda>�rEr%c�:���jjd�SrGr@r*s�r#rBzMTLSInitiatingInitializerTests.test_certificateVerifyContext.<locals>.<lambda>�rIr%rLrM)rrr6rrXr
rDrPrNr�r�rOrErRrr4)r!rYr^rAs`  @r#�test_certificateVerifyContextz;TLSInitiatingInitializerTests.test_certificateVerifyContext�s����
!�"���6�6��N�N��
��	�$'��	�	� �	$�$1�#@�#@�#B���� �,8���� � �)�@�����$F����!��I�I�O�O������#�#�$;�k�$I�J����3�T�Y�Y�?��r%c���dt_d|j_|jj	�}|j|jd�|j
dt|j��|S)zX
        No StartTLS is initiated when wanted, not required, SSL not available.
        NFr)	rrrr:rOr]rr�r3r�s  r#�"test_wantedNotSupportedNotRequiredz@TLSInitiatingInitializerTests.test_wantedNotSupportedNotRequired�sY���	�
�"��	�	���I�I�O�O���	�
�
�d�&�&��-�����C����,�-��r%c��dt_d|j_|jj	�}|j|tj�|jdt|j��|S)zS
        TLSNotSupported is raised when TLS is required but not available.
        NTr)
rrrr:rOrb�TLSNotSupportedrr�r3r�s  r#�test_wantedNotSupportedRequiredz=TLSInitiatingInitializerTests.test_wantedNotSupportedRequired�s[���	�
�!��	�	���I�I�O�O������1�i�7�7�8�����C����,�-��r%c��tjd�}|jd�|j|jf|i|j
_d|j_|jj�}|jdt|j��|j|t
j�|S)zW
        TLSRequired is raised when TLS is not wanted, but required by server.
        �rrKr:Fr)rr��
addElementrSrQrr�r�wantedrOrr�r3rb�TLSRequired�r!�tlsr^s   r#�test_notWantedRequiredz4TLSInitiatingInitializerTests.test_notWantedRequired�s����n�n�L�M�����z�"�$'�G�G�S�X�X�#6��"<����� ��	�	���I�I�O�O�������C����,�-����1�i�3�3�4��r%c�|�tjd�}|j|jf|i|j_d|j_d|j_|jj�}|j|jd�|jdt|j��|S)zL
        No StartTLS is initiated when not wanted and not required.
        rjFNr)rr�rSrQrr�rrlr:rOr]rr�r3rns   r#�test_notWantedNotRequiredz7TLSInitiatingInitializerTests.test_notWantedNotRequired
s����n�n�L�M��$'�G�G�S�X�X�#6��"<����� ��	�	��"��	�	���I�I�O�O���	�
�
�d�&�&��-�����C����,�-��r%c���dt_|jj�}|j	|tj
�|jj
dtz�|S)zN
        TLSFailed is raised when the server responds with a failure.
        rz<failure xmlns='%s'/>)rrrrOrb�	TLSFailedrErRr�s  r#�test_failedz)TLSInitiatingInitializerTests.test_failedsN���	�
��I�I�O�O������1�i�1�1�2����#�#�$;�k�$I�J��r%N)r1r2r3rIr8r;r�
skipWhenNoSSLrTr\rcrerhrprrrur5r%r#r1r1�sv��G�"&�,��]�����(�]�����(�]�����2��
��r%r1c��eZdZdZd�Zy)�TestFeatureInitializerr#c�,�tjd�Sry)r�succeedr*s r#rOzTestFeatureInitializer.start*s���}�}�T�"�"r%N)r1r2r3�featurerOr5r%r#rxrx's�� �G�#r%rxc�$�eZdZd�Zd�Zd�Zd�Zy)�%BaseFeatureInitiatingInitializerTestsc��tjtj��|_t|j�|_yry)rr>r�rxrr*s r#rIz+BaseFeatureInitiatingInitializerTests.setUp/s-��"�,�,�Y�-D�-D�-F�G���*�4�>�>�:��	r%c���|jjtj|jj�i|j_|jj
�S)zW
        Test that an advertized feature results in successful initialization.
        )rr{rr�rr�rr*s r#�testAdvertizedz4BaseFeatureInitiatingInitializerTests.testAdvertized3sE��$(�9�9�#4�#4�f�n�n�T�Y�Y�EV�EV�6W�"X������y�y�#�#�%�%r%c��d|j_|jtj|jj
�y)z�
        Test that when the feature is not advertized, but required by the
        initializer, an exception is raised.
        TN)rr:r(r�FeatureNotAdvertizedrr*s r#�testNotAdvertizedRequiredz?BaseFeatureInitiatingInitializerTests.testNotAdvertizedRequired:s0��
"��	�	�����)�8�8�$�)�)�:N�:N�Or%c�z�d|j_|jd|jj��y)z�
        Test that when the feature is not advertized, and not required by the
        initializer, the initializer silently succeeds.
        FN)rr:r�rr*s r#�testNotAdvertizedNotRequiredzBBaseFeatureInitiatingInitializerTests.testNotAdvertizedNotRequiredBs-��
#��	�	�����T�4�9�9�#7�#7�#9�:r%N)r1r2r3rIr�r�r�r5r%r#r}r}.s��;�&�P�;r%r}c�0�eZdZd�Zd�Zd�Zd�Zd�Zd�Zy)�ToResponseTestsc�N�tjd�}d|d<d|d<d|d<d|d	<tj|d
�}|j	||�|j|dd�|j|dd�|j|dd
�|j|d	d�y)zS
        Test that a response stanza is generated with addressing swapped.
        �r+rGr;rK�user1@example.com�to�user2@example.com/resource�from�stanza1rLrZN)rr�r�
toResponserr�r!�stanza�responses   r#�test_toResponsezToResponseTests.test_toResponseLs������ 7�8����v��*��t��5��v�� ��t���'�'���9�������1�����&�)�+>�?�����$��)E�F�����&�)�8�4�����$���3r%c���tjd�}d|d<d|d<tj|�}|j	|dd�|j|j
d��y)zY
        Test that a response is generated from a stanza without a from address.
        r�r;rKr�r�r�N)rr�rr�rri�hasAttributer�s   r#�test_toResponseNoFromz%ToResponseTests.test_toResponseNoFrom\sd����� 7�8����v��*��t���'�'��/������&�)�+>�?�����.�.�t�4�5r%c���tjd�}d|d<d|d<tj|�}|j	|jd��|j
|dd�y)zW
        Test that a response is generated from a stanza without a to address.
        r�r;rKr�r�r�N)rr�rr�rir�rr�s   r#�test_toResponseNoToz#ToResponseTests.test_toResponseNoTogsc����� 7�8����v��5��v���'�'��/������.�.�v�6�7�����$��)E�Fr%c���tjd�}d|d<tj|�}|j	|jd��|j	|jd��y)zY
        Test that a response is generated from a stanza without any addressing.
        �r+�message�chatrKr�r�N�rr�rr�rir�r�s   r#�test_toResponseNoAddressingz+ToResponseTests.test_toResponseNoAddressingrs^����� <�=����v���'�'��/������.�.�t�4�5�����.�.�v�6�7r%c��tjd�}tj|�}|j	|jd��y)zP
        Test that a proper response is generated without id attribute.
        r�rLNr�r�s   r#�	test_noIDzToResponseTests.test_noID|s<����� <�=���'�'��/������.�.�t�4�5r%c��tjd�}tj|�}|j	|jd��y)zR
        Test that a proper response is generated without type attribute.
        r�rKNr�r�s   r#�test_noTypezToResponseTests.test_noType�s<����� <�=���'�'��/������.�.�v�6�7r%N)	r1r2r3r�r�r�r�r�r�r5r%r#r�r�Ks!��4� 	6�	G�8�6�8r%r�c��eZdZdZd�Zd�Zy)�DummyFactoryzJ
    Dummy XmlStream factory that only registers bootstrap observers.
    c��i|_yry��	callbacksr*s r#�__init__zDummyFactory.__init__�s	����r%c�"�||j|<yryr�)r!�event�callbacks   r#�addBootstrapzDummyFactory.addBootstrap�s�� (����u�r%N)r1r2r3r4r�r�r5r%r#r�r��s����)r%r�c�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)�DummyXMPPHandlerzO
    Dummy XMPP subprotocol handler to count the methods are called on it.
    c�.�d|_d|_d|_y)Nr)�doneMade�doneInitialized�doneLostr*s r#r�zDummyXMPPHandler.__init__�s����
� �����
r%c�$�|j�yry)r�r�s  r#rCzDummyXMPPHandler.makeConnection�s�����r%c�.�|xjdz
c_y�Nr�r�r*s r#r�zDummyXMPPHandler.connectionMade�����
�
���
r%c�.�|xjdz
c_yr�)r�r*s r#�connectionInitializedz&DummyXMPPHandler.connectionInitialized�s������!�r%c�.�|xjdz
c_yr�)r��r!�reasons  r#ruzDummyXMPPHandler.connectionLost�r�r%N)	r1r2r3r4r�rCr�r�rur5r%r#r�r��s ����
��"�r%r�c��eZdZdZd�Zd�Zy)�FailureReasonXMPPHandlerz>
    Dummy handler specifically for failure Reason tests.
    c��d|_y)NF)�gotFailureReasonr*s r#r�z!FailureReasonXMPPHandler.__init__�s
�� %��r%c�H�t|tj�rd|_yyr�)�
isinstancer	�Failurer�r�s  r#ruz'FailureReasonXMPPHandler.connectionLost�s���f�g�o�o�.�$(�D�!�/r%N)r1r2r3r4r�rur5r%r#r�r��s���&�)r%r�c�(�eZdZdZd�Zd�Zd�Zd�Zy)�XMPPHandlerTestsz-
    Tests for L{xmlstream.XMPPHandler}.
    c�\�ttjtj��y)zN
        L{xmlstream.XMPPHandler} implements L{ijabber.IXMPPHandler}.
        N)rr
�IXMPPHandlerr�XMPPHandlerr*s r#�test_interfacezXMPPHandlerTests.test_interface�s��	�W�)�)�9�+@�+@�+B�Cr%c���Gd�d�}tj�}|�|_|jd�|j	dg|jj
�y)zP
        Test that data is passed on for sending by the stream manager.
        c��eZdZd�Zd�Zy)�6XMPPHandlerTests.test_send.<locals>.DummyStreamManagerc��g|_yry)�outlistr*s r#r�z?XMPPHandlerTests.test_send.<locals>.DummyStreamManager.__init__�s	��!��r%c�:�|jj|�yry)r�r�)r!�datas  r#rRz;XMPPHandlerTests.test_send.<locals>.DummyStreamManager.send�s�����#�#�D�)r%N)r1r2r3r�rRr5r%r#�DummyStreamManagerr��s��
"�
*r%r�r�N)rr��parentrRrr�)r!r��handlers   r#r�zXMPPHandlerTests.test_send�sN��
	*�	*��'�'�)��+�-������]�#����-��'�.�.�*@�*@�Ar%c�"�Gd�dtj�}|�}tjtj��}|j	|�|j|j�|j||j�y)zY
        Test that makeConnection saves the XML stream and calls connectionMade.
        c��eZdZd�Zy)�=XMPPHandlerTests.test_makeConnection.<locals>.TestXMPPHandlerc��d|_yr�r�r*s r#r�zLXMPPHandlerTests.test_makeConnection.<locals>.TestXMPPHandler.connectionMade�s	�� $��
r%N)r1r2r3r�r5r%r#�TestXMPPHandlerr��s��
%r%r�N)rr�r>r�rCrMr�r�)r!r�r�r_s    r#�test_makeConnectionz$XMPPHandlerTests.test_makeConnection�sm��
	%�i�3�3�	%�"�#��
�
 �
 ��!8�!8�!:�
;�����r�"�����(�(�)����R��!2�!2�3r%c��tj�}tjtj��}|j	|�|jt
��|jd|j�y)zB
        Test that connectionLost forgets the XML stream.
        N)rr�r>r�rCru�	Exceptionr�)r!r�r_s   r#�test_connectionLostz$XMPPHandlerTests.test_connectionLost�s_���'�'�)��
�
 �
 ��!8�!8�!:�
;�����r�"����y�{�+����T�7�#4�#4�5r%N)r1r2r3r4r�r�r�r�r5r%r#r�r��s���D�B�"
4�6r%r�c�(�eZdZdZd�Zd�Zd�Zd�Zy)�XMPPHandlerCollectionTestsz7
    Tests for L{xmlstream.XMPPHandlerCollection}.
    c�6�tj�|_yry)r�XMPPHandlerCollection�
collectionr*s r#rIz XMPPHandlerCollectionTests.setUp�s��#�9�9�;��r%c�L�ttj|j�y)zZ
        L{xmlstream.StreamManager} implements L{ijabber.IXMPPHandlerCollection}.
        N)rr
�IXMPPHandlerCollectionr�r*s r#r�z)XMPPHandlerCollectionTests.test_interface�s��	�W�3�3�T�_�_�Er%c���t�}|j|j�|j||j�|j	|j|j
�y)z:
        Test the addition of a protocol handler.
        N)r��setHandlerParentr�rTr�r��r!r�s  r#�test_addHandlerz*XMPPHandlerCollectionTests.test_addHandlersH��#�$��� � ����1��
�
�g�t���/����T�_�_�g�n�n�=r%c���t�}|j|j�|j|j�|j	||j�|jd|j�y)z5
        Test removal of a protocol handler.
        N)r�r�r��disownHandlerParentrqr�r�r�s  r#�test_removeHandlerz-XMPPHandlerCollectionTests.test_removeHandler
sX��#�$��� � ����1��#�#�D�O�O�4�����$�/�/�2����T�7�>�>�2r%N)r1r2r3r4rIr�r�r�r5r%r#r�r��s���<�F�>�3r%r�c�d�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zy)�StreamManagerTestsz/
    Tests for L{xmlstream.StreamManager}.
    c�L�t�}tj|�|_yry)r�r�
StreamManager�
streamManager)r!�factorys  r#rIzStreamManagerTests.setUps���.��&�4�4�W�=��r%c�$�|j}|jd|j�|jg|j�|j|j
|jjd�|j|j|jjd�|j|j|jjd�|j|j|jjd�y)zM
        Test correct initialization and setup of factory observers.
        Nz//event/stream/connectedrr�r)r�r�rr�handlers�
_connectedr�r��_authd�
_disconnected�initializationFailed)r!�sms  r#r$zStreamManagerTests.test_basics����
�
�����T�2�<�<�0�����R�[�[�)�����M�M�2�:�:�/�/�0J�K�	
�	
������B�J�J�$8�$8�9O�$P�Q�����)�)�2�:�:�+?�+?�@T�+U�V�����#�#�R�Z�Z�%9�%9�:S�%T�	
r%c�j�|j}t�}|j|�tjtj
��}|j
|�|jd|j�|jd|j�|jd|j�y)z
        Test that protocol handlers have their connectionMade method called
        when the XML stream is connected.
        rrN)r�r�r�rr>r�r�rr�r�r��r!r�r�r_s    r#�test_connectedz!StreamManagerTests.test_connected.s���
�
�
��"�$��� � ��$�
�
 �
 ��!8�!8�!:�
;��
�
�
�b������G�,�,�-�����G�3�3�4�����G�,�,�-r%c�2�|j}t�}|j|�tjtj
��}|j
|�|jd|j�|jd|j�y)zP
        Test raw data functions unset when logTraffic is set to False.
        N)
r�r�r�rr>r�r�r��rawDataInFn�rawDataOutFnr�s    r#�test_connectedLogTrafficFalsez0StreamManagerTests.test_connectedLogTrafficFalse<sr���
�
��"�$��� � ��$�
�
 �
 ��!8�!8�!:�
;��
�
�
�b�����T�2�>�>�2����T�2�?�?�3r%c�@�|j}d|_t�}|j|�t	j
t	j��}|j|�|jd|j�|jd|j�y)zM
        Test raw data functions set when logTraffic is set to True.
        TN)r��
logTrafficr�r�rr>r�r�rr�r�r�s    r#�test_connectedLogTrafficTruez/StreamManagerTests.test_connectedLogTrafficTrueHsy���
�
����
�"�$��� � ��$�
�
 �
 ��!8�!8�!:�
;��
�
�
�b������b�n�n�5�����b�o�o�6r%c�j�|j}t�}|j|�tjtj
��}|j
|�|jd|j�|jd|j�|jd|j�y)z�
        Test that protocol handlers have their connectionInitialized method
        called when the XML stream is initialized.
        rrN)r�r�r�rr>r�r�rr�r�r�r�s    r#�
test_authdzStreamManagerTests.test_authdUs���
�
�
��"�$��� � ��$�
�
 �
 ��!8�!8�!:�
;��
�	�	�"�
�����G�,�,�-�����G�3�3�4�����G�,�,�-r%c�j�|j}t�}|j|�tjtj
��}|j
|�|jd|j�|jd|j�|jd|j�y)z�
        Test that protocol handlers have their connectionLost method
        called when the XML stream is disconnected.
        rrN)r�r�r�rr>r�r�rr�r�r�r�s    r#�test_disconnectedz$StreamManagerTests.test_disconnectedcs���
�
�
��"�$��� � ��$�
�
 �
 ��!8�!8�!:�
;��
���������G�,�,�-�����G�3�3�4�����G�,�,�-r%c���|j}t�}|j|�|jt	j
t
d���|jd|j�y)z�
        A L{STREAM_END_EVENT} results in L{StreamManager} firing the handlers
        L{connectionLost} methods, passing a L{failure.Failure} reason.
        z	no reasonTN)	r�r�r�r�r	r�r�rr��r!r�r�s   r#�test_disconnectedReasonz*StreamManagerTests.test_disconnectedReasonqsW��
�
�
��*�,��� � ��$�
�������;�)?�@�A�����w�7�7�8r%c��|j}t�}|j|�|jd|j�|jd|j
�|jd|j�y)zN
        Test the addition of a protocol handler while not connected.
        rN)r�r�r�rr�r�r�rs   r#r�z"StreamManagerTests.test_addHandler|sg���
�
��"�$��� � ��$�����G�,�,�-�����G�3�3�4�����G�,�,�-r%c��|j}tjtj��}|j	|�|j|�t
�}|j|�|jd|j�|jd|j�|jd|j�y)a
        Test the addition of a protocol handler after the stream
        have been initialized.

        Make sure that the handler will have the connected stream
        passed via C{makeConnection} and have C{connectionInitialized}
        called.
        rrN)r�rr>r�r�r�r�r�rr�r�r�)r!r�r_r�s    r#�test_addHandlerInitializedz-StreamManagerTests.test_addHandlerInitialized�s����
�
��
�
 �
 ��!8�!8�!:�
;��
�
�
�b��
�	�	�"�
�"�$��� � ��$�����G�,�,�-�����G�3�3�4�����G�,�,�-r%c��tjtj��}tj|�}|j	d�}tj�|_|j�|jd�|j|d�|jd�|jd|jj��y)z�
        Test send when the stream has been initialized.

        The data should be sent directly over the XML stream.
        Nr�rr�r�)r�XmlStreamFactoryr�r��
buildProtocolr
rDrPr�rE�dispatchrRrrU�r!r�r�r_s    r#�test_sendInitializedz'StreamManagerTests.test_sendInitialized�s����,�,�Y�-D�-D�-F�G��
�
$�
$�W�
-��
�
"�
"�4�
(��$�4�4�6���
����
���
-�	
�
	���B�.�/�
���
���������);�);�)=�>r%c�<�tjtj��}tj|�}t	�}|j|�|j
d�}tj�|_	|jd�|jd|jj��|jd|jd�|j�|jd|jj��|jd|jd�|jd�|j!|d�|jd|jj��|j#|j�y)z�
        Test send when there is no established XML stream.

        The data should be cached until an XML stream has been established and
        initialized.
        Nr�r%rr�rr�)rr
r�r�r��
addHandlerrr
rDrPrRrrU�_packetQueuer�rErri�r!r�r�r�r_s     r#�test_sendNotConnectedz(StreamManagerTests.test_sendNotConnected�s6���,�,�Y�-D�-D�-F�G��
�
$�
$�W�
-��"�$��
�
�
�g��
�
"�
"�4�
(��$�4�4�6���
���
������b�l�l�0�0�2�3���������(:�;�
��������b�l�l�0�0�2�3���������(:�;�
���
-�	
�
	���B�.�/��������);�);�)=�>�������)r%c���tjtj��}tj|�}|j	d�}tj�|_|j�|jd�|jd�|jd|jj��|jd|jd�y)z�
        Test send when the stream is connected but not yet initialized.

        The data should be cached until the XML stream has been initialized.
        Nr�r�r%r)rr
r�r�rr
rDrPr�rErRrrUrrs    r#�test_sendNotInitializedz*StreamManagerTests.test_sendNotInitialized�s����,�,�Y�-D�-D�-F�G��
�
$�
$�W�
-��
�
"�
"�4�
(��$�4�4�6���
����
���
-�	
�
	���
������b�l�l�0�0�2�3���������(:�;r%c��tjtj��}tj|�}t	�}|j|�|j
d�}|j�tj�|_
|jd�|jd�|jd|jj��|jd|jd�y)z�
        Test send after XML stream disconnection.

        The data should be cached until a new XML stream has been established
        and initialized.
        Nr�r%r)rr
r�r�r�rrr�r
rDrPrurRrrUrrs     r#�test_sendDisconnectedz(StreamManagerTests.test_sendDisconnected�s����,�,�Y�-D�-D�-F�G��
�
$�
$�W�
-��"�$��
�
�
�g��
�
"�
"�4�
(��
����$�4�4�6���
���$��
���
������b�l�l�0�0�2�3���������(:�;r%N)r1r2r3r4rIr$r�r�rrrrr�rrrrrr5r%r#r�r�sN���>�
� .�
4�7�.�.�	9�
.�.�(?�(*�@<�(<r%r�c�.�eZdZdZd�Zd�Zd�Zd�Zd�Zy)�XmlStreamServerFactoryTestsz8
    Tests for L{xmlstream.XmlStreamServerFactory}.
    c�X��Gd�d���fd�}tj|�|_y)zQ
        Set up a server factory with an authenticator factory function.
        c��eZdZd�Zd�Zy)�<XmlStreamServerFactoryTests.setUp.<locals>.TestAuthenticatorc��g|_yry)�
xmlstreamsr*s r#r�zEXmlStreamServerFactoryTests.setUp.<locals>.TestAuthenticator.__init__s	��"$��r%c�:�|jj|�yry)r!r�r�s  r#r�zPXmlStreamServerFactoryTests.setUp.<locals>.TestAuthenticator.associateWithStreams�����&�&�r�*r%N)r1r2r3r�r�r5r%r#r�rs��
%�
+r%r�c�����Sryr5)r�s�r#�authenticatorFactoryz?XmlStreamServerFactoryTests.setUp.<locals>.authenticatorFactorys���$�&�&r%N)r�XmlStreamServerFactoryr�)r!r$r�s  @r#rIz!XmlStreamServerFactoryTests.setUp�s'���
	+�	+�	'�!�7�7�8L�M��r%c�8�tt|j�y)z<
        L{XmlStreamServerFactory} is a L{Factory}.
        N)rrr�r*s r#r�z*XmlStreamServerFactoryTests.test_interfaces��	�%�t�|�|�4r%c��|jjd�}|j|g|jj�y)a�
        The authenticator factory should be used to instantiate the
        authenticator and pass it to the protocol.

        The default protocol, L{XmlStream} stores the authenticator it is
        passed, and calls its C{associateWithStream} method. so we use that to
        check whether our authenticator factory is used and the protocol
        instance gets an authenticator.
        N)r�rrrHr!r�s  r#�,test_buildProtocolAuthenticatorInstantiationzHXmlStreamServerFactoryTests.test_buildProtocolAuthenticatorInstantiations6���\�\�
'�
'��
-�����"��r�/�/�:�:�;r%c�z�|jjd�}|j|tj�y)zV
        The protocol factory creates Jabber XML Stream protocols by default.
        N)r�rr-rr>r�s  r#�test_buildProtocolXmlStreamz7XmlStreamServerFactoryTests.test_buildProtocolXmlStream#s.���\�\�
'�
'��
-�����b�)�"5�"5�6r%c���|jjd�}|jjd�}|j||�|j|j|j�y)z�
        Subsequent calls to buildProtocol should result in different instances
        of the protocol, as well as their authenticators.
        N)r�rrrH)r!�xs1�xs2s   r#�test_buildProtocolTwicez3XmlStreamServerFactoryTests.test_buildProtocolTwice*sX��
�l�l�(�(��.���l�l�(�(��.������S�)����� 1� 1�3�3D�3D�Er%N)	r1r2r3r4rIr�r(r*r.r5r%r#rr�s"���N�"5�<�7�Fr%r)9r4rr�zope.interface.verifyr�twisted.internetrr�twisted.internet.errorr�twisted.internet.interfacesr�twisted.pythonr	�twisted.testr
�
twisted.trial�twisted.words.protocols.jabberrr
rr�!twisted.words.test.test_xmlstreamr�twisted.words.xishrr�_sslrv�twisted.internet._sslverifyr�twisted.internet.sslr�ImportErrorrR�TestCaserr7r�r�r�r�rr'r1� BaseFeatureInitiatingInitializerrxr}r�r�r�r�r�r�r�r�rr5r%r#�<module>r?s�����.�(�1�8�"�&�"�I�I�O�%�	8�,�
�C��M�<�7�/��K��)�)�K�@_�h���_�DX6�X�&�&�X6�v	�	�	�@-��*�*�@-�FI/�� 1� 1�I/�X*+�x�0�0�*+�Zc�H�$5�$5�c�L#�Y�G�G�#�;�H�,=�,=�;�:?8�h�'�'�?8�D	)�	)��y�,�,��.
)�y�4�4�
)�36�x�(�(�36�l3��!2�!2�3�Db<��*�*�b<�J8F�"C�8F��E'�0�
�C�/�M�0�s�G�	G�G

Zerion Mini Shell 1.0