diff --git a/src/api/v1/account/password.rs b/src/api/v1/account/password.rs index 8a548eb9..c6602022 100644 --- a/src/api/v1/account/password.rs +++ b/src/api/v1/account/password.rs @@ -170,7 +170,6 @@ mod tests { ROUTES.account.update_password, &update_password, ServiceError::PasswordsDontMatch, - StatusCode::BAD_REQUEST, ) .await; @@ -186,7 +185,6 @@ mod tests { ROUTES.account.update_password, &update_password, ServiceError::WrongPassword, - StatusCode::UNAUTHORIZED, ) .await; diff --git a/src/api/v1/account/test.rs b/src/api/v1/account/test.rs index 17924802..38a137cd 100644 --- a/src/api/v1/account/test.rs +++ b/src/api/v1/account/test.rs @@ -157,7 +157,6 @@ async fn email_udpate_password_validation_del_userworks() { ROUTES.account.update_email, &email_payload, ServiceError::EmailTaken, - StatusCode::BAD_REQUEST, ) .await; @@ -171,7 +170,6 @@ async fn email_udpate_password_validation_del_userworks() { ROUTES.account.delete, &payload, ServiceError::WrongPassword, - StatusCode::UNAUTHORIZED, ) .await; diff --git a/src/api/v1/mcaptcha/levels.rs b/src/api/v1/mcaptcha/levels.rs index 466029a4..d5ec5906 100644 --- a/src/api/v1/mcaptcha/levels.rs +++ b/src/api/v1/mcaptcha/levels.rs @@ -340,7 +340,6 @@ mod tests { ROUTES.mcaptcha.delete, &delete_payload, ServiceError::WrongPassword, - StatusCode::UNAUTHORIZED, ) .await; diff --git a/src/api/v1/tests/auth.rs b/src/api/v1/tests/auth.rs index bf274cd6..68bff8c6 100644 --- a/src/api/v1/tests/auth.rs +++ b/src/api/v1/tests/auth.rs @@ -71,7 +71,6 @@ async fn auth_works() { ROUTES.auth.register, &msg, ServiceError::UsernameTaken, - StatusCode::BAD_REQUEST, ) .await; @@ -83,7 +82,6 @@ async fn auth_works() { ROUTES.auth.register, &msg, ServiceError::EmailTaken, - StatusCode::BAD_REQUEST, ) .await; @@ -98,7 +96,6 @@ async fn auth_works() { ROUTES.auth.login, &creds, ServiceError::AccountNotFound, - StatusCode::NOT_FOUND, ) .await; @@ -109,7 +106,6 @@ async fn auth_works() { ROUTES.auth.login, &creds, ServiceError::AccountNotFound, - StatusCode::NOT_FOUND, ) .await; @@ -123,7 +119,6 @@ async fn auth_works() { ROUTES.auth.login, &creds, ServiceError::WrongPassword, - StatusCode::UNAUTHORIZED, ) .await; diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 245ff1a5..5d0ba3e1 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -3,6 +3,7 @@ use std::sync::Arc; use actix_web::test; use actix_web::{ dev::ServiceResponse, + error::ResponseError, http::{header, StatusCode}, middleware as actix_middleware, }; @@ -143,24 +144,23 @@ pub async fn bad_post_req_test( password: &str, url: &str, payload: &T, - dup_err: ServiceError, - s: StatusCode, + err: ServiceError, ) { let (data, _, signin_resp) = signin(name, password).await; let cookies = get_cookie!(signin_resp); let app = get_app!(data).await; - let dup_token_resp = test::call_service( + let resp = test::call_service( &app, post_request!(&payload, url) .cookie(cookies.clone()) .to_request(), ) .await; - assert_eq!(dup_token_resp.status(), s); - let txt: ErrorToResponse = test::read_body_json(dup_token_resp).await; + assert_eq!(resp.status(), err.status_code()); + let resp_err: ErrorToResponse = test::read_body_json(resp).await; //println!("{}", txt.error); - assert_eq!(txt.error, format!("{}", dup_err)); + assert_eq!(resp_err.error, format!("{}", err)); } pub const L1: Level = Level {