ó
    ×›‘h©  ã                   óª   • S r SSKJr  SSKJr  SSKJr   " S S\R                  5      r " S S\R                  5      r	 " S	 S
\R                  5      r
g)z>
Tests for L{twisted.words.protocols.jabber.sasl_mechanisms}.
é    )ÚnetworkString)Úunittest)Úsasl_mechanismsc                   ó"   • \ rS rSrSrSS jrSrg)Ú
PlainTestsé   zD
Tests for L{twisted.words.protocols.jabber.sasl_mechanisms.Plain}.
Nc                 ót   • [         R                  " SSS5      nU R                  UR                  5       S5        g)z
Test the initial response.
NÚtestÚsecrets    test secret)r   ÚPlainÚassertEqualÚgetInitialResponse©ÚselfÚms     ÚpC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/words/test/test_jabbersaslmechanisms.pyÚtest_getInitialResponseÚ"PlainTests.test_getInitialResponse   s2   € ô ×!Ò! $¨°Ó9ˆØ×Ñ˜×-Ñ-Ó/Ð1FÕGó    © ©ÚreturnN©Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__static_attributes__r   r   r   r   r      s   † ñ÷Hr   r   c                   ó"   • \ rS rSrSrSS jrSrg)ÚAnonymousTestsé   zH
Tests for L{twisted.words.protocols.jabber.sasl_mechanisms.Anonymous}.
Nc                 ón   • [         R                  " 5       nU R                  UR                  5       S5        g)z(
Test the initial response to be empty.
N)r   Ú	Anonymousr   r   r   s     r   r   Ú&AnonymousTests.test_getInitialResponse    s+   € ô ×%Ò%Ó'ˆØ×Ñ˜×-Ñ-Ó/°Õ6r   r   r   r   r   r   r   r!   r!      s   † ñ÷7r   r!   c                   ór   • \ rS rSrSrSS jrSS jrSS jrSS jrSS jr	SS	 jr
SS
 jrSS jrSS jrSrg)ÚDigestMD5Testsé(   zH
Tests for L{twisted.words.protocols.jabber.sasl_mechanisms.DigestMD5}.
Nc                 óB   • [         R                  " SSS SS5      U l        g )NÚxmppzexample.orgr
   r   )r   Ú	DigestMD5Ú	mechanism©r   s    r   ÚsetUpÚDigestMD5Tests.setUp-   s   € Ü(×2Ò2Ø�M 4¨°ó
ˆ�r   c                 óX   • U R                  U R                  R                  5       S5        g)z-
Test that no initial response is generated.
N)ÚassertIdenticalr,   r   r-   s    r   r   Ú&DigestMD5Tests.test_getInitialResponse2   s!   € ð 	×Ñ˜TŸ^™^×>Ñ>Ó@À$ÕGr   c           
      ó²   • SnU R                   R                  U R                   R                  U5      5      nUS	 US	 U R                  SSSS/SS	S
S.U5        g)zT
The response to a Digest-MD5 challenge includes the parameters from the
challenge.
sJ   realm="localhost",nonce="1234",qop="auth",charset=utf-8,algorithm=md5-sessó   cnonceó   responseó   testó   1234ó   00000001ó   authó   utf-8s	   localhostó   xmpp/example.org©s   usernameó   nonces   ncó   qopó   charsetó   realms
   digest-uriN©r,   Ú_parseÚgetResponser   ©r   Ú	challengeÚ
directivess      r   Útest_getResponseÚDigestMD5Tests.test_getResponse8   so   € ð"ð 	ð —^‘^×*Ñ*¨4¯>©>×+EÑ+EÀiÓ+PÓQˆ
Ø�yÐ! :¨kÐ#:Ø×Ñà$Ø!Ø"Ø ˜	Ø$Ø&Ø2ñð õ	
r   c           
      ó²   • SnU R                   R                  U R                   R                  U5      5      nUS	 US	 U R                  SSSS/SS	S
S.U5        g)z[
Bytes outside the ASCII range in the challenge are nevertheless
included in the response.
sS   realm="Ã©chec.example.org",nonce="1234",qop="auth",charset=utf-8,algorithm=md5-sessr4   r5   r6   r7   r8   r9   r:   ó   Ã©chec.example.orgr;   r<   NrA   rD   s      r   Útest_getResponseNonAsciiRealmÚ,DigestMD5Tests.test_getResponseNonAsciiRealmP   so   € ð;ð 	ð —^‘^×*Ñ*¨4¯>©>×+EÑ+EÀiÓ+PÓQˆ
Ø�yÐ! :¨kÐ#:Ø×Ñà$Ø!Ø"Ø ˜	Ø$Ø5Ø2ñð õ	
r   c                 óš   • SnU R                   R                  U R                   R                  U5      5      nU R                  US   S5        g)zY
The response to a challenge without a realm uses the host part of the
JID as the realm.
ó8   nonce="1234",qop="auth",charset=utf-8,algorithm=md5-sessr@   s   example.orgNrA   rD   s      r   Útest_getResponseNoRealmÚ&DigestMD5Tests.test_getResponseNoRealmh   sB   € ð
 Pˆ	Ø—^‘^×*Ñ*¨4¯>©>×+EÑ+EÀiÓ+PÓQˆ
