test: gate webhook host validation to production env

Webhook E2E tests use the docker service name request-catcher-webhook
as the target; that hostname does not resolve via standard DNS, so the
new PublicHostname check rejects it. Same env gate Appwrite already
uses elsewhere.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jake BarnbyandClaude Opus 4.7 committed 2026-05-28 23:14:26 +12:00
1 parent ec5b4ca565
commit e42fe21ff9
1 file changed
+7 -5
+7 -5
View File
@@ -103,11 +103,13 @@ class Webhooks extends Action
$url = \rawurldecode($webhook->getAttribute('url'));
$host = \parse_url($url, PHP_URL_HOST) ?? '';
$hostnameValidator = new PublicHostname();
if (!$hostnameValidator->isValid($host)) {
$this->errors[] = 'Webhook target ' . $host . ' rejected: ' . $hostnameValidator->getDescription();
return;
if (System::getEnv('_APP_ENV', 'development') === 'production') {
$host = \parse_url($url, PHP_URL_HOST) ?? '';
$hostnameValidator = new PublicHostname();
if (!$hostnameValidator->isValid($host)) {
$this->errors[] = 'Webhook target ' . $host . ' rejected: ' . $hostnameValidator->getDescription();
return;
}
}
$signatureKey = $webhook->getAttribute('signatureKey');