'test1' ))->get(); $customer_userdata = json_decode($json_result, true)['data']; $data = [ 'path' => '/test', 'username' => 'testing', 'directory_password' => generatePassword(), 'directory_authname' => 'test1' ]; $json_result = DirProtections::getLocal($customer_userdata, $data)->add(); $result = json_decode($json_result, true)['data']; $this->assertEquals($customer_userdata['documentroot'] . 'test/', $result['path']); $this->assertEquals('test1', $result['authname']); } public function testCustomerDirProtectionsAddSameUserPath() { global $admin_userdata; // get customer $json_result = Customers::getLocal($admin_userdata, array( 'loginname' => 'test1' ))->get(); $customer_userdata = json_decode($json_result, true)['data']; $data = [ 'path' => '/test', 'username' => 'testing', 'directory_password' => generatePassword(), 'directory_authname' => 'test2' ]; $this->expectExceptionMessage("Combination of username and path already exists"); DirProtections::getLocal($customer_userdata, $data)->add(); } public function testCustomerDirProtectionsAddPasswordEqualsUsername() { global $admin_userdata; // get customer $json_result = Customers::getLocal($admin_userdata, array( 'loginname' => 'test1' ))->get(); $customer_userdata = json_decode($json_result, true)['data']; $up = generatePassword(); $data = [ 'path' => '/test', 'username' => $up, 'directory_password' => $up, 'directory_authname' => 'test3' ]; $this->expectExceptionMessage("The password should not be the same as the username."); DirProtections::getLocal($customer_userdata, $data)->add(); } /** * @depends testCustomerDirProtectionsAdd */ public function testAdminDirProtectionsGet() { 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' => 'testing', 'customerid' => 1 ]; $json_result = DirProtections::getLocal($admin_userdata, $data)->get(); $result = json_decode($json_result, true)['data']; $this->assertEquals($customer_userdata['documentroot'] . 'test/', $result['path']); $this->assertEquals('test1', $result['authname']); } /** * @depends testCustomerDirProtectionsAdd */ public function testResellerDirProtectionsGet() { global $admin_userdata; // get customer $json_result = Admins::getLocal($admin_userdata, array( 'loginname' => 'reseller' ))->get(); $reseller_userdata = json_decode($json_result, true)['data']; $reseller_userdata['adminsession'] = 1; // get customer $json_result = Customers::getLocal($admin_userdata, array( 'loginname' => 'test1' ))->get(); $customer_userdata = json_decode($json_result, true)['data']; $data = [ 'username' => 'testing' ]; $json_result = DirProtections::getLocal($reseller_userdata, $data)->get(); $result = json_decode($json_result, true)['data']; $this->assertEquals($customer_userdata['documentroot'] . 'test/', $result['path']); $this->assertEquals('test1', $result['authname']); } }