webauthn_authenticator_rs/ctap2/commands/
reset.rs1use serde::Serialize;
2
3use self::CBORCommand;
4use super::*;
5
6#[derive(Serialize, Debug, Clone)]
14pub struct ResetRequest {}
15
16impl CBORCommand for ResetRequest {
17 const CMD: u8 = 0x07;
18 const HAS_PAYLOAD: bool = false;
19 type Response = NoResponse;
20}
21
22#[cfg(test)]
23mod tests {
24 use super::*;
25 use crate::transport::iso7816::ISO7816LengthForm;
26
27 #[test]
28 fn reset_request() {
29 let req = ResetRequest {};
30 let short = vec![0x80, 0x10, 0, 0, 1, 0x7, 0];
31 let ext = vec![0x80, 0x10, 0, 0, 0, 0, 1, 0x7, 0, 0];
32
33 let a = to_short_apdus(&req.cbor().unwrap());
34 assert_eq!(1, a.len());
35 assert_eq!(short, a[0].to_bytes(&ISO7816LengthForm::ShortOnly).unwrap());
36 assert_eq!(short, a[0].to_bytes(&ISO7816LengthForm::Extended).unwrap());
37
38 assert_eq!(
39 ext,
40 to_extended_apdu(req.cbor().unwrap())
41 .to_bytes(&ISO7816LengthForm::Extended)
42 .unwrap()
43 );
44 assert_eq!(
45 ext,
46 to_extended_apdu(req.cbor().unwrap())
47 .to_bytes(&ISO7816LengthForm::ExtendedOnly)
48 .unwrap()
49 );
50 assert!(to_extended_apdu(req.cbor().unwrap())
51 .to_bytes(&ISO7816LengthForm::ShortOnly)
52 .is_err());
53 }
54}