summaryrefslogtreecommitdiff
path: root/src/event/handlers/stream
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2025-12-09 15:13:21 -0500
committerOwen Jacobson <owen@grimoire.ca>2025-12-17 15:48:20 -0500
commit3c697f5fb1b8dbad46eac8fa299ed7cebfb36159 (patch)
treeb7854fb23d1e104f928acfe3bba75ea3b74b83d9 /src/event/handlers/stream
parent41a5a0f7e13bf5a82aaef59e34eb68f0fe7fa7f5 (diff)
Factor push message publication out to its own helper component.
The `Publisher` component handles the details of web push delivery. Callers must provide the subscription set, the current signer, and the message, while the publisher handles encoding and communication with web push endpoints. To facilitate testing, `Publisher` implements `Publish`, which is a new trait with the same interface. Components that might publish web push messages should rely on the trait where possible. The test suite now constructs an app with a dummy `Publish` impl, which captures push messages for examination. Note that the testing implementation of `Publish` is hand-crafted, and presently only acts to record the arguments it receives. The other alternative was to use a mocking library, such as `mockit`, and while I've used that approach before, I'm not super comfortable with the complexity in this situation. I think we can maintain a more reasonable testing `Publish` impl by hand, at least for now, and we can revisit that decision later if need be. Tests for the `ping` endpoint have been migrated to this endpoint.
Diffstat (limited to 'src/event/handlers/stream')
-rw-r--r--src/event/handlers/stream/test/vapid.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/event/handlers/stream/test/vapid.rs b/src/event/handlers/stream/test/vapid.rs
index dbc3929..4d7f2dd 100644
--- a/src/event/handlers/stream/test/vapid.rs
+++ b/src/event/handlers/stream/test/vapid.rs
@@ -7,7 +7,7 @@ use crate::test::{fixtures, fixtures::future::Expect as _};
#[tokio::test]
async fn live_vapid_key_changes() {
// Set up the context
- let app = fixtures::scratch_app().await;
+ let app = fixtures::scratch_app_without_vapid().await;
let resume_point = fixtures::boot::resume_point(&app).await;
// Subscribe to events
@@ -42,7 +42,7 @@ async fn live_vapid_key_changes() {
#[tokio::test]
async fn stored_vapid_key_changes() {
// Set up the context
- let app = fixtures::scratch_app().await;
+ let app = fixtures::scratch_app_without_vapid().await;
let resume_point = fixtures::boot::resume_point(&app).await;
// Rotate the VAPID key
@@ -77,7 +77,7 @@ async fn stored_vapid_key_changes() {
#[tokio::test]
async fn no_past_vapid_key_changes() {
// Set up the context
- let app = fixtures::scratch_app().await;
+ let app = fixtures::scratch_app_without_vapid().await;
// Rotate the VAPID key