%PDF- %PDF-
Mini Shell

Mini Shell

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

�

Ϫ�f�#���ddlmZddlmZddlmZddlmZmZm	Z	m
Z
ddlmZdZ
ee	j�Gd�d��ZGd	�d
ej �ZGd�dej$�ZGd
�dej$�Zy)�)�implementer)�defer)�unittest)�jid�sasl�sasl_mechanisms�	xmlstream)�domish� urn:ietf:params:xml:ns:xmpp-saslc�.�eZdZdZdZdZdZd�Zd�Zd�Z	y)�DummySASLMechanisma�
    Dummy SASL mechanism.

    This just returns the initialResponse passed on creation, stores any
    challenges and replies with the value of C{response}.

    @ivar challenge: Last received challenge.
    @type challenge: C{unicode}.
    @ivar initialResponse: Initial response to be returned when requested
                           via C{getInitialResponse} or L{None}.
    @type initialResponse: C{unicode}
    N�DUMMY�c��||_y�N��initialResponse)�selfrs  �D/usr/lib/python3/dist-packages/twisted/words/test/test_jabbersasl.py�__init__zDummySASLMechanism.__init__"s
��.��rc��|jSrr�rs r�getInitialResponsez%DummySASLMechanism.getInitialResponse%s���#�#�#rc�(�||_|jSr)�	challenge�response)rrs  r�getResponsezDummySASLMechanism.getResponse(s��"����}�}�r)
�__name__�
__module__�__qualname__�__doc__r�namerrrr�rrr
r
s'����I��D��H�/�$�rr
c��eZdZdZdZd�Zy)�DummySASLInitiatingInitializerac
    Dummy SASL Initializer for initiating entities.

    This hardwires the SASL mechanism to L{DummySASLMechanism}, that is
    instantiated with the value of C{initialResponse}.

    @ivar initialResponse: The initial response to be returned by the
                           dummy SASL mechanism or L{None}.
    @type initialResponse: C{unicode}.
    Nc�8�t|j�|_yr)r
r�	mechanismrs r�setMechanismz+DummySASLInitiatingInitializer.setMechanism;s��+�D�,@�,@�A��r)rrr r!rr(r#rrr%r%-s��	��O�Brr%c�R�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zy
)�SASLInitiatingInitializerTestsz5
    Tests for L{sasl.SASLInitiatingInitializer}
    c�t�g|_tj�|_tj|j�|_|jj
|j_|jj�|jjd�t|j�|_
y)Ns�<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='example.com' id='12345' version='1.0'>)�outputr	�
Authenticator�
authenticator�	XmlStream�append�send�connectionMade�dataReceivedr%�initrs r�setUpz$SASLInitiatingInitializerTests.setUpDs������&�4�4�6���"�,�,�T�-?�-?�@���"�k�k�0�0��������%�%�'����#�#�
<�	
�
3�4�>�>�B��	rc���tjd�}|jd�tj��j
_�j
j|��j�j
jtj��j
jj�fd���j
jS)zL
        Test that the SASL error condition is correctly extracted.
        )r�failure�not-authorizedc�<���jd|j�S)Nr8)�assertEqual�	condition)�ers �r�<lambda>z?SASLInitiatingInitializerTests.test_onFailure.<locals>.<lambda>\s���d�&�&�'7����E�r)r
