aboutsummaryrefslogtreecommitdiff
path: root/src/tests/list.rs
blob: cc969c696ccdecb4930c75fe5499913c9b19abfe (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
// list.rs

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

use super::*;

#[test_device]
fn not_connected() -> anyhow::Result<()> {
  let res = Nitrocli::new().handle(&["list"])?;
  assert_eq!(res, "No Nitrokey device connected\n");

  Ok(())
}

#[test_device]
fn connected(model: nitrokey::Model) -> anyhow::Result<()> {
  let re = regex::Regex::new(
    r#"^USB path\tmodel\tserial number
([[:^space:]]+\t(Pro|Storage|unknown)\t0x[[:xdigit:]]+
)+$"#,
  )
  .unwrap();

  let out = Nitrocli::new().model(model).handle(&["list"])?;
  assert!(re.is_match(&out), out);
  Ok(())
}