mirror of
https://github.com/veeso/termscp.git
synced 2025-12-07 09:36:00 -08:00
empty method sshkey_storage
This commit is contained in:
@@ -57,6 +57,15 @@ impl SshKeyStorage {
|
|||||||
SshKeyStorage { hosts }
|
SshKeyStorage { hosts }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ### empty
|
||||||
|
///
|
||||||
|
/// Create an empty ssh key storage; used in case `ConfigClient` is not available
|
||||||
|
pub fn empty() -> Self {
|
||||||
|
SshKeyStorage {
|
||||||
|
hosts: HashMap::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// ### resolve
|
/// ### resolve
|
||||||
///
|
///
|
||||||
/// Return RSA key path from host and username
|
/// Return RSA key path from host and username
|
||||||
@@ -97,11 +106,20 @@ mod tests {
|
|||||||
// Verify key exists
|
// Verify key exists
|
||||||
let mut exp_key_path: PathBuf = key_path.clone();
|
let mut exp_key_path: PathBuf = key_path.clone();
|
||||||
exp_key_path.push("pi@192.168.1.31.key");
|
exp_key_path.push("pi@192.168.1.31.key");
|
||||||
assert_eq!(*storage.resolve("192.168.1.31", "pi").unwrap(), exp_key_path);
|
assert_eq!(
|
||||||
|
*storage.resolve("192.168.1.31", "pi").unwrap(),
|
||||||
|
exp_key_path
|
||||||
|
);
|
||||||
// Verify unexisting key
|
// Verify unexisting key
|
||||||
assert!(storage.resolve("deskichup", "veeso").is_none());
|
assert!(storage.resolve("deskichup", "veeso").is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_system_sshkey_storage_empty() {
|
||||||
|
let storage: SshKeyStorage = SshKeyStorage::empty();
|
||||||
|
assert_eq!(storage.hosts.len(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
/// ### get_paths
|
/// ### get_paths
|
||||||
///
|
///
|
||||||
/// Get paths for configuration and keys directory
|
/// Get paths for configuration and keys directory
|
||||||
|
|||||||
Reference in New Issue
Block a user