aboutsummaryrefslogtreecommitdiff
path: root/tests/device.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/device.rs')
-rw-r--r--tests/device.rs38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/device.rs b/tests/device.rs
index d6ed0c4..f7d8df3 100644
--- a/tests/device.rs
+++ b/tests/device.rs
@@ -349,6 +349,44 @@ fn encrypted_volume(device: Storage) {
}
#[test_device]
+fn hidden_volume(device: Storage) {
+ assert_eq!(Ok(()), device.lock());
+
+ assert_eq!(1, count_nitrokey_block_devices());
+ assert_eq!(Ok(()), device.disable_hidden_volume());
+ assert_eq!(1, count_nitrokey_block_devices());
+
+ assert_eq!(Ok(()), device.enable_encrypted_volume(USER_PASSWORD));
+ assert_eq!(2, count_nitrokey_block_devices());
+
+ // TODO: why this error code?
+ assert_eq!(
+ Err(CommandError::WrongPassword),
+ device.create_hidden_volume(5, 0, 100, "hiddenpw")
+ );
+ assert_eq!(Ok(()), device.create_hidden_volume(0, 20, 21, "hidden-pw"));
+ assert_eq!(
+ Ok(()),
+ device.create_hidden_volume(0, 20, 21, "hiddenpassword")
+ );
+ assert_eq!(Ok(()), device.create_hidden_volume(1, 0, 1, "otherpw"));
+ // TODO: test invalid range (not handled by libnitrokey)
+ assert_eq!(2, count_nitrokey_block_devices());
+
+ assert_eq!(
+ Err(CommandError::WrongPassword),
+ device.enable_hidden_volume("blubb")
+ );
+ assert_eq!(Ok(()), device.enable_hidden_volume("hiddenpassword"));
+ assert_eq!(2, count_nitrokey_block_devices());
+ assert_eq!(Ok(()), device.enable_hidden_volume("otherpw"));
+ assert_eq!(2, count_nitrokey_block_devices());
+
+ assert_eq!(Ok(()), device.disable_hidden_volume());
+ assert_eq!(1, count_nitrokey_block_devices());
+}
+
+#[test_device]
fn lock(device: Storage) {
assert_eq!(Ok(()), device.enable_encrypted_volume(USER_PASSWORD));
assert_eq!(Ok(()), device.lock());