From e020dbfe16bb272a9de312a1b45cdc23bbebeb83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 20 Oct 2017 17:14:28 +0200 Subject: [PATCH] Add test for AuthenticationPlugin::authenticate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michal Čihař --- .../Plugins/Auth/AuthenticationCookieTest.php | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/classes/Plugins/Auth/AuthenticationCookieTest.php b/test/classes/Plugins/Auth/AuthenticationCookieTest.php index 13dae42877..1c410cfb71 100644 --- a/test/classes/Plugins/Auth/AuthenticationCookieTest.php +++ b/test/classes/Plugins/Auth/AuthenticationCookieTest.php @@ -1125,4 +1125,35 @@ class AuthenticationCookieTest extends PmaTestCase ), ); } + + /** + * Test for PhpMyAdmin\Plugins\Auth\AuthenticationCookie::authenticate + * + * @return void + */ + public function testAuthenticate() + { + $GLOBALS['cfg']['CaptchaLoginPrivateKey'] = ''; + $GLOBALS['cfg']['CaptchaLoginPublicKey'] = ''; + $GLOBALS['cfg']['Server']['AllowRoot'] = false; + $GLOBALS['cfg']['Server']['AllowNoPassword'] = false; + $_REQUEST['old_usr'] = ''; + $_REQUEST['pma_username'] = 'testUser'; + $_REQUEST['pma_password'] = 'testPassword'; + + ob_start(); + $this->object->authenticate(); + $result = ob_get_clean(); + + /* Nothing should be printed */ + $this->assertEquals('', $result); + + /* Verify readCredentials worked */ + $this->assertEquals('testUser', $this->object->user); + $this->assertEquals('testPassword', $this->object->password); + + /* Verify storeCredentials worked */ + $this->assertEquals('testUser', $GLOBALS['cfg']['Server']['user']); + $this->assertEquals('testPassword', $GLOBALS['cfg']['Server']['password']); + } }