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!(
38 report_body["reasonType"],
39 "com.atproto.moderation.defs#reasonSpam"
40 );
41 assert_eq!(report_body["reportedBy"], alice_did);
42 let account_report_payload = json!({
43 "reasonType": "com.atproto.moderation.defs#reasonOther",
44 "reason": "Suspicious account activity",
45 "subject": {
46 "$type": "com.atproto.admin.defs#repoRef",
47 "did": bob_did
48 }
49 });
50 let account_report_res = client
51 .post(format!(
52 "{}/xrpc/com.atproto.moderation.createReport",
53 base_url().await
54 ))
55 .bearer_auth(&alice_jwt)
56 .json(&account_report_payload)
57 .send()
58 .await
59 .expect("Failed to create account report");
60 assert_eq!(account_report_res.status(), StatusCode::OK);
61}