From 69c68b99bee22935151334b375ed4225942ef15d Mon Sep 17 00:00:00 2001 From: mulhern Date: Thu, 27 Apr 2023 12:27:15 -0400 Subject: [PATCH] Increase rpassword dependency lower bound to 7.2.0 Substitute prompt_password for removed prompt_password. Note that prompt_password prints the prompt string to /dev/tty, while prompt_password_stdout printed the prompt to stdout. Remove test that prints password prompt. Since the prompt goes to tty rather than stdout, the test framework is not able to handle it. This is a know limitation of the framework, see: https://github.com/assert-rs/assert_cmd/issues/138 Signed-off-by: mulhern --- Cargo.lock | 15 +++++++++++++-- Cargo.toml | 2 +- src/jsonrpc/client/key.rs | 3 +-- src/jsonrpc/client/pool.rs | 2 +- tests/stratis_min.rs | 20 -------------------- 5 files changed, 16 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 582f8e88fa..16051be14d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1212,9 +1212,20 @@ dependencies = [ [[package]] name = "rpassword" -version = "5.0.1" +version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffc936cf8a7ea60c58f030fd36a612a48f440610214dc54bc36431f9ea0c3efb" +checksum = "6678cf63ab3491898c0d021b493c94c9b221d91295294a2a5746eacbe5928322" +dependencies = [ + "libc", + "rtoolbox", + "winapi", +] + +[[package]] +name = "rtoolbox" +version = "0.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "034e22c514f5c0cb8a10ff341b9b048b5ceb21591f31c8f44c43b960f9b3524a" dependencies = [ "libc", "winapi", diff --git a/Cargo.toml b/Cargo.toml index a5e456e299..83461f6cbc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -166,7 +166,7 @@ version = "1.3.1" optional = true [dependencies.rpassword] -version = "5.0.0" +version = "7.2.0" optional = true [dependencies.serde] diff --git a/src/jsonrpc/client/key.rs b/src/jsonrpc/client/key.rs index e7a1bdfc76..8e7db15837 100644 --- a/src/jsonrpc/client/key.rs +++ b/src/jsonrpc/client/key.rs @@ -19,8 +19,7 @@ pub fn key_set(key_desc: KeyDescription, keyfile_path: Option<&str>) -> StratisR do_request!(KeySet, key_desc; file.as_raw_fd()) } None => { - let password = - rpassword::prompt_password_stdout("Enter passphrase followed by return: ")?; + let password = rpassword::prompt_password("Enter passphrase followed by return: ")?; if password.is_empty() { return Ok(()); } diff --git a/src/jsonrpc/client/pool.rs b/src/jsonrpc/client/pool.rs index 1a1338f87f..c26e1e8d23 100644 --- a/src/jsonrpc/client/pool.rs +++ b/src/jsonrpc/client/pool.rs @@ -29,7 +29,7 @@ pub fn pool_start( prompt: bool, ) -> StratisResult<()> { if prompt { - let password = rpassword::prompt_password_stdout("Enter passphrase followed by return: ")?; + let password = rpassword::prompt_password("Enter passphrase followed by return: ")?; if password.is_empty() { return Ok(()); } diff --git a/tests/stratis_min.rs b/tests/stratis_min.rs index 48b28e50d7..4d6fac27f0 100644 --- a/tests/stratis_min.rs +++ b/tests/stratis_min.rs @@ -248,23 +248,3 @@ fn stratis_min_list_default() { fn test_stratis_min_list_defaults() { test_with_stratisd_min_sim(stratis_min_list_default); } - -fn stratis_min_capture_key() { - let mut cmd = Command::cargo_bin("stratis-min").unwrap(); - let key = "akey"; - cmd.arg("key").arg("set").arg("--capture-key").arg(key); - cmd.write_stdin("keyval"); - cmd.assert().success(); - let mut cmd = Command::cargo_bin("stratis-min").unwrap(); - cmd.arg("key") - .assert() - .success() - .stdout(predicate::str::contains(key)); -} - -#[test] -// Verify that adding a key using --capture-key works and -// lists the new key in the output of 'keys'. -fn test_stratis_min_capture_key() { - test_with_stratisd_min_sim(stratis_min_capture_key); -}