�Element�
addElementr�Deferredr4�	_deferred�	onFailure�
assertFailurer�
SASLAuthError�addCallback)rr7s` r�test_onFailurez-SASLInitiatingInitializerTests.test_onFailureRs�����.�.�!P�Q�����+�,�#�n�n�.��	�	���	�	���G�$����4�9�9�.�.��0B�0B�C��	�	���'�'�E�	
��y�y�"�"�"rc�P�d|j_|jj�|jd}|j	t
|j�|j	d|j�|j	d|d�|j	dt|��y)zH
        Test starting authentication with an initial response.
        sdummyr�authrr'zZHVtbXk=N)	r4r�startr,r:�NS_XMPP_SASL�urir"�str�rrHs  r�test_sendAuthInitialResponsez;SASLInitiatingInitializerTests.test_sendAuthInitialResponse`s|��%-��	�	�!��	�	�����{�{�1�~������t�x�x�0��������+�����$�{�"3�4�����S��Y�/rc��d|j_|jj�|jd}|j	dt|��y)zK
        Test starting authentication without an initial response.
        Nr��r4rrIr,r:rLrMs  r�test_sendAuthNoInitialResponsez=SASLInitiatingInitializerTests.test_sendAuthNoInitialResponsels?��%)��	�	�!��	�	�����{�{�1�~������S��Y�'rc��d|j_|jj�|jd}|j	dt|��y)zS
        Test starting authentication where the initial response is empty.
        rr�=NrQrMs  r�!test_sendAuthEmptyInitialResponsez@SASLInitiatingInitializerTests.test_sendAuthEmptyInitialResponseus?��%(��	�	�!��	�	�����{�{�1�~������c�$�i�(rc�^�|jj�}tjtdf�}|jd�|jj
|�|jd|jjj�|jjd�|S)z5
        Test receiving a challenge message.
        r�bXkgY2hhbGxlbmdlsmy challengeN)r4rIr
r>rJ�
addContent�onChallenger:r'r�	onSuccess�r�drs   r�test_onChallengez/SASLInitiatingInitializerTests.test_onChallenge~s��
�I�I�O�O����N�N�L�+�#>�?�	����/�0��	�	���i�(�����$�)�)�*=�*=�*G�*G�H��	�	���D�!��rc��|jj�}tjtdf�}|jd�d|jj_|jj|�|jd}|jdt|��|jjd�|S)zS
        A non-empty response gets encoded and included as character data.
        rrWsresponse�zcmVzcG9uc2U=N)
r4rIr
r>rJrXr'rrYr,r:rLrZ)rr\rrs    r�test_onChallengeResponsez7SASLInitiatingInitializerTests.test_onChallengeResponse�s���
�I�I�O�O����N�N�L�+�#>�?�	����/�0�'2��	�	���$��	�	���i�(��;�;�q�>�������X��7��	�	���D�!��rc�<�|jj�}tjtdf�}|jj|�|j
d|jjj�|jjd�|S)z<
        Test receiving an empty challenge message.
        rrN)
r4rIr
r>rJrYr:r'rrZr[s   r�test_onChallengeEmptyz4SASLInitiatingInitializerTests.test_onChallengeEmpty�sp��
�I�I�O�O����N�N�L�+�#>�?�	��	�	���i�(�����d�i�i�1�1�;�;�<��	�	���D�!��rc��|jj�}tjtdf�}|jd�|jj
|�|j|tj�|S)zJ
        Test receiving a challenge message with illegal padding.
        rzbXkg=Y2hhbGxlbmdl�
r4rIr
r>rJrXrYrCr�SASLIncorrectEncodingErrorr[s   r�test_onChallengeIllegalPaddingz=SASLInitiatingInitializerTests.test_onChallengeIllegalPadding��c��
�I�I�O�O����N�N�L�+�#>�?�	����0�1��	�	���i�(����1�d�=�=�>��rc��|jj�}tjtdf�}|jd�|jj
|�|j|tj�|S)zM
        Test receiving a challenge message with illegal characters.
        rzbXkg*Y2hhbGxlbmdlrdr[s   r�!test_onChallengeIllegalCharactersz@SASLInitiatingInitializerTests.test_onChallengeIllegalCharacters�rgrc��|jj�}tjtdf�}|jd�|jj
