CCCID/CHUID: add basic tests and do some cleanups

- Adds tests for CCCID/CHUID, allowing not found (is that ok?)
- Move constants under their respective modules and remove `YKPIV_`
This commit is contained in:
Tony Arcieri
2019-12-07 13:08:30 -08:00
parent 2587a4ac1e
commit 9482ae62ab
9 changed files with 142 additions and 59 deletions
+33 -1
View File
@@ -6,7 +6,7 @@
use lazy_static::lazy_static;
use log::trace;
use std::{env, sync::Mutex};
use yubikey_piv::{key::Key, YubiKey};
use yubikey_piv::{key::Key, Error, YubiKey};
lazy_static! {
/// Provide thread-safe access to a YubiKey
@@ -27,6 +27,38 @@ fn init_yubikey() -> Mutex<YubiKey> {
Mutex::new(yubikey)
}
//
// CCCID support
//
#[test]
#[ignore]
fn test_get_cccid() {
let mut yubikey = YUBIKEY.lock().unwrap();
match yubikey.cccid() {
Ok(cccid) => trace!("CCCID: {:?}", cccid),
Err(Error::NotFound) => trace!("CCCID not found"),
Err(err) => panic!("error getting CCCID: {:?}", err),
}
}
//
// CHUID support
//
#[test]
#[ignore]
fn test_get_chuid() {
let mut yubikey = YUBIKEY.lock().unwrap();
match yubikey.chuid() {
Ok(chuid) => trace!("CHUID: {:?}", chuid),
Err(Error::NotFound) => trace!("CHUID not found"),
Err(err) => panic!("error getting CHUID: {:?}", err),
}
}
//
// Device config support
//