aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-01-31 11:07:50 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-01-31 12:10:38 +0100
commitad76653b3be57c0cfd31c8056a8d68537034324e (patch)
tree32302d740faa9403426cc38e993402ff84edd498 /tests
parent9a38dd456804035f88aa7c4042066e4cde67c04c (diff)
downloadnitrokey-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.rs30
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());