Run validation on all local test files that have been downloaded via the `test-files download` command.
(&self)
| 97 | /// Run validation on all local test files that have been downloaded via the |
| 98 | /// `test-files download` command. |
| 99 | pub fn run_tests(&self) -> Result<(), Error> { |
| 100 | let test_files = self.find_files_of_type()?; |
| 101 | info!( |
| 102 | "Found {} {} files for testing", |
| 103 | test_files.len(), |
| 104 | self.file_type |
| 105 | ); |
| 106 | |
| 107 | // Cache the certificates used for VOA-based verification as that significantly increases |
| 108 | // speed. |
| 109 | let os = Os::from_str("arch").map_err(voa::Error::VoaCore)?; |
| 110 | |
| 111 | let (artifact_verifiers, anchors) = if matches!(self.file_type, TestFileType::Signatures) { |
| 112 | let artifact_verifiers = read_openpgp_verifiers( |
| 113 | os.clone(), |
| 114 | Purpose::from_str("package").map_err(voa::Error::VoaCore)?, |
| 115 | Context::Default, |
| 116 | ); |
| 117 | let anchors = read_openpgp_verifiers( |
| 118 | os.clone(), |
| 119 | Purpose::from_str("trust-anchor-package").map_err(voa::Error::VoaCore)?, |
| 120 | Context::Default, |
| 121 | ); |
| 122 | (artifact_verifiers, anchors) |
| 123 | } else { |
| 124 | (Vec::new(), Vec::new()) |
| 125 | }; |
| 126 | |
| 127 | let config = get_voa_config(); |
| 128 | let purpose_and_context = PurposeAndContext::new( |
| 129 | Some(Purpose::from_str("package").map_err(voa::Error::VoaCore)?), |
| 130 | Some(Context::Default), |
| 131 | ); |
| 132 | let openpgp_settings = |
| 133 | get_technology_settings(&config, &os, purpose_and_context.as_ref()).openpgp_settings(); |
| 134 | |
| 135 | let model_verifier = |
| 136 | ModelBasedVerifier::new(openpgp_settings, &artifact_verifiers, &anchors); |
| 137 | |
| 138 | let progress_bar = get_progress_bar(test_files.len() as u64); |
| 139 | |
| 140 | // Run the validate subcommand for all files in parallel. |
| 141 | let asserts: Vec<(PathBuf, Result<(), Error>)> = test_files |
| 142 | .into_par_iter() |
| 143 | .map(|file| { |
| 144 | let result = match self.file_type { |
| 145 | TestFileType::BuildInfo => BuildInfo::from_file_with_schema(&file, None) |
| 146 | .map(|_| ()) |
| 147 | .map_err(|err| err.into()), |
| 148 | TestFileType::SrcInfo => SourceInfo::from_file_with_schema(&file, None) |
| 149 | .map(|_| ()) |
| 150 | .map_err(|err| err.into()), |
| 151 | TestFileType::MTree => Mtree::from_file_with_schema(&file, None) |
| 152 | .map(|_| ()) |
| 153 | .map_err(|err| err.into()), |
| 154 | TestFileType::PackageInfo => PackageInfo::from_file_with_schema(&file, None) |
| 155 | .map(|_| ()) |
| 156 | .map_err(|err| err.into()), |
no test coverage detected