rust: Service facade (profiles, credentials, TOTP, import/export, SSH keys, SFTP, updates)

This commit is contained in:
Andy Dixon
2026-10-11 16:36:37 +01:00
parent cbd83489b2
commit d654671bc1
4 changed files with 410 additions and 10 deletions
+3 -7
View File
@@ -2,7 +2,7 @@
use nexus_core::models::{Profile, Protocol, SessionState};
use nexus_core::secrets::{Keychain, Secrets, Vault};
use nexus_core::sessions::{Event, Manager, Prompt};
use nexus_core::sessions::{Event, Manager};
use nexus_core::storage::Store;
use std::io::{Read, Write};
use std::net::TcpListener;
@@ -25,10 +25,6 @@ fn manager(name: &str) -> (Arc<Manager>, mpsc::Receiver<Event>, std::path::PathB
(m, rx, dir)
}
fn no_prompt() -> Prompt {
Arc::new(|_| Err("no prompt in tests".into()))
}
/// Waits for an event matching `f`, answering host-key prompts with `accept`.
fn wait<T>(rx: &mpsc::Receiver<Event>, mut f: impl FnMut(&Event) -> Option<T>) -> T {
let deadline = std::time::Instant::now() + Duration::from_secs(15);
@@ -101,7 +97,7 @@ fn raw_session_and_auto_reconnect() {
p.host = "127.0.0.1".into();
p.port = port as i64;
p.raw.as_mut().unwrap().auto_reconnect = true;
let id = m.connect(p, no_prompt());
let id = m.connect(p);
wait(&rx, |e| state(e, SessionState::Connected));
m.raw_write_text(&id, "ping").unwrap();
wait(&rx, |e| matches!(e, Event::RawData { direction, data, .. } if direction == "recv" && data.starts_with(b"ping")).then_some(()));
@@ -124,7 +120,7 @@ fn connect_failure_reports_error_state() {
let mut p = Profile::new(Protocol::Telnet);
p.host = "127.0.0.1".into();
p.port = port as i64;
let id = m.connect(p, no_prompt());
let id = m.connect(p);
let err = wait(&rx, |e| state(e, SessionState::Error));
assert!(err.starts_with(&id) && err.len() > id.len() + 1, "{err}");
let _ = std::fs::remove_dir_all(dir);