aboutsummaryrefslogtreecommitdiff
path: root/src/tests/lock.rs
blob: 5180486381854e3afa3260ca6ee24ac517a7ef7c (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
// lock.rs

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

use super::*;

#[test_device(pro)]
fn lock_pro(model: nitrokey::Model) -> anyhow::Result<()> {
  // We can't really test much more here than just success of the command.
  let out = Nitrocli::new().model(model).handle(&["lock"])?;
  assert!(out.is_empty());

  Ok(())
}

#[test_device(storage)]
fn lock_storage(model: nitrokey::Model) -> anyhow::Result<()> {
  let mut ncli = Nitrocli::new().model(model);
  let _ = ncli.handle(&["encrypted", "open"])?;

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

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

  Ok(())
}