From 74272ed754d1bf7f64c41c91076e95f1348c3abd Mon Sep 17 00:00:00 2001 From: Bogdan Mart Date: Sat, 13 Mar 2021 22:36:40 +0200 Subject: [PATCH] more correct tests --- crates/api/src/lib.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/api/src/lib.rs b/crates/api/src/lib.rs index 0f77da5e..3b87b998 100644 --- a/crates/api/src/lib.rs +++ b/crates/api/src/lib.rs @@ -490,7 +490,7 @@ pub(crate) fn password_length_check(pass: &str) -> Result<(), LemmyError> { #[cfg(test)] mod tests { - use crate::{captcha_espeak_wav_base64, get_user_from_jwt}; + use crate::{captcha_espeak_wav_base64, get_user_from_jwt, get_user_safe_settings_from_jwt}; use lemmy_db_queries::{ establish_pooled_connection, source::user::User, @@ -558,13 +558,21 @@ mod tests { .await .expect("User should be decoded"); + get_user_safe_settings_from_jwt(&jwt_token, &conn) + .await + .expect("User should be decoded"); + std::thread::sleep(std::time::Duration::from_secs(1)); User_::update_password(&conn.get().unwrap(), inserted_user.id, &"password111").unwrap(); - let jwt_decode_res = get_user_from_jwt(&jwt_token, &conn).await; + get_user_from_jwt(&jwt_token, &conn) + .await + .expect_err("JWT decode should fail after password change"); - jwt_decode_res.expect_err("JWT decode should fail after password change"); + get_user_safe_settings_from_jwt(&jwt_token, &conn) + .await + .expect_err("JWT decode should fail after password change"); } #[test] -- 2.44.1