use crate::common::{setup_app, spawn_server}; #[tokio::test] async fn test_register_and_login() { let (app, _db) = setup_app().await; let (base_url, client) = spawn_server(app).await; let email = format!("user_{}@test.com", uuid::Uuid::new_v4()); // Register let resp = client .post(format!("{}/api/v1/auth/register", base_url)) .json(&serde_json::json!({"email": email, "password": "SuperSecureP@ssw0rd2024!"})) .send().await.unwrap(); assert!(resp.status().is_success(), "Register failed: {}", resp.text().await.unwrap_or_default()); let body: serde_json::Value = resp.json().await.unwrap(); assert!(body["access_token"].is_string()); // Login success let resp = client .post(format!("{}/api/v1/auth/login", base_url)) .json(&serde_json::json!({"email": email, "password": "SuperSecureP@ssw0rd2024!"})) .send().await.unwrap(); assert!(resp.status().is_success()); // Login failure let resp = client .post(format!("{}/api/v1/auth/login", base_url)) .json(&serde_json::json!({"email": email, "password": "WrongPassword"})) .send().await.unwrap(); assert_eq!(resp.status(), 401); }