EMAIL-WP-0005-T03: add test-user addressing and reset helper
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 2s

Adds the tests/harness helper package: address(), available(), reset(),
users(), smtp_provider() and mailbox_config().

Tests address mailboxes as harness.address("<test name>"), which slugs the name
under the RFC 2606 reserved harness.email-connect.test domain, so distinct test
names cannot collide and a stray send cannot leave the host. No provisioning
call is needed -- the auth-disabled harness creates the mailbox on first login.

reset() drops every user and message via GreenMail's service reset; the next
login recreates the mailbox empty. It is documented to run at test start so a
crashed test cannot leak state forward, and it is global, so resetting tests
cannot run in parallel against one harness.

Suite: 64 passed with the harness up, 61 passed + 3 skipped with it down.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
tegwick 2026-08-14 01:46:09 +02:00
parent 89fd13ac2d
commit 442a574cf9
5 changed files with 328 additions and 2 deletions

View file

@ -49,6 +49,51 @@ provider material is routed through OpenBao — see
`.claude/rules/credential-routing.md`. Never point this harness at real
credentials or a real mailbox.
### Addressing convention
Tests address mailboxes through the `harness` helper package rather than
hardcoding strings:
```python
import harness
recipient = harness.address("invitation resend")
# -> invitation-resend@harness.email-connect.test
```
`harness.address()` slugs the name, so each test picks its own address and two
tests cannot collide. `.test` is reserved by RFC 2606, so a stray send can never
leave the host.
### Reset contract
`harness.reset()` drops **every** user and message — GreenMail's reset clears
accounts along with their mail, and the next login recreates the mailbox empty.
Call it at the **start** of a test, not the end: a crashed or interrupted test
then cannot leave state behind for the next one. It is global, so tests that
reset cannot run in parallel against one harness.
```python
def test_something():
harness.reset()
...
```
### Skipping when the harness is down
Harness-dependent tests are gated so the default suite stays offline:
```python
requires_harness = pytest.mark.skipif(
not harness.available(),
reason="mail harness not running",
)
```
`harness.available()` is evaluated at import time, so start the harness before
invoking pytest.
## Scanning the harness
```bash