forked from
lewis.moe/bspds-sandbox
PDS software with bells & whistles you didn’t even know you needed. will move this to its own account when ready.
1mod common;
2use common::{base_url, client, create_admin_account_and_login};
3use serde_json::Value;
4
5#[tokio::test]
6async fn test_get_server_stats() {
7 let client = client();
8 let base = base_url().await;
9 let (token1, _) = create_admin_account_and_login(&client).await;
10
11 let (_, _) = create_admin_account_and_login(&client).await;
12
13 let resp = client
14 .get(format!("{}/xrpc/_admin.getServerStats", base))
15 .header("Authorization", format!("Bearer {}", token1))
16 .send()
17 .await
18 .unwrap();
19
20 assert_eq!(resp.status(), 200);
21 let body: Value = resp.json().await.unwrap();
22
23 let user_count = body["userCount"].as_i64().unwrap();
24 assert!(user_count >= 2);
25
26 assert!(body["repoCount"].is_number());
27 assert!(body["recordCount"].is_number());
28 assert!(body["blobStorageBytes"].is_number());
29}
30
31#[tokio::test]
32async fn test_get_server_stats_no_auth() {
33 let client = client();
34 let base = base_url().await;
35 let resp = client
36 .get(format!("{}/xrpc/_admin.getServerStats", base))
37 .send()
38 .await
39 .unwrap();
40 assert_eq!(resp.status(), 401);
41}