Add Login #4

Merged
phoenix merged 21 commits from add_login into main 2026-06-10 00:13:55 -04:00
Showing only changes of commit ebd9fb0a2e - Show all commits
+17 -10
View File
@@ -115,13 +115,6 @@ pub mod requests {
}
}
#[test]
fn test_demo() {
let i = 0;
assert_eq!(0, i, "Values should match {} {}", 0, 1);
}
const TEST_FIRSTNAME: &str = "Billy";
const TEST_LASTNAME: &str = "Bob";
const TEST_USERNAME: &str = "BillyBob01";
@@ -134,7 +127,10 @@ async fn register_user(
match requests::register_user(&app).await {
Ok(response) => {
if axum::http::StatusCode::CREATED != response.status() {
Err(std::io::Error::other(""))
Err(std::io::Error::other(format!(
"Status code is off {:?}",
response.status()
)))
} else {
match axum::body::to_bytes(response.into_body(), usize::MAX).await {
Ok(body) => {
@@ -158,7 +154,10 @@ async fn login_user(
match requests::login_user(&app, username, password).await {
Ok(response) => {
if axum::http::StatusCode::OK != response.status() {
Err(std::io::Error::other(""))
Err(std::io::Error::other(format!(
"Status code is off {:?}",
response.status()
)))
} else {
match axum::body::to_bytes(response.into_body(), usize::MAX).await {
Ok(body) => {
@@ -207,6 +206,8 @@ async fn test_register_user() {
.unwrap();
let parsed_body: callers::register::response::Response =
serde_json::from_slice(&body).unwrap();
assert!(parsed_body.data.len() > 0, "No data returned");
let returned_user = &parsed_body.data[0];
assert_eq!(
@@ -249,7 +250,13 @@ async fn test_login_user() {
match register_user(&app).await {
Ok(user) => match login_user(&app, &user.username, TEST_PASSWORD).await {
Ok(_login_result) => {}
Ok(login_result) => {
assert_eq!(
false,
login_result.access_token.is_empty(),
"Access token is empty when it should not be"
);
}
Err(err) => {
assert!(false, "Error: {err:?}");
}