diff options
author | Daniel Mueller <deso@posteo.net> | 2019-01-16 17:26:30 -0800 |
---|---|---|
committer | Daniel Mueller <deso@posteo.net> | 2019-01-16 17:26:30 -0800 |
commit | 8350ac6afb2d678b74581000a6aafe1994b72231 (patch) | |
tree | 2330da01a806921b3849c9e64d2b9f506495e2c0 /nitrokey/tests/device.rs | |
parent | d6652b913b33e432a748187f9f5623cec1e9926e (diff) | |
download | nitrocli-8350ac6afb2d678b74581000a6aafe1994b72231.tar.gz nitrocli-8350ac6afb2d678b74581000a6aafe1994b72231.tar.bz2 |
Update nitrokey crate to 0.3.3
This change updates the nitrokey crate to version 0.3.3. Along with that
change we update rand to 0.6.4 because rand 0.6.1 does not yet contain a
publicly accessible rand_os. Note that we no longer require all
crates in rand's workspace, but only rand_os and rand_core, which is a
significant reduction in the number of lines of code compiled.
Import subrepo nitrokey/:nitrokey at 7cf747d56ddc0b7eeedc3caf36dcc909907a171c
Import subrepo rand/:rand at 4336232dda03323634b10ec72ddf27914aebc3a2
Diffstat (limited to 'nitrokey/tests/device.rs')
-rw-r--r-- | nitrokey/tests/device.rs | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/nitrokey/tests/device.rs b/nitrokey/tests/device.rs index e40ae12..849d2ff 100644 --- a/nitrokey/tests/device.rs +++ b/nitrokey/tests/device.rs @@ -260,6 +260,15 @@ fn unlock_user_pin(device: DeviceWrapper) { #[test_device] fn factory_reset(device: DeviceWrapper) { + let admin = device.authenticate_admin(ADMIN_PASSWORD).unwrap(); + let otp_data = OtpSlotData::new(1, "test", "0123468790", OtpMode::SixDigits); + assert_eq!(Ok(()), admin.write_totp_slot(otp_data, 30)); + + let device = admin.device(); + let pws = device.get_password_safe(USER_PASSWORD).unwrap(); + assert_eq!(Ok(()), pws.write_slot(0, "test", "testlogin", "testpw")); + drop(pws); + assert_eq!( Ok(()), device.change_user_pin(USER_PASSWORD, USER_NEW_PASSWORD) @@ -269,15 +278,6 @@ fn factory_reset(device: DeviceWrapper) { device.change_admin_pin(ADMIN_PASSWORD, ADMIN_NEW_PASSWORD) ); - let admin = device.authenticate_admin(ADMIN_NEW_PASSWORD).unwrap(); - let otp_data = OtpSlotData::new(1, "test", "0123468790", OtpMode::SixDigits); - assert_eq!(Ok(()), admin.write_totp_slot(otp_data, 30)); - - let device = admin.device(); - let pws = device.get_password_safe(USER_NEW_PASSWORD).unwrap(); - assert_eq!(Ok(()), pws.write_slot(0, "test", "testlogin", "testpw")); - drop(pws); - assert_eq!( Err(CommandError::WrongPassword), device.factory_reset(USER_NEW_PASSWORD) @@ -439,6 +439,45 @@ 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 clear_new_sd_card_warning(device: Storage) { + assert_eq!(Ok(()), device.factory_reset(ADMIN_PASSWORD)); + thread::sleep(time::Duration::from_secs(3)); + assert_eq!(Ok(()), device.build_aes_key(ADMIN_PASSWORD)); + + // We have to perform an SD card operation to reset the new_sd_card_found field + assert_eq!(Ok(()), device.lock()); + + let status = device.get_status().unwrap(); + assert!(status.new_sd_card_found); + + assert_eq!(Ok(()), device.clear_new_sd_card_warning(ADMIN_PASSWORD)); + + let status = device.get_status().unwrap(); + assert!(!status.new_sd_card_found); +} + +#[test_device] fn export_firmware(device: Storage) { assert_eq!( Err(CommandError::WrongPassword), |