HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3/dist-packages/twisted/words/test/__pycache__/test_jabbersaslmechanisms.cpython-38.pyc
U


W[~�@srdZddlmZmZddlmZddlmZddlm	Z	Gdd�dej
�ZGdd	�d	ej
�ZGd
d�dej
�Z
dS)
z>
Tests for L{twisted.words.protocols.jabber.sasl_mechanisms}.
�)�absolute_import�division)�unittest)�
networkString)�sasl_mechanismsc@seZdZdZdd�ZdS)�
PlainTestszL
    Tests for L{twisted.words.protocols.jabber.sasl_mechanisms.Plain}.
    cCs"t�ddd�}|�|��d�dS)z,
        Test the initial response.
        N�test�secretstestsecret)rZPlain�assertEqual�getInitialResponse��self�m�r�N/usr/lib/python3/dist-packages/twisted/words/test/test_jabbersaslmechanisms.py�test_getInitialResponsesz"PlainTests.test_getInitialResponseN��__name__�
__module__�__qualname__�__doc__rrrrrrsrc@seZdZdZdd�ZdS)�AnonymousTestszP
    Tests for L{twisted.words.protocols.jabber.sasl_mechanisms.Anonymous}.
    cCst��}|�|��d�dS)z8
        Test the initial response to be empty.
        N)rZ	Anonymousr
rrrrrr sz&AnonymousTests.test_getInitialResponseNrrrrrrsrc@sXeZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�DigestMD5TestszP
    Tests for L{twisted.words.protocols.jabber.sasl_mechanisms.DigestMD5}.
    cCst�ddddd�|_dS)N�xmppzexample.orgrr	)r�	DigestMD5�	mechanism�r
rrr�setUp-s�zDigestMD5Tests.setUpcCs|�|j��d�dS)z=
        Test that no initial response is generated.
        N)ZassertIdenticalrrrrrrr2sz&DigestMD5Tests.test_getInitialResponsec
CsFd}|j�|j�|��}|d=|d=|�ddddgdd	d
d�|�dS)
zl
        The response to a Digest-MD5 challenge includes the parameters from the
        challenge.
        sJrealm="localhost",nonce="1234",qop="auth",charset=utf-8,algorithm=md5-sess�cnonce�response�test�1234�00000001�auth�utf-8s	localhost�xmpp/example.org�susername�noncesnc�qop�charset�realms
digest-uriN�r�_parse�getResponser
�r
�	challengeZ
directivesrrr�test_getResponse9s"�
���zDigestMD5Tests.test_getResponsec
CsFd}|j�|j�|��}|d=|d=|�ddddgdd	d
d�|�dS)
zs
        Bytes outside the ASCII range in the challenge are nevertheless
        included in the response.
        sSrealm="échec.example.org",nonce="1234",qop="auth",charset=utf-8,algorithm=md5-sessrrr r!r"r#r$�échec.example.orgr%r&Nr+r.rrr�test_getResponseNonAsciiRealmKs 
���z,DigestMD5Tests.test_getResponseNonAsciiRealmcCs,d}|j�|j�|��}|�|dd�dS)zq
        The response to a challenge without a realm uses the host part of the
        JID as the realm.
        �8nonce="1234",qop="auth",charset=utf-8,algorithm=md5-sessr*sexample.orgNr+r.rrr�test_getResponseNoRealm\s

�z&DigestMD5Tests.test_getResponseNoRealmcCs@t�ddddd�|_d}|j�|j�|��}|�|dd�dS)	z�
        If the challenge does not include a realm and the host part of the JID
        includes bytes outside of the ASCII range, the response still includes
        the host part of the JID as the realm.
        ruéchec.example.orgNrr	r3r*r1)rrrr,r-r
r.rrr�test_getResponseNoRealmIDNgs�
�z)DigestMD5Tests.test_getResponseNoRealmIDNcCs d}|j�|�}|�d|�dS)zW
        If the challenge just has a rspauth directive, the response is empty.
        s@rspauth=cnNwYXV0aD1lYTQwZjYwMzM1YzQyN2I1NTI3Yjg0ZGJhYmNkZmZmZA==�N)rr-r
)r
r/�responserrr�test_getResponseRspauthus�z&DigestMD5Tests.test_getResponseRspauthc
Csxd}d}tdd�}d}d}d}d}d	�|�}t�d
|d||�}	|	�||||�|�|�|�|�|�|�}
|�|
d�dS)
zc
        The response to a Digest-MD5 challenge is computed according to RFC
        2831.
        zutf-8sOA6MG9tEQGm2hhz%08x)�sOA6MHXh6VqTrRkuИchrisuИsecretuИelwood.innosoft.comuimap/Иelwood.innosoft.comsimapNs 7928f233258be88392424d094453c5e3)r�encoderrZ_calculateResponser
)r
�charsetZnonceZncZcnonceZusernameZpasswordZhostZ	digestURIrr7rrr�test_calculateResponses2
��z%DigestMD5Tests.test_calculateResponsecCs4d}|j�|�}|�dddddgddgd	�|�d
S)zc
        A challenge can be parsed into a L{dict} with L{bytes} or L{list}
        values.
        sTnonce="1234",qop="auth,auth-conf",charset=utf-8,algorithm=md5-sess,cipher="des,3des"smd5-sessr!r$r#s	auth-confsdess3des)s	algorithmr'r)r(scipherN)rr,r
r.rrr�
test_parse�s���zDigestMD5Tests.test_parseN)
rrrrrrr0r2r4r5r8r<r=rrrrr)s
rN)rZ
__future__rrZ
twisted.trialrZtwisted.python.compatrZtwisted.words.protocols.jabberrZTestCaserrrrrrr�<module>s