Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions tests/x509_limbo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use webpki::{
#[ignore] // Runs slower than other unit tests - opt-in with `cargo test -- --include-ignored`
#[test]
fn x509_limbo() {
let limbo: Limbo = serde_json::from_slice(LIMBO_JSON).expect("invalid test JSON");
let limbo = serde_json::from_slice::<Limbo>(LIMBO_JSON).expect("invalid test JSON");

let exceptions = serde_json::from_reader(
File::open("third-party/x509-limbo/exceptions.json")
Expand Down Expand Up @@ -69,21 +69,18 @@ fn evaluate_testcase(tc: &Testcase, exceptions: &HashMap<String, Exception>) ->
}

let validation_result = run_validation(tc);
let actual_success = validation_result.is_ok();
let expected_success = matches!(tc.expected_result, ExpectedResult::Success);

if let Some(exception) = exceptions.get(tc.id.as_str()) {
if actual_success == (exception.actual == "SUCCESS") {
if validation_result.is_ok() == (exception.actual == "SUCCESS") {
return Outcome::KnownDivergence;
}
// If the exception no longer applies (behavior changed), fall through to normal comparison
}

// Compare actual vs expected
match (expected_success, validation_result) {
(true, Ok(())) | (false, Err(_)) => Outcome::Pass,
(true, Err(err)) => Outcome::UnexpectedFailure(err),
(false, Ok(())) => Outcome::UnexpectedSuccess,
match (tc.expected_result, validation_result) {
(ExpectedResult::Success, Ok(())) | (ExpectedResult::Failure, Err(_)) => Outcome::Pass,
(ExpectedResult::Success, Err(err)) => Outcome::UnexpectedFailure(err),
(ExpectedResult::Failure, Ok(())) => Outcome::UnexpectedSuccess,
}
}

Expand All @@ -93,22 +90,22 @@ fn run_validation(tc: &Testcase) -> Result<(), String> {
let leaf =
EndEntityCert::try_from(&leaf_der).map_err(|e| format!("leaf cert parse failed: {e}"))?;

let intermediates: Vec<_> = tc
let intermediates = tc
.untrusted_intermediates
.iter()
.map(|ic| cert_der_from_pem(ic))
.collect();
.collect::<Vec<_>>();

let trust_anchor_ders: Vec<_> = tc
let trust_anchor_ders = tc
.trusted_certs
.iter()
.map(|ta| cert_der_from_pem(ta))
.collect();
.collect::<Vec<_>>();

let trust_anchors: Vec<_> = trust_anchor_ders
let trust_anchors = trust_anchor_ders
.iter()
.filter_map(|der| anchor_from_trusted_cert(der).ok())
.collect();
.collect::<Vec<_>>();

if trust_anchors.is_empty() && !trust_anchor_ders.is_empty() {
return Err("trust anchor extraction failed".into());
Expand All @@ -122,7 +119,7 @@ fn run_validation(tc: &Testcase) -> Result<(), String> {

let sig_algs = rustls_aws_lc_rs::ALL_VERIFICATION_ALGS;

let crls: Vec<_> = tc
let crls = tc
.crls
.iter()
.map(|pem| {
Expand All @@ -134,8 +131,8 @@ fn run_validation(tc: &Testcase) -> Result<(), String> {
.expect("CRL DER parse failed")
.into()
})
.collect();
let crls: Vec<_> = crls.iter().collect();
.collect::<Vec<_>>();
let crls = crls.iter().collect::<Vec<_>>();

let revocation_options = if !crls.is_empty() {
let opts = RevocationOptionsBuilder::new(crls.as_slice()).unwrap();
Expand Down
Loading