diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2019-01-03 12:16:21 +0000 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2019-01-03 13:17:54 +0100 |
commit | d60e03b46a6af75056f07394ef66ecaa35f32d77 (patch) | |
tree | eecd8b42abaf5a125d5d7ddcdc9e0b6225755ce5 /tests/device.rs | |
parent | 1061005a82ed0ba6ad5c48322e704f786bd802ab (diff) | |
download | nitrokey-rs-d60e03b46a6af75056f07394ef66ecaa35f32d77.tar.gz nitrokey-rs-d60e03b46a6af75056f07394ef66ecaa35f32d77.tar.bz2 |
Add Storage::change_update_pin method
This patch adds the change_update_pin method to the Storage struct that
uses the NK_change_update_password function to set the password required
for firmware updates.
Diffstat (limited to 'tests/device.rs')
-rw-r--r-- | tests/device.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/tests/device.rs b/tests/device.rs index 4551534..a225d2d 100644 --- a/tests/device.rs +++ b/tests/device.rs @@ -6,9 +6,10 @@ use std::{thread, time}; use nitrokey::{Authenticate, CommandError, Config, Device, Storage}; -use crate::util::{Target, ADMIN_PASSWORD, USER_PASSWORD}; +use crate::util::{Target, ADMIN_PASSWORD, USER_PASSWORD, UPDATE_PIN}; static ADMIN_NEW_PASSWORD: &str = "1234567890"; +static UPDATE_NEW_PIN: &str = "87654321"; static USER_NEW_PASSWORD: &str = "abcdefghij"; fn count_nitrokey_block_devices() -> usize { @@ -296,6 +297,16 @@ fn unlock_user_pin() { #[test] #[cfg_attr(not(feature = "test-storage"), ignore)] +fn change_update_pin() { + let device = Storage::connect().unwrap(); + + assert_eq!(Err(CommandError::WrongPassword), device.change_update_pin(UPDATE_NEW_PIN, UPDATE_PIN)); + assert_eq!(Ok(()), device.change_update_pin(UPDATE_PIN, UPDATE_NEW_PIN)); + assert_eq!(Ok(()), device.change_update_pin(UPDATE_NEW_PIN, UPDATE_PIN)); +} + +#[test] +#[cfg_attr(not(feature = "test-storage"), ignore)] fn encrypted_volume() { let device = Storage::connect().unwrap(); assert!(device.lock().is_ok()); |