- RETR and TOP now respond "-ERR You deleted message N" for messages
marked deleted, as RFC 1939 sections 5 (RETR) and 7 (TOP) require;
previously the message content was still sent.
- STLS: a failed TLS handshake previously continued the session with
the dead TLS connection installed as s.conn and a bogus tlsState,
producing confusing follow-on errors. RFC 2595 section 4 requires
the negotiation to complete before further commands, so a failure
is now fatal: log it and terminate the session.
Updates the scripted tests that previously pinned the old behavior,
and adds a STLS handshake failure regression test.
Signed-off-by: James Hillyerd <james@hillyerd.com>
- validateMsgNum parses and range-checks message-number arguments,
replacing five copies of the parse/check/respond sequence in the
LIST, UIDL, DELE, RETR and TOP arms (wire responses unchanged).
- listMessages implements LIST and UIDL, which differ only in the
per-message value reported.
- sendMessageLines unifies sendMessage/sendMessageTop via a body line
limit, negative meaning unlimited.
Adds a direct unit test for validateMsgNum and an equivalence test
asserting TOP with a large line limit matches RETR output. All
scripted session tests from the previous commit pass unchanged.
Signed-off-by: James Hillyerd <james@hillyerd.com>
Covers the POP3 TRANSACTION state machine via scripted sessions over
net.Pipe, mirroring the SMTP handler test harness: STAT/LIST/UIDL/DELE/
RETR/TOP/NOOP/RSET/QUIT including argument error paths, deleted-message
behavior, dot-stuffing, RETR/TOP source error paths, mailbox load
errors, session read error handling (idle timeout vs other), and the
TCP listener lifecycle (Start/serve/Notify/Drain).
No production code changes; current behavior is pinned as-is. Two
known RFC deviations are documented in tests (RETR/TOP of messages
marked deleted) for follow-up fixes. Package coverage: 24.4% -> 93.2%.
Signed-off-by: James Hillyerd <james@hillyerd.com>