tests: get status code from err
This commit is contained in:
parent
c3e43ff584
commit
1b0a95e768
5 changed files with 6 additions and 16 deletions
|
@ -170,7 +170,6 @@ mod tests {
|
||||||
ROUTES.account.update_password,
|
ROUTES.account.update_password,
|
||||||
&update_password,
|
&update_password,
|
||||||
ServiceError::PasswordsDontMatch,
|
ServiceError::PasswordsDontMatch,
|
||||||
StatusCode::BAD_REQUEST,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
@ -186,7 +185,6 @@ mod tests {
|
||||||
ROUTES.account.update_password,
|
ROUTES.account.update_password,
|
||||||
&update_password,
|
&update_password,
|
||||||
ServiceError::WrongPassword,
|
ServiceError::WrongPassword,
|
||||||
StatusCode::UNAUTHORIZED,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,6 @@ async fn email_udpate_password_validation_del_userworks() {
|
||||||
ROUTES.account.update_email,
|
ROUTES.account.update_email,
|
||||||
&email_payload,
|
&email_payload,
|
||||||
ServiceError::EmailTaken,
|
ServiceError::EmailTaken,
|
||||||
StatusCode::BAD_REQUEST,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
@ -171,7 +170,6 @@ async fn email_udpate_password_validation_del_userworks() {
|
||||||
ROUTES.account.delete,
|
ROUTES.account.delete,
|
||||||
&payload,
|
&payload,
|
||||||
ServiceError::WrongPassword,
|
ServiceError::WrongPassword,
|
||||||
StatusCode::UNAUTHORIZED,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
|
@ -340,7 +340,6 @@ mod tests {
|
||||||
ROUTES.mcaptcha.delete,
|
ROUTES.mcaptcha.delete,
|
||||||
&delete_payload,
|
&delete_payload,
|
||||||
ServiceError::WrongPassword,
|
ServiceError::WrongPassword,
|
||||||
StatusCode::UNAUTHORIZED,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,6 @@ async fn auth_works() {
|
||||||
ROUTES.auth.register,
|
ROUTES.auth.register,
|
||||||
&msg,
|
&msg,
|
||||||
ServiceError::UsernameTaken,
|
ServiceError::UsernameTaken,
|
||||||
StatusCode::BAD_REQUEST,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
@ -83,7 +82,6 @@ async fn auth_works() {
|
||||||
ROUTES.auth.register,
|
ROUTES.auth.register,
|
||||||
&msg,
|
&msg,
|
||||||
ServiceError::EmailTaken,
|
ServiceError::EmailTaken,
|
||||||
StatusCode::BAD_REQUEST,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
@ -98,7 +96,6 @@ async fn auth_works() {
|
||||||
ROUTES.auth.login,
|
ROUTES.auth.login,
|
||||||
&creds,
|
&creds,
|
||||||
ServiceError::AccountNotFound,
|
ServiceError::AccountNotFound,
|
||||||
StatusCode::NOT_FOUND,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
@ -109,7 +106,6 @@ async fn auth_works() {
|
||||||
ROUTES.auth.login,
|
ROUTES.auth.login,
|
||||||
&creds,
|
&creds,
|
||||||
ServiceError::AccountNotFound,
|
ServiceError::AccountNotFound,
|
||||||
StatusCode::NOT_FOUND,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
@ -123,7 +119,6 @@ async fn auth_works() {
|
||||||
ROUTES.auth.login,
|
ROUTES.auth.login,
|
||||||
&creds,
|
&creds,
|
||||||
ServiceError::WrongPassword,
|
ServiceError::WrongPassword,
|
||||||
StatusCode::UNAUTHORIZED,
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ use std::sync::Arc;
|
||||||
use actix_web::test;
|
use actix_web::test;
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
dev::ServiceResponse,
|
dev::ServiceResponse,
|
||||||
|
error::ResponseError,
|
||||||
http::{header, StatusCode},
|
http::{header, StatusCode},
|
||||||
middleware as actix_middleware,
|
middleware as actix_middleware,
|
||||||
};
|
};
|
||||||
|
@ -143,24 +144,23 @@ pub async fn bad_post_req_test<T: Serialize>(
|
||||||
password: &str,
|
password: &str,
|
||||||
url: &str,
|
url: &str,
|
||||||
payload: &T,
|
payload: &T,
|
||||||
dup_err: ServiceError,
|
err: ServiceError,
|
||||||
s: StatusCode,
|
|
||||||
) {
|
) {
|
||||||
let (data, _, signin_resp) = signin(name, password).await;
|
let (data, _, signin_resp) = signin(name, password).await;
|
||||||
let cookies = get_cookie!(signin_resp);
|
let cookies = get_cookie!(signin_resp);
|
||||||
let app = get_app!(data).await;
|
let app = get_app!(data).await;
|
||||||
|
|
||||||
let dup_token_resp = test::call_service(
|
let resp = test::call_service(
|
||||||
&app,
|
&app,
|
||||||
post_request!(&payload, url)
|
post_request!(&payload, url)
|
||||||
.cookie(cookies.clone())
|
.cookie(cookies.clone())
|
||||||
.to_request(),
|
.to_request(),
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
assert_eq!(dup_token_resp.status(), s);
|
assert_eq!(resp.status(), err.status_code());
|
||||||
let txt: ErrorToResponse = test::read_body_json(dup_token_resp).await;
|
let resp_err: ErrorToResponse = test::read_body_json(resp).await;
|
||||||
//println!("{}", txt.error);
|
//println!("{}", txt.error);
|
||||||
assert_eq!(txt.error, format!("{}", dup_err));
|
assert_eq!(resp_err.error, format!("{}", err));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const L1: Level = Level {
|
pub const L1: Level = Level {
|
||||||
|
|
Loading…
Reference in a new issue