summaryrefslogtreecommitdiff
path: root/src/tests/hidden.rs
blob: 1b072e1c9fae876ff970e242440b5f891fed126f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// hidden.rs

// Copyright (C) 2019-2020 The Nitrocli Developers
// SPDX-License-Identifier: GPL-3.0-or-later

use super::*;

#[test_device(storage)]
fn hidden_create_open_close(model: nitrokey::Model) -> anyhow::Result<()> {
  let mut ncli = Nitrocli::new().model(model).password("1234567");
  let out = ncli.handle(&["hidden", "create", "0", "50", "100"])?;
  assert!(out.is_empty());

  let out = ncli.handle(&["hidden", "open"])?;
  assert!(out.is_empty());

  {
    let mut manager = nitrokey::force_take()?;
    let device = manager.connect_storage()?;
    assert!(!device.get_storage_status()?.encrypted_volume.active);
    assert!(device.get_storage_status()?.hidden_volume.active);
  }

  let out = ncli.handle(&["hidden", "close"])?;
  assert!(out.is_empty());

  {
    let mut manager = nitrokey::force_take()?;
    let device = manager.connect_storage()?;
    assert!(!device.get_storage_status()?.encrypted_volume.active);
    assert!(!device.get_storage_status()?.hidden_volume.active);
  }

  Ok(())
}