687 lines
24 KiB
Rust
687 lines
24 KiB
Rust
use soaricarus_auth;
|
|
use soaricarus_auth::init;
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
// initialize tracing
|
|
tracing_subscriber::fmt::init();
|
|
|
|
let app = init::app().await;
|
|
|
|
// run our app with hyper, listening globally on port 8001
|
|
let url = soaricarus_auth::config::get_full();
|
|
let listener = tokio::net::TcpListener::bind(url).await.unwrap();
|
|
axum::serve(listener, app).await.unwrap();
|
|
}
|
|
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::*;
|
|
use soaricarus_auth;
|
|
use soaricarus_auth::callers;
|
|
use soaricarus_auth::db;
|
|
|
|
use axum::{
|
|
body::Body,
|
|
http::{Request, StatusCode},
|
|
};
|
|
use http_body_util::BodyExt;
|
|
use serde_json::json;
|
|
use tower::ServiceExt; // for `call`, `oneshot`, and `ready`
|
|
|
|
mod db_mgr {
|
|
use std::str::FromStr;
|
|
|
|
pub const LIMIT: usize = 6;
|
|
|
|
pub async fn get_pool() -> Result<sqlx::PgPool, sqlx::Error> {
|
|
let tm_db_url = sienvy::environment::get_db_url().value;
|
|
let tm_options = sqlx::postgres::PgConnectOptions::from_str(&tm_db_url).unwrap();
|
|
sqlx::PgPool::connect_with(tm_options).await
|
|
}
|
|
|
|
pub async fn generate_db_name() -> String {
|
|
let db_name = get_database_name().await.unwrap()
|
|
+ &"_"
|
|
+ &uuid::Uuid::new_v4().to_string()[..LIMIT];
|
|
db_name
|
|
}
|
|
|
|
pub async fn connect_to_db(db_name: &str) -> Result<sqlx::PgPool, sqlx::Error> {
|
|
let db_url = sienvy::environment::get_db_url().value;
|
|
let options = sqlx::postgres::PgConnectOptions::from_str(&db_url)?.database(db_name);
|
|
sqlx::PgPool::connect_with(options).await
|
|
}
|
|
|
|
pub async fn create_database(
|
|
template_pool: &sqlx::PgPool,
|
|
db_name: &str,
|
|
) -> Result<(), sqlx::Error> {
|
|
let create_query = format!("CREATE DATABASE {}", db_name);
|
|
match sqlx::query(sqlx::AssertSqlSafe(create_query))
|
|
.execute(template_pool)
|
|
.await
|
|
{
|
|
Ok(_) => Ok(()),
|
|
Err(e) => Err(e),
|
|
}
|
|
}
|
|
|
|
// Function to drop a database
|
|
pub async fn drop_database(
|
|
template_pool: &sqlx::PgPool,
|
|
db_name: &str,
|
|
) -> Result<(), sqlx::Error> {
|
|
let drop_query = format!("DROP DATABASE IF EXISTS {} WITH (FORCE)", db_name);
|
|
sqlx::query(sqlx::AssertSqlSafe(drop_query))
|
|
.execute(template_pool)
|
|
.await?;
|
|
Ok(())
|
|
}
|
|
|
|
pub async fn get_database_name() -> Result<String, Box<dyn std::error::Error>> {
|
|
let database_url = sienvy::environment::get_db_url().value;
|
|
|
|
let parsed_url = url::Url::parse(&database_url)?;
|
|
if parsed_url.scheme() == "postgres" || parsed_url.scheme() == "postgresql" {
|
|
match parsed_url
|
|
.path_segments()
|
|
.and_then(|segments| segments.last().map(|s| s.to_string()))
|
|
{
|
|
Some(sss) => Ok(sss),
|
|
None => Err("Error parsing".into()),
|
|
}
|
|
} else {
|
|
// Handle other database types if needed
|
|
Err("Error parsing".into())
|
|
}
|
|
}
|
|
}
|
|
|
|
fn get_test_register_request() -> callers::register::request::Request {
|
|
callers::register::request::Request {
|
|
username: String::from("somethingsss"),
|
|
password: String::from("Raindown!"),
|
|
email: String::from("dev@null.com"),
|
|
phone: String::from("1234567890"),
|
|
firstname: String::from("Bob"),
|
|
lastname: String::from("Smith"),
|
|
}
|
|
}
|
|
|
|
fn get_test_register_payload(usr: &callers::register::request::Request) -> serde_json::Value {
|
|
json!({
|
|
"username": &usr.username,
|
|
"password": &usr.password,
|
|
"email": &usr.email,
|
|
"phone": &usr.phone,
|
|
"firstname": &usr.firstname,
|
|
"lastname": &usr.lastname,
|
|
})
|
|
}
|
|
|
|
fn get_test_login_payload(usr: &callers::login::request::Request) -> serde_json::Value {
|
|
json!({
|
|
"username": &usr.username,
|
|
"password": &usr.password,
|
|
})
|
|
}
|
|
|
|
pub mod test_data {
|
|
use serde_json::json;
|
|
|
|
pub fn get_updated_password(user_id: &uuid::Uuid) -> serde_json::Value {
|
|
json!({
|
|
"username": "somethingsss",
|
|
"user_id": user_id,
|
|
"current_password": "Raindown!",
|
|
"updated_password": "SpeakWithUrChest22!",
|
|
"confirmed_password": "SpeakWithUrChest22!"
|
|
})
|
|
}
|
|
|
|
pub fn update_user_profile(user_id: &uuid::Uuid, firstname: &str, lastname: &str) -> serde_json::Value {
|
|
json!({
|
|
"firstname": firstname,
|
|
"lastname": lastname,
|
|
"user_id": user_id
|
|
})
|
|
}
|
|
}
|
|
|
|
pub mod requests {
|
|
use tower::ServiceExt; // for `call`, `oneshot`, and `ready`
|
|
use soaricarus_auth::callers;
|
|
|
|
pub async fn register(
|
|
app: &axum::Router,
|
|
usr: &super::callers::register::request::Request,
|
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
|
let payload = super::get_test_register_payload(&usr);
|
|
let req = axum::http::Request::builder()
|
|
.method(axum::http::Method::POST)
|
|
.uri(callers::endpoints::REGISTER)
|
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
|
.body(axum::body::Body::from(payload.to_string()))
|
|
.unwrap();
|
|
|
|
app.clone().oneshot(req).await
|
|
}
|
|
|
|
pub async fn login(
|
|
app: &axum::Router,
|
|
usr: &super::callers::login::request::Request,
|
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
|
let payload = super::get_test_login_payload(&usr);
|
|
let req = axum::http::Request::builder()
|
|
.method(axum::http::Method::POST)
|
|
.uri(callers::endpoints::LOGIN)
|
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
|
.body(axum::body::Body::from(payload.to_string()))
|
|
.unwrap();
|
|
|
|
app.clone().oneshot(req).await
|
|
}
|
|
|
|
pub async fn update_password(
|
|
app: &axum::Router,
|
|
user_id: &uuid::Uuid,
|
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
|
let payload = super::test_data::get_updated_password(user_id);
|
|
let req = axum::http::Request::builder()
|
|
.method(axum::http::Method::PATCH)
|
|
.uri(callers::endpoints::UPDATE_PASSWORD)
|
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
|
.body(axum::body::Body::from(payload.to_string()))
|
|
.unwrap();
|
|
|
|
app.clone().oneshot(req).await
|
|
}
|
|
|
|
pub async fn get_user_profile(
|
|
app: &axum::Router,
|
|
user_id: &uuid::Uuid,
|
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
|
let raw_uri = String::from(callers::endpoints::GET_USER_PROFILE);
|
|
let end_index = raw_uri.len() - 4;
|
|
|
|
let uri = format!("{}{user_id}", (&raw_uri[..end_index]).to_string());
|
|
let req = axum::http::Request::builder()
|
|
.method(axum::http::Method::GET)
|
|
.uri(uri)
|
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
|
.body(axum::body::Body::empty())
|
|
.unwrap();
|
|
app.clone().oneshot(req).await
|
|
}
|
|
|
|
pub async fn update_user_profile(
|
|
app: &axum::Router,
|
|
user_id: &uuid::Uuid,
|
|
firstname: &str,
|
|
lastname: &str,
|
|
) -> Result<axum::response::Response, std::convert::Infallible> {
|
|
let payload = super::test_data::update_user_profile(user_id, firstname, lastname);
|
|
let req = axum::http::Request::builder()
|
|
.method(axum::http::Method::PUT)
|
|
.uri(callers::endpoints::UPDATE_USER_PROFILE)
|
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
|
.body(axum::body::Body::from(payload.to_string()))
|
|
.unwrap();
|
|
|
|
app.clone().oneshot(req).await
|
|
}
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_hello_world() {
|
|
let app = init::app().await;
|
|
|
|
// `Router` implements `tower::Service<Request<Body>>` so we can
|
|
// call it like any tower service, no need to run an HTTP server.
|
|
let response = app
|
|
.oneshot(
|
|
Request::builder()
|
|
.uri(callers::endpoints::ROOT)
|
|
.body(Body::empty())
|
|
.unwrap(),
|
|
)
|
|
.await
|
|
.unwrap();
|
|
|
|
assert_eq!(response.status(), StatusCode::OK);
|
|
|
|
let body = response.into_body().collect().await.unwrap().to_bytes();
|
|
assert_eq!(&body[..], b"Hello, World!");
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_register_user() {
|
|
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 usr = get_test_register_request();
|
|
|
|
let response = requests::register(&app, &usr).await;
|
|
|
|
match response {
|
|
Ok(resp) => {
|
|
assert_eq!(
|
|
resp.status(),
|
|
StatusCode::CREATED,
|
|
"Message: {:?} {:?}",
|
|
resp,
|
|
usr.username
|
|
);
|
|
let body = axum::body::to_bytes(resp.into_body(), usize::MAX)
|
|
.await
|
|
.unwrap();
|
|
let parsed_body: callers::register::response::Response =
|
|
serde_json::from_slice(&body).unwrap();
|
|
let returned_usr = &parsed_body.data[0];
|
|
|
|
assert_eq!(false, returned_usr.id.is_nil(), "Id is not populated");
|
|
|
|
assert_eq!(
|
|
usr.username, returned_usr.username,
|
|
"Usernames do not match"
|
|
);
|
|
assert!(returned_usr.date_created.is_some(), "Date Created is empty");
|
|
}
|
|
Err(err) => {
|
|
assert!(false, "Error: {:?}", err.to_string());
|
|
}
|
|
};
|
|
|
|
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();
|
|
|
|
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 usr = get_test_register_request();
|
|
|
|
let response = requests::register(&app, &usr).await;
|
|
|
|
match response {
|
|
Ok(resp) => {
|
|
assert_eq!(
|
|
resp.status(),
|
|
StatusCode::CREATED,
|
|
"Message: {:?} {:?}",
|
|
resp,
|
|
usr.username
|
|
);
|
|
let body = axum::body::to_bytes(resp.into_body(), usize::MAX)
|
|
.await
|
|
.unwrap();
|
|
let parsed_body: callers::register::response::Response =
|
|
serde_json::from_slice(&body).unwrap();
|
|
let returned_usr = &parsed_body.data[0];
|
|
|
|
assert_eq!(false, returned_usr.id.is_nil(), "Id is not populated");
|
|
|
|
assert_eq!(
|
|
usr.username, returned_usr.username,
|
|
"Usernames do not match"
|
|
);
|
|
assert!(returned_usr.date_created.is_some(), "Date Created is empty");
|
|
|
|
let mut n_usr = callers::login::request::Request::default();
|
|
n_usr.username = usr.username.clone();
|
|
n_usr.password = usr.password.clone();
|
|
|
|
match requests::login(&app, &n_usr).await {
|
|
Ok(resp) => {
|
|
assert_eq!(StatusCode::OK, resp.status(), "Status is not right");
|
|
let body = axum::body::to_bytes(resp.into_body(), usize::MAX)
|
|
.await
|
|
.unwrap();
|
|
let parsed_body: callers::login::response::Response =
|
|
serde_json::from_slice(&body).unwrap();
|
|
let login_result = &parsed_body.data[0];
|
|
assert!(!login_result.id.is_nil(), "Id is nil");
|
|
}
|
|
Err(err) => {
|
|
assert!(false, "Error: {:?}", err.to_string());
|
|
}
|
|
}
|
|
}
|
|
Err(err) => {
|
|
assert!(false, "Error: {:?}", err.to_string());
|
|
}
|
|
};
|
|
|
|
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_service_login_user() {
|
|
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 passphrase =
|
|
String::from("iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH");
|
|
let payload = serde_json::json!({
|
|
"passphrase": passphrase
|
|
});
|
|
|
|
match app
|
|
.oneshot(
|
|
Request::builder()
|
|
.method(axum::http::Method::POST)
|
|
.uri(callers::endpoints::SERVICE_LOGIN)
|
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
|
.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:?}");
|
|
}
|
|
}
|
|
|
|
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_refresh_token() {
|
|
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 id = uuid::Uuid::parse_str("22f9c775-cce9-457a-a147-9dafbb801f61").unwrap();
|
|
let key = sienvy::environment::get_secret_key().value;
|
|
|
|
match soaricarus_auth::token_stuff::create_service_token(&key, &id) {
|
|
Ok((token, _expire)) => {
|
|
let payload = serde_json::json!({
|
|
"access_token": token
|
|
});
|
|
|
|
match app
|
|
.oneshot(
|
|
Request::builder()
|
|
.method(axum::http::Method::POST)
|
|
.uri(callers::endpoints::REFRESH_TOKEN)
|
|
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
|
.body(Body::from(payload.to_string()))
|
|
.unwrap(),
|
|
)
|
|
.await
|
|
{
|
|
Ok(response) => {
|
|
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];
|
|
|
|
assert_eq!(
|
|
id, login_result.id,
|
|
"The Id from the response does not match {id:?} {:?}",
|
|
login_result.id
|
|
);
|
|
}
|
|
Err(err) => {
|
|
assert!(false, "Error: {err:?}");
|
|
}
|
|
}
|
|
}
|
|
Err(err) => {
|
|
assert!(false, "Error: {err:?}");
|
|
}
|
|
}
|
|
|
|
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 usr = get_test_register_request();
|
|
|
|
match requests::register(&app, &usr).await {
|
|
Ok(resp) => {
|
|
assert_eq!(
|
|
resp.status(),
|
|
StatusCode::CREATED,
|
|
"Message: {:?} {:?}",
|
|
resp,
|
|
usr.username
|
|
);
|
|
let body = axum::body::to_bytes(resp.into_body(), usize::MAX)
|
|
.await
|
|
.unwrap();
|
|
let parsed_body: callers::register::response::Response =
|
|
serde_json::from_slice(&body).unwrap();
|
|
let returned_usr = &parsed_body.data[0];
|
|
|
|
assert_eq!(false, returned_usr.id.is_nil(), "Id is not populated");
|
|
|
|
assert_eq!(
|
|
usr.username, returned_usr.username,
|
|
"Usernames do not match"
|
|
);
|
|
assert!(returned_usr.date_created.is_some(), "Date Created is empty");
|
|
|
|
let mut n_usr = callers::login::request::Request::default();
|
|
n_usr.username = usr.username.clone();
|
|
n_usr.password = usr.password.clone();
|
|
|
|
match requests::login(&app, &n_usr).await {
|
|
Ok(resp) => {
|
|
assert_eq!(StatusCode::OK, resp.status(), "Status is not right");
|
|
let body = axum::body::to_bytes(resp.into_body(), usize::MAX)
|
|
.await
|
|
.unwrap();
|
|
let parsed_body: callers::login::response::Response =
|
|
serde_json::from_slice(&body).unwrap();
|
|
let login_result = &parsed_body.data[0];
|
|
assert!(!login_result.id.is_nil(), "Id is nil");
|
|
|
|
match requests::update_password(&app, &login_result.id).await {
|
|
Ok(resp) => {
|
|
assert_eq!(StatusCode::OK, resp.status(), "Status is not right");
|
|
let body = axum::body::to_bytes(resp.into_body(), usize::MAX)
|
|
.await
|
|
.unwrap();
|
|
let parsed_body: callers::login::response::update_password::Response =
|
|
serde_json::from_slice(&body).unwrap();
|
|
let id = parsed_body.data[0];
|
|
|
|
assert_eq!(id, login_result.id, "Ids do not match");
|
|
}
|
|
Err(err) => {
|
|
assert!(false, "Error: {err:?}");
|
|
}
|
|
}
|
|
}
|
|
Err(err) => {
|
|
assert!(false, "Error: {:?}", err.to_string());
|
|
}
|
|
}
|
|
}
|
|
Err(err) => {
|
|
assert!(false, "Error: {err:?}");
|
|
}
|
|
}
|
|
|
|
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_get_user_profile() {
|
|
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 usr = get_test_register_request();
|
|
|
|
let response = requests::register(&app, &usr).await;
|
|
|
|
match response {
|
|
Ok(resp) => {
|
|
assert_eq!(
|
|
resp.status(),
|
|
StatusCode::CREATED,
|
|
"Message: {:?} {:?}",
|
|
resp,
|
|
usr.username
|
|
);
|
|
let body = axum::body::to_bytes(resp.into_body(), usize::MAX)
|
|
.await
|
|
.unwrap();
|
|
let parsed_body: callers::register::response::Response =
|
|
serde_json::from_slice(&body).unwrap();
|
|
let returned_usr = &parsed_body.data[0];
|
|
|
|
let user_id = returned_usr.id;
|
|
assert_eq!(false, user_id.is_nil(), "Id is not populated");
|
|
|
|
assert_eq!(
|
|
usr.username, returned_usr.username,
|
|
"Usernames do not match"
|
|
);
|
|
assert!(returned_usr.date_created.is_some(), "Date Created is empty");
|
|
|
|
let mut n_usr = callers::login::request::Request::default();
|
|
n_usr.username = usr.username.clone();
|
|
n_usr.password = usr.password.clone();
|
|
|
|
match requests::get_user_profile(&app, &user_id).await {
|
|
Ok(resp) => {
|
|
assert_eq!(StatusCode::OK, resp.status(), "Status is not right");
|
|
let body = axum::body::to_bytes(resp.into_body(), usize::MAX)
|
|
.await
|
|
.unwrap();
|
|
let parsed_body: callers::login::response::get_user_profile::GetUserProfileResponse =
|
|
serde_json::from_slice(&body).unwrap();
|
|
let user_profile = &parsed_body.data[0];
|
|
assert!(
|
|
!user_profile.username.is_empty(),
|
|
"Username should not be null is nil"
|
|
);
|
|
}
|
|
Err(err) => {
|
|
assert!(false, "Error: {:?}", err.to_string());
|
|
}
|
|
}
|
|
}
|
|
Err(err) => {
|
|
assert!(false, "Error: {:?}", err.to_string());
|
|
}
|
|
};
|
|
|
|
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
|
|
}
|
|
}
|