|
@@ -47,7 +47,7 @@ function curlTest(string $address, array $post = [], bool $tor = false): string
|
|
|
if ($status_code >= 400 OR $result === false) {
|
|
|
var_dump($result);
|
|
|
var_dump(curl_error($req));
|
|
|
- exit($address . ' test failed with status code ' . $status_code . LF);
|
|
|
+ throw new Exception($address . ' test failed with status code ' . $status_code);
|
|
|
}
|
|
|
return $result;
|
|
|
}
|
|
@@ -60,13 +60,6 @@ curlTest('/auth/register', [
|
|
|
'password' => $password,
|
|
|
]);
|
|
|
|
|
|
-curlTest('/auth/logout', []);
|
|
|
-
|
|
|
-curlTest('/auth/login', [
|
|
|
- 'username' => $username,
|
|
|
- 'password' => $password,
|
|
|
-]);
|
|
|
-
|
|
|
$new_password = bin2hex(random_bytes(16));
|
|
|
curlTest('/auth/password', [
|
|
|
'current-password' => $password,
|
|
@@ -74,9 +67,20 @@ curlTest('/auth/password', [
|
|
|
]);
|
|
|
$password = $new_password;
|
|
|
|
|
|
+curlTest('/auth/register', [
|
|
|
+ 'username' => $username . '2',
|
|
|
+ 'password' => $password,
|
|
|
+]);
|
|
|
+curlTest('/auth/logout', []);
|
|
|
+
|
|
|
+curlTest('/auth/login', [
|
|
|
+ 'username' => $username,
|
|
|
+ 'password' => $password,
|
|
|
+]);
|
|
|
+
|
|
|
curlTest('/auth/username', [
|
|
|
'current-password' => $password,
|
|
|
- 'new-username' => $username . '2',
|
|
|
+ 'new-username' => $username . '3',
|
|
|
]);
|
|
|
curlTest('/auth/username', [
|
|
|
'current-password' => $password,
|
|
@@ -86,6 +90,8 @@ curlTest('/auth/username', [
|
|
|
echo 'Created account with username "' . $username . '" and password "' . $password . '".' . LF;
|
|
|
|
|
|
function testReg(): string {
|
|
|
+ global $username, $password;
|
|
|
+
|
|
|
$subdomain = bin2hex(random_bytes(16));
|
|
|
|
|
|
curlTest('/reg/register', [
|
|
@@ -116,6 +122,37 @@ function testReg(): string {
|
|
|
'ns' => 'ns1.servnest.invalid.',
|
|
|
]);
|
|
|
|
|
|
+ { // Domain transfer
|
|
|
+ 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);
|
|
|
+
|
|
|
+ curlTest('/auth/logout', []);
|
|
|
+ curlTest('/auth/login', [
|
|
|
+ 'username' => $username,
|
|
|
+ 'password' => $password,
|
|
|
+ ]);
|
|
|
+ curlTest('/reg/ns', [
|
|
|
+ 'action' => 'add',
|
|
|
+ 'domain' => $domain,
|
|
|
+ 'ns' => $matches['token'],
|
|
|
+ ]);
|
|
|
+
|
|
|
+ curlTest('/auth/logout', []);
|
|
|
+ curlTest('/auth/login', [
|
|
|
+ 'username' => $username . '2',
|
|
|
+ 'password' => $password,
|
|
|
+ ]);
|
|
|
+ curlTest('/reg/transfer', [
|
|
|
+ 'subdomain' => $subdomain,
|
|
|
+ 'suffix' => SUFFIX,
|
|
|
+ 'ns' => $matches['token'],
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
return $domain;
|
|
|
}
|
|
|
|