diff options
Diffstat (limited to 'src/test/fixtures')
| -rw-r--r-- | src/test/fixtures/mod.rs | 12 | ||||
| -rw-r--r-- | src/test/fixtures/vapid.rs | 16 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/fixtures/mod.rs b/src/test/fixtures/mod.rs index 53bf31b..85935d6 100644 --- a/src/test/fixtures/mod.rs +++ b/src/test/fixtures/mod.rs @@ -12,8 +12,20 @@ pub mod invite; pub mod login; pub mod message; pub mod user; +pub mod vapid; pub async fn scratch_app() -> App<Client> { + let app = scratch_app_without_vapid().await; + + app.vapid() + .refresh_key(&now()) + .await + .expect("refreshing the VAPID key always succeeds"); + + app +} + +pub async fn scratch_app_without_vapid() -> App<Client> { let pool = db::prepare("sqlite::memory:", "sqlite::memory:") .await .expect("setting up in-memory sqlite database"); diff --git a/src/test/fixtures/vapid.rs b/src/test/fixtures/vapid.rs new file mode 100644 index 0000000..29cdf1a --- /dev/null +++ b/src/test/fixtures/vapid.rs @@ -0,0 +1,16 @@ +use p256::ecdsa::VerifyingKey; + +use crate::{app::App, test::fixtures}; + +pub async fn key<P>(app: &App<P>) -> VerifyingKey { + let boot = app.boot().snapshot().await.expect("boot always succeeds"); + let changed = boot + .events + .into_iter() + .filter_map(fixtures::event::vapid) + .filter_map(fixtures::event::vapid::changed) + .next_back() + .expect("the application has a vapid key"); + + changed.key +} |
