mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-01 17:35:19 +00:00
tests: Allow controlling the password for SSH auth
The login details for the Windows VM are different. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
08ded4b449
commit
0eabc00b27
@ -532,9 +532,20 @@ mod tests {
|
|||||||
cmd.status().expect("Failed to launch ch-remote").success()
|
cmd.status().expect("Failed to launch ch-remote").success()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct PasswordAuth {
|
||||||
|
username: String,
|
||||||
|
password: String,
|
||||||
|
}
|
||||||
|
|
||||||
const DEFAULT_SSH_RETRIES: u8 = 6;
|
const DEFAULT_SSH_RETRIES: u8 = 6;
|
||||||
const DEFAULT_SSH_TIMEOUT: u8 = 10;
|
const DEFAULT_SSH_TIMEOUT: u8 = 10;
|
||||||
fn ssh_command_ip(command: &str, ip: &str, retries: u8, timeout: u8) -> Result<String, Error> {
|
fn ssh_command_ip_with_auth(
|
||||||
|
command: &str,
|
||||||
|
auth: &PasswordAuth,
|
||||||
|
ip: &str,
|
||||||
|
retries: u8,
|
||||||
|
timeout: u8,
|
||||||
|
) -> Result<String, Error> {
|
||||||
let mut s = String::new();
|
let mut s = String::new();
|
||||||
|
|
||||||
let mut counter = 0;
|
let mut counter = 0;
|
||||||
@ -545,7 +556,7 @@ mod tests {
|
|||||||
sess.set_tcp_stream(tcp);
|
sess.set_tcp_stream(tcp);
|
||||||
sess.handshake().map_err(Error::Handshake)?;
|
sess.handshake().map_err(Error::Handshake)?;
|
||||||
|
|
||||||
sess.userauth_password("cloud", "cloud123")
|
sess.userauth_password(&auth.username, &auth.password)
|
||||||
.map_err(Error::Authentication)?;
|
.map_err(Error::Authentication)?;
|
||||||
assert!(sess.authenticated());
|
assert!(sess.authenticated());
|
||||||
|
|
||||||
@ -572,6 +583,19 @@ mod tests {
|
|||||||
Ok(s)
|
Ok(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn ssh_command_ip(command: &str, ip: &str, retries: u8, timeout: u8) -> Result<String, Error> {
|
||||||
|
ssh_command_ip_with_auth(
|
||||||
|
command,
|
||||||
|
&PasswordAuth {
|
||||||
|
username: String::from("cloud"),
|
||||||
|
password: String::from("cloud123"),
|
||||||
|
},
|
||||||
|
ip,
|
||||||
|
retries,
|
||||||
|
timeout,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum Error {
|
enum Error {
|
||||||
Connection(std::io::Error),
|
Connection(std::io::Error),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user