ó
    Ö›‘hÆ  ã                   óZ   • S r SSKrSSKJr  SSKJr  SSKJrJr  SSK	J
r
   " S S\
5      rg)	z9
Tests for L{twisted.cred}'s implementation of CRAM-MD5.
é    N)Úhexlify)ÚHMAC)ÚCramMD5CredentialsÚIUsernameHashedPassword)ÚTestCasec                   óT   • \ 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
rg)ÚCramMD5CredentialsTestsé   z"
Tests for L{CramMD5Credentials}.
Nc                 óv   • [        5       nUR                  5       nU R                  X!R                  5       5        g)zo
The same L{CramMD5Credentials} will always provide the same challenge,
no matter how many times it is called.
N)r   ÚgetChallengeÚassertEqual©ÚselfÚcÚchals      ÚcC:\Users\psant\Downloads\Noiseback\school\venv\Lib\site-packages\twisted/cred/test/test_cramauth.pyÚtest_idempotentChallengeÚ0CramMD5CredentialsTests.test_idempotentChallenge   s-   € ô
 Ó ˆØ�~‰~ÓˆØ×Ñ˜Ÿ~™~Ó/Õ0ó    c                 óâ   • [        5       nUR                  5       n[        [        SU[        R
                  S9R                  5       5      Ul        U R                  UR                  S5      5        g)a
  
When a valid response (which is a hex digest of the challenge that has
been encrypted by the user's shared secret) is set on the
L{CramMD5Credentials} that created the challenge, and C{checkPassword}
is called with the user's shared secret, it will return L{True}.
ó   secret©Ú	digestmodN)
r   r   r   r   ÚhashlibÚmd5ÚdigestÚresponseÚ
assertTrueÚcheckPasswordr   s      r   Útest_checkPasswordÚ*CramMD5CredentialsTests.test_checkPassword   sO   € ô Ó ˆØ�~‰~ÓˆÜœT )¨T¼W¿[¹[ÑI×PÑPÓRÓSˆŒ
Ø�‰˜Ÿ™¨	Ó2Õ3r   c                 óX   • [        5       nU R                  UR                  S5      5        g)zO
When there is no response set, calling C{checkPassword} will return
L{False}.
r   N)r   ÚassertFalser   )r   r   s     r   Útest_noResponseÚ'CramMD5CredentialsTests.test_noResponse+   s#   € ô
 Ó ˆØ×Ñ˜Ÿ™¨Ó3Õ4r   c                 óâ   • [        5       nUR                  5       n[        [        SU[        R
                  S9R                  5       5      Ul        U R                  UR                  S5      5        g)zø
When an invalid response is set on the L{CramMD5Credentials} (one that
is not the hex digest of the challenge, encrypted with the user's shared
secret) and C{checkPassword} is called with the user's correct shared
secret, it will return L{False}.
s   thewrongsecretr   r   N)
r   r   r   r   r   r   r   r   r#   r   r   s      r   Útest_wrongPasswordÚ*CramMD5CredentialsTests.test_wrongPassword3   sW   € ô Ó ˆØ�~‰~ÓˆÜÜÐ" D´G·K±KÑ@×GÑGÓIó
ˆŒ
ð 	×Ñ˜Ÿ™¨Ó3Õ4r   c                 óP  • [        5       nUR                  5       nUR                  SR                  S[	        [        SU[        R                  S9R                  5       5      45      5        U R                  UR                  S5      5        U R                  UR                  S5        g)z¢
When C{setResponse} is called with a string that is the username and
the hashed challenge separated with a space, they will be set on the
L{CramMD5Credentials}.
ó    s   squirrels   supersecretr   N)r   r   ÚsetResponseÚjoinr   r   r   r   r   r   r   r   Úusernamer   s      r   Útest_setResponseÚ(CramMD5CredentialsTests.test_setResponseA   s�   € ô Ó ˆØ�~‰~ÓˆØ	�‰Ø�I‰IàÜœD °ÄÇÁÑM×TÑTÓVÓWðóô	
ð 	�‰˜Ÿ™¨Ó7Ô8Ø×Ñ˜Ÿ™ [Õ1r   c                 óV   • U R                  [        R                  " [        5      5        g)zL
L{CramMD5Credentials} implements the L{IUsernameHashedPassword}
interface.
N)r   r   ÚimplementedByr   )r   s    r   Útest_interfaceÚ&CramMD5CredentialsTests.test_interfaceT   s   € ð
 	�‰Ô/×=Ò=Ô>PÓQÕRr   © )ÚreturnN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r    r$   r'   r.   r2   Ú__static_attributes__r4   r   r   r	   r	      s&   † ñô1ô
4ô5ô5ô2÷&Sr   r	   )r:   r   Úbinasciir   Úhmacr   Útwisted.cred.credentialsr   r   Útwisted.trial.unittestr   r	   r4   r   r   Ú<module>r@      s+   ðñó
 Ý Ý ç PÝ +ôHS˜hõ HSr   