removing more ticket-stuff; update all unit-tests
Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
<?php
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use Froxlor\Settings;
|
||||
use Froxlor\Api\Commands\Customers;
|
||||
use Froxlor\Api\Commands\DomainZones;
|
||||
|
||||
/**
|
||||
*
|
||||
* @covers ApiCommand
|
||||
* @covers ApiParameter
|
||||
* @covers SubDomains
|
||||
* @covers DomainZones
|
||||
* @covers \Froxlor\Api\ApiCommand
|
||||
* @covers \Froxlor\Api\ApiParameter
|
||||
* @covers \Froxlor\Api\Commands\SubDomains
|
||||
* @covers \Froxlor\Api\Commands\DomainZones
|
||||
*/
|
||||
class DomainZonesTest extends TestCase
|
||||
{
|
||||
@@ -14,15 +18,15 @@ class DomainZonesTest extends TestCase
|
||||
public function testCustomerDomainZonesGet()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
|
||||
Settings::Set('system.dnsenabled', 1, true);
|
||||
|
||||
|
||||
// get customer
|
||||
$json_result = Customers::getLocal($admin_userdata, array(
|
||||
'loginname' => 'test1'
|
||||
))->get();
|
||||
$customer_userdata = json_decode($json_result, true)['data'];
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local'
|
||||
];
|
||||
@@ -33,18 +37,19 @@ class DomainZonesTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testCustomerDomainZonesGet
|
||||
*/
|
||||
public function testCustomerDomainZonesGetNoSubdomains()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
|
||||
// get customer
|
||||
$json_result = Customers::getLocal($admin_userdata, array(
|
||||
'loginname' => 'test1'
|
||||
))->get();
|
||||
$customer_userdata = json_decode($json_result, true)['data'];
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'mysub2.test2.local'
|
||||
];
|
||||
@@ -52,14 +57,14 @@ class DomainZonesTest extends TestCase
|
||||
$this->expectExceptionMessage("DNS zones can only be generated for the main domain, not for subdomains");
|
||||
DomainZones::getLocal($customer_userdata, $data)->get();
|
||||
}
|
||||
|
||||
|
||||
public function testAdminDomainZonesListing()
|
||||
{
|
||||
global $admin_userdata;
|
||||
$this->expectExceptionCode(303);
|
||||
DomainZones::getLocal($admin_userdata)->listing();
|
||||
}
|
||||
|
||||
|
||||
public function testAdminDomainZonesUpdate()
|
||||
{
|
||||
global $admin_userdata;
|
||||
@@ -68,6 +73,7 @@ class DomainZonesTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testCustomerDomainZonesGet
|
||||
*/
|
||||
public function testCustomerDomainZonesAddA()
|
||||
@@ -79,7 +85,7 @@ class DomainZonesTest extends TestCase
|
||||
'loginname' => 'test1'
|
||||
))->get();
|
||||
$customer_userdata = json_decode($json_result, true)['data'];
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local',
|
||||
'record' => 'www2',
|
||||
@@ -99,68 +105,71 @@ class DomainZonesTest extends TestCase
|
||||
$this->assertTrue($found);
|
||||
$this->assertEquals('www2 18000 IN A 127.0.0.1', $entry);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testCustomerDomainZonesAddA
|
||||
*/
|
||||
public function testCustomerDomainZonesAddAInvalid()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
|
||||
// get customer
|
||||
$json_result = Customers::getLocal($admin_userdata, array(
|
||||
'loginname' => 'test1'
|
||||
))->get();
|
||||
$customer_userdata = json_decode($json_result, true)['data'];
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local',
|
||||
'record' => 'www3',
|
||||
'type' => 'A',
|
||||
'content' => 'a.b.c.d',
|
||||
'ttl' => -1
|
||||
'ttl' => - 1
|
||||
];
|
||||
$this->expectExceptionMessage("No valid IP address for A-record given");
|
||||
DomainZones::getLocal($customer_userdata, $data)->add();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testCustomerDomainZonesAddA
|
||||
*/
|
||||
public function testCustomerDomainZonesAddADuplicate()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
|
||||
// get customer
|
||||
$json_result = Customers::getLocal($admin_userdata, array(
|
||||
'loginname' => 'test1'
|
||||
))->get();
|
||||
$customer_userdata = json_decode($json_result, true)['data'];
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local',
|
||||
'record' => 'www2',
|
||||
'type' => 'A',
|
||||
'content' => '127.0.0.1',
|
||||
'ttl' => -1
|
||||
'ttl' => - 1
|
||||
];
|
||||
$this->expectExceptionMessage("Record already exists");
|
||||
DomainZones::getLocal($customer_userdata, $data)->add();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testCustomerDomainZonesGet
|
||||
*/
|
||||
public function testCustomerDomainZonesAddAAAA()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
|
||||
// get customer
|
||||
$json_result = Customers::getLocal($admin_userdata, array(
|
||||
'loginname' => 'test1'
|
||||
))->get();
|
||||
$customer_userdata = json_decode($json_result, true)['data'];
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local',
|
||||
'record' => 'www3',
|
||||
@@ -180,31 +189,32 @@ class DomainZonesTest extends TestCase
|
||||
$this->assertTrue($found);
|
||||
$this->assertEquals('www3 18000 IN AAAA ::1', $entry);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testCustomerDomainZonesAddA
|
||||
*/
|
||||
public function testCustomerDomainZonesAddAAAAInvalid()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
|
||||
// get customer
|
||||
$json_result = Customers::getLocal($admin_userdata, array(
|
||||
'loginname' => 'test1'
|
||||
))->get();
|
||||
$customer_userdata = json_decode($json_result, true)['data'];
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local',
|
||||
'record' => 'www4',
|
||||
'type' => 'AAAA',
|
||||
'content' => 'z:z123.123',
|
||||
'ttl' => -1
|
||||
'ttl' => - 1
|
||||
];
|
||||
$this->expectExceptionMessage("No valid IP address for AAAA-record given");
|
||||
DomainZones::getLocal($customer_userdata, $data)->add();
|
||||
}
|
||||
|
||||
|
||||
public function testAdminDomainZonesAddMX()
|
||||
{
|
||||
global $admin_userdata;
|
||||
@@ -221,7 +231,7 @@ class DomainZonesTest extends TestCase
|
||||
$this->assertTrue(count($result) > 1);
|
||||
$found = false;
|
||||
foreach ($result as $entry) {
|
||||
if (substr($entry, strlen('mail.example.com.') * -1) == 'mail.example.com.') {
|
||||
if (substr($entry, strlen('mail.example.com.') * - 1) == 'mail.example.com.') {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
@@ -229,14 +239,15 @@ class DomainZonesTest extends TestCase
|
||||
$this->assertTrue($found);
|
||||
$this->assertEquals('@ 18000 IN MX 10 mail.example.com.', $entry);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testAdminDomainZonesAddMX
|
||||
*/
|
||||
public function testAdminDomainZonesAddMXNoPrio()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local',
|
||||
'record' => '',
|
||||
@@ -248,12 +259,13 @@ class DomainZonesTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testAdminDomainZonesAddMX
|
||||
*/
|
||||
public function testAdminDomainZonesAddMXInvalid()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local',
|
||||
'record' => '',
|
||||
@@ -264,11 +276,11 @@ class DomainZonesTest extends TestCase
|
||||
$this->expectExceptionMessage("The MX content value must be a valid domain-name");
|
||||
DomainZones::getLocal($admin_userdata, $data)->add();
|
||||
}
|
||||
|
||||
|
||||
public function testAdminDomainZonesAddCname()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local',
|
||||
'record' => 'db',
|
||||
@@ -280,7 +292,7 @@ class DomainZonesTest extends TestCase
|
||||
$this->assertTrue(count($result) > 1);
|
||||
$found = false;
|
||||
foreach ($result as $entry) {
|
||||
if (substr($entry, strlen('db.example.com.') * -1) == 'db.example.com.') {
|
||||
if (substr($entry, strlen('db.example.com.') * - 1) == 'db.example.com.') {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
@@ -288,11 +300,11 @@ class DomainZonesTest extends TestCase
|
||||
$this->assertTrue($found);
|
||||
$this->assertEquals('db 18000 IN CNAME db.example.com.', $entry);
|
||||
}
|
||||
|
||||
|
||||
public function testAdminDomainZonesAddCnameLocal()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local',
|
||||
'record' => 'db',
|
||||
@@ -304,7 +316,7 @@ class DomainZonesTest extends TestCase
|
||||
$this->assertTrue(count($result) > 1);
|
||||
$found = false;
|
||||
foreach ($result as $entry) {
|
||||
if (substr($entry, strlen('db2.test2.local.') * -1) == 'db2.test2.local.') {
|
||||
if (substr($entry, strlen('db2.test2.local.') * - 1) == 'db2.test2.local.') {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
@@ -312,14 +324,15 @@ class DomainZonesTest extends TestCase
|
||||
$this->assertTrue($found);
|
||||
$this->assertEquals('db 18000 IN CNAME db2.test2.local.', $entry);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testAdminDomainZonesAddCname
|
||||
*/
|
||||
public function testAdminDomainZonesAddCnameInvalid()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local',
|
||||
'record' => '',
|
||||
@@ -329,8 +342,9 @@ class DomainZonesTest extends TestCase
|
||||
$this->expectExceptionMessage("Invalid domain-name for CNAME record");
|
||||
DomainZones::getLocal($admin_userdata, $data)->add();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @depends testAdminDomainZonesAddCname
|
||||
*/
|
||||
public function testAdminDomainZonesAddCnameUnderscore()
|
||||
@@ -348,7 +362,7 @@ class DomainZonesTest extends TestCase
|
||||
$this->assertTrue(count($result) > 1);
|
||||
$found = false;
|
||||
foreach ($result as $entry) {
|
||||
if (substr($entry, strlen('test._domainkey.myhost.tld.') * -1) == 'test._domainkey.myhost.tld.') {
|
||||
if (substr($entry, strlen('test._domainkey.myhost.tld.') * - 1) == 'test._domainkey.myhost.tld.') {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
@@ -360,7 +374,7 @@ class DomainZonesTest extends TestCase
|
||||
public function testAdminDomainZonesAddNS()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local',
|
||||
'record' => '',
|
||||
@@ -372,7 +386,7 @@ class DomainZonesTest extends TestCase
|
||||
$this->assertTrue(count($result) > 1);
|
||||
$found = false;
|
||||
foreach ($result as $entry) {
|
||||
if (substr($entry, strlen('ns.example.com.') * -1) == 'ns.example.com.') {
|
||||
if (substr($entry, strlen('ns.example.com.') * - 1) == 'ns.example.com.') {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
@@ -384,7 +398,7 @@ class DomainZonesTest extends TestCase
|
||||
public function testAdminDomainZonesAddNsInvalid()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local',
|
||||
'record' => '',
|
||||
@@ -394,11 +408,11 @@ class DomainZonesTest extends TestCase
|
||||
$this->expectExceptionMessage("Invalid domain-name for NS record");
|
||||
DomainZones::getLocal($admin_userdata, $data)->add();
|
||||
}
|
||||
|
||||
|
||||
public function testAdminDomainZonesAddTXT()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local',
|
||||
'record' => '_test1',
|
||||
@@ -418,11 +432,11 @@ class DomainZonesTest extends TestCase
|
||||
$this->assertTrue($found);
|
||||
$this->assertEquals('_test1 18000 IN TXT aw yeah', $entry);
|
||||
}
|
||||
|
||||
|
||||
public function testAdminDomainZonesAddSRV()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local',
|
||||
'record' => '_test2',
|
||||
@@ -443,11 +457,11 @@ class DomainZonesTest extends TestCase
|
||||
$this->assertTrue($found);
|
||||
$this->assertEquals('_test2 18000 IN SRV 50 2 1 srv.example.com.', $entry);
|
||||
}
|
||||
|
||||
|
||||
public function testAdminDomainZonesAddSrvInvalid()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local',
|
||||
'record' => '_test2',
|
||||
@@ -458,7 +472,7 @@ class DomainZonesTest extends TestCase
|
||||
$this->expectExceptionMessage("Invalid SRV content, must contain of fields weight, port and target, e.g.: 5 5060 sipserver.example.com.");
|
||||
DomainZones::getLocal($admin_userdata, $data)->add();
|
||||
}
|
||||
|
||||
|
||||
public function testCustomerDomainZonesDelete()
|
||||
{
|
||||
global $admin_userdata;
|
||||
@@ -468,7 +482,7 @@ class DomainZonesTest extends TestCase
|
||||
'loginname' => 'test1'
|
||||
))->get();
|
||||
$customer_userdata = json_decode($json_result, true)['data'];
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local',
|
||||
'entry_id' => 1
|
||||
@@ -478,17 +492,17 @@ class DomainZonesTest extends TestCase
|
||||
$this->assertTrue($result['data']);
|
||||
$this->assertEquals(200, $result['status']);
|
||||
}
|
||||
|
||||
|
||||
public function testCustomerDomainZonesDeleteUnmodified()
|
||||
{
|
||||
global $admin_userdata;
|
||||
|
||||
|
||||
// get customer
|
||||
$json_result = Customers::getLocal($admin_userdata, array(
|
||||
'loginname' => 'test1'
|
||||
))->get();
|
||||
$customer_userdata = json_decode($json_result, true)['data'];
|
||||
|
||||
|
||||
$data = [
|
||||
'domainname' => 'test2.local',
|
||||
'entry_id' => 1337
|
||||
|
||||
Reference in New Issue
Block a user