Code formatting
Some checks failed
Rust Build / Check (pull_request) Successful in 48s
Rust Build / Test Suite (pull_request) Failing after 58s
Rust Build / Rustfmt (pull_request) Successful in 26s
Rust Build / Clippy (pull_request) Failing after 46s
Rust Build / build (pull_request) Successful in 47s

This commit is contained in:
2025-08-02 17:37:55 -04:00
parent 4db6c16e06
commit 99fd64d5c8
3 changed files with 40 additions and 28 deletions

View File

@@ -95,8 +95,13 @@ pub mod endpoint {
}
}
pub async fn service_login(axum::Extension(pool): axum::Extension<sqlx::PgPool>, axum::Json(payload): axum::Json<request::service_login::Request>)
-> (axum::http::StatusCode, axum::Json<response::service_login::Response>) {
pub async fn service_login(
axum::Extension(pool): axum::Extension<sqlx::PgPool>,
axum::Json(payload): axum::Json<request::service_login::Request>,
) -> (
axum::http::StatusCode,
axum::Json<response::service_login::Response>,
) {
let mut response = response::service_login::Response::default();
match repo::service::valid_passphrase(&pool, &payload.passphrase).await {

View File

@@ -41,7 +41,10 @@ mod init {
callers::endpoints::LOGIN,
post(callers::login::endpoint::login),
)
.route(callers::endpoints::SERVICE_LOGIN, post(callers::login::endpoint::service_login))
.route(
callers::endpoints::SERVICE_LOGIN,
post(callers::login::endpoint::service_login),
)
}
pub async fn app() -> Router {
@@ -158,7 +161,10 @@ mod tests {
pub mod requests {
use tower::ServiceExt; // for `call`, `oneshot`, and `ready`
pub async fn register(app: &axum::Router, usr: &icarus_auth::callers::register::request::Request) -> Result<axum::response::Response, std::convert::Infallible> {
pub async fn register(
app: &axum::Router,
usr: &icarus_auth::callers::register::request::Request,
) -> Result<axum::response::Response, std::convert::Infallible> {
// let usr = super::get_test_register_request();
let payload = super::get_test_register_payload(&usr);
let req = axum::http::Request::builder()
@@ -251,7 +257,6 @@ mod tests {
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
}
#[tokio::test]
async fn test_login_user() {
let tm_pool = db_mgr::get_pool().await.unwrap();
@@ -365,7 +370,6 @@ mod tests {
"passphrase": passphrase
});
match app
.oneshot(
Request::builder()
@@ -375,7 +379,8 @@ mod tests {
.body(Body::from(payload.to_string()))
.unwrap(),
)
.await {
.await
{
Ok(response) => {
assert_eq!(StatusCode::OK, response.status(), "Status is not right");
let body = axum::body::to_bytes(response.into_body(), usize::MAX)
@@ -390,7 +395,6 @@ mod tests {
}
}
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
}
}

View File

@@ -199,11 +199,14 @@ pub mod salt {
pub mod service {
use sqlx::Row;
pub async fn valid_passphrase(pool: &sqlx::PgPool, passphrase: &String) -> Result<(uuid::Uuid, String, time::OffsetDateTime), sqlx::Error> {
pub async fn valid_passphrase(
pool: &sqlx::PgPool,
passphrase: &String,
) -> Result<(uuid::Uuid, String, time::OffsetDateTime), sqlx::Error> {
let result = sqlx::query(
r#"
SELECT * FROM "passphrase" WHERE passphrase = $1
"#
"#,
)
.bind(passphrase)
.fetch_one(pool)
@@ -217,7 +220,7 @@ pub mod service {
Ok((id, passphrase, date_created.unwrap()))
}
Err(err) => Err(err)
Err(err) => Err(err),
}
}
}