summaryrefslogtreecommitdiff
path: root/src/tests/hidden.rs
blob: 82a463052583d7b4883f26ec8983cb4bf18e9032 (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::with_model(model);
  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(())
}