use lemmy_api_common::check_validator_time;
use lemmy_db_queries::{
establish_unpooled_connection,
- source::{local_user::LocalUser_, secret::SecretSingleton},
+ source::{local_user::LocalUser_, secret::Secret_},
Crud,
};
use lemmy_db_schema::source::{
person::{Person, PersonForm},
secret::Secret,
};
- use lemmy_utils::claims::Claims;
+ use lemmy_utils::{claims::Claims, settings::structs::Settings};
#[test]
fn test_should_not_validate_user_token_after_password_change() {
let conn = establish_unpooled_connection();
+ let secret = Secret::init(&conn).unwrap();
+ let settings = Settings::init().unwrap();
let new_person = PersonForm {
name: "Gerry9812".into(),
let inserted_local_user = LocalUser::create(&conn, &local_user_form).unwrap();
- let jwt_secret = Secret::get().jwt_secret;
- let jwt = Claims::jwt(inserted_local_user.id.0, &jwt_secret).unwrap();
- let claims = Claims::decode(&jwt, jwt_secret.as_ref()).unwrap().claims;
+ let jwt = Claims::jwt(
+ inserted_local_user.id.0,
+ &secret.jwt_secret,
+ &settings.hostname,
+ )
+ .unwrap();
+ let claims = Claims::decode(&jwt, &secret.jwt_secret).unwrap().claims;
let check = check_validator_time(&inserted_local_user.validator_time, &claims);
assert!(check.is_ok());