presseportale/tests/Unit/GibberishDetectorTest.php
Kevin Adametz 06d2889a4d feat: Spamschutz für Kontakt-Widget und Registrierung mit Cloudflare Turnstile
- Turnstile für Gäste und unbestätigte Konten (TurnstileVerifier,
  <x-turnstile>); ist Cloudflare nicht erreichbar, wird durchgelassen und
  im Verlauf, in der Kontakt-Queue und in der Betriebsüberwachung markiert
- Inhaltsfilter des Kontaktformulars (fremde Links, Floskel mit
  Seitentitel, Zeichensalat, Sperrliste, Absenden unter 3 Sekunden);
  Treffer landen in der Spam-Quarantäne ohne Mail, Löschung nach 30 Tagen
- Admin: Filter „Spam“, Sammelaktion, „Kein Spam“ holt die Mail nach
- Registrierung lehnt Zufallsnamen ab; users:prune-bot-registrations
  (täglicher Lauf erst mit USERS_PRUNE_BOT_REGISTRATIONS=true)
- contact-messages:quarantine-spam für den Altbestand
- CSP erlaubt challenges.cloudflare.com, Log-Kanal spam
- Datenschutzerklärung: Abschnitt 6a Cloudflare Turnstile (Vorschlag)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 08:49:58 +00:00

21 lines
1 KiB
PHP

<?php
use App\Services\Spam\GibberishDetector;
test('bot names are recognised as random person names', function (string $name) {
expect(GibberishDetector::isRandomPersonName($name))->toBeTrue();
})->with(['ruLrlotwaCoVStmZetSxD', 'VBwauClhcuUvMvksdgWnjr', 'iOmGRYDQjETnnHmPKzjgGe']);
test('real person names are never random', function (string $name) {
expect(GibberishDetector::isRandomPersonName($name))->toBeFalse();
})->with(['Paula Presse', 'MacGregor', 'Anna-Lena Müller', 'McDonaldSmith', 'RobertHix', 'ABCDEFGHIJKLMN']);
test('the contact name check spares company names but catches bot tokens', function (string $value, bool $random) {
expect(GibberishDetector::isRandomToken($value))->toBe($random);
})->with([
'company with camel case' => ['StammZellenPowerTeam', false],
'company with caps' => ['KUUNSTPavillon', false],
'bot name' => ['ruLrlotwaCoVStmZetSxD', true],
'letter-digit block' => ['NAEWTRER2720160NEYRTHYT', true],
'normal sentence' => ['Guten Tag, ich habe eine Frage.', false],
]);