From 6917be7ab3c5a9d47866a45855c836a9cc6f86ff Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Sat, 25 Jan 2020 20:33:57 +0100 Subject: Add --serial-number option This patch adds the --serial-number option that allows the user to filter the attached Nitrokey devices by serial number. As the Nitrokey Storage does not include its serial number in the USB device descriptor and as we don't want to connect to it just to query the serial number, this option only works for Nitrokey Storage devices. --- src/tests/status.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/tests') diff --git a/src/tests/status.rs b/src/tests/status.rs index 7946929..268e36f 100644 --- a/src/tests/status.rs +++ b/src/tests/status.rs @@ -28,6 +28,16 @@ fn not_found_pro() { assert_eq!(err, "Nitrokey device not found (filter: model=pro)"); } +#[test_device] +fn not_found_by_serial_number() { + let res = Nitrocli::new().handle(&["status", "--model=storage", "--serial-number=deadbeef"]); + let err = res.unwrap_err().to_string(); + assert_eq!( + err, + "Nitrokey device not found (filter: model=storage, serial number in [0xdeadbeef])" + ); +} + #[test_device(pro)] fn output_pro(model: nitrokey::Model) -> anyhow::Result<()> { let re = regex::Regex::new( -- cgit v1.2.3