+
    Dfj                     \    R t ^ RIt^ RIHt ^ RIHt ^ RIHtHt ^ RI	H
t
  ! R R]
4      tR# )z9
Tests for L{twisted.cred}'s implementation of CRAM-MD5.
N)hexlify)HMAC)CramMD5CredentialsIUsernameHashedPassword)TestCasec                      a  ] tR t^t o RtV 3R lR ltV 3R lR ltV 3R lR ltV 3R lR	 ltV 3R
 lR lt	V 3R lR lt
RtV tR# )CramMD5CredentialsTestsz"
Tests for L{CramMD5Credentials}.
c                   < V ^8  d   QhRR/#    returnN )format__classdict__s   "A/usr/lib/python3/dist-packages/twisted/cred/test/test_cramauth.py__annotate__$CramMD5CredentialsTests.__annotate__   s     1 1$ 1    c                x    \        4       pVP                  4       pV P                  W!P                  4       4       R# )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   &  r   test_idempotentChallenge0CramMD5CredentialsTests.test_idempotentChallenge   s-    
  ~~~~/0r   c                   < V ^8  d   QhRR/# r
   r   )r   r   s   "r   r   r      s     
4 
4D 
4r   c                    \        4       pVP                  4       p\        \        RV\        P
                  R7      P                  4       4      Vn        V P                  VP                  R4      4       R# )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)TW[[IPPRS
	23r   c                   < V ^8  d   QhRR/# r
   r   )r   r   s   "r   r   r   +   s     5 5 5r   c                Z    \        4       pV P                  VP                  R4      4       R# )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                   < V ^8  d   QhRR/# r
   r   )r   r   s   "r   r   r   3   s     5 5D 5r   c                    \        4       pVP                  4       p\        \        RV\        P
                  R7      P                  4       4      Vn        V P                  VP                  R4      4       R# )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      ~~"DGKK@GGI

 	34r   c                   < V ^8  d   QhRR/# r
   r   )r   r   s   "r   r   r   A   s     2 2$ 2r   c                X   \        4       pVP                  4       pVP                  RP                  R\	        \        RV\        P                  R7      P                  4       4      34      4       V P                  VP                  R4      4       V P                  VP                  R4       R# )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      ~~	IIDMTTVW	
 	78[1r   c                   < V ^8  d   QhRR/# r
   r   )r   r   s   "r   r   r   T   s     S S Sr   c                X    V P                  \        P                  ! \        4      4       R# )zL
L{CramMD5Credentials} implements the L{IUsernameHashedPassword}
interface.
N)r&   r   implementedByr   )r   s   &r   test_interface&CramMD5CredentialsTests.test_interfaceT   s    
 	/==>PQRr   r   N)__name__
__module____qualname____firstlineno____doc__r   r(   r-   r1   r9   r>   __static_attributes____classdictcell__)r   s   @r   r   r      sH     1 1
4 
45 55 52 2&S Sr   r   )rD   r"   binasciir   hmacr   twisted.cred.credentialsr   r   twisted.trial.unittestr   r   r   r   r   <module>rK      s+   
    P +HSh HSr   