'L{DigestCredentialFactory.decode} returns an L{IUsernameDigestHash}
provider which can verify a hash of the form \'username:realm:password\'.'

def test_checkHash(self):

    challenge = self.credentialFactory.getChallenge(self.clientAddress.host)
    nc = '00000001'
    clientResponse = self.formatResponse(nonce=challenge['nonce'], response=self.getDigestResponse(challenge, nc), nc=nc, opaque=challenge['opaque'])
    creds = self.credentialFactory.decode(clientResponse, self.method, self.clientAddress.host)
    self.assertTrue(verifyObject(IUsernameDigestHash, creds))
    cleartext = ((((self.username + ':') + self.realm) + ':') + self.password)
    hash = md5(cleartext)
    self.assertTrue(creds.checkHash(hexlify(hash.digest())))
    hash.update('wrong')
    self.assertFalse(creds.checkHash(hexlify(hash.digest())))
