mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
Logging setup
This commit is contained in:
@@ -152,6 +152,13 @@ pub fn fmt_path_elide(p: &Path, width: usize) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
/// ### shadow_password
|
||||
///
|
||||
/// Return a string with the same length of input string, but each character is replaced by '*'
|
||||
pub fn shadow_password(s: &str) -> String {
|
||||
(0..s.len()).map(|_| '*').collect()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
@@ -219,4 +226,9 @@ mod tests {
|
||||
let p: &Path = &Path::new("/develop/pippo/foo/bar");
|
||||
assert_eq!(fmt_path_elide(p, 16), String::from("/develop/.../foo/bar"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_utils_fmt_shadow_password() {
|
||||
assert_eq!(shadow_password("foobar"), String::from("******"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user