Story 5.5: endpoint contact PHP

This commit is contained in:
2026-02-04 21:22:13 +01:00
parent 267b6ff7fa
commit 5b1539a3aa
6 changed files with 274 additions and 33 deletions

View File

@@ -0,0 +1,23 @@
<?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");

View File

@@ -24,4 +24,5 @@ php (Join-Path $here 'contact.test.php')
php (Join-Path $here 'contact-validation.test.php')
php (Join-Path $here 'contact-state.test.php')
php (Join-Path $here 'recaptcha.test.php')
php (Join-Path $here 'contact-api.test.php')
'OK'