From 9e67f120b797bae10bd226bbb4632f8d19a24361 Mon Sep 17 00:00:00 2001 From: KunoiSayami Date: Thu, 11 Jun 2026 14:53:23 +0800 Subject: fix: Fix OsRng import and refactor Redis connection setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix password-hash version mismatch (0.6→0.5) causing OsRng to be gated behind missing getrandom feature; enable argon2 rand feature - Extract get_redis_connection() helper to deduplicate Redis client setup across authentication, repo control, and tests - Tighten username validation regex to require ≥2 chars and disallow leading/trailing dots or hyphens - Handle malformed cookies without split_once gracefully (continue instead of panic) - Fix typos: "rated commands" → "related commands" in CLI help text Co-Authored-By: Claude Sonnet 4.6 Signed-off-by: KunoiSayami --- src/test.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/test.rs') diff --git a/src/test.rs b/src/test.rs index 7628921..e71aee4 100644 --- a/src/test.rs +++ b/src/test.rs @@ -55,8 +55,9 @@ mod core { } async fn async_test_redis() -> anyhow::Result<()> { - let redis_conn = redis::Client::open(crate::datastructures::DEFAULT_REDIS_URL)?; - let mut conn = redis_conn.get_multiplexed_async_connection().await?; + let mut conn = + crate::datastructures::get_redis_connection(crate::datastructures::DEFAULT_REDIS_URL) + .await?; let s = rand_str(crate::datastructures::COOKIE_LENGTH); conn.set_ex::<_, _, String>("auth_test", &s, 60).await?; @@ -344,8 +345,9 @@ mod core { } async fn clear_redis_setting() -> anyhow::Result<()> { - let client = redis::Client::open(crate::datastructures::DEFAULT_REDIS_URL)?; - let mut conn = client.get_multiplexed_async_connection().await?; + let mut conn = + crate::datastructures::get_redis_connection(crate::datastructures::DEFAULT_REDIS_URL) + .await?; for key in &[ "cgit_repo_test", -- cgit v1.3.1