From 3dcbbb9e7b8e8d5fd4635a83f7b6656a3a985a2d Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Wed, 14 Oct 2020 14:25:06 +0200 Subject: [PATCH] do not set description to empty value if not passed as parameter as it is optionally; fixes #890 Signed-off-by: Michael Kaufmann --- lib/Froxlor/Api/Commands/Mysqls.php | 2 +- tests/Mysqls/MysqlsTest.php | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/Froxlor/Api/Commands/Mysqls.php b/lib/Froxlor/Api/Commands/Mysqls.php index 4a0afa00..d22cf46a 100644 --- a/lib/Froxlor/Api/Commands/Mysqls.php +++ b/lib/Froxlor/Api/Commands/Mysqls.php @@ -307,7 +307,7 @@ class Mysqls extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEnt // paramters $password = $this->getParam('mysql_password', true, ''); - $databasedescription = $this->getParam('description', true, ''); + $databasedescription = $this->getParam('description', true, $result['description']); // validation $password = \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true); diff --git a/tests/Mysqls/MysqlsTest.php b/tests/Mysqls/MysqlsTest.php index d216c08b..6bd2909d 100644 --- a/tests/Mysqls/MysqlsTest.php +++ b/tests/Mysqls/MysqlsTest.php @@ -136,6 +136,26 @@ class MysqlsTest extends TestCase } } + + /** + * + * @depends testCustomerMysqlsAdd + */ + public function testAdminMysqlsUpdatePwdOnly() + { + global $admin_userdata; + + $newPwd = \Froxlor\System\Crypt::generatePassword(); + $data = [ + 'dbname' => 'test1sql1', + 'mysql_password' => $newPwd, + 'loginname' => 'test1' + ]; + $json_result = Mysqls::getLocal($admin_userdata, $data)->update(); + $result = json_decode($json_result, true)['data']; + $this->assertEquals('testdb-upd', $result['description']); + } + /** * * @depends testCustomerMysqlsAdd