aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2020-02-03 12:59:37 +0100
committerRobin Krahl <robin.krahl@ireas.org>2020-02-03 12:59:37 +0100
commita3dd6afb8c23c8975737d1484e152d530a975c11 (patch)
tree83c94299f3e8efdf288a569ea36e25a053b8d4f3 /tests
parent3bdc550ce31aa9a8aaec13b4901e8517d34272be (diff)
parent2a8ce725407f32db5ad61c37475719737c9b5c9c (diff)
downloadnitrokey-rs-a3dd6afb8c23c8975737d1484e152d530a975c11.tar.gz
nitrokey-rs-a3dd6afb8c23c8975737d1484e152d530a975c11.tar.bz2
Merge branch 'release-0.6.0'
Diffstat (limited to 'tests')
-rw-r--r--tests/device.rs15
-rw-r--r--tests/pws.rs2
2 files changed, 5 insertions, 12 deletions
diff --git a/tests/device.rs b/tests/device.rs
index a88c956..1669d9d 100644
--- a/tests/device.rs
+++ b/tests/device.rs
@@ -10,7 +10,7 @@ use std::{thread, time};
use nitrokey::{
Authenticate, CommandError, CommunicationError, Config, ConfigureOtp, Device, DeviceInfo,
Error, GenerateOtp, GetPasswordSafe, LibraryError, OperationStatus, OtpMode, OtpSlotData,
- Storage, VolumeMode, DEFAULT_ADMIN_PIN, DEFAULT_USER_PIN,
+ SerialNumber, Storage, VolumeMode, DEFAULT_ADMIN_PIN, DEFAULT_USER_PIN,
};
use nitrokey_test::test as test_device;
@@ -47,8 +47,7 @@ fn list_devices(_device: DeviceWrapper) {
nitrokey::Model::Pro => {
assert!(device.serial_number.is_some());
let serial_number = device.serial_number.unwrap();
- assert!(!serial_number.is_empty());
- assert_valid_serial_number(&serial_number);
+ assert!(serial_number != SerialNumber::empty());
}
nitrokey::Model::Storage => {
assert_eq!(None, device.serial_number);
@@ -157,20 +156,14 @@ fn disconnect(device: DeviceWrapper) {
fn get_status(device: DeviceWrapper) {
let status = unwrap_ok!(device.get_status());
assert_ok!(status.firmware_version, device.get_firmware_version());
- let serial_number = format!("{:08x}", status.serial_number);
- assert_ok!(serial_number, device.get_serial_number());
+ assert_ok!(status.serial_number, device.get_serial_number());
assert_ok!(status.config, device.get_config());
}
-fn assert_valid_serial_number(serial_number: &str) {
- assert!(serial_number.is_ascii());
- assert!(serial_number.chars().all(|c| c.is_ascii_hexdigit()));
-}
-
#[test_device]
fn get_serial_number(device: DeviceWrapper) {
let serial_number = unwrap_ok!(device.get_serial_number());
- assert_valid_serial_number(&serial_number);
+ assert!(serial_number != SerialNumber::empty());
}
#[test_device]
diff --git a/tests/pws.rs b/tests/pws.rs
index 7169695..47e9703 100644
--- a/tests/pws.rs
+++ b/tests/pws.rs
@@ -16,7 +16,7 @@ use nitrokey_test::test as test_device;
fn get_slot_name_direct(slot: u8) -> Result<String, Error> {
let ptr = unsafe { nitrokey_sys::NK_get_password_safe_slot_name(slot) };
if ptr.is_null() {
- return Err(Error::UnexpectedError);
+ return Err(Error::UnexpectedError("null pointer".to_owned()));
}
let s = unsafe { CStr::from_ptr(ptr).to_string_lossy().into_owned() };
unsafe { free(ptr as *mut c_void) };