use matter_commissioning::{AttestationError, Dac, Paa, PaaTrustStore, Pai, ProductId, VendorId};
const DAC_DER: &[u8] = include_bytes!(
"../../../test-vectors/certs/attestation/happy-path/Chip-Test-DAC-FFF1-8000-0004-Cert.der"
);
const PAI_DER: &[u8] = include_bytes!(
"../../../test-vectors/certs/attestation/happy-path/Chip-Test-PAI-FFF1-8000-Cert.der"
);
#[test]
#[allow(clippy::expect_used)] fn dac_parses_with_expected_identifiers() {
let dac = Dac::from_der(DAC_DER).expect("happy-path DAC parses");
assert_eq!(dac.subject_vid(), VendorId::new(0xFFF1));
assert_eq!(dac.subject_pid(), ProductId::new(0x8000));
assert_eq!(dac.public_key().len(), 65);
assert_eq!(dac.public_key()[0], 0x04);
assert_eq!(dac.der(), DAC_DER);
}
#[test]
#[allow(clippy::expect_used)] fn pai_parses_with_expected_identifiers() {
let pai = Pai::from_der(PAI_DER).expect("happy-path PAI parses");
assert_eq!(pai.subject_vid(), VendorId::new(0xFFF1));
assert_eq!(pai.subject_pid(), Some(ProductId::new(0x8000)));
}
#[test]
fn with_example_device_roots_contains_pai_issuer_root() {
let store = PaaTrustStore::with_example_device_roots();
let has_matching_vid = store
.iter()
.any(|paa| paa.subject_vid() == Some(VendorId::new(0xFFF1)));
assert!(
has_matching_vid,
"bundled CSA test roots include a PAA for VID 0xFFF1"
);
}
#[test]
fn paa_from_der_rejects_a_dac() {
let err = Paa::from_der(DAC_DER);
assert!(matches!(err, Err(AttestationError::Parse(_))));
}