fix: random 12 character string tests

This commit is contained in:
Sebastian Pravda 2022-12-16 17:46:21 +01:00
parent db0d72a4f2
commit 0ef7844bcb
No known key found for this signature in database
GPG key ID: F3BC84F08EFA3F57
2 changed files with 4 additions and 4 deletions

View file

@ -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);
}
}

View file

@ -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<char> = rand::thread_rng()
@ -339,11 +339,11 @@ pub async fn decrypt_file_with_private_key_as_buffer<P: AsRef<Path>>(
#[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'));