#NEWLINE# def test_checkHash( self ) : #NEWLINE# #INDENT# "\n        L{DigestCredentialFactory.decode} returns an L{IUsernameDigestHash}\n        provider which can verify a hash of the form 'username:realm:password'.\n        " #NEWLINE# challenge = self . credentialFactory . getChallenge ( self . clientAddress . host ) #NEWLINE# nc = '00000001' #NEWLINE# clientResponse = self . formatResponse ( nonce = challenge [ 'nonce' ] , response = self . getDigestResponse ( challenge , nc ) , nc = nc , opaque = challenge [ 'opaque' ] ) #NEWLINE# creds = self . credentialFactory . decode ( clientResponse , self . method , self . clientAddress . host ) #NEWLINE# self . assertTrue ( verifyObject ( IUsernameDigestHash , creds ) ) #NEWLINE# cleartext = ( '%s:%s:%s' % ( self . username , self . realm , self . password ) ) #NEWLINE# hash = md5 ( cleartext ) #NEWLINE# self . assertTrue ( creds . checkHash ( hash . hexdigest ( ) ) ) #NEWLINE# hash . update ( 'wrong' ) #NEWLINE# self . assertFalse ( creds . checkHash ( hash . hexdigest ( ) ) )