mirror of
https://github.com/dani-garcia/vaultwarden.wiki.git
synced 2026-10-23 01:48:09 +03:00
Fix Clippy warnings across all targets (#7782)
This commit is contained in:
3 files changed
+29
-29
No files matched your search
+13
-13
@@ -905,23 +905,23 @@ mod tests {
|
|||||||
fn validate_web_vault_compare() {
|
fn validate_web_vault_compare() {
|
||||||
// web_vault_compare(active, latest)
|
// web_vault_compare(active, latest)
|
||||||
// Test normal versions
|
// Test normal versions
|
||||||
assert!(web_vault_compare("2025.12.0", "2025.12.1") == -1);
|
assert_eq!(web_vault_compare("2025.12.0", "2025.12.1"), -1);
|
||||||
assert!(web_vault_compare("2025.12.1", "2025.12.1") == 0);
|
assert_eq!(web_vault_compare("2025.12.1", "2025.12.1"), 0);
|
||||||
assert!(web_vault_compare("2025.12.2", "2025.12.1") == 1);
|
assert_eq!(web_vault_compare("2025.12.2", "2025.12.1"), 1);
|
||||||
|
|
||||||
// Test patched/+build.n versions
|
// Test patched/+build.n versions
|
||||||
// Newer latest version
|
// Newer latest version
|
||||||
assert!(web_vault_compare("2025.12.0+build.1", "2025.12.1") == -1);
|
assert_eq!(web_vault_compare("2025.12.0+build.1", "2025.12.1"), -1);
|
||||||
assert!(web_vault_compare("2025.12.1", "2025.12.1+build.1") == -1);
|
assert_eq!(web_vault_compare("2025.12.1", "2025.12.1+build.1"), -1);
|
||||||
assert!(web_vault_compare("2025.12.0+build.1", "2025.12.1+build.1") == -1);
|
assert_eq!(web_vault_compare("2025.12.0+build.1", "2025.12.1+build.1"), -1);
|
||||||
assert!(web_vault_compare("2025.12.1+build.1", "2025.12.1+build.2") == -1);
|
assert_eq!(web_vault_compare("2025.12.1+build.1", "2025.12.1+build.2"), -1);
|
||||||
// Equal versions
|
// Equal versions
|
||||||
assert!(web_vault_compare("2025.12.1+build.1", "2025.12.1+build.1") == 0);
|
assert_eq!(web_vault_compare("2025.12.1+build.1", "2025.12.1+build.1"), 0);
|
||||||
assert!(web_vault_compare("2025.12.2+build.2", "2025.12.2+build.2") == 0);
|
assert_eq!(web_vault_compare("2025.12.2+build.2", "2025.12.2+build.2"), 0);
|
||||||
// Newer active version
|
// Newer active version
|
||||||
assert!(web_vault_compare("2025.12.1+build.1", "2025.12.1") == 1);
|
assert_eq!(web_vault_compare("2025.12.1+build.1", "2025.12.1"), 1);
|
||||||
assert!(web_vault_compare("2025.12.2", "2025.12.1+build.1") == 1);
|
assert_eq!(web_vault_compare("2025.12.2", "2025.12.1+build.1"), 1);
|
||||||
assert!(web_vault_compare("2025.12.2+build.1", "2025.12.1+build.1") == 1);
|
assert_eq!(web_vault_compare("2025.12.2+build.1", "2025.12.1+build.1"), 1);
|
||||||
assert!(web_vault_compare("2025.12.1+build.3", "2025.12.1+build.2") == 1);
|
assert_eq!(web_vault_compare("2025.12.1+build.3", "2025.12.1+build.2"), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
-9
@@ -466,7 +466,7 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn dotted_decimal_loopback_normalizes() {
|
fn dotted_decimal_loopback_normalizes() {
|
||||||
let ip = parse_to_ip("127.0.0.1").unwrap();
|
let ip = parse_to_ip("127.0.0.1").unwrap();
|
||||||
assert_eq!(ip, IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));
|
assert_eq!(ip, IpAddr::V4(Ipv4Addr::LOCALHOST));
|
||||||
assert!(!is_global_hardcoded(ip));
|
assert!(!is_global_hardcoded(ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -474,21 +474,21 @@ mod tests {
|
|||||||
fn single_decimal_loopback_normalizes() {
|
fn single_decimal_loopback_normalizes() {
|
||||||
// 127.0.0.1 == 2130706433
|
// 127.0.0.1 == 2130706433
|
||||||
let ip = parse_to_ip("2130706433").unwrap();
|
let ip = parse_to_ip("2130706433").unwrap();
|
||||||
assert_eq!(ip, IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));
|
assert_eq!(ip, IpAddr::V4(Ipv4Addr::LOCALHOST));
|
||||||
assert!(!is_global_hardcoded(ip));
|
assert!(!is_global_hardcoded(ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hex_loopback_normalizes() {
|
fn hex_loopback_normalizes() {
|
||||||
let ip = parse_to_ip("0x7f000001").unwrap();
|
let ip = parse_to_ip("0x7f000001").unwrap();
|
||||||
assert_eq!(ip, IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));
|
assert_eq!(ip, IpAddr::V4(Ipv4Addr::LOCALHOST));
|
||||||
assert!(!is_global_hardcoded(ip));
|
assert!(!is_global_hardcoded(ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn dotted_hex_loopback_normalizes() {
|
fn dotted_hex_loopback_normalizes() {
|
||||||
let ip = parse_to_ip("0x7f.0.0.1").unwrap();
|
let ip = parse_to_ip("0x7f.0.0.1").unwrap();
|
||||||
assert_eq!(ip, IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));
|
assert_eq!(ip, IpAddr::V4(Ipv4Addr::LOCALHOST));
|
||||||
assert!(!is_global_hardcoded(ip));
|
assert!(!is_global_hardcoded(ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -496,14 +496,14 @@ mod tests {
|
|||||||
fn octal_loopback_normalizes() {
|
fn octal_loopback_normalizes() {
|
||||||
// 017700000001 == 127.0.0.1
|
// 017700000001 == 127.0.0.1
|
||||||
let ip = parse_to_ip("017700000001").unwrap();
|
let ip = parse_to_ip("017700000001").unwrap();
|
||||||
assert_eq!(ip, IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));
|
assert_eq!(ip, IpAddr::V4(Ipv4Addr::LOCALHOST));
|
||||||
assert!(!is_global_hardcoded(ip));
|
assert!(!is_global_hardcoded(ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn dotted_octal_loopback_normalizes() {
|
fn dotted_octal_loopback_normalizes() {
|
||||||
let ip = parse_to_ip("0177.0.0.01").unwrap();
|
let ip = parse_to_ip("0177.0.0.01").unwrap();
|
||||||
assert_eq!(ip, IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)));
|
assert_eq!(ip, IpAddr::V4(Ipv4Addr::LOCALHOST));
|
||||||
assert!(!is_global_hardcoded(ip));
|
assert!(!is_global_hardcoded(ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -535,19 +535,19 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn get_valid_host_normalizes_decimal_int() {
|
fn get_valid_host_normalizes_decimal_int() {
|
||||||
let h = get_valid_host("2130706433").expect("valid");
|
let h = get_valid_host("2130706433").expect("valid");
|
||||||
assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::new(127, 0, 0, 1)));
|
assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn get_valid_host_normalizes_hex() {
|
fn get_valid_host_normalizes_hex() {
|
||||||
let h = get_valid_host("0x7f000001").expect("valid");
|
let h = get_valid_host("0x7f000001").expect("valid");
|
||||||
assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::new(127, 0, 0, 1)));
|
assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn get_valid_host_normalizes_octal() {
|
fn get_valid_host_normalizes_octal() {
|
||||||
let h = get_valid_host("017700000001").expect("valid");
|
let h = get_valid_host("017700000001").expect("valid");
|
||||||
assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::new(127, 0, 0, 1)));
|
assert!(matches!(h, Host::Ipv4(ip) if ip == Ipv4Addr::LOCALHOST));
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===
|
// ===
|
||||||
|
|||||||
+7
-7
@@ -943,15 +943,15 @@ mod tests {
|
|||||||
use std::net::IpAddr;
|
use std::net::IpAddr;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
#[ignore = "exhaustive IPv4 check is too slow for the regular test suite"]
|
||||||
fn test_ipv4_global() {
|
fn test_ipv4_global() {
|
||||||
for a in 0..u8::MAX {
|
for a in 0..u8::MAX {
|
||||||
println!("Iter: {}/255", a);
|
println!("Iter: {a}/255");
|
||||||
for b in 0..u8::MAX {
|
for b in 0..u8::MAX {
|
||||||
for c in 0..u8::MAX {
|
for c in 0..u8::MAX {
|
||||||
for d in 0..u8::MAX {
|
for d in 0..u8::MAX {
|
||||||
let ip = IpAddr::V4(std::net::Ipv4Addr::new(a, b, c, d));
|
let ip = IpAddr::V4(std::net::Ipv4Addr::new(a, b, c, d));
|
||||||
assert_eq!(ip.is_global(), is_global_hardcoded(ip), "IP mismatch: {}", ip)
|
assert_eq!(ip.is_global(), is_global_hardcoded(ip), "IP mismatch: {ip}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -959,15 +959,15 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[ignore]
|
#[ignore = "random IPv6 check is too slow for the regular test suite"]
|
||||||
fn test_ipv6_global() {
|
fn test_ipv6_global() {
|
||||||
use rand::Rng;
|
use rand::RngExt;
|
||||||
|
|
||||||
std::thread::scope(|s| {
|
std::thread::scope(|s| {
|
||||||
for t in 0..16 {
|
for t in 0..16 {
|
||||||
let handle = s.spawn(move || {
|
let _handle = s.spawn(move || {
|
||||||
let mut v = [0u8; 16];
|
let mut v = [0u8; 16];
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::rng();
|
||||||
|
|
||||||
for i in 0..20 {
|
for i in 0..20 {
|
||||||
println!("Thread {t} Iter: {i}/50");
|
println!("Thread {t} Iter: {i}/50");
|
||||||
|
|||||||
Reference in new issue
Block a user