More stuff
soaricarus_auth Build / Clippy (pull_request) Failing after 52s
soaricarus_auth Build / Rustfmt (pull_request) Successful in 1m6s
soaricarus_auth Build / build (pull_request) Successful in 1m7s
soaricarus_auth Build / Test Suite (pull_request) Failing after 1m15s
soaricarus_auth Build / Check (pull_request) Successful in 1m44s

This commit is contained in:
2026-09-20 19:50:03 -04:00
parent 476b25fecf
commit e2cd7a52cf
2 changed files with 38 additions and 9 deletions
+3 -2
View File
@@ -305,7 +305,8 @@ pub mod endpoint {
), ),
responses( responses(
(status = 200, description = "Password updated successfully", body = super::response::update_password::Response), (status = 200, description = "Password updated successfully", body = super::response::update_password::Response),
(status = 400, description = "Failure", body = super::response::update_password::Response) (status = 400, description = "Invalid", body = super::response::update_password::Response),
(status = 500, description = "Failure", body = super::response::update_password::Response)
) )
)] )]
pub async fn update_password( pub async fn update_password(
@@ -356,7 +357,7 @@ pub mod endpoint {
Err(err) => { Err(err) => {
response.message = err.to_string(); response.message = err.to_string();
( (
axum::http::StatusCode::BAD_REQUEST, axum::http::StatusCode::INTERNAL_SERVER_ERROR,
axum::Json(response), axum::Json(response),
) )
} }
+35 -7
View File
@@ -38,11 +38,11 @@ mod init {
paths( paths(
common_callers::endpoint::db_ping, common_callers::endpoint::root, common_callers::endpoint::db_ping, common_callers::endpoint::root,
register_caller::register_user, register_caller::register_user,
login_endpoints::login, login_endpoints::service_login, login_endpoints::refresh_token login_endpoints::login, login_endpoints::update_password, login_endpoints::service_login, login_endpoints::refresh_token
), ),
components(schemas(common_callers::response::TestResult, components(schemas(common_callers::response::TestResult,
register_responses::Response, register_responses::Response,
login_responses::Response, login_responses::service_login::Response, login_responses::refresh_token::Response)), login_responses::Response, login_responses::service_login::Response, login_responses::update_password::Response, login_responses::refresh_token::Response)),
tags( tags(
(name = "soaricarus Auth API", description = "Auth API for soaricarus API") (name = "soaricarus Auth API", description = "Auth API for soaricarus API")
) )
@@ -51,20 +51,20 @@ mod init {
mod cors { mod cors {
pub async fn configure_cors() -> tower_http::cors::CorsLayer { pub async fn configure_cors() -> tower_http::cors::CorsLayer {
// Start building the CORS layer with common settings
let cors = tower_http::cors::CorsLayer::new() let cors = tower_http::cors::CorsLayer::new()
.allow_methods([ .allow_methods([
axum::http::Method::GET, axum::http::Method::GET,
axum::http::Method::PATCH,
axum::http::Method::POST, axum::http::Method::POST,
axum::http::Method::PUT, axum::http::Method::PUT,
axum::http::Method::DELETE, axum::http::Method::DELETE,
]) // Specify allowed methods:cite[2] ])
.allow_headers([ .allow_headers([
axum::http::header::CONTENT_TYPE, axum::http::header::CONTENT_TYPE,
axum::http::header::AUTHORIZATION, axum::http::header::AUTHORIZATION,
]) // Specify allowed headers:cite[2] ])
.allow_credentials(true) // If you need to send cookies or authentication headers:cite[2] .allow_credentials(true)
.max_age(std::time::Duration::from_secs(3600)); // Cache the preflight response for 1 hour:cite[2] .max_age(std::time::Duration::from_secs(3600));
// Dynamically set the allowed origin based on the environment // Dynamically set the allowed origin based on the environment
match std::env::var(sienvy::keys::APP_ENV).as_deref() { match std::env::var(sienvy::keys::APP_ENV).as_deref() {
@@ -116,6 +116,10 @@ mod init {
callers::endpoints::LOGIN, callers::endpoints::LOGIN,
post(callers::login::endpoint::login), post(callers::login::endpoint::login),
) )
.route(
callers::endpoints::UPDATE_PASSWORD,
post(callers::login::endpoint::update_password),
)
.route( .route(
callers::endpoints::SERVICE_LOGIN, callers::endpoints::SERVICE_LOGIN,
post(callers::login::endpoint::service_login), post(callers::login::endpoint::service_login),
@@ -553,4 +557,28 @@ mod tests {
let _ = db_mgr::drop_database(&tm_pool, &db_name).await; let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
} }
#[tokio::test]
async fn test_update_password() {
let tm_pool = db_mgr::get_pool().await.unwrap();
let db_name = db_mgr::generate_db_name().await;
match db_mgr::create_database(&tm_pool, &db_name).await {
Ok(_) => {
println!("Success");
}
Err(e) => {
assert!(false, "Error: {:?}", e.to_string());
}
}
let pool = db_mgr::connect_to_db(&db_name).await.unwrap();
db::init::migrations(&pool).await;
let app = init::routes().await.layer(axum::Extension(pool));
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
}
} }