1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2026-10-29 13:42:30 +00:00
Commit Graph

20 Commits

Author SHA1 Message Date
James Hillyerd 9aaad6b950 test(rest): add black-box WebSocket monitor tests (#621)
Cover the REST WebSocket monitor endpoints (v1 + v2), previously at 0%
for all 18 functions in socketv1_controller.go and socketv2_controller.go;
pkg/rest coverage goes from 20.9% to 73.2%.

The harness dials a real gorilla/websocket client into an httptest server
wired to a running msghub.Hub, and relies on the hub's history replay for
deterministic ordering: dispatching before dialing seeds the replay, and
events are relayed in dispatch order, so receiving event N next proves
filtered events were skipped rather than delayed.

Covered for both API versions:

- monitor-all and per-mailbox endpoints, including history replay and live
  delivery, and mailbox filtering of both message-stored and (v2)
  message-deleted events
- address-form mailbox names via Manager.MailboxForAddress (user%40example.com)
- invalid mailbox names rejected with 500 before the upgrade, and plain GET
  requests failing the handshake with 400
- client data messages discarded by the read pump
- clean client shutdown: listener deregistration, empty close frame from
  the writer racing the read pump's close-code echo, and the
  WebSocketConnectsCurrent expvar gauge increment/decrement

Tests only; no production changes.  Notes for follow-up commits:

- v1 monitors ignore deletions while v2 reports them (pinned as current
  behavior in TestMonitorMailboxMessagesV1)
- httptest.Server.Close does not wait for hijacked connections, so
  dialMonitor's cleanup awaits the handler goroutine via the connections
  gauge before the hub is stopped; the read/write pumps calling
  msgListener.Close concurrently can still double-close its channel
  (check-then-act race in Close's select) and deserves a fix
- deadline-set error paths, the 54s ping/pong cycle, and write-failure
  paths remain uncovered, consistent with the POP3 send-error paths
2026-09-17 18:23:26 -07:00
James Hillyerd 25c6f58535 chore: fix testutils linter warnings (#502)
Signed-off-by: James Hillyerd <james@hillyerd.com>
2024-02-19 12:02:06 -08:00
James Hillyerd 0361e971e0 chore: many small lint/perf fixes (#491)
Signed-off-by: James Hillyerd <james@hillyerd.com>
2024-02-16 14:27:04 -08:00
James Hillyerd 9836c0ffbb go: update mod and imports to correctly reflect major version (#388) 2023-09-09 12:36:21 -07:00
Benson Margulies 9f0fef3180 Implement STLS for pop3 (#384) 2023-09-05 14:28:26 -07:00
James Hillyerd eae4926b23 Dependency injection improvements (#288)
Refactor server life-cycle into it's own file, make service startup and monitoring more consistent and testable.

* Extract services creation in preparation for DI
* pop3: rename New to NewServer
* lifecycle: Add fatal error Notify()
* web: Introduce Server struct w/ Notify()
* Extract Start in lifecycle
* Add Start() to Hub
* RetentionScanner startup consistent with other svcs
* Remove global shutdown channel
* Implement a readiness notification system
2022-08-13 13:22:34 -07:00
James Hillyerd e4c48a0705 go code: rename to github.com/inbucket/inbucket 2019-02-24 09:43:10 -08:00
James Hillyerd cf265dbe2c rest: Add posix-millis field for easier date parsing 2018-11-17 20:57:52 -08:00
James Hillyerd dd14fb9989 ui: Much elm work, such wow
- ui: Fix favicon
- webui: Changes to support serving Elm UI
- Static files now served from `/` mount point.
- Old UI handlers moved to `/serve` mount point, some will still be
  needed by the Elm UI; safe HTML and attachments for example.
- Update dev-start.sh for new UI, with tip on how to build it.
- ui: Detect browser host:port for websocket URL,
- webui: Remove unused mailbox handlers, rename routes
- Many routes not needed by Elm UI.
- `/serve/mailbox/*` becomes `/serve/m/*`.
- webui: Impl custom JSON message API for web UI,
- ui: Refactor Mailbox view functions,
- ui: Add body tabs for safe HTML and plain text,
- webui: Format plain text for new UI,
- ui: List attachments with view & download links,
2018-11-12 20:34:51 -08:00
James Hillyerd 82e6a9fe5d rest: Use a subrouter for /api/ paths 2018-10-22 10:48:08 -07:00
James Hillyerd dc02092cf6 rest: Implement MarkSeen for #58
- message: Add MarkSeen to Manager, StoreManager.
- rest: Add PATCH for /mailbox/name/id.
- rest: Add MailboxMarkSeenV1 handler.
- rest: Add Seen to model.
- rest: Update handlers to set Seen.
- rest: Add doJSONBody func.
2018-04-01 13:30:43 -07:00
James Hillyerd 04bb842549 config: Combine TemplateDir and PublicDir into UIDir
- Define static names for `templates` and `static`
2018-03-25 11:55:23 -07:00
James Hillyerd 845cbedc0d config: Replace robfig with envconfig for #86
- Initial envconfig system is working, not bulletproof.
- Added sane defaults for required parameters.
2018-03-21 22:50:21 -07:00
James Hillyerd 5cb07d5780 rest: Refactor JSON result value testing 2018-03-18 12:08:40 -07:00
James Hillyerd 519779b7ba storage: eliminate mocks, closes #80 2018-03-14 21:05:59 -07:00
James Hillyerd 219862797e web: remove DataStore from Context and controllers for #81 2018-03-12 20:49:06 -07:00
James Hillyerd 10bc07a18e message: Implement service layer, stubs for #81
I've made some effort to wire the manager into the controllers, but
tests are currently failing.
2018-03-12 20:21:59 -07:00
James Hillyerd 3bc66d2788 storage: Store addresses as mail.Address for #69 2018-03-11 16:57:53 -07:00
James Hillyerd a58dfc5e4f storage: finish renaming storage packages for #79 #69
- storage: rename DataStore to Store
- file: rename types to appease linter
2018-03-10 14:00:21 -08:00
James Hillyerd f8c30a678a Reorganize packages, closes #79
- All packages go into either cmd or pkg directories
- Most packages renamed
- Server packages moved into pkg/server
- sanitize moved into webui, as that's the only place it's used
- filestore moved into pkg/storage/file
- Makefile updated, and PKG variable use fixed
2018-03-10 12:04:13 -08:00