Right now I'm using the Zend Framework and messing around with that and phpunit. Here is my dilemma.
When I create a user I hash the password in the user table. I add two salts, a static one from the application and one that is randomly generated. I use the database SHA function and then UNHEX that to store the password in a binary column. In order to tell the database how to hash the password I use a Zend_Db_Expr like so :
protected function _createPasswordDbExpression( $password )
{
$quoted = $this->getDbTable()->getAdapter()->quoteInto( 'UNHEX( SHA1( ? ) )', $password );
$binaryPassword = new Zend_Db_Expr( $quoted );
return $binaryPassword;
}
Up till now I've been using xml datasets to specify the expected results but now, with the hashed passwords, I don't know what to do.
I see a solution to this but there has to be a better way.
I could prehash a password, or passwords, and only use that during my testing and in my xml files.
Is there any other solution that might be better and more testable?
I don't know exactly how this binary column would affect things when phpunit tries to insert a "hashed" password directly.