summaryrefslogtreecommitdiff
path: root/src/tests/lock.rs
blob: e04e8eba1f75d4385647b2b4a2aa3f930672619e (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::with_model(model).handle(&["lock"])?;
  assert!(out.is_empty());

  Ok(())
}

#[test_device(storage)]
fn lock_storage(model: nitrokey::Model) -> anyhow::Result<()> {
  let mut ncli = Nitrocli::with_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(())
}