From 1831d8a0f848f2e0dd5ef195791b6beaa5d1acb7 Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Tue, 1 May 2012 21:33:06 +0200
Subject: [PATCH] fixed password hashing tests for recent PMD5 change

---
 _test/tests/inc/auth_password.test.php | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/_test/tests/inc/auth_password.test.php b/_test/tests/inc/auth_password.test.php
index 4c922d0e3..515adc8f5 100644
--- a/_test/tests/inc/auth_password.test.php
+++ b/_test/tests/inc/auth_password.test.php
@@ -17,8 +17,6 @@ class auth_password_test extends PHPUnit_Framework_TestCase {
         'mysql' => '4a1fa3780bd6fd55',
         'my411' => '*e5929347e25f82e19e4ebe92f1dc6b6e7c2dbd29',
         'kmd5'  => 'a579299436d7969791189acadd86fcb716',
-        'pmd5'  => '$P$abcdefgh1RC6Fd32heUzl7EYCG9uGw.',
-        'hmd5'  => '$H$abcdefgh1ZbJodHxmeXVAhEzTG7IAp.',
         'djangomd5'  => 'md5$abcde$d0fdddeda8cd92725d2b54148ac09158',
         'djangosha1' => 'sha1$abcde$c8e65a7f0acc9158843048a53dcc5a6bc4d17678',
     );
@@ -36,6 +34,7 @@ class auth_password_test extends PHPUnit_Framework_TestCase {
         foreach($this->passes as $method => $hash){
             $info = "testing method $method";
             $this->assertTrue(auth_verifyPassword('foo'.$method, $hash), $info);
+            $this->assertFalse(auth_verifyPassword('bar'.$method, $hash), $info);
         }
     }
 
@@ -65,6 +64,20 @@ class auth_password_test extends PHPUnit_Framework_TestCase {
         $this->assertTrue(auth_verifyPassword('test12345','$H$9IQRaTwmfeRo7ud9Fh4E2PdI0S3r.L0'));
     }
 
+    /**
+     * pmd5 checking should throw an exception when a hash with a too high
+     * iteration count is passed
+     */
+    function test_verifyPassword_pmd5Exception(){
+        $except = false;
+        try{
+            auth_verifyPassword('foopmd5', '$H$abcdefgh1ZbJodHxmeXVAhEzTG7IAp.');
+        }catch (Exception $e){
+            $except = true;
+        }
+        $this->assertTrue($except);
+    }
+
 }
 
 //Setup VIM: ex: et ts=4 :
-- 
GitLab