aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-01-14 15:26:02 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-01-14 16:28:58 +0100
commit0262ed2e614e9222b69970289a32ddb3683b3535 (patch)
tree6fe55a9854e8c61daf7bdec9b636260aa2b92253 /tests
parent6ea73f29daa5db0215663a0a38334b764863671d (diff)
downloadnitrokey-rs-0262ed2e614e9222b69970289a32ddb3683b3535.tar.gz
nitrokey-rs-0262ed2e614e9222b69970289a32ddb3683b3535.tar.bz2
Add the get_production_info method to the Storage struct
The get_production_info method maps to the NK_get_production_info function of libnitrokey. The Storage firmware supports two query modes: with or without a write test. libnitrokey only performs the query without write test, so the fields that are only set for the write test are ignored in our implementation. This affects: - user and admin retry counts - smart card ID - SD card size
Diffstat (limited to 'tests')
-rw-r--r--tests/device.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/device.rs b/tests/device.rs
index e40ae12..915bd3a 100644
--- a/tests/device.rs
+++ b/tests/device.rs
@@ -439,6 +439,27 @@ fn get_storage_status(device: Storage) {
}
#[test_device]
+fn get_production_info(device: Storage) {
+ let info = device.get_production_info().unwrap();
+ assert_eq!(0, info.firmware_version_major);
+ assert!(info.firmware_version_minor != 0);
+ assert!(info.serial_number_cpu != 0);
+ assert!(info.sd_card.serial_number != 0);
+ assert!(info.sd_card.size > 0);
+ assert!(info.sd_card.manufacturing_year > 10);
+ assert!(info.sd_card.manufacturing_year < 100);
+ // TODO: month value is not valid atm
+ // assert!(info.sd_card.manufacturing_month < 12);
+ assert!(info.sd_card.oem != 0);
+ assert!(info.sd_card.manufacturer != 0);
+
+ let status = device.get_status().unwrap();
+ assert_eq!(status.firmware_version_major, info.firmware_version_major);
+ assert_eq!(status.firmware_version_minor, info.firmware_version_minor);
+ assert_eq!(status.serial_number_sd_card, info.sd_card.serial_number);
+}
+
+#[test_device]
fn export_firmware(device: Storage) {
assert_eq!(
Err(CommandError::WrongPassword),