24 lines
1.0 KiB
PHP
24 lines
1.0 KiB
PHP
<?php
|
|
function assertTrue($cond, $msg) {
|
|
if (!$cond) {
|
|
fwrite(STDERR, $msg . PHP_EOL);
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
$path = __DIR__ . '/../api/contact.php';
|
|
assertTrue(file_exists($path), 'missing api/contact.php');
|
|
$content = file_get_contents($path);
|
|
|
|
assertTrue(strpos($content, 'Content-Type: application/json') !== false, 'missing json header');
|
|
assertTrue(strpos($content, 'X-Content-Type-Options') !== false, 'missing nosniff');
|
|
assertTrue(strpos($content, "REQUEST_METHOD'] !== 'POST'") !== false, 'missing method check');
|
|
assertTrue(strpos($content, 'verifyCsrfToken') !== false, 'missing csrf verification');
|
|
assertTrue(strpos($content, 'verifyRecaptcha') !== false, 'missing recaptcha verification');
|
|
assertTrue(strpos($content, 'validateContactData') !== false, 'missing data validation');
|
|
assertTrue(strpos($content, 'sendContactEmail') !== false, 'missing email send');
|
|
assertTrue(strpos($content, 'success') !== false, 'missing success response');
|
|
assertTrue(strpos($content, 'error') !== false, 'missing error response');
|
|
|
|
fwrite(STDOUT, "OK\n");
|