Pakete 7 und 9: Auskunft und Buchungswunsch, Aufenthalt und Abschluss (Zwischenstand)
- Haltefrist 0: unverbindliche Auskunft mit signiertem Link "Buchung anfragen", erneute Prüfung unter Sperre, automatische oder manuelle Bestätigung, Absage bei vergebenem Zeitraum, Ablauf unbeantworteter Auskünfte - Aufenthalt: Anreisedaten, Aufgaben je Wohnung, gebuchte Leistungen, Abweichungen und Folgeaufgaben als Aufgaben am Vorgang - Abschluss getrennt: Aufenthalt abgeschlossen / kaufmännisch abgeschlossen, Nachläufer (Forderung, Auszahlung) bleiben sichtbar - Zahlungsstatus nur aus Geld auf unserem Konto; Altbestand per Vorschau-Befehl - Verlauf weist Testzustellungen als solche aus - Abnahmetests T16-T25, T23 über isolierten SMTP-Empfänger Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
3bcfc09417
commit
40d20cb7d1
52 files changed
+3196
-89
No files matched your search
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* An isolated SMTP test receiver for the acceptance test of the test operation (T23): accepts every message on
|
||||
* 127.0.0.1:<port>, delivers nothing anywhere and writes one JSON line per message (envelope sender, envelope
|
||||
* recipients, raw data) to <file>. It stops when <file>.stop exists or after <seconds> (default 120).
|
||||
*
|
||||
* Usage: php tests/Support/smtp-sink.php <port> <file> [seconds]
|
||||
*/
|
||||
$port = (int) ($argv[1] ?? 2525);
|
||||
$file = (string) ($argv[2] ?? sys_get_temp_dir().'/smtp-sink.jsonl');
|
||||
$until = time() + (int) ($argv[3] ?? 120);
|
||||
|
||||
$server = stream_socket_server('tcp://127.0.0.1:'.$port, $errorCode, $errorMessage);
|
||||
if ($server === false) {
|
||||
fwrite(STDERR, "SMTP sink: {$errorMessage}\n");
|
||||
exit(1);
|
||||
}
|
||||
stream_set_blocking($server, false);
|
||||
file_put_contents($file.'.ready', (string) getmypid());
|
||||
|
||||
/** @var array<int, array{socket: resource, buffer: string, from: ?string, to: list<string>, data: ?string}> $clients */
|
||||
$clients = [];
|
||||
|
||||
$send = function ($socket, string $line): void {
|
||||
@fwrite($socket, $line."\r\n");
|
||||
};
|
||||
|
||||
while (time() < $until && ! file_exists($file.'.stop')) {
|
||||
$read = [$server];
|
||||
foreach ($clients as $entry) {
|
||||
$read[] = $entry['socket'];
|
||||
}
|
||||
$write = $except = null;
|
||||
if (@stream_select($read, $write, $except, 0, 200000) === false) {
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($read as $socket) {
|
||||
if ($socket === $server) {
|
||||
$connection = @stream_socket_accept($server, 0);
|
||||
if ($connection !== false) {
|
||||
stream_set_blocking($connection, false);
|
||||
$clients[(int) $connection] = ['socket' => $connection, 'buffer' => '', 'from' => null, 'to' => [], 'data' => null];
|
||||
$send($connection, '220 fewo-smtp-sink ESMTP');
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$id = (int) $socket;
|
||||
$chunk = @fread($socket, 65536);
|
||||
if ($chunk === '' || $chunk === false) {
|
||||
if (feof($socket)) {
|
||||
fclose($socket);
|
||||
unset($clients[$id]);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
$clients[$id]['buffer'] .= $chunk;
|
||||
|
||||
while (true) {
|
||||
$client = &$clients[$id];
|
||||
if ($client['data'] !== null) {
|
||||
$end = strpos($client['buffer'], "\r\n.\r\n");
|
||||
if ($end === false) {
|
||||
break;
|
||||
}
|
||||
$client['data'] .= substr($client['buffer'], 0, $end);
|
||||
$client['buffer'] = substr($client['buffer'], $end + 5);
|
||||
file_put_contents($file, json_encode(['from' => $client['from'], 'to' => $client['to'], 'data' => $client['data']])."\n", FILE_APPEND | LOCK_EX);
|
||||
$client['from'] = null;
|
||||
$client['to'] = [];
|
||||
$client['data'] = null;
|
||||
$send($socket, '250 OK: queued in the sink');
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$position = strpos($client['buffer'], "\r\n");
|
||||
if ($position === false) {
|
||||
break;
|
||||
}
|
||||
$line = substr($client['buffer'], 0, $position);
|
||||
$client['buffer'] = substr($client['buffer'], $position + 2);
|
||||
$command = strtoupper(substr($line, 0, 4));
|
||||
|
||||
match (true) {
|
||||
$command === 'EHLO' => $send($socket, "250-fewo-smtp-sink\r\n250 8BITMIME"),
|
||||
$command === 'HELO' => $send($socket, '250 fewo-smtp-sink'),
|
||||
$command === 'MAIL' => [$client['from'] = trim(substr($line, 10), ' <>'), $send($socket, '250 OK')],
|
||||
$command === 'RCPT' => [$client['to'][] = trim(substr($line, 8), ' <>'), $send($socket, '250 OK')],
|
||||
$command === 'DATA' => [$client['data'] = '', $send($socket, '354 End data with <CR><LF>.<CR><LF>')],
|
||||
$command === 'RSET' => [$client['from'] = null, $client['to'] = [], $send($socket, '250 OK')],
|
||||
$command === 'NOOP' => $send($socket, '250 OK'),
|
||||
$command === 'QUIT' => [$send($socket, '221 Bye'), fclose($socket), $clients[$id] = null],
|
||||
default => $send($socket, '502 Command not implemented'),
|
||||
};
|
||||
unset($client);
|
||||
if ($clients[$id] === null) {
|
||||
unset($clients[$id]);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
unset($client);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($clients as $entry) {
|
||||
@fclose($entry['socket']);
|
||||
}
|
||||
fclose($server);
|
||||
@unlink($file.'.ready');
|
||||
Reference in new issue
Block a user