()
| 2971 | |
| 2972 | #[tokio::test] |
| 2973 | async fn validate_active_user() { |
| 2974 | let _guard = test::prepare().await; |
| 2975 | let users = vec![ |
| 2976 | user::User { |
| 2977 | email: "active@user".into(), |
| 2978 | is_active: true, |
| 2979 | is_admin: false, |
| 2980 | ..Default::default() |
| 2981 | }, |
| 2982 | user::User { |
| 2983 | email: "inactive@user".into(), |
| 2984 | is_active: false, |
| 2985 | is_admin: false, |
| 2986 | ..Default::default() |
| 2987 | }, |
| 2988 | ]; |
| 2989 | for u in &users { |
| 2990 | user::create(u.clone()).await.unwrap(); |
| 2991 | } |
| 2992 | |
| 2993 | let api_key = api_key::test::create_api_key(true, false).await; |
| 2994 | |
| 2995 | let tests = vec![ |
| 2996 | // active user |
| 2997 | ValidatorTest { |
| 2998 | validators: vec![ValidateActiveUser::new()], |
| 2999 | id: AuthID::User(users[0].id.into()), |
| 3000 | ok: true, |
| 3001 | }, |
| 3002 | // inactive user |
| 3003 | ValidatorTest { |
| 3004 | validators: vec![ValidateActiveUser::new()], |
| 3005 | id: AuthID::User(users[1].id.into()), |
| 3006 | ok: false, |
| 3007 | }, |
| 3008 | // api key |
| 3009 | ValidatorTest { |
| 3010 | validators: vec![ValidateActiveUser::new()], |
| 3011 | id: AuthID::Key(api_key.id.into()), |
| 3012 | ok: false, |
| 3013 | }, |
| 3014 | ]; |
| 3015 | |
| 3016 | run_tests(tests).await; |
| 3017 | } |
| 3018 | |
| 3019 | #[tokio::test] |
| 3020 | async fn validate_active_user_or_key() { |
nothing calls this directly
no test coverage detected