Compare commits
1 Commits
v0.1.0-dev
...
v0.1.0-dev
Author | SHA1 | Date | |
---|---|---|---|
c9873d95d7 |
@@ -8,5 +8,7 @@ axum = { version = "0.8.3" }
|
|||||||
serde = { version = "1.0.218", features = ["derive"] }
|
serde = { version = "1.0.218", features = ["derive"] }
|
||||||
serde_json = { version = "1.0.139" }
|
serde_json = { version = "1.0.139" }
|
||||||
tokio = { version = "1.44.1", features = ["rt-multi-thread"] }
|
tokio = { version = "1.44.1", features = ["rt-multi-thread"] }
|
||||||
tracing-subscriber = "0.3.19"
|
tracing-subscriber = { version = "0.3.19" }
|
||||||
|
tower = { version = "0.5.2" }
|
||||||
|
hyper = { version = "1.6.0" }
|
||||||
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.2.0" }
|
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.2.0" }
|
||||||
|
3
src/lib.rs
Normal file
3
src/lib.rs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
pub mod callers;
|
||||||
|
pub mod config;
|
||||||
|
pub mod models;
|
@@ -3,9 +3,8 @@ use axum::{
|
|||||||
routing::{get, post},
|
routing::{get, post},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub mod callers;
|
use icarus_auth::callers;
|
||||||
pub mod config;
|
use icarus_auth::config;
|
||||||
pub mod models;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
42
tests/auth_tests.rs
Normal file
42
tests/auth_tests.rs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
extern crate icarus_auth;
|
||||||
|
|
||||||
|
use axum::body::Body;
|
||||||
|
// use axum::response::Response;
|
||||||
|
use axum::{
|
||||||
|
Router,
|
||||||
|
http::{Request, StatusCode},
|
||||||
|
routing::get,
|
||||||
|
};
|
||||||
|
// use http::{Request, StatusCode};
|
||||||
|
// use serde_json::json;
|
||||||
|
// use tower::ServiceExt; // for `.oneshot()`
|
||||||
|
use tower::util::ServiceExt;
|
||||||
|
|
||||||
|
use crate::icarus_auth::callers;
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_hello_world() {
|
||||||
|
let app = Router::new().route(callers::endpoints::ROOT, get(callers::common::root)); // Replace with your handler
|
||||||
|
|
||||||
|
let response = app
|
||||||
|
.oneshot(
|
||||||
|
Request::builder()
|
||||||
|
.uri(callers::endpoints::ROOT)
|
||||||
|
.body(Body::empty())
|
||||||
|
.unwrap(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(response.status(), StatusCode::OK);
|
||||||
|
|
||||||
|
let body = String::from_utf8(
|
||||||
|
axum::body::to_bytes(response.into_body(), usize::MAX)
|
||||||
|
.await
|
||||||
|
.unwrap()
|
||||||
|
.to_vec(),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(body, "Hello, World!");
|
||||||
|
}
|
Reference in New Issue
Block a user