From d35cdf7f0a9822f73f4e1d18494350840de2a421 Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Mon, 27 May 2019 08:09:48 -0700 Subject: Move storage status subcommand into status command In an attempt to rework the structure of the storage command to better accommodate future requirements for allowing to change the read-write state of the unencrypted volume (as well as potentially the encrypted one), this change removes the storage status subcommand and merges its output into the storage command. --- nitrocli/src/tests/storage.rs | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'nitrocli/src/tests/storage.rs') diff --git a/nitrocli/src/tests/storage.rs b/nitrocli/src/tests/storage.rs index be933ca..5b45bdc 100644 --- a/nitrocli/src/tests/storage.rs +++ b/nitrocli/src/tests/storage.rs @@ -19,15 +19,6 @@ use super::*; -#[test_device] -fn status_on_pro(device: nitrokey::Pro) { - let res = Nitrocli::with_dev(device).handle(&["storage", "status"]); - assert_eq!( - res.unwrap_str_err(), - "This command is only available on the Nitrokey Storage", - ); -} - #[test_device] fn status_open_close(device: nitrokey::Storage) -> crate::Result<()> { fn make_re(open: Option) -> regex::Regex { @@ -42,14 +33,11 @@ fn status_open_close(device: nitrokey::Storage) -> crate::Result<()> { None => "(read-only|active|inactive)", }; let re = format!( - r#"^Status: - SD card ID: 0x[[:xdigit:]]{{8}} - firmware: (un)?locked - storage keys: (not )?created - volumes: - unencrypted: (read-only|active|inactive) - encrypted: {} - hidden: (read-only|active|inactive) + r#" + volumes: + unencrypted: (read-only|active|inactive) + encrypted: {} + hidden: (read-only|active|inactive) $"#, encrypted ); @@ -57,20 +45,29 @@ $"#, } let mut ncli = Nitrocli::with_dev(device); - let out = ncli.handle(&["storage", "status"])?; + let out = ncli.handle(&["status"])?; assert!(make_re(None).is_match(&out), out); let _ = ncli.handle(&["storage", "open"])?; - let out = ncli.handle(&["storage", "status"])?; + let out = ncli.handle(&["status"])?; assert!(make_re(Some(true)).is_match(&out), out); let _ = ncli.handle(&["storage", "close"])?; - let out = ncli.handle(&["storage", "status"])?; + let out = ncli.handle(&["status"])?; assert!(make_re(Some(false)).is_match(&out), out); Ok(()) } +#[test_device] +fn encrypted_open_on_pro(device: nitrokey::Pro) { + let res = Nitrocli::with_dev(device).handle(&["storage", "open"]); + assert_eq!( + res.unwrap_str_err(), + "This command is only available on the Nitrokey Storage", + ); +} + #[test_device] fn encrypted_open_close(device: nitrokey::Storage) -> crate::Result<()> { let mut ncli = Nitrocli::with_dev(device); -- cgit v1.2.1