opzimize ApiParameter::getModFunctionString(); corrected FpmDaemons::update(); added a few more unit-tests
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -17,7 +17,8 @@ class FpmDaemonsTest extends TestCase
|
||||
$data = [
|
||||
'description' => 'test2 fpm',
|
||||
'reload_cmd' => 'service php7.1-fpm reload',
|
||||
'config_dir' => '/etc/php/7.1/fpm/pool.d'
|
||||
'config_dir' => '/etc/php/7.1/fpm/pool.d',
|
||||
'limit_extensions' => ''
|
||||
];
|
||||
$json_result = FpmDaemons::getLocal($admin_userdata, $data)->add();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
@@ -27,6 +28,33 @@ class FpmDaemonsTest extends TestCase
|
||||
self::$id = $result['id'];
|
||||
}
|
||||
|
||||
public function testAdminFpmDaemonsAddUnknownPM()
|
||||
{
|
||||
global $admin_userdata;
|
||||
$data = [
|
||||
'description' => 'test2 fpm',
|
||||
'reload_cmd' => 'service php7.3-fpm reload',
|
||||
'config_dir' => '/etc/php/7.3/fpm/pool.d',
|
||||
'pm' => 'supermegapm'
|
||||
];
|
||||
$this->expectExceptionCode(406);
|
||||
$this->expectExceptionMessage("Unknown process manager");
|
||||
FpmDaemons::getLocal($admin_userdata, $data)->add();
|
||||
}
|
||||
|
||||
public function testAdminFpmDaemonsAddInvalidDesc()
|
||||
{
|
||||
// max 50. characters
|
||||
global $admin_userdata;
|
||||
$data = [
|
||||
'description' => str_repeat('test', 30),
|
||||
'reload_cmd' => 'service php7.3-fpm reload',
|
||||
'config_dir' => '/etc/php/7.3/fpm/pool.d'
|
||||
];
|
||||
$this->expectExceptionMessage("The description is too short, too long or contains illegal characters.");
|
||||
FpmDaemons::getLocal($admin_userdata, $data)->add();
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAdminFpmDaemonsAdd
|
||||
*/
|
||||
@@ -48,6 +76,51 @@ class FpmDaemonsTest extends TestCase
|
||||
$this->assertEquals('.php .php.xml', $result['limit_extensions']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAdminFpmDaemonsUpdate
|
||||
*/
|
||||
public function testAdminFpmDaemonsUpdate2()
|
||||
{
|
||||
global $admin_userdata;
|
||||
$data = [
|
||||
'id' => self::$id,
|
||||
'limit_extensions' => '',
|
||||
];
|
||||
$json_result = FpmDaemons::getLocal($admin_userdata, $data)->update();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
$this->assertEquals('.php', $result['limit_extensions']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAdminFpmDaemonsAdd
|
||||
*/
|
||||
public function testAdminFpmDaemonsUpdateUnknownPM()
|
||||
{
|
||||
global $admin_userdata;
|
||||
$data = [
|
||||
'id' => self::$id,
|
||||
'pm' => 'supermegapm'
|
||||
];
|
||||
$this->expectExceptionCode(406);
|
||||
$this->expectExceptionMessage("Unknown process manager");
|
||||
FpmDaemons::getLocal($admin_userdata, $data)->update();
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAdminFpmDaemonsAdd
|
||||
*/
|
||||
public function testAdminFpmDaemonsUpdateInvalidDesc()
|
||||
{
|
||||
// max 50. characters
|
||||
global $admin_userdata;
|
||||
$data = [
|
||||
'id' => self::$id,
|
||||
'description' => str_repeat('test', 30)
|
||||
];
|
||||
$this->expectExceptionMessage("The description is too short, too long or contains illegal characters.");
|
||||
FpmDaemons::getLocal($admin_userdata, $data)->update();
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAdminFpmDaemonsUpdate
|
||||
*/
|
||||
@@ -61,6 +134,79 @@ class FpmDaemonsTest extends TestCase
|
||||
$this->assertEquals('test2 fpm edit', $result['list'][1]['description']);
|
||||
}
|
||||
|
||||
public function testAdminFpmDaemonsGetNotFound()
|
||||
{
|
||||
global $admin_userdata;
|
||||
$this->expectExceptionCode(404);
|
||||
$this->expectExceptionMessage("fpm-daemon with id #-1 could not be found");
|
||||
FpmDaemons::getLocal($admin_userdata, array('id' => -1))->get();
|
||||
}
|
||||
|
||||
public function testCustomerFpmDaemonsAdd()
|
||||
{
|
||||
global $admin_userdata;
|
||||
// get customer
|
||||
$json_result = Customers::getLocal($admin_userdata, array(
|
||||
'loginname' => 'test1'
|
||||
))->get();
|
||||
$customer_userdata = json_decode($json_result, true)['data'];
|
||||
$this->expectExceptionCode(403);
|
||||
$this->expectExceptionMessage("Not allowed to execute given command.");
|
||||
FpmDaemons::getLocal($customer_userdata)->add();
|
||||
}
|
||||
|
||||
public function testCustomerFpmDaemonsGet()
|
||||
{
|
||||
global $admin_userdata;
|
||||
// get customer
|
||||
$json_result = Customers::getLocal($admin_userdata, array(
|
||||
'loginname' => 'test1'
|
||||
))->get();
|
||||
$customer_userdata = json_decode($json_result, true)['data'];
|
||||
$this->expectExceptionCode(403);
|
||||
$this->expectExceptionMessage("Not allowed to execute given command.");
|
||||
FpmDaemons::getLocal($customer_userdata)->get();
|
||||
}
|
||||
|
||||
public function testCustomerFpmDaemonsList()
|
||||
{
|
||||
global $admin_userdata;
|
||||
// get customer
|
||||
$json_result = Customers::getLocal($admin_userdata, array(
|
||||
'loginname' => 'test1'
|
||||
))->get();
|
||||
$customer_userdata = json_decode($json_result, true)['data'];
|
||||
$this->expectExceptionCode(403);
|
||||
$this->expectExceptionMessage("Not allowed to execute given command.");
|
||||
FpmDaemons::getLocal($customer_userdata)->listing();
|
||||
}
|
||||
|
||||
public function testCustomerFpmDaemonsUpdate()
|
||||
{
|
||||
global $admin_userdata;
|
||||
// get customer
|
||||
$json_result = Customers::getLocal($admin_userdata, array(
|
||||
'loginname' => 'test1'
|
||||
))->get();
|
||||
$customer_userdata = json_decode($json_result, true)['data'];
|
||||
$this->expectExceptionCode(403);
|
||||
$this->expectExceptionMessage("Not allowed to execute given command.");
|
||||
FpmDaemons::getLocal($customer_userdata)->update();
|
||||
}
|
||||
|
||||
public function testCustomerFpmDaemonsDelete()
|
||||
{
|
||||
global $admin_userdata;
|
||||
// get customer
|
||||
$json_result = Customers::getLocal($admin_userdata, array(
|
||||
'loginname' => 'test1'
|
||||
))->get();
|
||||
$customer_userdata = json_decode($json_result, true)['data'];
|
||||
$this->expectExceptionCode(403);
|
||||
$this->expectExceptionMessage("Not allowed to execute given command.");
|
||||
FpmDaemons::getLocal($customer_userdata)->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testAdminFpmDaemonsList
|
||||
*/
|
||||
@@ -74,7 +220,7 @@ class FpmDaemonsTest extends TestCase
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
$this->assertEquals('/etc/php/7.1/fpm/pool.d/', $result['config_dir']);
|
||||
$this->assertEquals(10, $result['max_children']);
|
||||
$this->assertEquals('.php .php.xml', $result['limit_extensions']);
|
||||
$this->assertEquals('.php', $result['limit_extensions']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user