aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/federation-tests.md2
-rw-r--r--src/federation/keys.rs42
2 files changed, 22 insertions, 22 deletions
diff --git a/docs/federation-tests.md b/docs/federation-tests.md
index 6754060..ba182ad 100644
--- a/docs/federation-tests.md
+++ b/docs/federation-tests.md
@@ -31,7 +31,7 @@ built to: a stage is done when its tests are.
* **Keys.** Ed25519 keys made from seeds, signing as `ssh-keygen -Y sign` does; a vector
checks one signature against `ssh-keygen` itself. An ECDSA key `ssh-keygen` made, and
events it signed with it, are vectors; a test signs through a running `ssh-agent`, and
- `ssh-keygen -Y verify` checks what it signed, where OpenSSH is installed.
+ `ssh-keygen -Y verify` checks what it signed: the machine testing needs OpenSSH.
* **Events.** A builder for every kind (writes, key sets, node lists, proposals, votes,
version events, checkpoints, roots and forks), each from a party, a key and its
dependencies, encoded and signed as the design says; and for what is none: bytes that
diff --git a/src/federation/keys.rs b/src/federation/keys.rs
index fa13ec4..ed47b9b 100644
--- a/src/federation/keys.rs
+++ b/src/federation/keys.rs
@@ -421,47 +421,47 @@ mod tests {
/// A signature through a running `ssh-agent` checks here and with `ssh-keygen -Y
/// verify`, of an ECDSA key the agent alone holds and of an Ed25519 one; of ECDSA, also
- /// one the agent gave with a high `s`. Where OpenSSH isn't installed, nothing is asked.
+ /// one the agent gave with a high `s`. The machine testing needs OpenSSH (`ssh-agent`,
+ /// `ssh-add`, `ssh-keygen`): without it, the test fails.
#[test]
fn signs_through_an_ssh_agent() {
use std::process::{Command, Stdio};
- let dir = std::env::temp_dir().join(format!("continuum-agent-{}", std::process::id()));
- std::fs::create_dir_all(&dir).expect("a directory");
+ let dir = crate::files::scratch_dir("agent");
let socket = dir.join("agent");
- let agent = match Command::new("ssh-agent")
- .arg("-D")
- .arg("-a")
- .arg(&socket)
- .stdout(Stdio::null())
- .spawn()
- {
- Ok(agent) => agent,
- Err(error) if error.kind() == std::io::ErrorKind::NotFound => {
- eprintln!("no ssh-agent: skipped");
- return;
- }
- Err(error) => panic!("ssh-agent: {error}"),
- };
- struct Stop(std::process::Child, std::path::PathBuf);
+ // The agent, stopped when the test ends: dropped before its directory, declared
+ // after it.
+ struct Stop(std::process::Child);
impl Drop for Stop {
fn drop(&mut self) {
let _ = self.0.kill();
let _ = self.0.wait();
- let _ = std::fs::remove_dir_all(&self.1);
}
}
- let _stop = Stop(agent, dir.clone());
+ let _agent = Stop(
+ Command::new("ssh-agent")
+ .arg("-D")
+ .arg("-a")
+ .arg(&socket)
+ .stdout(Stdio::null())
+ .spawn()
+ .expect("ssh-agent, of OpenSSH, which this test needs"),
+ );
for _ in 0..100 {
if socket.exists() {
break;
}
std::thread::sleep(std::time::Duration::from_millis(50));
}
+ assert!(
+ socket.exists(),
+ "ssh-agent made no socket at {}",
+ socket.display()
+ );
let run = |command: &mut Command| {
let out = command
.env("SSH_AUTH_SOCK", &socket)
.output()
- .expect("OpenSSH");
+ .expect("OpenSSH, which this test needs");
assert!(out.status.success(), "{command:?}: {out:?}");
};
for kind in [["-t", "ecdsa", "-b", "256"].as_slice(), &["-t", "ed25519"]] {