add some more unit-tests for Cronjobs and PhpSettings
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -18,6 +18,19 @@ class CronjobsTest extends TestCase
|
|||||||
$this->assertTrue(isset($result['list'][0]['cronfile']));
|
$this->assertTrue(isset($result['list'][0]['cronfile']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCustomerCronjobsListNotAllowed()
|
||||||
|
{
|
||||||
|
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.");
|
||||||
|
Cronjobs::getLocal($customer_userdata)->listing();
|
||||||
|
}
|
||||||
|
|
||||||
public function testAdminCronjobsAdd()
|
public function testAdminCronjobsAdd()
|
||||||
{
|
{
|
||||||
global $admin_userdata;
|
global $admin_userdata;
|
||||||
|
|||||||
@@ -11,6 +11,28 @@ class PhpSettingsText extends TestCase
|
|||||||
{
|
{
|
||||||
private static $id = 0;
|
private static $id = 0;
|
||||||
|
|
||||||
|
public function testAdminPhpSettingsList()
|
||||||
|
{
|
||||||
|
global $admin_userdata;
|
||||||
|
$json_result = PhpSettings::getLocal($admin_userdata)->listing();
|
||||||
|
$result = json_decode($json_result, true)['data'];
|
||||||
|
$this->assertEquals("Default Config", $result['list'][0]['description']);
|
||||||
|
$this->assertEquals("/usr/bin/php-cgi", $result['list'][0]['binary']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCustomerPhpSettingsListNotAllowed()
|
||||||
|
{
|
||||||
|
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.");
|
||||||
|
PhpSettings::getLocal($customer_userdata)->listing();
|
||||||
|
}
|
||||||
|
|
||||||
public function testAdminPhpSettingsAdd()
|
public function testAdminPhpSettingsAdd()
|
||||||
{
|
{
|
||||||
global $admin_userdata;
|
global $admin_userdata;
|
||||||
@@ -26,4 +48,36 @@ class PhpSettingsText extends TestCase
|
|||||||
self::$id = $result['id'];
|
self::$id = $result['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testAdminPhpSettingsGet()
|
||||||
|
{
|
||||||
|
global $admin_userdata;
|
||||||
|
$data = [
|
||||||
|
'id' => self::$id
|
||||||
|
];
|
||||||
|
$json_result = PhpSettings::getLocal($admin_userdata, $data)->get();
|
||||||
|
$result = json_decode($json_result, true)['data'];
|
||||||
|
$this->assertEquals('error_reporting=E_ALL', $result['phpsettings']);
|
||||||
|
$this->assertEquals('60s', $result['fpm_reqterm']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAdminPhpSettingsGetNotFound()
|
||||||
|
{
|
||||||
|
global $admin_userdata;
|
||||||
|
$this->expectExceptionCode(404);
|
||||||
|
$this->expectExceptionMessage("php-config with id #999 could not be found");
|
||||||
|
PhpSettings::getLocal($admin_userdata, array('id' => 999))->get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCustomerPhpSettingsGetNotAllowed()
|
||||||
|
{
|
||||||
|
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.");
|
||||||
|
PhpSettings::getLocal($customer_userdata, array('id' => 1))->get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user