diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2019-01-31 11:07:50 +0000 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2019-01-31 12:10:38 +0100 |
commit | ad76653b3be57c0cfd31c8056a8d68537034324e (patch) | |
tree | 32302d740faa9403426cc38e993402ff84edd498 /tests | |
parent | 9a38dd456804035f88aa7c4042066e4cde67c04c (diff) | |
download | nitrokey-rs-ad76653b3be57c0cfd31c8056a8d68537034324e.tar.gz nitrokey-rs-ad76653b3be57c0cfd31c8056a8d68537034324e.tar.bz2 |
Add set_encrypted_volume_mode method to Storage
Previously, we considered this command as unsupported as it only was
available with firmware version 0.49. But as discussed in nitrocli
issue 80 [0], it will probably be re-enabled in future firmware
versions. Therefore this patch adds the set_encrypted_volume_mode to
Storage.
[0] https://github.com/d-e-s-o/nitrocli/issues/80
Diffstat (limited to 'tests')
-rw-r--r-- | tests/device.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/device.rs b/tests/device.rs index 306b33f..969a7df 100644 --- a/tests/device.rs +++ b/tests/device.rs @@ -402,6 +402,36 @@ fn lock(device: Storage) { } #[test_device] +fn set_encrypted_volume_mode(device: Storage) { + // This test case does not check the device status as the command only works with firmware + // version 0.49. For later versions, it does not do anything and always returns Ok(()). + + assert_ok!( + (), + device.set_encrypted_volume_mode(ADMIN_PASSWORD, VolumeMode::ReadOnly) + ); + + // TODO: re-enable once the password is checked in the firmware + // assert_cmd_err!( + // CommandError::WrongPassword, + // device.set_encrypted_volume_mode(USER_PASSWORD, VolumeMode::ReadOnly) + // ); + + assert_ok!( + (), + device.set_encrypted_volume_mode(ADMIN_PASSWORD, VolumeMode::ReadOnly) + ); + assert_ok!( + (), + device.set_encrypted_volume_mode(ADMIN_PASSWORD, VolumeMode::ReadWrite) + ); + assert_ok!( + (), + device.set_encrypted_volume_mode(ADMIN_PASSWORD, VolumeMode::ReadOnly) + ); +} + +#[test_device] fn set_unencrypted_volume_mode(device: Storage) { fn assert_mode(device: &Storage, mode: VolumeMode) { let status = unwrap_ok!(device.get_status()); |