From 0ef7844bcba4f811a6156934267afa0562012e47 Mon Sep 17 00:00:00 2001 From: Sebastian Pravda Date: Fri, 16 Dec 2022 17:46:21 +0100 Subject: [PATCH] fix: random 12 character string tests --- api/src/routes/admin.rs | 2 +- core/src/crypto.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/src/routes/admin.rs b/api/src/routes/admin.rs index cdc7333..02c0112 100644 --- a/api/src/routes/admin.rs +++ b/api/src/routes/admin.rs @@ -287,6 +287,6 @@ pub mod tests { let cookies = admin_login(&client); let response = create_candidate(&client, cookies, 1031511, "0".to_string()); - assert_eq!(response.password.len(), 8); + assert_eq!(response.password.len(), 12); } } \ No newline at end of file diff --git a/core/src/crypto.rs b/core/src/crypto.rs index 61d8924..427fb48 100644 --- a/core/src/crypto.rs +++ b/core/src/crypto.rs @@ -13,7 +13,7 @@ use std::str::FromStr; use crate::error::ServiceError; -/// Foolproof random 8 char string +/// Foolproof random 12 char string /// only uppercase letters (except for 0 and O) and numbers pub fn random_12_char_string() -> String { let random_chars_12: Vec = rand::thread_rng() @@ -339,11 +339,11 @@ pub async fn decrypt_file_with_private_key_as_buffer>( #[cfg(test)] mod tests { #[test] - fn test_random_8_char_string() { + fn test_random_12_char_string() { for _ in 0..1000 { let s = super::random_12_char_string(); // Is 8 chars long - assert_eq!(s.len(), 8); + assert_eq!(s.len(), 12); // Does not contain possibly confusing characters assert!(!s.contains('0')); assert!(!s.contains('O'));