minor fixes and first tests for Domains-ApiCommand
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
@@ -69,7 +69,6 @@ class ConfigServicesCmd extends CmdLineHandler
|
|||||||
self::println("--daemon\t\tWhen running --apply you can specify a daemon. This will be the only service that gets configured");
|
self::println("--daemon\t\tWhen running --apply you can specify a daemon. This will be the only service that gets configured");
|
||||||
self::println("\t\t\tExample: --apply=/path/to/my-config.json --daemon=apache24");
|
self::println("\t\t\tExample: --apply=/path/to/my-config.json --daemon=apache24");
|
||||||
self::println("");
|
self::println("");
|
||||||
self::println("");
|
|
||||||
self::println("--import-settings\tImport settings from another froxlor installation. This should be done prior to running --apply or alternatively in the same command together.");
|
self::println("--import-settings\tImport settings from another froxlor installation. This should be done prior to running --apply or alternatively in the same command together.");
|
||||||
self::println("\t\t\tExample: --import-settings=/path/to/Froxlor_settings-[version]-[dbversion]-[date].json");
|
self::println("\t\t\tExample: --import-settings=/path/to/Froxlor_settings-[version]-[dbversion]-[date].json");
|
||||||
self::println("");
|
self::println("");
|
||||||
|
|||||||
@@ -183,10 +183,6 @@ class Domains extends ApiCommand implements ResourceEntity
|
|||||||
))->get();
|
))->get();
|
||||||
$customer = json_decode($json_result, true)['data'];
|
$customer = json_decode($json_result, true)['data'];
|
||||||
|
|
||||||
if (empty($customer) || $customer['customerid'] != $customerid) {
|
|
||||||
standard_error('customerdoesntexist', '', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->getUserDetail('customers_see_all') == '1') {
|
if ($this->getUserDetail('customers_see_all') == '1') {
|
||||||
$admin_stmt = Database::prepare("
|
$admin_stmt = Database::prepare("
|
||||||
SELECT * FROM `" . TABLE_PANEL_ADMINS . "`
|
SELECT * FROM `" . TABLE_PANEL_ADMINS . "`
|
||||||
@@ -194,10 +190,6 @@ class Domains extends ApiCommand implements ResourceEntity
|
|||||||
$admin = Database::pexecute_first($admin_stmt, array(
|
$admin = Database::pexecute_first($admin_stmt, array(
|
||||||
'adminid' => $adminid
|
'adminid' => $adminid
|
||||||
), true, true);
|
), true, true);
|
||||||
|
|
||||||
if (empty($admin) || $admin['adminid'] != $adminid) {
|
|
||||||
standard_error('admindoesntexist', '', true);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$adminid = $this->getUserDetail('adminid');
|
$adminid = $this->getUserDetail('adminid');
|
||||||
$admin = $this->getUserData();
|
$admin = $this->getUserData();
|
||||||
|
|||||||
@@ -26,13 +26,12 @@ function getIpPortCombinations($ssl = false) {
|
|||||||
|
|
||||||
if ($userinfo['ip'] != '-1') {
|
if ($userinfo['ip'] != '-1') {
|
||||||
$admin_ip_stmt = Database::prepare("
|
$admin_ip_stmt = Database::prepare("
|
||||||
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = :ipid
|
SELECT `id`, `ip`, `port` FROM `" . TABLE_PANEL_IPSANDPORTS . "` WHERE `id` = IN (:ipid)
|
||||||
");
|
");
|
||||||
$admin_ip = Database::pexecute_first($admin_ip_stmt, array('ipid' => $userinfo['ip']));
|
$myips = implode(",", json_decode($userinfo['ip'], true));
|
||||||
|
Database::pexecute($admin_ip_stmt, array('ipid' => $myips));
|
||||||
$additional_conditions_array[] = "`ip` = :adminip";
|
$additional_conditions_array[] = "`ip` IN (:adminips)";
|
||||||
$additional_conditions_params['adminip'] = $admin_ip['ip'];
|
$additional_conditions_params['adminips'] = $myips;
|
||||||
$admin_ip = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ssl !== null) {
|
if ($ssl !== null) {
|
||||||
|
|||||||
87
tests/Domains/DomainsTest.php
Normal file
87
tests/Domains/DomainsTest.php
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
<?php
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers ApiCommand
|
||||||
|
* @covers SubDomains
|
||||||
|
* @covers Domains
|
||||||
|
*/
|
||||||
|
class DomainsTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testAdminDomainsAdd()
|
||||||
|
{
|
||||||
|
global $admin_userdata;
|
||||||
|
// get customer
|
||||||
|
$json_result = Customers::getLocal($admin_userdata, array(
|
||||||
|
'loginname' => 'test1'
|
||||||
|
))->get();
|
||||||
|
$customer_userdata = json_decode($json_result, true)['data'];
|
||||||
|
$data = [
|
||||||
|
'domain' => 'test.local',
|
||||||
|
'customerid' => $customer_userdata['customerid']
|
||||||
|
];
|
||||||
|
$json_result = Domains::getLocal($admin_userdata, $data)->add();
|
||||||
|
$result = json_decode($json_result, true)['data'];
|
||||||
|
$this->assertEquals($customer_userdata['documentroot'].'test.local/', $result['documentroot']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testAdminDomainsAdd
|
||||||
|
*/
|
||||||
|
public function testAdminDomainsList()
|
||||||
|
{
|
||||||
|
global $admin_userdata;
|
||||||
|
$json_result = Domains::getLocal($admin_userdata)->list();
|
||||||
|
$result = json_decode($json_result, true)['data'];
|
||||||
|
$this->assertEquals(1, $result['count']);
|
||||||
|
$this->assertEquals('test.local', $result['list'][0]['domain']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAdminDomainsAddSysHostname()
|
||||||
|
{
|
||||||
|
global $admin_userdata;
|
||||||
|
$data = [
|
||||||
|
'domain' => 'dev.froxlor.org',
|
||||||
|
'customerid' => 1
|
||||||
|
];
|
||||||
|
$this->expectExceptionMessage('The server-hostname cannot be used as customer-domain.');
|
||||||
|
$json_result = Domains::getLocal($admin_userdata, $data)->add();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAdminDomainsAddNoPunycode()
|
||||||
|
{
|
||||||
|
global $admin_userdata;
|
||||||
|
$data = [
|
||||||
|
'domain' => 'xn--asdasd.tld',
|
||||||
|
'customerid' => 1
|
||||||
|
];
|
||||||
|
$this->expectExceptionMessage('You must not specify punycode (IDNA). The domain will automatically be converted');
|
||||||
|
$json_result = Domains::getLocal($admin_userdata, $data)->add();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAdminDomainsAddInvalidDomain()
|
||||||
|
{
|
||||||
|
global $admin_userdata;
|
||||||
|
$data = [
|
||||||
|
'domain' => 'dom?*ain.tld',
|
||||||
|
'customerid' => 1
|
||||||
|
];
|
||||||
|
$this->expectExceptionMessage("Wrong Input in Field 'Domain'");
|
||||||
|
$json_result = Domains::getLocal($admin_userdata, $data)->add();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @depends testAdminDomainsList
|
||||||
|
*/
|
||||||
|
public function testAdminDomainsDelete()
|
||||||
|
{
|
||||||
|
global $admin_userdata;
|
||||||
|
$data = [
|
||||||
|
'domainname' => 'test.local',
|
||||||
|
'delete_mainsubdomains' => 1
|
||||||
|
];
|
||||||
|
$json_result = Domains::getLocal($admin_userdata, $data)->delete();
|
||||||
|
$result = json_decode($json_result, true)['data'];
|
||||||
|
$this->assertEquals('test.local', $result['domain']);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user