mirror of
https://github.com/trussed-dev/piv-authenticator.git
synced 2026-06-20 04:16:15 -07:00
Add admin test with opensc
This commit is contained in:
+8
-2
@@ -565,7 +565,10 @@ impl<'a, T: trussed::Client + trussed::client::Ed255> LoadedAuthenticator<'a, T>
|
||||
reply: Reply<'_, R>,
|
||||
) -> Result {
|
||||
info!("Response for challenge ");
|
||||
self.admin_challenge_respond(requested_alg, data, reply)
|
||||
match self.state.runtime.take_challenge() {
|
||||
Some(original) => self.admin_challenge_validate(requested_alg, data, original, reply),
|
||||
None => self.admin_challenge_respond(requested_alg, data, reply),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn admin_challenge_respond<const R: usize>(
|
||||
@@ -717,7 +720,10 @@ impl<'a, T: trussed::Client + trussed::client::Ed255> LoadedAuthenticator<'a, T>
|
||||
reply: Reply<'_, R>,
|
||||
) -> Result {
|
||||
info!("Admin witness");
|
||||
self.admin_witness_respond(requested_alg, data, reply)
|
||||
match self.state.runtime.take_witness() {
|
||||
Some(original) => self.admin_witness_validate(requested_alg, data, original, reply),
|
||||
None => self.admin_witness_respond(requested_alg, data, reply),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn admin_witness_respond<const R: usize>(
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
mod card;
|
||||
|
||||
use std::process::Command;
|
||||
|
||||
use card::with_vsc;
|
||||
|
||||
use expectrl::{spawn, Eof, Regex, WaitStatus};
|
||||
@@ -20,3 +22,37 @@ fn list() {
|
||||
assert_eq!(p.wait().unwrap(), WaitStatus::Exited(p.pid(), 0));
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn admin_mutual() {
|
||||
with_vsc(|| {
|
||||
let mut command = Command::new("piv-tool");
|
||||
command
|
||||
.env("PIV_EXT_AUTH_KEY", "tests/default_admin_key")
|
||||
.args(&["-A", "M:9B:03"]);
|
||||
let mut p = expectrl::session::Session::spawn(command).unwrap();
|
||||
p.check("Using reader with a card: Virtual PCD 00 00")
|
||||
.unwrap();
|
||||
p.check("Personal Identity Verification Card").unwrap();
|
||||
p.check(Eof).unwrap();
|
||||
assert_eq!(p.wait().unwrap(), WaitStatus::Exited(p.pid(), 0));
|
||||
});
|
||||
}
|
||||
|
||||
// I can't understand the error for this specific case, it may be comming from opensc and not us.
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn admin_card() {
|
||||
with_vsc(|| {
|
||||
let mut command = Command::new("piv-tool");
|
||||
command
|
||||
.env("PIV_EXT_AUTH_KEY", "tests/default_admin_key")
|
||||
.args(&["-A", "A:9B:03"]);
|
||||
let mut p = expectrl::session::Session::spawn(command).unwrap();
|
||||
p.check("Using reader with a card: Virtual PCD 00 00")
|
||||
.unwrap();
|
||||
p.check("Personal Identity Verification Card").unwrap();
|
||||
p.check(Eof).unwrap();
|
||||
assert_eq!(p.wait().unwrap(), WaitStatus::Exited(p.pid(), 0));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user