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>)
|
pub async fn service_login(
|
||||||
-> (axum::http::StatusCode, axum::Json<response::service_login::Response>) {
|
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();
|
let mut response = response::service_login::Response::default();
|
||||||
|
|
||||||
match repo::service::valid_passphrase(&pool, &payload.passphrase).await {
|
match repo::service::valid_passphrase(&pool, &payload.passphrase).await {
|
||||||
|
16
src/main.rs
16
src/main.rs
@@ -41,7 +41,10 @@ mod init {
|
|||||||
callers::endpoints::LOGIN,
|
callers::endpoints::LOGIN,
|
||||||
post(callers::login::endpoint::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 {
|
pub async fn app() -> Router {
|
||||||
@@ -158,7 +161,10 @@ mod tests {
|
|||||||
pub mod requests {
|
pub mod requests {
|
||||||
use tower::ServiceExt; // for `call`, `oneshot`, and `ready`
|
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 usr = super::get_test_register_request();
|
||||||
let payload = super::get_test_register_payload(&usr);
|
let payload = super::get_test_register_payload(&usr);
|
||||||
let req = axum::http::Request::builder()
|
let req = axum::http::Request::builder()
|
||||||
@@ -251,7 +257,6 @@ mod tests {
|
|||||||
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
|
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_login_user() {
|
async fn test_login_user() {
|
||||||
let tm_pool = db_mgr::get_pool().await.unwrap();
|
let tm_pool = db_mgr::get_pool().await.unwrap();
|
||||||
@@ -365,7 +370,6 @@ mod tests {
|
|||||||
"passphrase": passphrase
|
"passphrase": passphrase
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
match app
|
match app
|
||||||
.oneshot(
|
.oneshot(
|
||||||
Request::builder()
|
Request::builder()
|
||||||
@@ -375,7 +379,8 @@ mod tests {
|
|||||||
.body(Body::from(payload.to_string()))
|
.body(Body::from(payload.to_string()))
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
.await {
|
.await
|
||||||
|
{
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
assert_eq!(StatusCode::OK, response.status(), "Status is not right");
|
assert_eq!(StatusCode::OK, response.status(), "Status is not right");
|
||||||
let body = axum::body::to_bytes(response.into_body(), usize::MAX)
|
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;
|
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -199,11 +199,14 @@ pub mod salt {
|
|||||||
pub mod service {
|
pub mod service {
|
||||||
use sqlx::Row;
|
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(
|
let result = sqlx::query(
|
||||||
r#"
|
r#"
|
||||||
SELECT * FROM "passphrase" WHERE passphrase = $1
|
SELECT * FROM "passphrase" WHERE passphrase = $1
|
||||||
"#
|
"#,
|
||||||
)
|
)
|
||||||
.bind(passphrase)
|
.bind(passphrase)
|
||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
@@ -217,7 +220,7 @@ pub mod service {
|
|||||||
|
|
||||||
Ok((id, passphrase, date_created.unwrap()))
|
Ok((id, passphrase, date_created.unwrap()))
|
||||||
}
|
}
|
||||||
Err(err) => Err(err)
|
Err(err) => Err(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user