mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-08 06:13:14 +00:00
fix:Apply suggestions from clippy 1.88
This commit is contained in:
@@ -80,9 +80,9 @@ mod tests {
|
||||
let argon2_chacha = ID::Argon2idChaCHa20Poly1305;
|
||||
let pbkdf2 = ID::Pbkdf2AESGCM;
|
||||
|
||||
assert_eq!(format!("{:?}", argon2_aes), "Argon2idAESGCM");
|
||||
assert_eq!(format!("{:?}", argon2_chacha), "Argon2idChaCHa20Poly1305");
|
||||
assert_eq!(format!("{:?}", pbkdf2), "Pbkdf2AESGCM");
|
||||
assert_eq!(format!("{argon2_aes:?}"), "Argon2idAESGCM");
|
||||
assert_eq!(format!("{argon2_chacha:?}"), "Argon2idChaCHa20Poly1305");
|
||||
assert_eq!(format!("{pbkdf2:?}"), "Pbkdf2AESGCM");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -205,13 +205,13 @@ mod tests {
|
||||
|
||||
for algorithm in &algorithms {
|
||||
let result = algorithm.get_key(password, salt);
|
||||
assert!(result.is_ok(), "Algorithm {:?} should generate valid key", algorithm);
|
||||
assert!(result.is_ok(), "Algorithm {algorithm:?} should generate valid key");
|
||||
|
||||
let key = result.expect("Key generation should succeed for all algorithms");
|
||||
assert_eq!(key.len(), 32, "Key length should be 32 bytes for {:?}", algorithm);
|
||||
assert_eq!(key.len(), 32, "Key length should be 32 bytes for {algorithm:?}");
|
||||
|
||||
// Verify key is not all zeros (very unlikely with proper implementation)
|
||||
assert_ne!(key, [0u8; 32], "Key should not be all zeros for {:?}", algorithm);
|
||||
assert_ne!(key, [0u8; 32], "Key should not be all zeros for {algorithm:?}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ fn test_encrypt_decrypt_unicode_data() -> Result<(), crate::Error> {
|
||||
let data = text.as_bytes();
|
||||
let encrypted = encrypt_data(PASSWORD, data)?;
|
||||
let decrypted = decrypt_data(PASSWORD, &encrypted)?;
|
||||
assert_eq!(data, decrypted.as_slice(), "Unicode data mismatch for: {}", text);
|
||||
assert_eq!(data, decrypted.as_slice(), "Unicode data mismatch for: {text}");
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -125,7 +125,7 @@ fn test_decrypt_with_corrupted_data() {
|
||||
corrupted[*corrupt_index] ^= 0xFF; // Flip all bits
|
||||
|
||||
let result = decrypt_data(PASSWORD, &corrupted);
|
||||
assert!(result.is_err(), "{} should cause decryption to fail", description);
|
||||
assert!(result.is_err(), "{description} should cause decryption to fail");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ fn test_decrypt_with_truncated_data() {
|
||||
for &length in &truncation_lengths {
|
||||
let truncated = &encrypted[..length.min(encrypted.len())];
|
||||
let result = decrypt_data(PASSWORD, truncated);
|
||||
assert!(result.is_err(), "Truncated data (length {}) should cause decryption to fail", length);
|
||||
assert!(result.is_err(), "Truncated data (length {length}) should cause decryption to fail");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,7 @@ fn test_password_variations() -> Result<(), crate::Error> {
|
||||
for password in &password_variations {
|
||||
let encrypted = encrypt_data(password, data)?;
|
||||
let decrypted = decrypt_data(password, &encrypted)?;
|
||||
assert_eq!(data, decrypted.as_slice(), "Failed with password: {:?}", password);
|
||||
assert_eq!(data, decrypted.as_slice(), "Failed with password: {password:?}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -292,7 +292,7 @@ fn test_concurrent_encryption_safety() -> Result<(), crate::Error> {
|
||||
thread::spawn(move || {
|
||||
let encrypted = encrypt_data(&password, &data).expect("Encryption should succeed");
|
||||
let decrypted = decrypt_data(&password, &encrypted).expect("Decryption should succeed");
|
||||
assert_eq!(**data, decrypted, "Thread {} failed", i);
|
||||
assert_eq!(**data, decrypted, "Thread {i} failed");
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
||||
@@ -74,7 +74,7 @@ fn test_jwt_decode_invalid_token_format() {
|
||||
|
||||
for invalid_token in &invalid_tokens {
|
||||
let result = decode(invalid_token, secret);
|
||||
assert!(result.is_err(), "Invalid token '{}' should fail to decode", invalid_token);
|
||||
assert!(result.is_err(), "Invalid token '{invalid_token}' should fail to decode");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +207,7 @@ fn test_jwt_token_structure() {
|
||||
|
||||
// Each part should be non-empty
|
||||
for (i, part) in parts.iter().enumerate() {
|
||||
assert!(!part.is_empty(), "JWT part {} should not be empty", i);
|
||||
assert!(!part.is_empty(), "JWT part {i} should not be empty");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user