mirror of
https://tangled.org/tranquil.farm/tranquil-pds
synced 2026-09-19 00:34:15 +00:00
Rename to tranquil PDS, sounds better than bullshit PDS
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
mod common;
|
||||
use common::{base_url, client, create_account_and_login, get_db_connection_string};
|
||||
use bspds::comms::{NewComms, CommsType, enqueue_comms};
|
||||
use tranquil_pds::comms::{NewComms, CommsType, enqueue_comms};
|
||||
use serde_json::{Value, json};
|
||||
use sqlx::PgPool;
|
||||
|
||||
@@ -37,7 +37,7 @@ async fn test_get_notification_history() {
|
||||
}
|
||||
|
||||
let resp = client
|
||||
.get(format!("{}/xrpc/com.bspds.account.getNotificationHistory", base))
|
||||
.get(format!("{}/xrpc/com.tranquil.account.getNotificationHistory", base))
|
||||
.header("Authorization", format!("Bearer {}", token))
|
||||
.send()
|
||||
.await
|
||||
@@ -63,7 +63,7 @@ async fn test_verify_channel_discord() {
|
||||
"discordId": "123456789"
|
||||
});
|
||||
let resp = client
|
||||
.post(format!("{}/xrpc/com.bspds.account.updateNotificationPrefs", base))
|
||||
.post(format!("{}/xrpc/com.tranquil.account.updateNotificationPrefs", base))
|
||||
.header("Authorization", format!("Bearer {}", token))
|
||||
.json(&prefs)
|
||||
.send()
|
||||
@@ -92,7 +92,7 @@ async fn test_verify_channel_discord() {
|
||||
"code": code
|
||||
});
|
||||
let resp = client
|
||||
.post(format!("{}/xrpc/com.bspds.account.confirmChannelVerification", base))
|
||||
.post(format!("{}/xrpc/com.tranquil.account.confirmChannelVerification", base))
|
||||
.header("Authorization", format!("Bearer {}", token))
|
||||
.json(&input)
|
||||
.send()
|
||||
@@ -101,7 +101,7 @@ async fn test_verify_channel_discord() {
|
||||
assert_eq!(resp.status(), 200);
|
||||
|
||||
let resp = client
|
||||
.get(format!("{}/xrpc/com.bspds.account.getNotificationPrefs", base))
|
||||
.get(format!("{}/xrpc/com.tranquil.account.getNotificationPrefs", base))
|
||||
.header("Authorization", format!("Bearer {}", token))
|
||||
.send()
|
||||
.await
|
||||
@@ -121,7 +121,7 @@ async fn test_verify_channel_invalid_code() {
|
||||
"telegramUsername": "testuser"
|
||||
});
|
||||
let resp = client
|
||||
.post(format!("{}/xrpc/com.bspds.account.updateNotificationPrefs", base))
|
||||
.post(format!("{}/xrpc/com.tranquil.account.updateNotificationPrefs", base))
|
||||
.header("Authorization", format!("Bearer {}", token))
|
||||
.json(&prefs)
|
||||
.send()
|
||||
@@ -134,7 +134,7 @@ async fn test_verify_channel_invalid_code() {
|
||||
"code": "000000"
|
||||
});
|
||||
let resp = client
|
||||
.post(format!("{}/xrpc/com.bspds.account.confirmChannelVerification", base))
|
||||
.post(format!("{}/xrpc/com.tranquil.account.confirmChannelVerification", base))
|
||||
.header("Authorization", format!("Bearer {}", token))
|
||||
.json(&input)
|
||||
.send()
|
||||
@@ -154,7 +154,7 @@ async fn test_verify_channel_not_set() {
|
||||
"code": "123456"
|
||||
});
|
||||
let resp = client
|
||||
.post(format!("{}/xrpc/com.bspds.account.confirmChannelVerification", base))
|
||||
.post(format!("{}/xrpc/com.tranquil.account.confirmChannelVerification", base))
|
||||
.header("Authorization", format!("Bearer {}", token))
|
||||
.json(&input)
|
||||
.send()
|
||||
@@ -175,7 +175,7 @@ async fn test_update_email_via_notification_prefs() {
|
||||
"email": unique_email
|
||||
});
|
||||
let resp = client
|
||||
.post(format!("{}/xrpc/com.bspds.account.updateNotificationPrefs", base))
|
||||
.post(format!("{}/xrpc/com.tranquil.account.updateNotificationPrefs", base))
|
||||
.header("Authorization", format!("Bearer {}", token))
|
||||
.json(&prefs)
|
||||
.send()
|
||||
@@ -203,7 +203,7 @@ async fn test_update_email_via_notification_prefs() {
|
||||
"code": code
|
||||
});
|
||||
let resp = client
|
||||
.post(format!("{}/xrpc/com.bspds.account.confirmChannelVerification", base))
|
||||
.post(format!("{}/xrpc/com.tranquil.account.confirmChannelVerification", base))
|
||||
.header("Authorization", format!("Bearer {}", token))
|
||||
.json(&input)
|
||||
.send()
|
||||
@@ -212,7 +212,7 @@ async fn test_update_email_via_notification_prefs() {
|
||||
assert_eq!(resp.status(), 200);
|
||||
|
||||
let resp = client
|
||||
.get(format!("{}/xrpc/com.bspds.account.getNotificationPrefs", base))
|
||||
.get(format!("{}/xrpc/com.tranquil.account.getNotificationPrefs", base))
|
||||
.header("Authorization", format!("Bearer {}", token))
|
||||
.send()
|
||||
.await
|
||||
|
||||
@@ -11,7 +11,7 @@ async fn test_get_server_stats() {
|
||||
let (_, _) = create_admin_account_and_login(&client).await;
|
||||
|
||||
let resp = client
|
||||
.get(format!("{}/xrpc/com.bspds.admin.getServerStats", base))
|
||||
.get(format!("{}/xrpc/com.tranquil.admin.getServerStats", base))
|
||||
.header("Authorization", format!("Bearer {}", token1))
|
||||
.send()
|
||||
.await
|
||||
@@ -33,7 +33,7 @@ async fn test_get_server_stats_no_auth() {
|
||||
let client = client();
|
||||
let base = base_url().await;
|
||||
let resp = client
|
||||
.get(format!("{}/xrpc/com.bspds.admin.getServerStats", base))
|
||||
.get(format!("{}/xrpc/com.tranquil.admin.getServerStats", base))
|
||||
.send()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
@@ -33,7 +33,7 @@ async fn test_change_password_success() {
|
||||
let jwt = verify_new_account(&client, did).await;
|
||||
let change_res = client
|
||||
.post(format!(
|
||||
"{}/xrpc/com.bspds.account.changePassword",
|
||||
"{}/xrpc/com.tranquil.account.changePassword",
|
||||
base_url().await
|
||||
))
|
||||
.bearer_auth(&jwt)
|
||||
@@ -79,7 +79,7 @@ async fn test_change_password_wrong_current() {
|
||||
let (_, jwt) = setup_new_user("change-pw-wrong").await;
|
||||
let res = client
|
||||
.post(format!(
|
||||
"{}/xrpc/com.bspds.account.changePassword",
|
||||
"{}/xrpc/com.tranquil.account.changePassword",
|
||||
base_url().await
|
||||
))
|
||||
.bearer_auth(&jwt)
|
||||
@@ -122,7 +122,7 @@ async fn test_change_password_too_short() {
|
||||
let jwt = verify_new_account(&client, did).await;
|
||||
let res = client
|
||||
.post(format!(
|
||||
"{}/xrpc/com.bspds.account.changePassword",
|
||||
"{}/xrpc/com.tranquil.account.changePassword",
|
||||
base_url().await
|
||||
))
|
||||
.bearer_auth(&jwt)
|
||||
@@ -144,7 +144,7 @@ async fn test_change_password_empty_current() {
|
||||
let (_, jwt) = setup_new_user("change-pw-empty").await;
|
||||
let res = client
|
||||
.post(format!(
|
||||
"{}/xrpc/com.bspds.account.changePassword",
|
||||
"{}/xrpc/com.tranquil.account.changePassword",
|
||||
base_url().await
|
||||
))
|
||||
.bearer_auth(&jwt)
|
||||
@@ -164,7 +164,7 @@ async fn test_change_password_empty_new() {
|
||||
let (_, jwt) = setup_new_user("change-pw-emptynew").await;
|
||||
let res = client
|
||||
.post(format!(
|
||||
"{}/xrpc/com.bspds.account.changePassword",
|
||||
"{}/xrpc/com.tranquil.account.changePassword",
|
||||
base_url().await
|
||||
))
|
||||
.bearer_auth(&jwt)
|
||||
@@ -183,7 +183,7 @@ async fn test_change_password_requires_auth() {
|
||||
let client = client();
|
||||
let res = client
|
||||
.post(format!(
|
||||
"{}/xrpc/com.bspds.account.changePassword",
|
||||
"{}/xrpc/com.tranquil.account.changePassword",
|
||||
base_url().await
|
||||
))
|
||||
.json(&json!({
|
||||
|
||||
+10
-10
@@ -1,7 +1,7 @@
|
||||
use aws_config::BehaviorVersion;
|
||||
use aws_sdk_s3::Client as S3Client;
|
||||
use aws_sdk_s3::config::Credentials;
|
||||
use bspds::state::AppState;
|
||||
use tranquil_pds::state::AppState;
|
||||
use chrono::Utc;
|
||||
use reqwest::{Client, StatusCode, header};
|
||||
use serde_json::{Value, json};
|
||||
@@ -40,7 +40,7 @@ pub const AUTH_DID: &str = "did:plc:fake";
|
||||
pub const TARGET_DID: &str = "did:plc:target";
|
||||
|
||||
fn has_external_infra() -> bool {
|
||||
std::env::var("BSPDS_TEST_INFRA_READY").is_ok()
|
||||
std::env::var("TRANQUIL_PDS_TEST_INFRA_READY").is_ok()
|
||||
|| (std::env::var("DATABASE_URL").is_ok() && std::env::var("S3_ENDPOINT").is_ok())
|
||||
}
|
||||
#[cfg(test)]
|
||||
@@ -51,7 +51,7 @@ fn cleanup() {
|
||||
}
|
||||
if std::env::var("XDG_RUNTIME_DIR").is_ok() {
|
||||
let _ = std::process::Command::new("podman")
|
||||
.args(&["rm", "-f", "--filter", "label=bspds_test=true"])
|
||||
.args(&["rm", "-f", "--filter", "label=tranquil_pds_test=true"])
|
||||
.output();
|
||||
}
|
||||
let _ = std::process::Command::new("docker")
|
||||
@@ -60,7 +60,7 @@ fn cleanup() {
|
||||
"prune",
|
||||
"-f",
|
||||
"--filter",
|
||||
"label=bspds_test=true",
|
||||
"label=tranquil_pds_test=true",
|
||||
])
|
||||
.output();
|
||||
}
|
||||
@@ -80,7 +80,7 @@ pub async fn base_url() -> &'static str {
|
||||
let (tx, rx) = std::sync::mpsc::channel();
|
||||
std::thread::spawn(move || {
|
||||
unsafe {
|
||||
std::env::set_var("BSPDS_ALLOW_INSECURE_SECRETS", "1");
|
||||
std::env::set_var("TRANQUIL_PDS_ALLOW_INSECURE_SECRETS", "1");
|
||||
}
|
||||
if std::env::var("DOCKER_HOST").is_err() {
|
||||
if let Ok(runtime_dir) = std::env::var("XDG_RUNTIME_DIR") {
|
||||
@@ -152,7 +152,7 @@ async fn setup_with_testcontainers() -> String {
|
||||
.with_env_var("MINIO_ROOT_USER", "minioadmin")
|
||||
.with_env_var("MINIO_ROOT_PASSWORD", "minioadmin")
|
||||
.with_cmd(vec!["server".to_string(), "/data".to_string()])
|
||||
.with_label("bspds_test", "true")
|
||||
.with_label("tranquil_pds_test", "true")
|
||||
.start()
|
||||
.await
|
||||
.expect("Failed to start MinIO");
|
||||
@@ -195,7 +195,7 @@ async fn setup_with_testcontainers() -> String {
|
||||
S3_CONTAINER.set(s3_container).ok();
|
||||
let container = Postgres::default()
|
||||
.with_tag("18-alpine")
|
||||
.with_label("bspds_test", "true")
|
||||
.with_label("tranquil_pds_test", "true")
|
||||
.start()
|
||||
.await
|
||||
.expect("Failed to start Postgres");
|
||||
@@ -236,7 +236,7 @@ async fn setup_mock_appview(_mock_server: &MockServer) {
|
||||
}
|
||||
|
||||
async fn spawn_app(database_url: String) -> String {
|
||||
use bspds::rate_limit::RateLimiters;
|
||||
use tranquil_pds::rate_limit::RateLimiters;
|
||||
let pool = PgPoolOptions::new()
|
||||
.max_connections(50)
|
||||
.connect(&database_url)
|
||||
@@ -260,8 +260,8 @@ async fn spawn_app(database_url: String) -> String {
|
||||
.with_oauth_authorize_limit(10000)
|
||||
.with_oauth_token_limit(10000);
|
||||
let state = AppState::new(pool).await.with_rate_limiters(rate_limiters);
|
||||
bspds::sync::listener::start_sequencer_listener(state.clone()).await;
|
||||
let app = bspds::app(state);
|
||||
tranquil_pds::sync::listener::start_sequencer_listener(state.clone()).await;
|
||||
let app = tranquil_pds::app(state);
|
||||
tokio::spawn(async move {
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use bspds::image::{
|
||||
use tranquil_pds::image::{
|
||||
DEFAULT_MAX_FILE_SIZE, ImageError, ImageProcessor, OutputFormat, THUMB_SIZE_FEED,
|
||||
THUMB_SIZE_FULL,
|
||||
};
|
||||
|
||||
@@ -194,7 +194,7 @@ async fn get_user_signing_key(did: &str) -> Option<Vec<u8>> {
|
||||
.fetch_optional(&pool)
|
||||
.await
|
||||
.ok()??;
|
||||
bspds::config::decrypt_key(&row.key_bytes, row.encryption_version).ok()
|
||||
tranquil_pds::config::decrypt_key(&row.key_bytes, row.encryption_version).ok()
|
||||
}
|
||||
#[tokio::test]
|
||||
#[ignore = "requires exclusive env var access; run with: cargo test test_import_with_valid_signature_and_mock_plc -- --ignored --test-threads=1"]
|
||||
|
||||
+20
-4
@@ -1,7 +1,7 @@
|
||||
#![allow(unused_imports)]
|
||||
mod common;
|
||||
use base64::{Engine as _, engine::general_purpose::URL_SAFE_NO_PAD};
|
||||
use bspds::auth::{
|
||||
use tranquil_pds::auth::{
|
||||
self, SCOPE_ACCESS, SCOPE_APP_PASS, SCOPE_APP_PASS_PRIVILEGED, SCOPE_REFRESH,
|
||||
TOKEN_TYPE_ACCESS, TOKEN_TYPE_REFRESH, TOKEN_TYPE_SERVICE, create_access_token,
|
||||
create_refresh_token, create_service_token, get_did_from_token, get_jti_from_token,
|
||||
@@ -409,7 +409,7 @@ async fn test_session_lifecycle_security() {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_deactivated_account_rejected() {
|
||||
async fn test_deactivated_account_behavior() {
|
||||
let url = base_url().await;
|
||||
let http_client = client();
|
||||
let (access_jwt, _did) = create_account_and_login(&http_client).await;
|
||||
@@ -423,9 +423,25 @@ async fn test_deactivated_account_rejected() {
|
||||
let res = http_client.get(format!("{}/xrpc/com.atproto.server.getSession", url))
|
||||
.header("Authorization", format!("Bearer {}", access_jwt))
|
||||
.send().await.unwrap();
|
||||
assert_eq!(res.status(), StatusCode::UNAUTHORIZED);
|
||||
assert_eq!(res.status(), StatusCode::OK);
|
||||
let body: Value = res.json().await.unwrap();
|
||||
assert_eq!(body["error"], "AccountDeactivated");
|
||||
assert_eq!(body["active"], false);
|
||||
|
||||
let post_res = http_client.post(format!("{}/xrpc/com.atproto.repo.createRecord", url))
|
||||
.header("Authorization", format!("Bearer {}", access_jwt))
|
||||
.json(&json!({
|
||||
"repo": _did,
|
||||
"collection": "app.bsky.feed.post",
|
||||
"record": {
|
||||
"$type": "app.bsky.feed.post",
|
||||
"text": "test",
|
||||
"createdAt": "2024-01-01T00:00:00Z"
|
||||
}
|
||||
}))
|
||||
.send().await.unwrap();
|
||||
assert_eq!(post_res.status(), StatusCode::UNAUTHORIZED);
|
||||
let post_body: Value = post_res.json().await.unwrap();
|
||||
assert_eq!(post_body["error"], "AccountDeactivated");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
mod common;
|
||||
use bspds::comms::{
|
||||
use tranquil_pds::comms::{
|
||||
CommsChannel, CommsStatus, CommsType, NewComms, enqueue_comms, enqueue_welcome,
|
||||
};
|
||||
use sqlx::PgPool;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
mod common;
|
||||
mod helpers;
|
||||
use base64::{Engine as _, engine::general_purpose::URL_SAFE_NO_PAD};
|
||||
use bspds::oauth::dpop::{DPoPJwk, DPoPVerifier, compute_jwk_thumbprint};
|
||||
use tranquil_pds::oauth::dpop::{DPoPJwk, DPoPVerifier, compute_jwk_thumbprint};
|
||||
use chrono::Utc;
|
||||
use common::{base_url, client};
|
||||
use helpers::verify_new_account;
|
||||
|
||||
@@ -50,7 +50,7 @@ async fn get_user_signing_key(did: &str) -> Option<Vec<u8>> {
|
||||
.fetch_optional(&pool)
|
||||
.await
|
||||
.ok()??;
|
||||
bspds::config::decrypt_key(&row.key_bytes, row.encryption_version).ok()
|
||||
tranquil_pds::config::decrypt_key(&row.key_bytes, row.encryption_version).ok()
|
||||
}
|
||||
|
||||
async fn get_plc_token_from_db(did: &str) -> Option<String> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use bspds::plc::{
|
||||
use tranquil_pds::plc::{
|
||||
PlcError, PlcOperation, PlcService, PlcValidationContext, cid_for_cbor, sign_operation,
|
||||
signing_key_to_did_key, validate_plc_operation, validate_plc_operation_for_submission,
|
||||
verify_operation_signature,
|
||||
|
||||
+1
-1
@@ -162,7 +162,7 @@ async fn test_distributed_rate_limiter_directly() {
|
||||
println!("VALKEY_URL not set, skipping distributed rate limiter test");
|
||||
return;
|
||||
}
|
||||
use bspds::cache::{DistributedRateLimiter, RedisRateLimiter};
|
||||
use tranquil_pds::cache::{DistributedRateLimiter, RedisRateLimiter};
|
||||
let valkey_url = std::env::var("VALKEY_URL").unwrap();
|
||||
let client = redis::Client::open(valkey_url.as_str()).expect("Failed to create Redis client");
|
||||
let conn = client
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use bspds::validation::{
|
||||
use tranquil_pds::validation::{
|
||||
RecordValidator, ValidationError, ValidationStatus, validate_collection_nsid,
|
||||
validate_record_key,
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
mod common;
|
||||
use bspds::image::{ImageError, ImageProcessor};
|
||||
use bspds::comms::{SendError, is_valid_phone_number, sanitize_header_value};
|
||||
use bspds::oauth::templates::{error_page, login_page, success_page};
|
||||
use tranquil_pds::image::{ImageError, ImageProcessor};
|
||||
use tranquil_pds::comms::{SendError, is_valid_phone_number, sanitize_header_value};
|
||||
use tranquil_pds::oauth::templates::{error_page, login_page, success_page};
|
||||
|
||||
#[test]
|
||||
fn test_header_injection_sanitization() {
|
||||
|
||||
@@ -11,7 +11,7 @@ async fn test_list_sessions_returns_current_session() {
|
||||
let (did, jwt) = setup_new_user("list-sessions").await;
|
||||
let res = client
|
||||
.get(format!(
|
||||
"{}/xrpc/com.bspds.account.listSessions",
|
||||
"{}/xrpc/com.tranquil.account.listSessions",
|
||||
base_url().await
|
||||
))
|
||||
.bearer_auth(&jwt)
|
||||
@@ -74,7 +74,7 @@ async fn test_list_sessions_multiple_sessions() {
|
||||
let jwt2 = login_body["accessJwt"].as_str().unwrap();
|
||||
let list_res = client
|
||||
.get(format!(
|
||||
"{}/xrpc/com.bspds.account.listSessions",
|
||||
"{}/xrpc/com.tranquil.account.listSessions",
|
||||
base_url().await
|
||||
))
|
||||
.bearer_auth(jwt2)
|
||||
@@ -93,7 +93,7 @@ async fn test_list_sessions_requires_auth() {
|
||||
let client = client();
|
||||
let res = client
|
||||
.get(format!(
|
||||
"{}/xrpc/com.bspds.account.listSessions",
|
||||
"{}/xrpc/com.tranquil.account.listSessions",
|
||||
base_url().await
|
||||
))
|
||||
.send()
|
||||
@@ -145,7 +145,7 @@ async fn test_revoke_session_success() {
|
||||
let jwt2 = login_body["accessJwt"].as_str().unwrap();
|
||||
let list_res = client
|
||||
.get(format!(
|
||||
"{}/xrpc/com.bspds.account.listSessions",
|
||||
"{}/xrpc/com.tranquil.account.listSessions",
|
||||
base_url().await
|
||||
))
|
||||
.bearer_auth(jwt2)
|
||||
@@ -159,7 +159,7 @@ async fn test_revoke_session_success() {
|
||||
let session_id = other_session.unwrap()["id"].as_str().unwrap();
|
||||
let revoke_res = client
|
||||
.post(format!(
|
||||
"{}/xrpc/com.bspds.account.revokeSession",
|
||||
"{}/xrpc/com.tranquil.account.revokeSession",
|
||||
base_url().await
|
||||
))
|
||||
.bearer_auth(jwt2)
|
||||
@@ -170,7 +170,7 @@ async fn test_revoke_session_success() {
|
||||
assert_eq!(revoke_res.status(), StatusCode::OK);
|
||||
let list_after_res = client
|
||||
.get(format!(
|
||||
"{}/xrpc/com.bspds.account.listSessions",
|
||||
"{}/xrpc/com.tranquil.account.listSessions",
|
||||
base_url().await
|
||||
))
|
||||
.bearer_auth(jwt2)
|
||||
@@ -190,7 +190,7 @@ async fn test_revoke_session_invalid_id() {
|
||||
let (_, jwt) = setup_new_user("revoke-invalid").await;
|
||||
let res = client
|
||||
.post(format!(
|
||||
"{}/xrpc/com.bspds.account.revokeSession",
|
||||
"{}/xrpc/com.tranquil.account.revokeSession",
|
||||
base_url().await
|
||||
))
|
||||
.bearer_auth(&jwt)
|
||||
@@ -207,7 +207,7 @@ async fn test_revoke_session_not_found() {
|
||||
let (_, jwt) = setup_new_user("revoke-notfound").await;
|
||||
let res = client
|
||||
.post(format!(
|
||||
"{}/xrpc/com.bspds.account.revokeSession",
|
||||
"{}/xrpc/com.tranquil.account.revokeSession",
|
||||
base_url().await
|
||||
))
|
||||
.bearer_auth(&jwt)
|
||||
@@ -223,7 +223,7 @@ async fn test_revoke_session_requires_auth() {
|
||||
let client = client();
|
||||
let res = client
|
||||
.post(format!(
|
||||
"{}/xrpc/com.bspds.account.revokeSession",
|
||||
"{}/xrpc/com.tranquil.account.revokeSession",
|
||||
base_url().await
|
||||
))
|
||||
.json(&json!({"sessionId": "1"}))
|
||||
|
||||
Reference in New Issue
Block a user