|�|j|tj�|S)z?
        Test receiving a malformed challenge message.
        r�ardr[s   r�test_onChallengeMalformedz8SASLInitiatingInitializerTests.test_onChallengeMalformed�sb��
�I�I�O�O����N�N�L�+�#>�?�	����S�!��	�	���i�(����1�d�=�=�>��rN)rrr r!r5rFrNrRrUr]r`rbrfrirlr#rrr*r*?s?���C�#�
0�(�)�
��	�	�	�	rr*c�:�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
y	)
�*SASLInitiatingInitializerSetMechanismTestszB
    Test for L{sasl.SASLInitiatingInitializer.setMechanism}.
    c��g|_tj�|_tj|j�|_|jj
|j_|jj�|jjd�tj|j�|_y)Nz�<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' from='example.com' id='12345' version='1.0'>)r,r	r-r.r/r0r1r2r3r�SASLInitiatingInitializerr4rs rr5z0SASLInitiatingInitializerSetMechanismTests.setUp�s������&�4�4�6���"�,�,�T�-?�-?�@���"�k�k�0�0��������%�%�'����#�#�
;�	
��2�2�4�>�>�B��	rc�0�tjtdf�}|jd|��||jj
|j|jf<|jj�|jjjS)zX
        Set up the XML Stream to have a SASL feature with the given mechanism.
        �
mechanismsr')�content)r
r>rJr?r	�featuresrKr"r4r(r')rr"�features   r�
_setMechanismz8SASLInitiatingInitializerSetMechanismTests._setMechanism�sq���.�.�,��!=�>�����;���5�?F���������g�l�l� ;�<��	�	��� ��y�y�"�"�'�'�'rc��tjd�|j_d|j_d}|j	||j|��y)zI
        Test setting ANONYMOUS as the authentication mechanism.
        �example.comN�	ANONYMOUS�r�JIDr.�passwordr:rv�rr"s  r�test_anonymousz9SASLInitiatingInitializerSetMechanismTests.test_anonymous�sI��"%����!7�����&*����#�������t�1�1�$�7�8rc��tjd�|j_d|j_d}|j	||j|��y)zE
        Test setting PLAIN as the authentication mechanism.
        �test@example.com�secret�PLAINNrzr}s  r�
test_plainz5SASLInitiatingInitializerSetMechanismTests.test_plain�sJ��"%���);�!<�����&.����#�������t�1�1�$�7�8rc��tjd�|j_d|j_d}|j	||j|��y)zJ
        Test setting DIGEST-MD5 as the authentication mechanism.
        r�r�z
DIGEST-MD5Nrzr}s  r�test_digestz6SASLInitiatingInitializerSetMechanismTests.test_digest�sJ��"%���);�!<�����&.����#�������t�1�1�$�7�8rc���tjd�|j_d|j_|j	t
j|jd�y)zK
        Test using an unacceptable SASL authentication mechanism.
        r�r��SOMETHING_UNACCEPTABLEN�rr{r.r|�assertRaisesr�SASLNoAcceptableMechanismrvrs r�test_notAcceptablez=SASLInitiatingInitializerSetMechanismTests.test_notAcceptablesL��
"%���);�!<�����&.����#�����*�*�D�,>�,>�@X�	
rc���tjd�|j_d|j_|j	t
j|jd�y)zW
        Test using an unacceptable SASL authentication mechanism with no JID.
        rxr�r�Nr�rs r�test_notAcceptableWithoutUserzHSASLInitiatingInitializerSetMechanismTests.test_notAcceptableWithoutUsersK��"%����!7�����&.����#�����*�*�D�,>�,>�@X�	
rN)rrr r!r5rvr~r�r�r�r�r#rrrnrn�s+���
C�	(�9�9�9�

�	
rrnN)�zope.interfacer�twisted.internetr�
twisted.trialr�twisted.words.protocols.jabberrrrr	�twisted.words.xishr
rJ�ISASLMechanismr
rpr%�TestCaser*rnr#rr�<module>r�s��
'�"�"�P�P�%�1��
�_�
+�
+�,���-��:B�T�%C�%C�B�$C�X�%6�%6�C�LR
��1B�1B�R
r

Zerion Mini Shell 1.0