Adding portion to test service user refresh token
This commit is contained in:
+46
-1
@@ -198,7 +198,12 @@ mod util {
|
|||||||
{
|
{
|
||||||
match axum::body::to_bytes(response.into_body(), usize::MAX).await {
|
match axum::body::to_bytes(response.into_body(), usize::MAX).await {
|
||||||
Ok(body) => {
|
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)
|
Ok(resp)
|
||||||
}
|
}
|
||||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
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 {
|
match db_mgr::drop_database(&tm_pool, &db_name).await {
|
||||||
Ok(()) => {}
|
Ok(()) => {}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user