check dns for lets encrypt when adding/editing domains and via cron; fixes #971

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2021-08-04 13:44:13 +02:00
parent bef5cedcd0
commit 0a1a3e023f
7 changed files with 85 additions and 0 deletions

View File

@@ -24,6 +24,7 @@ class DomainsTest extends TestCase
$json_result = Customers::getLocal($admin_userdata, array(
'loginname' => 'test1'
))->get();
$customer_userdata = json_decode($json_result, true)['data'];
$data = [
'domain' => 'TEST.local',
@@ -425,4 +426,25 @@ class DomainsTest extends TestCase
'domainname' => 'उदाहरण.भारत'
])->delete();
}
public function testAdminDomainsAddDnsLetsEncryptFail()
{
global $admin_userdata;
// get customer
$json_result = Customers::getLocal($admin_userdata, array(
'loginname' => 'test1'
))->get();
Settings::Set('system.le_domain_dnscheck', 1);
$customer_userdata = json_decode($json_result, true)['data'];
$data = [
'domain' => 'no-dns.local',
'customerid' => $customer_userdata['customerid'],
'letsencrypt' => 1,
'description' => 'no dns domain'
];
$this->expectExceptionCode(400);
$this->expectExceptionMessage('The domains DNS does not include any of the chosen IP addresses. Let\'s Encrypt certificate generation not possible.');
Domains::getLocal($admin_userdata, $data)->add();
}
}

View File

@@ -260,4 +260,24 @@ class SubDomainsTest extends TestCase
$this->assertEquals('mysub.test2.local', $result['domain']);
$this->assertEquals($customer_userdata['customerid'], $result['customerid']);
}
public function testCustomerSubDomainsAddDnsLetsEncryptFail()
{
global $admin_userdata;
// get customer
$json_result = Customers::getLocal($admin_userdata, array(
'loginname' => 'test1'
))->get();
\Froxlor\Settings::Set('system.le_domain_dnscheck', 1);
$customer_userdata = json_decode($json_result, true)['data'];
$data = [
'subdomain' => 'nodns',
'domain' => 'test2.local',
'letsencrypt' => 1
];
$this->expectExceptionCode(400);
$this->expectExceptionMessage('The domains DNS does not include any of the chosen IP addresses. Let\'s Encrypt certificate generation not possible.');
SubDomains::getLocal($customer_userdata, $data)->add();
}
}