SSH configuration path (#84)

SSH configuration
This commit is contained in:
Christian Visintin
2021-12-11 21:43:23 +01:00
parent 9284f101c8
commit e6ba4d8430
18 changed files with 155 additions and 9 deletions

View File

@@ -239,6 +239,18 @@ impl ConfigClient {
self.config.user_interface.notification_threshold = Some(value);
}
// Remote params
/// Get ssh config path
pub fn get_ssh_config(&self) -> Option<&str> {
self.config.remote.ssh_config.as_deref()
}
/// Set ssh config path
pub fn set_ssh_config(&mut self, p: Option<String>) {
self.config.remote.ssh_config = p;
}
// SSH Keys
/// Save a SSH key into configuration.
@@ -655,6 +667,20 @@ mod tests {
assert_eq!(client.get_notification_threshold(), 64);
}
#[test]
fn test_system_config_remote_ssh_config() {
let tmp_dir: TempDir = TempDir::new().ok().unwrap();
let (cfg_path, key_path): (PathBuf, PathBuf) = get_paths(tmp_dir.path());
let mut client: ConfigClient = ConfigClient::new(cfg_path.as_path(), key_path.as_path())
.ok()
.unwrap();
assert_eq!(client.get_ssh_config(), None); // Null ?
client.set_ssh_config(Some(String::from("/tmp/ssh_config")));
assert_eq!(client.get_ssh_config(), Some("/tmp/ssh_config"));
client.set_ssh_config(None);
assert_eq!(client.get_ssh_config(), None);
}
#[test]
fn test_system_config_ssh_keys() {
let tmp_dir: TempDir = TempDir::new().ok().unwrap();