aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/otp.rs14
-rw-r--r--src/tests/pws.rs18
-rw-r--r--src/tests/status.rs9
3 files changed, 12 insertions, 29 deletions
diff --git a/src/tests/otp.rs b/src/tests/otp.rs
index 7361688..65c1cb5 100644
--- a/src/tests/otp.rs
+++ b/src/tests/otp.rs
@@ -28,7 +28,7 @@ fn set_invalid_slot_raw(model: nitrokey::Model) {
assert_ne!(rc, 0);
assert_eq!(out, b"");
- assert_eq!(&err[..24], b"Could not write OTP slot");
+ assert_eq!(&err[..24], b"Failed to write OTP slot");
}
#[test_device]
@@ -37,12 +37,8 @@ fn set_invalid_slot(model: nitrokey::Model) {
.handle(&["otp", "set", "100", "name", "1234", "-f", "hex"])
.unwrap_err()
.to_string();
- let expected = format!(
- "Could not write OTP slot: {}",
- nitrokey::Error::LibraryError(nitrokey::LibraryError::InvalidSlot)
- );
- assert_eq!(err, expected);
+ assert_eq!(err, "Failed to write OTP slot");
}
#[test_device]
@@ -122,10 +118,6 @@ fn clear(model: nitrokey::Model) -> crate::Result<()> {
let res = ncli.handle(&["otp", "get", "3"]);
let err = res.unwrap_err().to_string();
- let expected = format!(
- "Could not generate OTP: {}",
- nitrokey::Error::CommandError(nitrokey::CommandError::SlotNotProgrammed)
- );
- assert_eq!(err, expected);
+ assert_eq!(err, "Failed to generate OTP");
Ok(())
}
diff --git a/src/tests/pws.rs b/src/tests/pws.rs
index 7f8107e..910ef92 100644
--- a/src/tests/pws.rs
+++ b/src/tests/pws.rs
@@ -25,12 +25,8 @@ fn set_invalid_slot(model: nitrokey::Model) {
.handle(&["pws", "set", "100", "name", "login", "1234"])
.unwrap_err()
.to_string();
- let expected = format!(
- "Could not write PWS slot: {}",
- nitrokey::Error::LibraryError(nitrokey::LibraryError::InvalidSlot)
- );
- assert_eq!(err, expected);
+ assert_eq!(err, "Failed to write PWS slot");
}
#[test_device]
@@ -97,11 +93,7 @@ fn set_reset_get(model: nitrokey::Model) -> crate::Result<()> {
let res = ncli.handle(&["pws", "get", "2"]);
let err = res.unwrap_err().to_string();
- let expected = format!(
- "Could not access PWS slot: {}",
- nitrokey::Error::CommandError(nitrokey::CommandError::SlotNotProgrammed)
- );
- assert_eq!(err, expected);
+ assert_eq!(err, "Failed to access PWS slot");
Ok(())
}
@@ -113,10 +105,6 @@ fn clear(model: nitrokey::Model) -> crate::Result<()> {
let res = ncli.handle(&["pws", "get", "10"]);
let err = res.unwrap_err().to_string();
- let expected = format!(
- "Could not access PWS slot: {}",
- nitrokey::Error::CommandError(nitrokey::CommandError::SlotNotProgrammed)
- );
- assert_eq!(err, expected);
+ assert_eq!(err, "Failed to access PWS slot");
Ok(())
}
diff --git a/src/tests/status.rs b/src/tests/status.rs
index e80fadc..c617a9e 100644
--- a/src/tests/status.rs
+++ b/src/tests/status.rs
@@ -19,15 +19,18 @@
use super::*;
-// This test acts as verification that conversion of Error::Error
-// variants into the proper exit code works properly.
#[test_device]
fn not_found_raw() {
let (rc, out, err) = Nitrocli::new().run(&["status"]);
assert_ne!(rc, 0);
assert_eq!(out, b"");
- assert_eq!(err, b"Nitrokey device not found\n");
+ let expected = r#"Nitrokey device not found
+
+Caused by:
+ Communication error: Could not connect to a Nitrokey device
+"#;
+ assert_eq!(err, expected.as_bytes());
}
#[test_device]