From 495eda9df35a156ccacd743d4176f26c04904518 Mon Sep 17 00:00:00 2001 From: minhaz Date: Thu, 27 Feb 2014 04:23:43 +0530 Subject: [PATCH 1/2] testBlowFishDecrypt() testcase added Signed-off-by: A V Minhaz --- .../classes/plugin/auth/PMA_AuthenticationCookie_test.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php b/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php index b00e9ad51c..0862fe22e2 100644 --- a/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php +++ b/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php @@ -1101,7 +1101,13 @@ class PMA_AuthenticationCookie_Test extends PHPUnit_Framework_TestCase public function testBlowfishDecrypt() { if (function_exists('mcrypt_encrypt')) { - $this->markTestIncomplete('Not testing mcrypt support'); + $this->assertEquals( + 'root', + $this->object->blowfishDecrypt( + 'UG1MQSH8SSM=', + '04a4f0a762b42202d7c90fb0a1b83451' + ) + ); } else { $this->assertEquals( 'data123', From 501d25fe622a83826b0d57541eb4f2551c49f5af Mon Sep 17 00:00:00 2001 From: minhaz Date: Thu, 27 Feb 2014 14:46:57 +0530 Subject: [PATCH 2/2] fixing build test and adding test cases Test case added for testBlowfishDecrypt() and modified for testBlowfishEncrypt() Signed-off-by: A V Minhaz --- .../auth/PMA_AuthenticationCookie_test.php | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php b/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php index 0862fe22e2..9cefe5e2b6 100644 --- a/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php +++ b/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php @@ -1078,18 +1078,14 @@ class PMA_AuthenticationCookie_Test extends PHPUnit_Framework_TestCase $this->object->blowfishEncrypt('data123', 'sec321') ); } else { + //using our own iv for testing + $tmp = $GLOBALS['iv']; + $GLOBALS['iv'] = "testiv09"; $this->assertEquals( - base64_encode( - mcrypt_encrypt( - MCRYPT_BLOWFISH, - 'sec321', - 'data123', - MCRYPT_MODE_CBC, - $GLOBALS['iv'] - ) - ), + 'x/2GwHKoPyc=', $this->object->blowfishEncrypt('data123', 'sec321') ); + $GLOBALS['iv'] = $tmp; } } @@ -1101,13 +1097,16 @@ class PMA_AuthenticationCookie_Test extends PHPUnit_Framework_TestCase public function testBlowfishDecrypt() { if (function_exists('mcrypt_encrypt')) { - $this->assertEquals( - 'root', - $this->object->blowfishDecrypt( - 'UG1MQSH8SSM=', - '04a4f0a762b42202d7c90fb0a1b83451' - ) - ); + + //using our own iv for testing + $tmp = $GLOBALS['iv']; + $GLOBALS['iv'] = "testiv09"; + $this->assertEquals( + 'data123', + $this->object->blowfishDecrypt('x/2GwHKoPyc=', 'sec321') + ); + $GLOBALS['iv'] = $tmp; + } else { $this->assertEquals( 'data123',