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
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:
@@ -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 {
|
||||
|
40
src/main.rs
40
src/main.rs
@@ -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,21 +379,21 @@ mod tests {
|
||||
.body(Body::from(payload.to_string()))
|
||||
.unwrap(),
|
||||
)
|
||||
.await {
|
||||
Ok(response) => {
|
||||
assert_eq!(StatusCode::OK, response.status(), "Status is not right");
|
||||
let body = axum::body::to_bytes(response.into_body(), usize::MAX)
|
||||
.await
|
||||
.unwrap();
|
||||
let parsed_body: callers::login::response::service_login::Response =
|
||||
serde_json::from_slice(&body).unwrap();
|
||||
let _login_result = &parsed_body.data[0];
|
||||
}
|
||||
Err(err) => {
|
||||
assert!(false, "Error: {err:?}");
|
||||
}
|
||||
.await
|
||||
{
|
||||
Ok(response) => {
|
||||
assert_eq!(StatusCode::OK, response.status(), "Status is not right");
|
||||
let body = axum::body::to_bytes(response.into_body(), usize::MAX)
|
||||
.await
|
||||
.unwrap();
|
||||
let parsed_body: callers::login::response::service_login::Response =
|
||||
serde_json::from_slice(&body).unwrap();
|
||||
let _login_result = &parsed_body.data[0];
|
||||
}
|
||||
|
||||
Err(err) => {
|
||||
assert!(false, "Error: {err:?}");
|
||||
}
|
||||
}
|
||||
|
||||
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
|
||||
}
|
||||
|
@@ -199,15 +199,18 @@ 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)
|
||||
.await;
|
||||
"#,
|
||||
)
|
||||
.bind(passphrase)
|
||||
.fetch_one(pool)
|
||||
.await;
|
||||
|
||||
match result {
|
||||
Ok(row) => {
|
||||
@@ -217,7 +220,7 @@ pub mod service {
|
||||
|
||||
Ok((id, passphrase, date_created.unwrap()))
|
||||
}
|
||||
Err(err) => Err(err)
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user