|
@@ -3,15 +3,14 @@
|
|
|
|
|
|
require __DIR__ . '/../init.php';
|
|
|
|
|
|
-const SFTP = '/usr/bin/sftp';
|
|
|
-const SSHPASS = '/usr/bin/sshpass';
|
|
|
-
|
|
|
const HTTPS_PORT = '42443';
|
|
|
-const CORE_DOMAIN = 'servnest.test';
|
|
|
-const CORE_URL = 'https://' . CORE_DOMAIN . ':' . HTTPS_PORT;
|
|
|
-const SUFFIX = 'test.servnest.test.';
|
|
|
+const CORE_URL = 'https://' . CONF['common']['public_domains'][0] . ':' . CONF['check']['https_port'];
|
|
|
|
|
|
-const TOR_PROXY = 'socks5h://127.0.0.1:9050';
|
|
|
+foreach (CONF['reg']['suffixes'] as $suffix => $openness)
|
|
|
+ if ($openness === 'all')
|
|
|
+ define('SUFFIX', $suffix);
|
|
|
+if (!defined('SUFFIX'))
|
|
|
+ exit('Unable to start tests: no suffix open to registration');
|
|
|
|
|
|
if (kdig(name: 'nlnet.nl', type: 'AAAA')['AD'] !== 1)
|
|
|
exit('DNS queries don\'t seem to be DNSSEC-validated.' . LF);
|
|
@@ -38,7 +37,7 @@ function curlTest(string $address, array $post = [], bool $tor = false): string
|
|
|
curl_setopt($req, CURLOPT_URL, $address);
|
|
|
|
|
|
if ($tor)
|
|
|
- curl_setopt($req, CURLOPT_PROXY, TOR_PROXY);
|
|
|
+ curl_setopt($req, CURLOPT_PROXY, CONF['check']['tor_proxy']);
|
|
|
else
|
|
|
curl_setopt($req, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
|
|
@@ -71,7 +70,7 @@ curlTest('/auth/register', [
|
|
|
'username' => $username . '2',
|
|
|
'password' => $password,
|
|
|
]);
|
|
|
-curlTest('/auth/logout', []);
|
|
|
+curlTest('/auth/logout');
|
|
|
|
|
|
curlTest('/auth/login', [
|
|
|
'username' => $username,
|
|
@@ -118,14 +117,14 @@ function testReg(): string {
|
|
|
]);
|
|
|
|
|
|
{ // Domain transfer
|
|
|
- curlTest('/auth/logout', []);
|
|
|
+ curlTest('/auth/logout');
|
|
|
curlTest('/auth/login', [
|
|
|
'username' => $username . '2',
|
|
|
'password' => $password,
|
|
|
]);
|
|
|
- preg_match('#\<code\>(?<token>[0-9a-z-]{16,128}\._transfer-verification\.' . preg_quote(CORE_DOMAIN, '#') . '\.)\</code\>#', curlTest('/reg/transfer', []), $matches);
|
|
|
+ preg_match('#\<code\>(?<token>[0-9a-z-]{16,128}\._transfer-verification\.' . preg_quote(CONF['common']['public_domains'][0], '#') . '\.)\</code\>#', curlTest('/reg/transfer'), $matches);
|
|
|
|
|
|
- curlTest('/auth/logout', []);
|
|
|
+ curlTest('/auth/logout');
|
|
|
curlTest('/auth/login', [
|
|
|
'username' => $username,
|
|
|
'password' => $password,
|
|
@@ -136,7 +135,7 @@ function testReg(): string {
|
|
|
'ns' => $matches['token'],
|
|
|
]);
|
|
|
|
|
|
- curlTest('/auth/logout', []);
|
|
|
+ curlTest('/auth/logout');
|
|
|
curlTest('/auth/login', [
|
|
|
'username' => $username . '2',
|
|
|
'password' => $password,
|
|
@@ -161,7 +160,7 @@ function testNs(string $domain): void {
|
|
|
'ns' => $ns,
|
|
|
]);
|
|
|
|
|
|
- preg_match('#\<code\>(?<token>[0-9a-z-]{16,128}\._domain-verification\.' . preg_quote(CORE_DOMAIN, '#') . '\.)\</code\>#', curlTest('/ns/zone-add', []), $matches);
|
|
|
+ preg_match('#\<code\>(?<token>[0-9a-z-]{16,128}\._domain-verification\.' . preg_quote(CONF['common']['public_domains'][0], '#') . '\.)\</code\>#', curlTest('/ns/zone-add'), $matches);
|
|
|
curlTest('/reg/ns', [
|
|
|
'action' => 'add',
|
|
|
'domain' => $domain,
|
|
@@ -214,7 +213,7 @@ put ' . sys_get_temp_dir() . '/index.html /_site0-/index.html
|
|
|
exit
|
|
|
');
|
|
|
|
|
|
- $process = proc_open(SSHPASS . ' ' . SFTP . ' -o BatchMode=no -b ' . sys_get_temp_dir() . '/exec.txt -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -P ' . CONF['ht']['public_sftp_port'] . ' ' . $username . '@' . CONF['ht']['sftp_domain'], [0 => ['pipe', 'r']], $pipes);
|
|
|
+ $process = proc_open(CONF['check']['sshpass_path'] . ' ' . CONF['check']['sftp_path'] . ' -o BatchMode=no -b ' . sys_get_temp_dir() . '/exec.txt -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -P ' . CONF['ht']['public_sftp_port'] . ' ' . $username . '@' . CONF['ht']['sftp_domain'], [0 => ['pipe', 'r']], $pipes);
|
|
|
if (is_resource($process) !== true)
|
|
|
exit('Can\'t spawn sftp with sshpass.' . LF);
|
|
|
fwrite($pipes[0], $password);
|