diff options
author | Daniel Mueller <deso@posteo.net> | 2019-06-08 11:02:12 -0700 |
---|---|---|
committer | Daniel Mueller <deso@posteo.net> | 2019-06-08 11:02:12 -0700 |
commit | a83454bcc9cb3f7d10b4ee5926490c80b222430b (patch) | |
tree | 3a48e86219c175258130c3854287d08b7b046597 /nitrocli/src/tests | |
parent | 74be24daf592f3408524081c3760ca153294d643 (diff) | |
download | nitrocli-a83454bcc9cb3f7d10b4ee5926490c80b222430b.tar.gz nitrocli-a83454bcc9cb3f7d10b4ee5926490c80b222430b.tar.bz2 |
Add support for changing read-write mode of unencrypted volume
This change adds support for changing the read-write mode of the
unencrypted volume. To do so, we introduce a new top-level command,
unencrypted, with a new subcommand, set, that accepts the new mode of
the volume.
Diffstat (limited to 'nitrocli/src/tests')
-rw-r--r-- | nitrocli/src/tests/mod.rs | 1 | ||||
-rw-r--r-- | nitrocli/src/tests/unencrypted.rs | 41 |
2 files changed, 42 insertions, 0 deletions
diff --git a/nitrocli/src/tests/mod.rs b/nitrocli/src/tests/mod.rs index 70a3d20..2f2926f 100644 --- a/nitrocli/src/tests/mod.rs +++ b/nitrocli/src/tests/mod.rs @@ -46,6 +46,7 @@ mod pws; mod reset; mod run; mod status; +mod unencrypted; /// A trait simplifying checking for expected errors. pub trait UnwrapError { diff --git a/nitrocli/src/tests/unencrypted.rs b/nitrocli/src/tests/unencrypted.rs new file mode 100644 index 0000000..c976f50 --- /dev/null +++ b/nitrocli/src/tests/unencrypted.rs @@ -0,0 +1,41 @@ +// unencrypted.rs + +// ************************************************************************* +// * Copyright (C) 2019 Daniel Mueller (deso@posteo.net) * +// * * +// * This program is free software: you can redistribute it and/or modify * +// * it under the terms of the GNU General Public License as published by * +// * the Free Software Foundation, either version 3 of the License, or * +// * (at your option) any later version. * +// * * +// * This program is distributed in the hope that it will be useful, * +// * but WITHOUT ANY WARRANTY; without even the implied warranty of * +// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +// * GNU General Public License for more details. * +// * * +// * You should have received a copy of the GNU General Public License * +// * along with this program. If not, see <http://www.gnu.org/licenses/>. * +// ************************************************************************* + +use super::*; + +#[test_device] +fn unencrypted_set_read_write(device: nitrokey::Storage) -> crate::Result<()> { + let mut ncli = Nitrocli::with_dev(device); + let out = ncli.handle(&["unencrypted", "set", "read-write"])?; + assert!(out.is_empty()); + + let device = nitrokey::Storage::connect()?; + assert!(device.get_status()?.unencrypted_volume.active); + assert!(!device.get_status()?.unencrypted_volume.read_only); + drop(device); + + let out = ncli.handle(&["unencrypted", "set", "read-only"])?; + assert!(out.is_empty()); + + let device = nitrokey::Storage::connect()?; + assert!(device.get_status()?.unencrypted_volume.active); + assert!(device.get_status()?.unencrypted_volume.read_only); + + Ok(()) +} |