use serde_json::json; use uuid::Uuid; use crate::common::{Client, get_server}; mod common; #[tokio::test] async fn failes_without_login() { let server = get_server().await; let client = Client::new_no_user(&server); let response = client.get_todos().await; response.assert_status_unauthorized(); } #[tokio::test] async fn works_with_org() { let server = get_server().await; let mut client = Client::new(&server); let org_uuid = Uuid::new_v4(); client .add_organization_json(json!({ "uuid": org_uuid, "name": "Test Organization", })) .await; client.set_org(org_uuid); let response = client.get_todos().await; response.assert_status_success(); } #[tokio::test] async fn failes_for_unknown_org() { let server = get_server().await; let client = Client::new_with_org(&server, Uuid::new_v4()); let response = client.get_todos().await; response.assert_status_unauthorized(); } #[tokio::test] async fn failes_for_not_joined_org() { let server = get_server().await; let user1_client = Client::new(&server); let org_uuid = Uuid::new_v4(); let add_org_response = user1_client .add_organization(json!({ "uuid": org_uuid, "name": "Test Organization", })) .await; add_org_response.assert_status_success(); // User 2 tries to access the organization without joining let user2_client = Client::new_with_org(&server, org_uuid); let response = user2_client.get_todos().await; response.assert_status_unauthorized(); }