mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-10 23:26:53 +00:00
fix:Apply suggestions from clippy 1.88
This commit is contained in:
+15
-18
@@ -14,17 +14,16 @@ use tracing::{debug, warn};
|
||||
/// This function loads a public certificate from the specified file.
|
||||
pub fn load_certs(filename: &str) -> io::Result<Vec<CertificateDer<'static>>> {
|
||||
// Open certificate file.
|
||||
let cert_file = fs::File::open(filename).map_err(|e| certs_error(format!("failed to open {}: {}", filename, e)))?;
|
||||
let cert_file = fs::File::open(filename).map_err(|e| certs_error(format!("failed to open {filename}: {e}")))?;
|
||||
let mut reader = io::BufReader::new(cert_file);
|
||||
|
||||
// Load and return certificate.
|
||||
let certs = certs(&mut reader)
|
||||
.collect::<Result<Vec<_>, _>>()
|
||||
.map_err(|e| certs_error(format!("certificate file {} format error:{:?}", filename, e)))?;
|
||||
.map_err(|e| certs_error(format!("certificate file {filename} format error:{e:?}")))?;
|
||||
if certs.is_empty() {
|
||||
return Err(certs_error(format!(
|
||||
"No valid certificate was found in the certificate file {}",
|
||||
filename
|
||||
"No valid certificate was found in the certificate file {filename}"
|
||||
)));
|
||||
}
|
||||
Ok(certs)
|
||||
@@ -34,11 +33,11 @@ pub fn load_certs(filename: &str) -> io::Result<Vec<CertificateDer<'static>>> {
|
||||
/// This function loads a private key from the specified file.
|
||||
pub fn load_private_key(filename: &str) -> io::Result<PrivateKeyDer<'static>> {
|
||||
// Open keyfile.
|
||||
let keyfile = fs::File::open(filename).map_err(|e| certs_error(format!("failed to open {}: {}", filename, e)))?;
|
||||
let keyfile = fs::File::open(filename).map_err(|e| certs_error(format!("failed to open {filename}: {e}")))?;
|
||||
let mut reader = io::BufReader::new(keyfile);
|
||||
|
||||
// Load and return a single private key.
|
||||
private_key(&mut reader)?.ok_or_else(|| certs_error(format!("no private key found in {}", filename)))
|
||||
private_key(&mut reader)?.ok_or_else(|| certs_error(format!("no private key found in {filename}")))
|
||||
}
|
||||
|
||||
/// error function
|
||||
@@ -58,8 +57,7 @@ pub fn load_all_certs_from_directory(
|
||||
|
||||
if !dir.exists() || !dir.is_dir() {
|
||||
return Err(certs_error(format!(
|
||||
"The certificate directory does not exist or is not a directory: {}",
|
||||
dir_path
|
||||
"The certificate directory does not exist or is not a directory: {dir_path}"
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -71,10 +69,10 @@ pub fn load_all_certs_from_directory(
|
||||
debug!("find the root directory certificate: {:?}", root_cert_path);
|
||||
let root_cert_str = root_cert_path
|
||||
.to_str()
|
||||
.ok_or_else(|| certs_error(format!("Invalid UTF-8 in root certificate path: {:?}", root_cert_path)))?;
|
||||
.ok_or_else(|| certs_error(format!("Invalid UTF-8 in root certificate path: {root_cert_path:?}")))?;
|
||||
let root_key_str = root_key_path
|
||||
.to_str()
|
||||
.ok_or_else(|| certs_error(format!("Invalid UTF-8 in root key path: {:?}", root_key_path)))?;
|
||||
.ok_or_else(|| certs_error(format!("Invalid UTF-8 in root key path: {root_key_path:?}")))?;
|
||||
match load_cert_key_pair(root_cert_str, root_key_str) {
|
||||
Ok((certs, key)) => {
|
||||
// The root directory certificate is used as the default certificate and is stored using special keys.
|
||||
@@ -95,7 +93,7 @@ pub fn load_all_certs_from_directory(
|
||||
let domain_name = path
|
||||
.file_name()
|
||||
.and_then(|name| name.to_str())
|
||||
.ok_or_else(|| certs_error(format!("invalid domain name directory:{:?}", path)))?;
|
||||
.ok_or_else(|| certs_error(format!("invalid domain name directory:{path:?}")))?;
|
||||
|
||||
// find certificate and private key files
|
||||
let cert_path = path.join(RUSTFS_TLS_CERT); // e.g., rustfs_cert.pem
|
||||
@@ -117,8 +115,7 @@ pub fn load_all_certs_from_directory(
|
||||
|
||||
if cert_key_pairs.is_empty() {
|
||||
return Err(certs_error(format!(
|
||||
"No valid certificate/private key pair found in directory {}",
|
||||
dir_path
|
||||
"No valid certificate/private key pair found in directory {dir_path}"
|
||||
)));
|
||||
}
|
||||
|
||||
@@ -165,7 +162,7 @@ pub fn create_multi_cert_resolver(
|
||||
for (domain, (certs, key)) in cert_key_pairs {
|
||||
// create a signature
|
||||
let signing_key = rustls::crypto::aws_lc_rs::sign::any_supported_type(&key)
|
||||
.map_err(|e| certs_error(format!("unsupported private key types:{}, err:{:?}", domain, e)))?;
|
||||
.map_err(|e| certs_error(format!("unsupported private key types:{domain}, err:{e:?}")))?;
|
||||
|
||||
// create a CertifiedKey
|
||||
let certified_key = CertifiedKey::new(certs, signing_key);
|
||||
@@ -175,7 +172,7 @@ pub fn create_multi_cert_resolver(
|
||||
// add certificate to resolver
|
||||
resolver
|
||||
.add(&domain, certified_key)
|
||||
.map_err(|e| certs_error(format!("failed to add a domain name certificate:{},err: {:?}", domain, e)))?;
|
||||
.map_err(|e| certs_error(format!("failed to add a domain name certificate:{domain},err: {e:?}")))?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,10 +340,10 @@ mod tests {
|
||||
];
|
||||
|
||||
for (input, _expected_pattern) in test_cases {
|
||||
let error1 = certs_error(format!("failed to open test.pem: {}", input));
|
||||
let error1 = certs_error(format!("failed to open test.pem: {input}"));
|
||||
assert!(error1.to_string().contains(input));
|
||||
|
||||
let error2 = certs_error(format!("failed to open key.pem: {}", input));
|
||||
let error2 = certs_error(format!("failed to open key.pem: {input}"));
|
||||
assert!(error2.to_string().contains(input));
|
||||
}
|
||||
}
|
||||
@@ -455,6 +452,6 @@ mod tests {
|
||||
let error_size = mem::size_of_val(&error);
|
||||
|
||||
// Error should not be excessively large
|
||||
assert!(error_size < 1024, "Error size should be reasonable, got {} bytes", error_size);
|
||||
assert!(error_size < 1024, "Error size should be reasonable, got {error_size} bytes");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ impl std::str::FromStr for CompressionAlgorithm {
|
||||
"brotli" => Ok(CompressionAlgorithm::Brotli),
|
||||
"snappy" => Ok(CompressionAlgorithm::Snappy),
|
||||
"none" => Ok(CompressionAlgorithm::None),
|
||||
_ => Err(std::io::Error::other(format!("Unsupported compression algorithm: {}", s))),
|
||||
_ => Err(std::io::Error::other(format!("Unsupported compression algorithm: {s}"))),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -243,7 +243,7 @@ mod tests {
|
||||
|
||||
println!("Compression results:");
|
||||
for (name, dur, size) in × {
|
||||
println!("{}: {} bytes, {:?}", name, size, dur);
|
||||
println!("{name}: {size} bytes, {dur:?}");
|
||||
}
|
||||
// All should decompress to the original
|
||||
assert_eq!(decompress_block(&gzip, CompressionAlgorithm::Gzip).unwrap(), data);
|
||||
|
||||
@@ -54,7 +54,7 @@ mod tests {
|
||||
assert!(path.exists(), "The project root directory does not exist:{}", path.display());
|
||||
println!("The test is passed, the project root directory:{}", path.display());
|
||||
}
|
||||
Err(e) => panic!("Failed to get the project root directory:{}", e),
|
||||
Err(e) => panic!("Failed to get the project root directory:{e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ pub async fn read_full<R: AsyncRead + Send + Sync + Unpin>(mut reader: R, mut bu
|
||||
}
|
||||
return Err(std::io::Error::new(
|
||||
std::io::ErrorKind::UnexpectedEof,
|
||||
format!("read {} bytes, error: {}", total, e),
|
||||
format!("read {total} bytes, error: {e}"),
|
||||
));
|
||||
}
|
||||
};
|
||||
@@ -116,7 +116,7 @@ mod tests {
|
||||
rev[total - n..total].copy_from_slice(&buf[..n]);
|
||||
|
||||
count += 1;
|
||||
println!("count: {}, total: {}, n: {}", count, total, n);
|
||||
println!("count: {count}, total: {total}, n: {n}");
|
||||
}
|
||||
assert_eq!(total, size);
|
||||
|
||||
@@ -167,8 +167,8 @@ mod tests {
|
||||
for &v in &[1u64, 127, 128, 255, 300, 16384, u32::MAX as u64] {
|
||||
let n = put_uvarint(&mut buf, v);
|
||||
let (decoded, m) = uvarint(&buf[..n]);
|
||||
assert_eq!(decoded, v, "decode mismatch for {}", v);
|
||||
assert_eq!(m as usize, n, "length mismatch for {}", v);
|
||||
assert_eq!(decoded, v, "decode mismatch for {v}");
|
||||
assert_eq!(m as usize, n, "length mismatch for {v}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -40,16 +40,16 @@ mod tests {
|
||||
assert!(ip.is_some(), "Should be able to get local IP address");
|
||||
|
||||
if let Some(ip_addr) = ip {
|
||||
println!("Local IP address: {}", ip_addr);
|
||||
println!("Local IP address: {ip_addr}");
|
||||
// Verify that the returned IP address is valid
|
||||
match ip_addr {
|
||||
IpAddr::V4(ipv4) => {
|
||||
assert!(!ipv4.is_unspecified(), "IPv4 should not be unspecified (0.0.0.0)");
|
||||
println!("Got IPv4 address: {}", ipv4);
|
||||
println!("Got IPv4 address: {ipv4}");
|
||||
}
|
||||
IpAddr::V6(ipv6) => {
|
||||
assert!(!ipv6.is_unspecified(), "IPv6 should not be unspecified (::)");
|
||||
println!("Got IPv6 address: {}", ipv6);
|
||||
println!("Got IPv6 address: {ipv6}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,9 +63,9 @@ mod tests {
|
||||
|
||||
// Verify that the returned string can be parsed as a valid IP address
|
||||
let parsed_ip: Result<IpAddr, _> = ip_string.parse();
|
||||
assert!(parsed_ip.is_ok(), "Returned string should be a valid IP address: {}", ip_string);
|
||||
assert!(parsed_ip.is_ok(), "Returned string should be a valid IP address: {ip_string}");
|
||||
|
||||
println!("Local IP with default: {}", ip_string);
|
||||
println!("Local IP with default: {ip_string}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -91,22 +91,22 @@ mod tests {
|
||||
match ip {
|
||||
IpAddr::V4(ipv4) => {
|
||||
// Test IPv4 address properties
|
||||
println!("IPv4 address: {}", ipv4);
|
||||
println!("IPv4 address: {ipv4}");
|
||||
assert!(!ipv4.is_multicast(), "Local IP should not be multicast");
|
||||
assert!(!ipv4.is_broadcast(), "Local IP should not be broadcast");
|
||||
|
||||
// Check if it's a private address (usually local IP is private)
|
||||
let is_private = ipv4.is_private();
|
||||
let is_loopback = ipv4.is_loopback();
|
||||
println!("IPv4 is private: {}, is loopback: {}", is_private, is_loopback);
|
||||
println!("IPv4 is private: {is_private}, is loopback: {is_loopback}");
|
||||
}
|
||||
IpAddr::V6(ipv6) => {
|
||||
// Test IPv6 address properties
|
||||
println!("IPv6 address: {}", ipv6);
|
||||
println!("IPv6 address: {ipv6}");
|
||||
assert!(!ipv6.is_multicast(), "Local IP should not be multicast");
|
||||
|
||||
let is_loopback = ipv6.is_loopback();
|
||||
println!("IPv6 is loopback: {}", is_loopback);
|
||||
println!("IPv6 is loopback: {is_loopback}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ mod tests {
|
||||
let back_to_string = parsed_ip.to_string();
|
||||
|
||||
// For standard IP addresses, round-trip conversion should be consistent
|
||||
println!("Original: {}, Parsed back: {}", ip_string, back_to_string);
|
||||
println!("Original: {ip_string}, Parsed back: {back_to_string}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -186,7 +186,7 @@ mod tests {
|
||||
|
||||
// If it's not a loopback address, it should be routable
|
||||
if !ipv4.is_loopback() {
|
||||
println!("Got routable IPv4: {}", ipv4);
|
||||
println!("Got routable IPv4: {ipv4}");
|
||||
}
|
||||
}
|
||||
IpAddr::V6(ipv6) => {
|
||||
@@ -194,7 +194,7 @@ mod tests {
|
||||
assert!(!ipv6.is_unspecified(), "Should not be ::");
|
||||
|
||||
if !ipv6.is_loopback() {
|
||||
println!("Got routable IPv6: {}", ipv6);
|
||||
println!("Got routable IPv6: {ipv6}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ pub fn get_available_port() -> u16 {
|
||||
pub fn must_get_local_ips() -> std::io::Result<Vec<IpAddr>> {
|
||||
match netif::up() {
|
||||
Ok(up) => Ok(up.map(|x| x.address().to_owned()).collect()),
|
||||
Err(err) => Err(std::io::Error::other(format!("Unable to get IP addresses of this host: {}", err))),
|
||||
Err(err) => Err(std::io::Error::other(format!("Unable to get IP addresses of this host: {err}"))),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ pub fn parse_and_resolve_address(addr_str: &str) -> std::io::Result<SocketAddr>
|
||||
let port_str = port;
|
||||
let port: u16 = port_str
|
||||
.parse()
|
||||
.map_err(|e| std::io::Error::other(format!("Invalid port format: {}, err:{:?}", addr_str, e)))?;
|
||||
.map_err(|e| std::io::Error::other(format!("Invalid port format: {addr_str}, err:{e:?}")))?;
|
||||
let final_port = if port == 0 {
|
||||
get_available_port() // assume get_available_port is available here
|
||||
} else {
|
||||
@@ -342,7 +342,7 @@ mod test {
|
||||
|
||||
for (addr, expected) in test_cases {
|
||||
let result = is_socket_addr(addr);
|
||||
assert_eq!(expected, result, "addr: '{}', expected: {}, got: {}", addr, expected, result);
|
||||
assert_eq!(expected, result, "addr: '{addr}', expected: {expected}, got: {result}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ mod test {
|
||||
|
||||
for addr in valid_cases {
|
||||
let result = check_local_server_addr(addr);
|
||||
assert!(result.is_ok(), "Expected '{}' to be valid, but got error: {:?}", addr, result);
|
||||
assert!(result.is_ok(), "Expected '{addr}' to be valid, but got error: {result:?}");
|
||||
}
|
||||
|
||||
// Test invalid addresses
|
||||
@@ -368,15 +368,12 @@ mod test {
|
||||
|
||||
for (addr, expected_error_pattern) in invalid_cases {
|
||||
let result = check_local_server_addr(addr);
|
||||
assert!(result.is_err(), "Expected '{}' to be invalid, but it was accepted: {:?}", addr, result);
|
||||
assert!(result.is_err(), "Expected '{addr}' to be invalid, but it was accepted: {result:?}");
|
||||
|
||||
let error_msg = result.unwrap_err().to_string();
|
||||
assert!(
|
||||
error_msg.contains(expected_error_pattern) || error_msg.contains("invalid socket address"),
|
||||
"Error message '{}' doesn't contain expected pattern '{}' for address '{}'",
|
||||
error_msg,
|
||||
expected_error_pattern,
|
||||
addr
|
||||
"Error message '{error_msg}' doesn't contain expected pattern '{expected_error_pattern}' for address '{addr}'"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ mod tests {
|
||||
let temp_dir = tempfile::tempdir().unwrap();
|
||||
let info = get_info(temp_dir.path()).unwrap();
|
||||
|
||||
println!("Disk Info: {:?}", info);
|
||||
println!("Disk Info: {info:?}");
|
||||
|
||||
assert!(info.total > 0);
|
||||
assert!(info.free > 0);
|
||||
@@ -98,7 +98,7 @@ mod tests {
|
||||
let result = same_disk(path1, path2).unwrap();
|
||||
// Since both temporary directories are created in the same file system,
|
||||
// they should be on the same disk in most cases
|
||||
println!("Path1: {}, Path2: {}, Same disk: {}", path1, path2, result);
|
||||
println!("Path1: {path1}, Path2: {path2}, Same disk: {result}");
|
||||
// Test passes if the function doesn't panic - the actual result depends on test environment
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ pub fn retain_slash(s: &str) -> String {
|
||||
if s.ends_with(SLASH_SEPARATOR) {
|
||||
s.to_string()
|
||||
} else {
|
||||
format!("{}{}", s, SLASH_SEPARATOR)
|
||||
format!("{s}{SLASH_SEPARATOR}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ pub fn path_join_buf(elements: &[&str]) -> String {
|
||||
let clean_path = cpath.to_string_lossy();
|
||||
|
||||
if trailing_slash {
|
||||
return format!("{}{}", clean_path, SLASH_SEPARATOR);
|
||||
return format!("{clean_path}{SLASH_SEPARATOR}");
|
||||
}
|
||||
clean_path.to_string()
|
||||
}
|
||||
@@ -265,9 +265,9 @@ mod tests {
|
||||
#[test]
|
||||
fn test_base_dir_from_prefix() {
|
||||
let a = "da/";
|
||||
println!("---- in {}", a);
|
||||
println!("---- in {a}");
|
||||
let a = base_dir_from_prefix(a);
|
||||
println!("---- out {}", a);
|
||||
println!("---- out {a}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -7,7 +7,7 @@ pub fn parse_bool(str: &str) -> Result<bool> {
|
||||
match str {
|
||||
"1" | "t" | "T" | "true" | "TRUE" | "True" | "on" | "ON" | "On" | "enabled" => Ok(true),
|
||||
"0" | "f" | "F" | "false" | "FALSE" | "False" | "off" | "OFF" | "Off" | "disabled" => Ok(false),
|
||||
_ => Err(Error::other(format!("ParseBool: parsing {}", str))),
|
||||
_ => Err(Error::other(format!("ParseBool: parsing {str}"))),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,8 +208,7 @@ pub fn find_ellipses_patterns(arg: &str) -> Result<ArgPattern> {
|
||||
Some(caps) => caps,
|
||||
None => {
|
||||
return Err(Error::other(format!(
|
||||
"Invalid ellipsis format in ({}), Ellipsis range must be provided in format {{N...M}} where N and M are positive integers, M must be greater than N, with an allowed minimum range of 4",
|
||||
arg
|
||||
"Invalid ellipsis format in ({arg}), Ellipsis range must be provided in format {{N...M}} where N and M are positive integers, M must be greater than N, with an allowed minimum range of 4"
|
||||
)));
|
||||
}
|
||||
};
|
||||
@@ -248,8 +247,7 @@ pub fn find_ellipses_patterns(arg: &str) -> Result<ArgPattern> {
|
||||
|| p.suffix.contains(CLOSE_BRACES)
|
||||
{
|
||||
return Err(Error::other(format!(
|
||||
"Invalid ellipsis format in ({}), Ellipsis range must be provided in format {{N...M}} where N and M are positive integers, M must be greater than N, with an allowed minimum range of 4",
|
||||
arg
|
||||
"Invalid ellipsis format in ({arg}), Ellipsis range must be provided in format {{N...M}} where N and M are positive integers, M must be greater than N, with an allowed minimum range of 4"
|
||||
)));
|
||||
}
|
||||
}
|
||||
@@ -300,7 +298,7 @@ pub fn parse_ellipses_range(pattern: &str) -> Result<Vec<String>> {
|
||||
if ellipses_range[0].starts_with('0') && ellipses_range[0].len() > 1 {
|
||||
ret.push(format!("{:0width$}", i, width = ellipses_range[1].len()));
|
||||
} else {
|
||||
ret.push(format!("{}", i));
|
||||
ret.push(format!("{i}"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,7 +379,7 @@ mod tests {
|
||||
|
||||
for (i, args, expected) in test_cases {
|
||||
let ret = has_ellipses(&args);
|
||||
assert_eq!(ret, expected, "Test{}: Expected {}, got {}", i, expected, ret);
|
||||
assert_eq!(ret, expected, "Test{i}: Expected {expected}, got {ret}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ impl UserAgent {
|
||||
let cpu_info = if arch == "aarch64" { "Apple" } else { "Intel" };
|
||||
|
||||
// Convert to User-Agent format
|
||||
format!("Macintosh; {} Mac OS X {}_{}_{}", cpu_info, major, minor, patch)
|
||||
format!("Macintosh; {cpu_info} Mac OS X {major}_{minor}_{patch}")
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
@@ -145,40 +145,40 @@ mod tests {
|
||||
fn test_user_agent_format_basis() {
|
||||
let ua = get_user_agent(ServiceType::Basis);
|
||||
assert!(ua.starts_with("Mozilla/5.0"));
|
||||
assert!(ua.contains(&format!("RustFS/{}", VERSION).to_string()));
|
||||
println!("User-Agent: {}", ua);
|
||||
assert!(ua.contains(&format!("RustFS/{VERSION}").to_string()));
|
||||
println!("User-Agent: {ua}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_user_agent_format_core() {
|
||||
let ua = get_user_agent(ServiceType::Core);
|
||||
assert!(ua.starts_with("Mozilla/5.0"));
|
||||
assert!(ua.contains(&format!("RustFS/{} (core)", VERSION).to_string()));
|
||||
println!("User-Agent: {}", ua);
|
||||
assert!(ua.contains(&format!("RustFS/{VERSION} (core)").to_string()));
|
||||
println!("User-Agent: {ua}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_user_agent_format_event() {
|
||||
let ua = get_user_agent(ServiceType::Event);
|
||||
assert!(ua.starts_with("Mozilla/5.0"));
|
||||
assert!(ua.contains(&format!("RustFS/{} (event)", VERSION).to_string()));
|
||||
println!("User-Agent: {}", ua);
|
||||
assert!(ua.contains(&format!("RustFS/{VERSION} (event)").to_string()));
|
||||
println!("User-Agent: {ua}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_user_agent_format_logger() {
|
||||
let ua = get_user_agent(ServiceType::Logger);
|
||||
assert!(ua.starts_with("Mozilla/5.0"));
|
||||
assert!(ua.contains(&format!("RustFS/{} (logger)", VERSION).to_string()));
|
||||
println!("User-Agent: {}", ua);
|
||||
assert!(ua.contains(&format!("RustFS/{VERSION} (logger)").to_string()));
|
||||
println!("User-Agent: {ua}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_user_agent_format_custom() {
|
||||
let ua = get_user_agent(ServiceType::Custom("monitor".to_string()));
|
||||
assert!(ua.starts_with("Mozilla/5.0"));
|
||||
assert!(ua.contains(&format!("RustFS/{} (monitor)", VERSION).to_string()));
|
||||
println!("User-Agent: {}", ua);
|
||||
assert!(ua.contains(&format!("RustFS/{VERSION} (monitor)").to_string()));
|
||||
println!("User-Agent: {ua}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -189,9 +189,9 @@ mod tests {
|
||||
let ua_logger = get_user_agent(ServiceType::Logger);
|
||||
let ua_custom = get_user_agent(ServiceType::Custom("monitor".to_string()));
|
||||
|
||||
println!("Core User-Agent: {}", ua_core);
|
||||
println!("Event User-Agent: {}", ua_event);
|
||||
println!("Logger User-Agent: {}", ua_logger);
|
||||
println!("Custom User-Agent: {}", ua_custom);
|
||||
println!("Core User-Agent: {ua_core}");
|
||||
println!("Event User-Agent: {ua_event}");
|
||||
println!("Logger User-Agent: {ua_logger}");
|
||||
println!("Custom User-Agent: {ua_custom}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user