mirror of
https://github.com/rosenpass/rosenpass.git
synced 2025-12-12 07:40:30 -08:00
chore: Smoketests for rp
This commit is contained in:
50
rp/tests/smoketest.rs
Normal file
50
rp/tests/smoketest.rs
Normal file
@@ -0,0 +1,50 @@
|
||||
use std::process::Command;
|
||||
|
||||
#[test]
|
||||
fn smoketest() -> anyhow::Result<()> {
|
||||
let tmpdir = tempfile::tempdir()?;
|
||||
|
||||
let secret = tmpdir.path().join("server.secret");
|
||||
let public = tmpdir.path().join("server.public");
|
||||
let invalid = tmpdir.path().join("invalid.secret");
|
||||
let toml = tmpdir.path().join("config.toml");
|
||||
|
||||
let invalid_config = r#"
|
||||
verbose = false
|
||||
private_keys_dir = "invliad"
|
||||
|
||||
[[peers]]
|
||||
public_keys_dir = "invliad"
|
||||
"#;
|
||||
|
||||
// Generate keys
|
||||
let status = Command::new(env!("CARGO_BIN_EXE_rp"))
|
||||
.args(["genkey", secret.to_str().unwrap()])
|
||||
.spawn()?
|
||||
.wait()?;
|
||||
assert!(status.success());
|
||||
|
||||
// Derive Public keys
|
||||
let status = Command::new(env!("CARGO_BIN_EXE_rp"))
|
||||
.args(["pubkey", secret.to_str().unwrap(), public.to_str().unwrap()])
|
||||
.spawn()?
|
||||
.wait()?;
|
||||
assert!(status.success());
|
||||
|
||||
// Can not exchange keys using exchange with invalid keys
|
||||
let out = Command::new(env!("CARGO_BIN_EXE_rp"))
|
||||
.args(["exchange", invalid.to_str().unwrap()])
|
||||
.output()?;
|
||||
assert!(!out.status.success());
|
||||
|
||||
std::fs::write(toml, invalid_config)?;
|
||||
let out = Command::new(env!("CARGO_BIN_EXE_rp"))
|
||||
.args([
|
||||
"exchange-config",
|
||||
tmpdir.path().join("invalid_config").to_str().unwrap(),
|
||||
])
|
||||
.output()?;
|
||||
assert!(!out.status.success());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user