fix: CI workflow, password reset flow, health/limits in services, session refactor, dead mixin stub cleanup

This commit is contained in:
loki5512344 2026-10-09 19:21:17 +02:00
parent 45dd592c40
commit f4e15b45c9
Signed by: boba
GPG key ID: 253067914055423B
95 changed files with 899 additions and 185 deletions

View file

@ -8,6 +8,10 @@ use uuid::Uuid;
// mounts as `mod common;`).
pub use ::common::internal::{ACCOUNT_ID_HEADER, INTERNAL_KEY_HEADER};
pub fn init_test_logging() {
let _ = tracing_subscriber::fmt::try_init();
}
pub async fn test_pool() -> sqlx::PgPool {
let url = std::env::var("DATABASE_URL")
.unwrap_or_else(|_| "postgres://lovisual:lovisual@localhost:5432/accounts_db".into());
@ -60,3 +64,65 @@ pub async fn register_account(server: &TestServer) -> (Uuid, String) {
email,
)
}
/// Creates the test avatar bucket if it does not exist yet, so the avatar
/// tests are self-contained: any S3-compatible backend (MinIO, SeaweedFS)
/// works without external `mc mb` bootstrap. Mirrors `S3Storage::from_config`.
/// Retries briefly so a just-started container does not race the test.
pub async fn ensure_avatar_bucket() {
let creds =
aws_sdk_s3::config::Credentials::new("minioadmin", "minioadmin", None, None, "static");
let config = aws_sdk_s3::config::Builder::new()
.endpoint_url("http://localhost:9000")
.credentials_provider(creds)
.region(aws_sdk_s3::config::Region::new("us-east-1"))
.force_path_style(true)
.behavior_version(aws_sdk_s3::config::BehaviorVersion::latest())
.build();
let client = aws_sdk_s3::Client::from_conf(config);
let mut last_err = String::new();
for _ in 0..30 {
// Probe writability, not just bucket existence: a freshly started
// S3 backend may still be electing volumes ("Not enough data nodes"
// on SeaweedFS) right after create_bucket succeeds.
match async {
// Already-exists is success (MinIO: BucketAlreadyOwnedByYou,
// SeaweedFS: BucketAlreadyExists); anything else aborts.
if let Err(e) = client
.create_bucket()
.bucket("lovisual-avatars-test")
.send()
.await
{
let msg = format!("{e:?}");
if !msg.contains("BucketAlready") {
return Err(msg);
}
}
client
.put_object()
.bucket("lovisual-avatars-test")
.key(".probe")
.body(aws_sdk_s3::primitives::ByteStream::from_static(b"probe"))
.send()
.await
.map_err(|e| format!("{e:?}"))?;
let _ = client
.delete_object()
.bucket("lovisual-avatars-test")
.key(".probe")
.send()
.await;
Ok::<(), String>(())
}
.await
{
Ok(_) => return,
Err(msg) => {
last_err = msg;
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
}
}
}
panic!("S3 backend is not writable: {last_err}");
}