feat: define internfaces to create,fetch and rm auth challenges

This commit is contained in:
Aravinth Manivannan
2023-06-13 19:23:23 +05:30
parent 78de0b266f
commit c53fe2e3ff
3 changed files with 82 additions and 0 deletions

View File

@@ -296,3 +296,14 @@ pub async fn database_works<'a, T: MCDatabase>(
db.delete_captcha(p.username, p.username).await.unwrap();
assert!(!db.captcha_exists(Some(p.username), c.key).await.unwrap());
}
/// test all challenge routines
pub async fn challenges_works<'a, T: MCDatabase>(db: &T) {
let mut challenge = Challenge::new(ChallengeReason::PasswordReset);
db.new_challenge(&mut challenge).await.unwrap();
db.new_challenge(&mut challenge).await.unwrap();
let c = db.fetch_challenge(&challenge).await.unwrap();
assert_eq!(c, challenge);
db.delete_challenge(&challenge).await.unwrap();
assert!(db.fetch_challenge(&challenge).await.is_err())
}