ϪfdZddlmZddlmZddlmZGddejZGddejZ Gd d ejZ y ) z> Tests for L{twisted.words.protocols.jabber.sasl_mechanisms}. ) networkString)unittest)sasl_mechanismsceZdZdZddZy) PlainTestszL Tests for L{twisted.words.protocols.jabber.sasl_mechanisms.Plain}. Ncrtjddd}|j|jdy)z, Test the initial response. Ntestsecrets testsecret)rPlain assertEqualgetInitialResponseselfms N/usr/lib/python3/dist-packages/twisted/words/test/test_jabbersaslmechanisms.pytest_getInitialResponsez"PlainTests.test_getInitialResponses2  ! !$ 9 --/1FGreturnN__name__ __module__ __qualname____doc__rrrrrs HrrceZdZdZddZy)AnonymousTestszP Tests for L{twisted.words.protocols.jabber.sasl_mechanisms.Anonymous}. Ncltj}|j|jdy)z8 Test the initial response to be empty. N)r Anonymousr r rs rrz&AnonymousTests.test_getInitialResponse s+  % % ' --/6rrrrrrrrs 7rrcXeZdZdZd dZd dZd dZd dZd dZd dZ d d Z d d Z d d Z y) DigestMD5TestszP Tests for L{twisted.words.protocols.jabber.sasl_mechanisms.DigestMD5}. Nc@tjddddd|_y)Nxmppz example.orgr r )r DigestMD5 mechanismrs rsetUpzDigestMD5Tests.setUp-s(22 M4 rcX|j|jjdy)z= Test that no initial response is generated. N)assertIdenticalr%r r&s rrz&DigestMD5Tests.test_getInitialResponse2s! T^^>>@$Grc d}|jj|jj|}|d=|d=|jddddgdd d d |y ) 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-sesscnonceresponsetest123400000001authutf-8s localhostxmpp/example.orgsusernamenoncesncqopcharsetrealms digest-uriNr%_parse getResponser r challenge directivess rtest_getResponsezDigestMD5Tests.test_getResponse8so  " ^^**4>>+E+Ei+PQ y !:k#: $!" $&2   rc d}|jj|jj|}|d=|d=|jddddgdd d d |y ) 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-sessr+r,r-r.r/r0r1échec.example.orgr2r3Nr8r;s rtest_getResponseNonAsciiRealmz,DigestMD5Tests.test_getResponseNonAsciiRealmPso  ; ^^**4>>+E+Ei+PQ y !:k#: $!" $52   rcd}|jj|jj|}|j|ddy)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-sessr7s example.orgNr8r;s rtest_getResponseNoRealmz&DigestMD5Tests.test_getResponseNoRealmhsB P ^^**4>>+E+Ei+PQ  H-~>rctjddddd|_d}|jj|jj |}|j |ddy) 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 rCr7r@)rr$r%r9r:r r;s rtest_getResponseNoRealmIDNz)DigestMD5Tests.test_getResponseNoRealmIDNqsc )22 ,dFH P ^^**4>>+E+Ei+PQ  H-/JKrcbd}|jj|}|jd|y)zW If the challenge just has a rspauth directive, the response is empty. s@rspauth=cnNwYXV0aD1lYTQwZjYwMzM1YzQyN2I1NTI3Yjg0ZGJhYmNkZmZmZA==rN)r%r:r )rr<responses rtest_getResponseRspauthz&DigestMD5Tests.test_getResponseRspauth~s.X >>--i8 h'rc 6d}d}tdd}d}d}d}d}d j|}tjd |d ||} | j ||||j||j||j||} |j | d y ) zc The response to a Digest-MD5 challenge is computed according to RFC 2831. zutf-8sOA6MG9tEQGm2hh08xsOA6MHXh6VqTrRkuИchrisuИsecretuИelwood.innosoft.comuimap/Иelwood.innosoft.comsimapNs 7928f233258be88392424d094453c5e3)rencoderr$_calculateResponser ) rcharsetnoncenccnonceusernamepasswordhost digestURIr%rHs rtest_calculateResponsez%DigestMD5Tests.test_calculateResponses ! aW &" !*4;;GD #--gtT8XV //    OOG $ OOG $ KK   #FGrcvd}|jj|}|jdddddgddgd |y ) 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.r1r0s auth-confsdess3des)s algorithmr4r6r5scipherN)r%r9r r;s r test_parsezDigestMD5Tests.test_parsesS  4 ^^**95  )!$ ,/"G,    rr) rrrrr'rr>rArDrFrIrWrYrrrr!r!(s7 H  0 0? L(H6 rr!N) rtwisted.python.compatr twisted.trialrtwisted.words.protocols.jabberrTestCaserrr!rrrr^sO 0": H"" H 7X&& 7L X&&L r