summaryrefslogtreecommitdiff
path: root/src/user/handlers/login
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/handlers/login')
-rw-r--r--src/user/handlers/login/test.rs29
1 files changed, 7 insertions, 22 deletions
diff --git a/src/user/handlers/login/test.rs b/src/user/handlers/login/test.rs
index cb387ad..56fc2c4 100644
--- a/src/user/handlers/login/test.rs
+++ b/src/user/handlers/login/test.rs
@@ -1,6 +1,10 @@
use axum::extract::{Json, State};
-use crate::{empty::Empty, test::fixtures, token::app};
+use crate::{
+ empty::Empty,
+ test::{fixtures, verify},
+ token::app,
+};
#[tokio::test]
async fn correct_credentials() {
@@ -24,19 +28,7 @@ async fn correct_credentials() {
// Verify the return value's basic structure
- let secret = identity
- .secret()
- .expect("logged in with valid credentials issues an identity cookie");
-
- // Verify the semantics
-
- let validated = app
- .tokens()
- .validate(&secret, &fixtures::now())
- .await
- .expect("identity secret is valid");
-
- assert_eq!(name, validated.user.name);
+ verify::identity::valid_for_name(&app, &identity, &name).await;
}
#[tokio::test]
@@ -114,12 +106,5 @@ async fn token_expires() {
.await
.expect("expiring tokens never fails");
- let verified_at = fixtures::now();
- let error = app
- .tokens()
- .validate(&secret, &verified_at)
- .await
- .expect_err("validating an expired token");
-
- assert!(matches!(error, app::ValidateError::InvalidToken));
+ verify::token::invalid(&app, &secret).await;
}