use anyhow::Result;
use dialoguer::Password;
use super::UnlockBackend;
pub(crate) struct PassphraseBackend;
impl UnlockBackend for PassphraseBackend {
#[cfg_attr(coverage_nightly, coverage(off))]
fn retrieve_passphrase(&self) -> Result<String> {
Ok(Password::new()
.with_prompt("Enter moshpit-agent master passphrase")
.interact()?)
}
#[cfg_attr(coverage_nightly, coverage(off))]
fn set_passphrase(&self) -> Result<String> {
Ok(Password::new()
.with_prompt("Set moshpit-agent master passphrase")
.with_confirmation("Confirm master passphrase", "Passphrases do not match")
.interact()?)
}
fn name(&self) -> &'static str {
"passphrase"
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn backend_name() {
assert_eq!(PassphraseBackend.name(), "passphrase");
}
}