From bc603150239888637f21b3fef821d9cde8f65565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 12 Jun 2014 10:18:45 +0200 Subject: [PATCH] Adjust tests to new IV logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- .../plugins/auth/AuthenticationCookie.class.php | 12 ++++++++++++ .../plugin/auth/PMA_AuthenticationCookie_test.php | 15 ++++++++------- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/libraries/plugins/auth/AuthenticationCookie.class.php b/libraries/plugins/auth/AuthenticationCookie.class.php index 44aedc09d5..6855261d98 100644 --- a/libraries/plugins/auth/AuthenticationCookie.class.php +++ b/libraries/plugins/auth/AuthenticationCookie.class.php @@ -793,6 +793,18 @@ class AuthenticationCookie extends AuthenticationPlugin } } + /** + * Sets Blowfis IV to use + * + * @param string $vector The IV + * + * @return void + */ + public function setBlowfishIv($vector) + { + $this->_blowfish_iv = $vector; + } + /** * This method is called when any PluginManager to which the observer * is attached calls PluginManager::notify() diff --git a/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php b/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php index 03b2245a5b..623c8ac180 100644 --- a/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php +++ b/test/classes/plugin/auth/PMA_AuthenticationCookie_test.php @@ -576,6 +576,7 @@ class PMA_AuthenticationCookie_Test extends PHPUnit_Framework_TestCase $GLOBALS['server'] = 1; $_COOKIE['pmaServer-1'] = 'pmaServ1'; $_COOKIE['pmaUser-1'] = ''; + $_COOKIE['pma_mcrypt_iv'] = base64_encode('testiv09'); $this->assertFalse( $this->object->authCheck() @@ -591,6 +592,7 @@ class PMA_AuthenticationCookie_Test extends PHPUnit_Framework_TestCase $GLOBALS['server'] = 1; $_COOKIE['pmaServer-1'] = 'pmaServ1'; $_COOKIE['pmaUser-1'] = 'pmaUser1'; + $_COOKIE['pma_mcrypt_iv'] = base64_encode('testiv09'); $_COOKIE['pmaPass-1'] = ''; $GLOBALS['cfg']['blowfish_secret'] = 'secret'; $_SESSION['last_access_time'] = time() - 1000; @@ -666,6 +668,7 @@ class PMA_AuthenticationCookie_Test extends PHPUnit_Framework_TestCase $_REQUEST['pma_username'] = ''; $_COOKIE['pmaServer-1'] = 'pmaServ1'; $_COOKIE['pmaUser-1'] = 'pmaUser1'; + $_COOKIE['pma_mcrypt_iv'] = base64_encode('testiv09'); $GLOBALS['cfg']['blowfish_secret'] = 'secret'; $_SESSION['last_access_time'] = ''; $_SESSION['last_valid_captcha'] = true; @@ -704,6 +707,7 @@ class PMA_AuthenticationCookie_Test extends PHPUnit_Framework_TestCase $_COOKIE['pmaServer-1'] = 'pmaServ1'; $_COOKIE['pmaUser-1'] = 'pmaUser1'; $_COOKIE['pmaPass-1'] = 'pmaPass1'; + $_COOKIE['pma_mcrypt_iv'] = base64_encode('testiv09'); $GLOBALS['cfg']['blowfish_secret'] = 'secret'; $_SESSION['last_valid_captcha'] = true; $_SESSION['last_access_time'] = time() - 1000; @@ -747,6 +751,7 @@ class PMA_AuthenticationCookie_Test extends PHPUnit_Framework_TestCase $_REQUEST['pma_username'] = ''; $_COOKIE['pmaServer-1'] = 'pmaServ1'; $_COOKIE['pmaUser-1'] = 'pmaUser1'; + $_COOKIE['pma_mcrypt_iv'] = base64_encode('testiv09'); $GLOBALS['cfg']['blowfish_secret'] = 'secret'; $_SESSION['last_access_time'] = 1; $_SESSION['last_valid_captcha'] = true; @@ -1059,13 +1064,12 @@ class PMA_AuthenticationCookie_Test extends PHPUnit_Framework_TestCase ); } else { //using our own iv for testing - $tmp = $GLOBALS['iv']; - $GLOBALS['iv'] = "testiv09"; + $this->object->createBlowfishIV(); + $this->object->setBlowfishIv('testiv09'); $this->assertEquals( 'x/2GwHKoPyc=', $this->object->blowfishEncrypt('data123', 'sec321') ); - $GLOBALS['iv'] = $tmp; } } @@ -1079,14 +1083,11 @@ class PMA_AuthenticationCookie_Test extends PHPUnit_Framework_TestCase if (function_exists('mcrypt_encrypt')) { //using our own iv for testing - $tmp = $GLOBALS['iv']; - $GLOBALS['iv'] = "testiv09"; + $this->object->setBlowfishIv('testiv09'); $this->assertEquals( 'data123', $this->object->blowfishDecrypt('x/2GwHKoPyc=', 'sec321') ); - $GLOBALS['iv'] = $tmp; - } else { $this->assertEquals( 'data123',