Refactor test suite to handle 303 See Other
This commit is contained in:
@@ -11,10 +11,7 @@ use axum::{
|
|||||||
extract::State,
|
extract::State,
|
||||||
response::{Html, IntoResponse, Response},
|
response::{Html, IntoResponse, Response},
|
||||||
};
|
};
|
||||||
use axum::{
|
use axum::{http::StatusCode, response::Redirect};
|
||||||
http::{HeaderMap, StatusCode},
|
|
||||||
response::Redirect,
|
|
||||||
};
|
|
||||||
use secrecy::SecretString;
|
use secrecy::SecretString;
|
||||||
|
|
||||||
#[derive(thiserror::Error)]
|
#[derive(thiserror::Error)]
|
||||||
@@ -117,9 +114,11 @@ pub async fn post_login(
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| LoginError::UnexpectedError(e.into()))?;
|
.map_err(|e| LoginError::UnexpectedError(e.into()))?;
|
||||||
|
|
||||||
let mut headers = HeaderMap::new();
|
let mut response = Redirect::to("/admin/dashboard").into_response();
|
||||||
headers.insert("HX-Redirect", "/admin/dashboard".parse().unwrap());
|
response
|
||||||
Ok((StatusCode::OK, headers).into_response())
|
.headers_mut()
|
||||||
|
.insert("HX-Redirect", "/admin/dashboard".parse().unwrap());
|
||||||
|
Ok(response)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -297,9 +297,8 @@ async fn configure_database(config: &DatabaseSettings) -> PgPool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn assert_is_redirect_to(response: &reqwest::Response, location: &str) {
|
pub fn assert_is_redirect_to(response: &reqwest::Response, location: &str) {
|
||||||
dbg!(&response);
|
assert_eq!(response.status().as_u16(), 303);
|
||||||
assert_eq!(response.status().as_u16(), 200);
|
assert_eq!(response.headers().get("location").unwrap(), location);
|
||||||
assert_eq!(response.headers().get("hx-redirect").unwrap(), location);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn when_sending_an_email() -> MockBuilder {
|
pub fn when_sending_an_email() -> MockBuilder {
|
||||||
|
|||||||
Reference in New Issue
Block a user