validate that a customer gets the default ftp account created even if the admin/reseller has no more resource for ftp accounts; fixes #741
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -56,7 +56,9 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
|
||||
throw new \Exception("You cannot access this resource", 405);
|
||||
}
|
||||
|
||||
if ($this->getUserDetail('ftps_used') < $this->getUserDetail('ftps') || $this->getUserDetail('ftps') == '-1') {
|
||||
$is_defaultuser = $this->getBoolParam('is_defaultuser', true, 0);
|
||||
|
||||
if (($this->getUserDetail('ftps_used') < $this->getUserDetail('ftps') || $this->getUserDetail('ftps') == '-1') || $this->isAdmin() && $is_defaultuser == 1) {
|
||||
|
||||
// required paramters
|
||||
$path = $this->getParam('path');
|
||||
@@ -71,7 +73,6 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
|
||||
$ftpdomain = $this->getParam('ftp_domain', true, '');
|
||||
|
||||
$additional_members = $this->getParam('additional_members', true, array());
|
||||
$is_defaultuser = $this->getBoolParam('is_defaultuser', true, 0);
|
||||
|
||||
// validation
|
||||
$password = \Froxlor\Validate\Validate::validate($password, 'password', '', '', array(), true);
|
||||
@@ -105,7 +106,7 @@ class Ftps extends \Froxlor\Api\ApiCommand implements \Froxlor\Api\ResourceEntit
|
||||
$sendinfomail = 0;
|
||||
}
|
||||
|
||||
if (Settings::Get('customer.ftpatdomain') == '1' && !$is_defaultuser) {
|
||||
if (Settings::Get('customer.ftpatdomain') == '1' && ! $is_defaultuser) {
|
||||
if ($ftpusername == '') {
|
||||
\Froxlor\UI\Response::standard_error(array(
|
||||
'stringisempty',
|
||||
|
||||
@@ -6,6 +6,7 @@ use Froxlor\Database\Database;
|
||||
use Froxlor\Api\Commands\Admins;
|
||||
use Froxlor\Api\Commands\Customers;
|
||||
use Froxlor\Api\Commands\SubDomains;
|
||||
use Froxlor\Api\Commands\Ftps;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -61,7 +62,9 @@ class CustomersTest extends TestCase
|
||||
$this->assertEquals('secret', $result['custom_notes']);
|
||||
|
||||
// validate that the std-subdomain has been added
|
||||
$json_result = SubDomains::getLocal($admin_userdata, array('id' => $result['standardsubdomain']))->get();
|
||||
$json_result = SubDomains::getLocal($admin_userdata, array(
|
||||
'id' => $result['standardsubdomain']
|
||||
))->get();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
$this->assertEquals('test1.dev.froxlor.org', $result['domain']);
|
||||
}
|
||||
@@ -555,4 +558,49 @@ class CustomersTest extends TestCase
|
||||
$this->expectExceptionMessage('Loginname contains too many characters. Only ' . (\Froxlor\Database\Database::getSqlUsernameLength() - strlen(Settings::Get('customer.mysqlprefix'))) . ' characters are allowed.');
|
||||
Customers::getLocal($admin_userdata, $data)->add();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testAdminCustomersAddAutoLoginname
|
||||
*/
|
||||
public function testResellerCustomersAddNoFtpValidateDefaultUserExists()
|
||||
{
|
||||
global $admin_userdata;
|
||||
// get reseller
|
||||
$json_result = Admins::getLocal($admin_userdata, array(
|
||||
'loginname' => 'reseller'
|
||||
))->get();
|
||||
$reseller_userdata = json_decode($json_result, true)['data'];
|
||||
$reseller_userdata['adminsession'] = 1;
|
||||
|
||||
// set available ftp resources to 0 to validate that when the customer
|
||||
// is added the default ftp user for the customer is created too regardless of
|
||||
// available resource of the reseller/admin
|
||||
$reseller_userdata['ftps'] = 0;
|
||||
|
||||
// add new customer
|
||||
$data = [
|
||||
'new_loginname' => 'testftpx',
|
||||
'email' => 'testftp@froxlor.org',
|
||||
'firstname' => 'Test',
|
||||
'name' => 'Ftpman',
|
||||
'customernumber' => 1339,
|
||||
'new_customer_password' => 'h0lYmo1y'
|
||||
];
|
||||
Customers::getLocal($reseller_userdata, $data)->add();
|
||||
|
||||
// get FTP user
|
||||
$json_result = Ftps::getLocal($reseller_userdata, [
|
||||
'username' => 'testftpx'
|
||||
])->get();
|
||||
$ftp_data = json_decode($json_result, true)['data'];
|
||||
$this->assertEquals("testftpx", $ftp_data['username']);
|
||||
|
||||
// now get rid of the customer again
|
||||
$json_result = Customers::getLocal($reseller_userdata, array(
|
||||
'loginname' => 'testftpx'
|
||||
))->delete();
|
||||
$result = json_decode($json_result, true)['data'];
|
||||
$this->assertEquals('testftpx', $result['loginname']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user