mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 18:15:39 +00:00
chore: migrate tests to also run with mariadb
This commit is contained in:
@@ -106,12 +106,22 @@ pub mod tests {
|
||||
use crate::tests::*;
|
||||
|
||||
#[actix_rt::test]
|
||||
pub async fn update_password_works() {
|
||||
async fn update_password_works_pg() {
|
||||
let data = crate::tests::pg::get_data().await;
|
||||
update_password_works(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn update_password_works_maria() {
|
||||
let data = crate::tests::maria::get_data().await;
|
||||
update_password_works(data).await;
|
||||
}
|
||||
|
||||
pub async fn update_password_works(data: ArcData) {
|
||||
const NAME: &str = "updatepassuser";
|
||||
const PASSWORD: &str = "longpassword2";
|
||||
const EMAIL: &str = "updatepassuser@a.com";
|
||||
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
|
||||
delete_user(data, NAME).await;
|
||||
|
||||
@@ -29,11 +29,21 @@ use crate::errors::*;
|
||||
use crate::tests::*;
|
||||
|
||||
#[actix_rt::test]
|
||||
pub async fn uname_email_exists_works() {
|
||||
async fn uname_email_exists_works_pg() {
|
||||
let data = crate::tests::pg::get_data().await;
|
||||
uname_email_exists_works(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn uname_email_exists_works_maria() {
|
||||
let data = crate::tests::maria::get_data().await;
|
||||
uname_email_exists_works(data).await;
|
||||
}
|
||||
|
||||
pub async fn uname_email_exists_works(data: ArcData) {
|
||||
const NAME: &str = "testuserexists";
|
||||
const PASSWORD: &str = "longpassword2";
|
||||
const EMAIL: &str = "testuserexists@a.com2";
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
delete_user(data, NAME).await;
|
||||
|
||||
@@ -115,14 +125,24 @@ pub async fn uname_email_exists_works() {
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
pub async fn email_udpate_password_validation_del_userworks() {
|
||||
async fn email_udpate_password_validation_del_userworks_pg() {
|
||||
let data = crate::tests::pg::get_data().await;
|
||||
email_udpate_password_validation_del_userworks(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn email_udpate_password_validation_del_userworks_maria() {
|
||||
let data = crate::tests::maria::get_data().await;
|
||||
email_udpate_password_validation_del_userworks(data).await;
|
||||
}
|
||||
|
||||
pub async fn email_udpate_password_validation_del_userworks(data: ArcData) {
|
||||
const NAME: &str = "testuser2";
|
||||
const PASSWORD: &str = "longpassword2";
|
||||
const EMAIL: &str = "testuser1@a.com2";
|
||||
const NAME2: &str = "eupdauser";
|
||||
const EMAIL2: &str = "eupdauser@a.com";
|
||||
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
delete_user(data, NAME).await;
|
||||
delete_user(data, NAME2).await;
|
||||
@@ -198,7 +218,18 @@ pub async fn email_udpate_password_validation_del_userworks() {
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
pub async fn username_update_works() {
|
||||
async fn username_update_works_pg() {
|
||||
let data = crate::tests::pg::get_data().await;
|
||||
username_update_works(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn username_update_works_maria() {
|
||||
let data = crate::tests::maria::get_data().await;
|
||||
username_update_works(data).await;
|
||||
}
|
||||
|
||||
pub async fn username_update_works(data: ArcData) {
|
||||
const NAME: &str = "testuserupda";
|
||||
const EMAIL: &str = "testuserupda@sss.com";
|
||||
const EMAIL2: &str = "testuserupda2@sss.com";
|
||||
@@ -206,7 +237,6 @@ pub async fn username_update_works() {
|
||||
const NAME2: &str = "terstusrtds";
|
||||
const NAME_CHANGE: &str = "terstusrtdsxx";
|
||||
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
|
||||
futures::join!(
|
||||
|
||||
@@ -263,11 +263,21 @@ pub mod tests {
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
pub async fn easy_works() {
|
||||
async fn easy_works_pg() {
|
||||
let data = crate::tests::pg::get_data().await;
|
||||
easy_works(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn easy_works_maria() {
|
||||
let data = crate::tests::maria::get_data().await;
|
||||
easy_works(data).await;
|
||||
}
|
||||
|
||||
pub async fn easy_works(data: ArcData) {
|
||||
const NAME: &str = "defaultuserconfgworks";
|
||||
const PASSWORD: &str = "longpassworddomain";
|
||||
const EMAIL: &str = "defaultuserconfgworks@a.com";
|
||||
let data = crate::tests::get_data().await;
|
||||
let data = &data;
|
||||
|
||||
delete_user(data, NAME).await;
|
||||
|
||||
@@ -37,11 +37,21 @@ const L2: Level = Level {
|
||||
};
|
||||
|
||||
#[actix_rt::test]
|
||||
pub async fn level_routes_work() {
|
||||
async fn level_routes_work_pg() {
|
||||
let data = crate::tests::pg::get_data().await;
|
||||
level_routes_work(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn level_routes_work_maria() {
|
||||
let data = crate::tests::maria::get_data().await;
|
||||
level_routes_work(data).await;
|
||||
}
|
||||
|
||||
pub async fn level_routes_work(data: ArcData) {
|
||||
const NAME: &str = "testuserlevelroutes";
|
||||
const PASSWORD: &str = "longpassworddomain";
|
||||
const EMAIL: &str = "testuserlevelrouts@a.com";
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
|
||||
delete_user(data, NAME).await;
|
||||
|
||||
@@ -155,11 +155,21 @@ mod tests {
|
||||
use crate::*;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn update_and_get_mcaptcha_works() {
|
||||
async fn update_and_get_mcaptcha_works_pg() {
|
||||
let data = crate::tests::pg::get_data().await;
|
||||
update_and_get_mcaptcha_works(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn update_and_get_mcaptcha_works_maria() {
|
||||
let data = crate::tests::maria::get_data().await;
|
||||
update_and_get_mcaptcha_works(data).await;
|
||||
}
|
||||
|
||||
async fn update_and_get_mcaptcha_works(data: ArcData) {
|
||||
const NAME: &str = "updateusermcaptcha";
|
||||
const PASSWORD: &str = "longpassworddomain";
|
||||
const EMAIL: &str = "testupdateusermcaptcha@a.com";
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
delete_user(data, NAME).await;
|
||||
|
||||
|
||||
@@ -121,9 +121,19 @@ pub mod tests {
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
pub async fn health_works() {
|
||||
async fn health_works_pg() {
|
||||
let data = crate::tests::pg::get_data().await;
|
||||
health_works(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn health_works_maria() {
|
||||
let data = crate::tests::maria::get_data().await;
|
||||
health_works(data).await;
|
||||
}
|
||||
|
||||
pub async fn health_works(data: ArcData) {
|
||||
println!("{}", V1_API_ROUTES.meta.health);
|
||||
let data = crate::tests::get_data().await;
|
||||
let data = &data;
|
||||
let app = get_app!(data).await;
|
||||
|
||||
|
||||
@@ -66,14 +66,24 @@ pub mod tests {
|
||||
use crate::*;
|
||||
|
||||
#[actix_rt::test]
|
||||
pub async fn notification_works() {
|
||||
async fn notification_works_pg() {
|
||||
let data = pg::get_data().await;
|
||||
notification_works(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn notification_works_maria() {
|
||||
let data = maria::get_data().await;
|
||||
notification_works(data).await;
|
||||
}
|
||||
|
||||
pub async fn notification_works(data: ArcData) {
|
||||
const NAME1: &str = "notifuser1";
|
||||
const NAME2: &str = "notiuser2";
|
||||
const PASSWORD: &str = "longpassworddomain";
|
||||
const EMAIL1: &str = "testnotification1@a.com";
|
||||
const EMAIL2: &str = "testnotification2@a.com";
|
||||
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
|
||||
delete_user(data, NAME1).await;
|
||||
|
||||
@@ -86,7 +86,18 @@ pub mod tests {
|
||||
use crate::*;
|
||||
|
||||
#[actix_rt::test]
|
||||
pub async fn notification_get_works() {
|
||||
async fn notification_get_works_pg() {
|
||||
let data = pg::get_data().await;
|
||||
notification_get_works(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn notification_get_works_maria() {
|
||||
let data = maria::get_data().await;
|
||||
notification_get_works(data).await;
|
||||
}
|
||||
|
||||
pub async fn notification_get_works(data: ArcData) {
|
||||
const NAME1: &str = "notifuser12";
|
||||
const NAME2: &str = "notiuser22";
|
||||
const PASSWORD: &str = "longpassworddomain";
|
||||
@@ -95,7 +106,6 @@ pub mod tests {
|
||||
const HEADING: &str = "testing notifications get";
|
||||
const MESSAGE: &str = "testing notifications get message";
|
||||
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
|
||||
delete_user(data, NAME1).await;
|
||||
|
||||
@@ -60,7 +60,18 @@ pub mod tests {
|
||||
use crate::*;
|
||||
|
||||
#[actix_rt::test]
|
||||
pub async fn notification_mark_read_works() {
|
||||
async fn notification_mark_read_works_pg() {
|
||||
let data = pg::get_data().await;
|
||||
notification_mark_read_works(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn notification_mark_read_works_maria() {
|
||||
let data = maria::get_data().await;
|
||||
notification_mark_read_works(data).await;
|
||||
}
|
||||
|
||||
pub async fn notification_mark_read_works(data: ArcData) {
|
||||
const NAME1: &str = "notifuser122";
|
||||
const NAME2: &str = "notiuser222";
|
||||
const PASSWORD: &str = "longpassworddomain";
|
||||
@@ -68,7 +79,6 @@ pub mod tests {
|
||||
const EMAIL2: &str = "testnotification222@a.com";
|
||||
const HEADING: &str = "testing notifications get";
|
||||
const MESSAGE: &str = "testing notifications get message";
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
|
||||
delete_user(data, NAME1).await;
|
||||
|
||||
@@ -147,7 +147,18 @@ pub mod tests {
|
||||
use libmcaptcha::pow::PoWConfig;
|
||||
|
||||
#[actix_rt::test]
|
||||
pub async fn get_pow_config_works() {
|
||||
async fn get_pow_config_works_pg() {
|
||||
let data = crate::tests::pg::get_data().await;
|
||||
get_pow_config_works(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn get_pow_config_works_maria() {
|
||||
let data = crate::tests::maria::get_data().await;
|
||||
get_pow_config_works(data).await;
|
||||
}
|
||||
|
||||
pub async fn get_pow_config_works(data: ArcData) {
|
||||
use super::*;
|
||||
use crate::tests::*;
|
||||
use crate::*;
|
||||
@@ -157,7 +168,6 @@ pub mod tests {
|
||||
const PASSWORD: &str = "testingpas";
|
||||
const EMAIL: &str = "randomuser@a.com";
|
||||
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
|
||||
delete_user(data, NAME).await;
|
||||
@@ -186,7 +196,20 @@ pub mod tests {
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
pub async fn pow_difficulty_factor_increases_on_visitor_count_increase() {
|
||||
async fn pow_difficulty_factor_increases_on_visitor_count_increase_pg() {
|
||||
let data = crate::tests::pg::get_data().await;
|
||||
pow_difficulty_factor_increases_on_visitor_count_increase(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn pow_difficulty_factor_increases_on_visitor_count_increase_maria() {
|
||||
let data = crate::tests::maria::get_data().await;
|
||||
pow_difficulty_factor_increases_on_visitor_count_increase(data).await;
|
||||
}
|
||||
|
||||
pub async fn pow_difficulty_factor_increases_on_visitor_count_increase(
|
||||
data: ArcData,
|
||||
) {
|
||||
use super::*;
|
||||
use crate::tests::*;
|
||||
use crate::*;
|
||||
@@ -214,7 +237,6 @@ pub mod tests {
|
||||
visitor_threshold: 30,
|
||||
};
|
||||
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
let levels = [L1, L2, L3];
|
||||
|
||||
|
||||
@@ -59,11 +59,21 @@ pub mod tests {
|
||||
use crate::*;
|
||||
|
||||
#[actix_rt::test]
|
||||
pub async fn verify_pow_works() {
|
||||
async fn verify_pow_works_pg() {
|
||||
let data = crate::tests::pg::get_data().await;
|
||||
verify_pow_works(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn verify_pow_works_maria() {
|
||||
let data = crate::tests::maria::get_data().await;
|
||||
verify_pow_works(data).await;
|
||||
}
|
||||
|
||||
pub async fn verify_pow_works(data: ArcData) {
|
||||
const NAME: &str = "powverifyusr";
|
||||
const PASSWORD: &str = "testingpas";
|
||||
const EMAIL: &str = "verifyuser@a.com";
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
|
||||
delete_user(data, NAME).await;
|
||||
|
||||
@@ -80,7 +80,18 @@ pub mod tests {
|
||||
use crate::*;
|
||||
|
||||
#[actix_rt::test]
|
||||
pub async fn validate_captcha_token_works() {
|
||||
async fn validate_captcha_token_works_pg() {
|
||||
let data = crate::tests::pg::get_data().await;
|
||||
validate_captcha_token_works(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn validate_captcha_token_works_maria() {
|
||||
let data = crate::tests::maria::get_data().await;
|
||||
validate_captcha_token_works(data).await;
|
||||
}
|
||||
|
||||
pub async fn validate_captcha_token_works(data: ArcData) {
|
||||
const NAME: &str = "enterprisetken";
|
||||
const PASSWORD: &str = "testingpas";
|
||||
const EMAIL: &str = "verifyuser@enter.com";
|
||||
@@ -89,7 +100,6 @@ pub mod tests {
|
||||
const VERIFY_TOKEN_URL: &str = "/api/v1/pow/siteverify";
|
||||
// const UPDATE_URL: &str = "/api/v1/mcaptcha/domain/token/duration/update";
|
||||
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
delete_user(data, NAME).await;
|
||||
|
||||
|
||||
@@ -26,12 +26,22 @@ use crate::*;
|
||||
use crate::tests::*;
|
||||
|
||||
#[actix_rt::test]
|
||||
pub async fn auth_works() {
|
||||
async fn auth_works_pg_test() {
|
||||
let data = pg::get_data().await;
|
||||
auth_works(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn auth_works_maria_test() {
|
||||
let data = maria::get_data().await;
|
||||
auth_works(data).await;
|
||||
}
|
||||
|
||||
pub async fn auth_works(data: ArcData) {
|
||||
const NAME: &str = "testuser";
|
||||
const PASSWORD: &str = "longpassword";
|
||||
const EMAIL: &str = "testuser1@a.com";
|
||||
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
|
||||
let app = get_app!(data).await;
|
||||
@@ -143,11 +153,21 @@ pub async fn auth_works() {
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
pub async fn serverside_password_validation_works() {
|
||||
async fn serverside_password_validation_works_pg() {
|
||||
let data = pg::get_data().await;
|
||||
serverside_password_validation_works(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn serverside_password_validation_works_maria() {
|
||||
let data = maria::get_data().await;
|
||||
serverside_password_validation_works(data).await;
|
||||
}
|
||||
|
||||
pub async fn serverside_password_validation_works(data: ArcData) {
|
||||
const NAME: &str = "testuser542";
|
||||
const PASSWORD: &str = "longpassword2";
|
||||
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
delete_user(data, NAME).await;
|
||||
|
||||
|
||||
@@ -23,11 +23,21 @@ use crate::*;
|
||||
use crate::tests::*;
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn protected_routes_work() {
|
||||
async fn protected_routes_work_pg() {
|
||||
let data = pg::get_data().await;
|
||||
protected_routes_work(data).await;
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
async fn protected_routes_work_maria() {
|
||||
let data = maria::get_data().await;
|
||||
protected_routes_work(data).await;
|
||||
}
|
||||
|
||||
async fn protected_routes_work(data: ArcData) {
|
||||
const NAME: &str = "testuser619";
|
||||
const PASSWORD: &str = "longpassword2";
|
||||
const EMAIL: &str = "testuser119@a.com2";
|
||||
let data = get_data().await;
|
||||
let data = &data;
|
||||
|
||||
let _post_protected_urls = [
|
||||
|
||||
Reference in New Issue
Block a user