summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/device.rs20
1 files changed, 14 insertions, 6 deletions
diff --git a/tests/device.rs b/tests/device.rs
index d80f011..cd37869 100644
--- a/tests/device.rs
+++ b/tests/device.rs
@@ -264,6 +264,14 @@ fn unlock_user_pin(device: DeviceWrapper) {
assert_ok!((), device.change_user_pin(USER_NEW_PASSWORD, USER_PASSWORD));
}
+fn assert_utf8_err_or_ne(left: &str, right: Result<String, Error>) {
+ match right {
+ Ok(s) => assert_ne!(left.to_string(), s),
+ Err(Error::Utf8Error(_)) => {}
+ Err(err) => panic!("Expected Utf8Error, got {}!", err),
+ }
+}
+
#[test_device]
fn factory_reset(device: DeviceWrapper) {
let admin = device.authenticate_admin(ADMIN_PASSWORD).unwrap();
@@ -298,9 +306,9 @@ fn factory_reset(device: DeviceWrapper) {
let device = user.device();
let pws = device.get_password_safe(USER_PASSWORD).unwrap();
- assert_ne!("test".to_string(), pws.get_slot_name(0).unwrap());
- assert_ne!("testlogin".to_string(), pws.get_slot_login(0).unwrap());
- assert_ne!("testpw".to_string(), pws.get_slot_password(0).unwrap());
+ assert_utf8_err_or_ne("test", pws.get_slot_name(0));
+ assert_utf8_err_or_ne("testlogin", pws.get_slot_login(0));
+ assert_utf8_err_or_ne("testpw", pws.get_slot_password(0));
assert_ok!((), device.build_aes_key(ADMIN_PASSWORD));
}
@@ -320,9 +328,9 @@ fn build_aes_key(device: DeviceWrapper) {
let device = device.authenticate_admin(ADMIN_PASSWORD).unwrap().device();
let pws = device.get_password_safe(USER_PASSWORD).unwrap();
- assert_ne!("test".to_string(), pws.get_slot_name(0).unwrap());
- assert_ne!("testlogin".to_string(), pws.get_slot_login(0).unwrap());
- assert_ne!("testpw".to_string(), pws.get_slot_password(0).unwrap());
+ assert_utf8_err_or_ne("test", pws.get_slot_name(0));
+ assert_utf8_err_or_ne("testlogin", pws.get_slot_login(0));
+ assert_utf8_err_or_ne("testpw", pws.get_slot_password(0));
}
#[test_device]