diff --git a/tests/tests.rs b/tests/tests.rs index ee7005e..e861f47 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -198,7 +198,12 @@ mod util { { match axum::body::to_bytes(response.into_body(), usize::MAX).await { Ok(body) => { - let resp: T = serde_json::from_slice(&body).unwrap(); + let resp: T = match serde_json::from_slice(&body) { + Ok(val) => val, + Err(err) => { + return Err(std::io::Error::other(err.to_string())); + } + }; Ok(resp) } Err(err) => Err(std::io::Error::other(err.to_string())), @@ -619,6 +624,46 @@ async fn test_refresh_token() { } } + match flow::register_service_user(&app).await { + Ok(user) => { + assert_eq!( + false, + user.id.is_nil(), + "The service user id should not be nil" + ); + match flow::login_service_user(&app, TEST_SERVICE_USERNAME, TEST_SERVICE_PASSPHRASE) + .await + { + Ok(login_result) => { + assert_eq!( + false, + login_result.access_token.is_empty(), + "Access token is empty when it should not be" + ); + + match flow::refresh_token(&app, &login_result.access_token).await { + Ok(refresh_login_result) => { + assert_eq!( + false, + refresh_login_result.access_token.is_empty(), + "Refreshed access token should not be empty" + ); + } + Err(err) => { + assert!(false, "Error: {err:?}"); + } + } + } + Err(err) => { + assert!(false, "Error: {err:?}"); + } + } + } + Err(err) => { + assert!(false, "Error: {err:?}"); + } + } + match db_mgr::drop_database(&tm_pool, &db_name).await { Ok(()) => {} Err(err) => {