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