From 9a883436fc282d5bc57de2b304048bd614fdbe53 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 20 Jan 2026 13:38:55 +0000 Subject: [PATCH] Make `test_sig` more robust `test_sig` fails if the signature already contained a zero byte, at the overwritten position, due to a hex <-> bytes conversion issue. Fixes #83 --- rust/auth-impls/src/signature.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/auth-impls/src/signature.rs b/rust/auth-impls/src/signature.rs index 28b2751..f47e4d4 100644 --- a/rust/auth-impls/src/signature.rs +++ b/rust/auth-impls/src/signature.rs @@ -140,7 +140,7 @@ mod tests { token = token .chars() .enumerate() - .map(|(idx, c)| if idx == 33 * 2 + 10 || idx == 33 * 2 + 11 { '0' } else { c }) + .map(|(idx, c)| if (33 * 2 + 10..33 * 2 + 15).contains(&idx) { '0' } else { c }) .collect(); headers_map.insert("Authorization".to_string(), token); assert!(matches!(auth.verify(&headers_map).await.unwrap_err(), VssError::AuthError(_))); @@ -150,7 +150,7 @@ mod tests { token = token .chars() .enumerate() - .map(|(idx, c)| if idx == 10 || idx == 11 { '0' } else { c }) + .map(|(idx, c)| if (10..15).contains(&idx) { '0' } else { c }) .collect(); headers_map.insert("Authorization".to_string(), token); assert!(matches!(auth.verify(&headers_map).await.unwrap_err(), VssError::AuthError(_)));