Ø×Ñ˜ HÑ-¨~Õ>r   c                 óØ   • [         R                  " SSSSS5      U l        SnU R                  R                  U R                  R	                  U5      5      nU R                  US   S5        g)	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.
r*   u   Ã©chec.example.orgNr
   r   rN   r@   rJ   )r   r+   r,   rB   rC   r   rD   s      r   Útest_getResponseNoRealmIDNÚ)DigestMD5Tests.test_getResponseNoRealmIDNq   sc   € ô )×2Ò2ØÐ,¨d°F¸Hó
ˆŒð Pˆ	Ø—^‘^×*Ñ*¨4¯>©>×+EÑ+EÀiÓ+PÓQˆ
Ø×Ñ˜ HÑ-Ð/JÕKr   c                 ób   • SnU R                   R                  U5      nU R                  SU5        g)zG
If the challenge just has a rspauth directive, the response is empty.
s@   rspauth=cnNwYXV0aD1lYTQwZjYwMzM1YzQyN2I1NTI3Yjg0ZGJhYmNkZmZmZA==r   N)r,   rC   r   )r   rE   Úresponses      r   Útest_getResponseRspauthÚ&DigestMD5Tests.test_getResponseRspauth~   s.   € ð Xˆ	Ø—>‘>×-Ñ-¨iÓ8ˆØ×Ñ˜˜hÕ'r   c           
      ó6  • SnSn[        SS 5      nSnSnSnSnS	R                  U5      n[        R                  " S
USXV5      n	U	R	                  UUUUR                  U5      UR                  U5      UR                  U5      U5      n
U R                  U
S5        g)zK
The response to a Digest-MD5 challenge is computed according to RFC
2831.
zutf-8s   OA6MG9tEQGm2hhé   Ú08xs   OA6MHXh6VqTrRku   Ð˜chrisu   Ð˜secretu   Ð˜elwood.innosoft.comu   imap/Ð˜elwood.innosoft.coms   imapNs    7928f233258be88392424d094453c5e3)r   Úencoder   r+   Ú_calculateResponser   )r   ÚcharsetÚnonceÚncÚcnonceÚusernameÚpasswordÚhostÚ	digestURIr,   rU   s              r   Útest_calculateResponseÚ%DigestMD5Tests.test_calculateResponse†   s©   € ð
 ˆØ!ˆÜ˜a ˜WÓ&ˆØ"ˆà ˆØ!ˆØ*ˆØ4×;Ñ;¸GÓDˆ	ä#×-Ò-¨g°t¸TÀ8ÓVˆ	Ø×/Ñ/ØØØØ�O‰O˜GÓ$Ø�O‰O˜GÓ$Ø�K‰K˜Ó Øó
ˆð 	×Ñ˜Ð#FÕGr   c                 óv   • SnU R                   R                  U5      nU R                  SSSSS/SS/S	.U5        g
)zK
A challenge can be parsed into a L{dict} with L{bytes} or L{list}
values.
sT   nonce="1234",qop="auth,auth-conf",charset=utf-8,algorithm=md5-sess,cipher="des,3des"s   md5-sessr7   r:   r9   s	   auth-confs   dess   3des)s	   algorithmr=   r?   r>   s   cipherN)r,   rB   r   rD   s      r   Ú
test_parseÚDigestMD5Tests.test_parse¡   sS   € ð4ð 	ð —^‘^×*Ñ*¨9Ó5ˆ
Ø×Ñà)Ø!Ø$Ø  ,Ð/Ø" GÐ,ñð õ		
r   )r,   r   )r   r   r   r   r   r.   r   rG   rK   rO   rR   rV   re   rh   r   r   r   r   r'   r'   (   s7   † ñô
ô
Hô
ô0
ô0?ôLô(ôH÷6
r   r'   N)r   Útwisted.python.compatr   Útwisted.trialr   Útwisted.words.protocols.jabberr   ÚTestCaser   r!   r'   r   r   r   Ú<module>rn      sO   ðñõ
 0Ý "Ý :ô
H�×"Ñ"ô 
Hô
7�X×&Ñ&ô 
7ôL
�X×&Ñ&õ L
r   