this repo has no description
1mod common; 2mod helpers; 3 4use common::*; 5use helpers::*; 6 7use reqwest::StatusCode; 8use serde_json::{Value, json}; 9 10#[tokio::test] 11async fn test_moderation_report_lifecycle() { 12 let client = client(); 13 let (alice_did, alice_jwt) = setup_new_user("alice-report").await; 14 let (bob_did, bob_jwt) = setup_new_user("bob-report").await; 15 16 let (post_uri, post_cid) = 17 create_post(&client, &bob_did, &bob_jwt, "This is a reportable post").await; 18 19 let report_payload = json!({ 20 "reasonType": "com.atproto.moderation.defs#reasonSpam", 21 "reason": "This looks like spam to me", 22 "subject": { 23 "$type": "com.atproto.repo.strongRef", 24 "uri": post_uri, 25 "cid": post_cid 26 } 27 }); 28 29 let report_res = client 30 .post(format!( 31 "{}/xrpc/com.atproto.moderation.createReport", 32 base_url().await 33 )) 34 .bearer_auth(&alice_jwt) 35 .json(&report_payload) 36 .send() 37 .await 38 .expect("Failed to create report"); 39 40 assert_eq!(report_res.status(), StatusCode::OK); 41 let report_body: Value = report_res.json().await.unwrap(); 42 assert!(report_body["id"].is_number(), "Report should have an ID"); 43 assert_eq!(report_body["reasonType"], "com.atproto.moderation.defs#reasonSpam"); 44 assert_eq!(report_body["reportedBy"], alice_did); 45 46 let account_report_payload = json!({ 47 "reasonType": "com.atproto.moderation.defs#reasonOther", 48 "reason": "Suspicious account activity", 49 "subject": { 50 "$type": "com.atproto.admin.defs#repoRef", 51 "did": bob_did 52 } 53 }); 54 55 let account_report_res = client 56 .post(format!( 57 "{}/xrpc/com.atproto.moderation.createReport", 58 base_url().await 59 )) 60 .bearer_auth(&alice_jwt) 61 .json(&account_report_payload) 62 .send() 63 .await 64 .expect("Failed to create account report"); 65 66 assert_eq!(account_report_res.status(), StatusCode::OK); 67}