diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2025-08-24 16:37:41 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2025-08-26 00:57:57 -0400 |
| commit | c52e24f17ed615b2e2dd55a285eb272014a2ccbf (patch) | |
| tree | 757fbef4a4e8236f831d859370e4774e86138bd5 /src/setup/handlers | |
| parent | 6c65e97e49d1d56380aa7d71abb0394b08ff60ca (diff) | |
Factor out common authentication test verification steps into helpers.
These checks tended to be wordy, and were prone to being done subtly differently in different locations for no good reason. Centralizing them cleans this up and makes the tests easier to follow, at the expense of making it somewhat harder to follow what the test is specifically checking.
Diffstat (limited to 'src/setup/handlers')
| -rw-r--r-- | src/setup/handlers/setup/test.rs | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/src/setup/handlers/setup/test.rs b/src/setup/handlers/setup/test.rs index 133a162..283fe8b 100644 --- a/src/setup/handlers/setup/test.rs +++ b/src/setup/handlers/setup/test.rs @@ -1,6 +1,10 @@ use axum::extract::{Json, State}; -use crate::{empty::Empty, setup::app, test::fixtures}; +use crate::{ + empty::Empty, + setup::app, + test::{fixtures, verify}, +}; #[tokio::test] async fn fresh_instance() { @@ -21,30 +25,10 @@ async fn fresh_instance() { .expect("setup in a fresh app succeeds"); // Verify that the issued token is valid - - let secret = identity - .secret() - .expect("newly-issued identity has a token secret"); - let identity = app - .tokens() - .validate(&secret, &fixtures::now()) - .await - .expect("newly-issued identity cookie is valid"); - assert_eq!(name, identity.user.name); + verify::identity::valid_for_name(&app, &identity, &name).await; // Verify that the given credentials can log in - - let secret = app - .tokens() - .login(&name, &password, &fixtures::now()) - .await - .expect("credentials given on signup are valid"); - let identity = app - .tokens() - .validate(&secret, &fixtures::now()) - .await - .expect("validating a newly-issued token secret succeeds"); - assert_eq!(name, identity.user.name); + verify::login::valid_login(&app, &name, &password).await; } #[tokio::test] |
