removing more ticket-stuff; update all unit-tests

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2018-12-19 19:42:50 +01:00
parent 60f1db5caf
commit 26510f0745
63 changed files with 537 additions and 1579 deletions

View File

@@ -1,12 +1,17 @@
<?php
use PHPUnit\Framework\TestCase;
use Froxlor\Api\Commands\Admins;
use Froxlor\Api\Commands\Customers;
use Froxlor\Api\Commands\Ftps;
/**
* @covers ApiCommand
* @covers ApiParameter
* @covers Ftps
* @covers Customers
* @covers Admins
*
* @covers \Froxlor\Api\ApiCommand
* @covers \Froxlor\Api\ApiParameter
* @covers \Froxlor\Api\Commands\Admins
* @covers \Froxlor\Api\Commands\Customers
* @covers \Froxlor\Api\Commands\Ftps
*/
class FtpsTest extends TestCase
{
@@ -19,7 +24,7 @@ class FtpsTest extends TestCase
'id' => 1
))->get();
$result = json_decode($json_result, true)['data'];
// should be the ftp user of the first added customr 'test1'
$this->assertEquals('test1', $result['username']);
}
@@ -39,30 +44,30 @@ class FtpsTest extends TestCase
$result = json_decode($json_result, true)['data'];
$this->assertEquals('test1', $result['username']);
}
public function testCustomerFtpsGetId()
{
global $admin_userdata;
// get customer
$json_result = Customers::getLocal($admin_userdata, array(
'id' => 1
))->get();
$customer_userdata = json_decode($json_result, true)['data'];
$json_result = Ftps::getLocal($customer_userdata, array(
'id' => 1
))->get();
$result = json_decode($json_result, true)['data'];
// should be the ftp user of the first added customr 'test1'
$this->assertEquals('test1', $result['username']);
}
public function testCustomerFtpsGetOtherId()
{
global $admin_userdata;
// get customer
$json_result = Customers::getLocal($admin_userdata, array(
'id' => 1
@@ -75,11 +80,11 @@ class FtpsTest extends TestCase
'id' => 10
))->get();
}
public function testAdminFtpsList()
{
global $admin_userdata;
$json_result = Ftps::getLocal($admin_userdata)->listing();
$result = json_decode($json_result, true)['data'];
$this->assertEquals(2, $result['count']);
@@ -88,13 +93,15 @@ class FtpsTest extends TestCase
public function testAdminFtpsListSpecificCustomer()
{
global $admin_userdata;
$json_result = Ftps::getLocal($admin_userdata, array('loginname' => 'test1'))->listing();
$json_result = Ftps::getLocal($admin_userdata, array(
'loginname' => 'test1'
))->listing();
$result = json_decode($json_result, true)['data'];
$this->assertEquals(1, $result['count']);
$this->assertEquals('test1', $result['list'][0]['username']);
}
public function testResellerFtpsList()
{
global $admin_userdata;
@@ -109,7 +116,7 @@ class FtpsTest extends TestCase
$this->assertEquals(1, $result['count']);
$this->assertEquals('test1', $result['list'][0]['username']);
}
public function testCustomerFtpsList()
{
global $admin_userdata;
@@ -123,17 +130,17 @@ class FtpsTest extends TestCase
$this->assertEquals(1, $result['count']);
$this->assertEquals('test1', $result['list'][0]['username']);
}
public function testCustomerFtpsAdd()
{
global $admin_userdata;
// get customer
$json_result = Customers::getLocal($admin_userdata, array(
'loginname' => 'test1'
))->get();
$customer_userdata = json_decode($json_result, true)['data'];
$data = [
'ftp_password' => 'h4xXx0r',
'path' => '/',
@@ -148,13 +155,13 @@ class FtpsTest extends TestCase
public function testCustomerFtpsAddNoMoreResources()
{
global $admin_userdata;
// get customer
$json_result = Customers::getLocal($admin_userdata, array(
'loginname' => 'test1'
))->get();
$customer_userdata = json_decode($json_result, true)['data'];#
$customer_userdata = json_decode($json_result, true)['data']; //
$customer_userdata['ftps_used'] = 100;
$this->expectExceptionCode(406);
@@ -172,7 +179,7 @@ class FtpsTest extends TestCase
'ftp_description' => 'testing',
'sendinfomail' => 1
];
$this->expectExceptionCode(406);
$this->expectExceptionMessage('Requested parameter "loginname" is empty where it should not be for "Customers:get"');
$json_result = Ftps::getLocal($admin_userdata, $data)->add();
@@ -181,13 +188,13 @@ class FtpsTest extends TestCase
public function testCustomerFtpsEdit()
{
global $admin_userdata;
// get customer
$json_result = Customers::getLocal($admin_userdata, array(
'loginname' => 'test1'
))->get();
$customer_userdata = json_decode($json_result, true)['data'];
$data = [
'username' => 'test1ftp1',
'ftp_password' => 'h4xXx0r2',
@@ -196,10 +203,10 @@ class FtpsTest extends TestCase
];
$json_result = Ftps::getLocal($customer_userdata, $data)->update();
$result = json_decode($json_result, true)['data'];
$this->assertEquals($customer_userdata['documentroot'].'subfolder/', $result['homedir']);
$this->assertEquals($customer_userdata['documentroot'] . 'subfolder/', $result['homedir']);
$this->assertEquals('testing2', $result['description']);
}
public function testAdminFtpsEdit()
{
global $admin_userdata;
@@ -217,20 +224,20 @@ class FtpsTest extends TestCase
];
$json_result = Ftps::getLocal($admin_userdata, $data)->update();
$result = json_decode($json_result, true)['data'];
$this->assertEquals($customer_userdata['documentroot'].'anotherfolder/', $result['homedir']);
$this->assertEquals($customer_userdata['documentroot'] . 'anotherfolder/', $result['homedir']);
$this->assertEquals('testing3', $result['description']);
}
public function testAdminFtpsAdd()
{
global $admin_userdata;
// get customer
$json_result = Customers::getLocal($admin_userdata, array(
'loginname' => 'test1'
))->get();
$customer_userdata = json_decode($json_result, true)['data'];
$data = [
'customerid' => $customer_userdata['customerid'],
'ftp_password' => 'h4xXx0r',
@@ -242,11 +249,11 @@ class FtpsTest extends TestCase
$result = json_decode($json_result, true)['data'];
$this->assertEquals($customer_userdata['documentroot'], $result['homedir']);
}
public function testCustomerFtpsDelete()
{
global $admin_userdata;
// get customer
$json_result = Customers::getLocal($admin_userdata, array(
'loginname' => 'test1'
@@ -259,7 +266,7 @@ class FtpsTest extends TestCase
$result = json_decode($json_result, true)['data'];
$this->assertEquals('test1ftp1', $result['username']);
}
public function testAdminFtpsDelete()
{
global $admin_userdata;