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