|
1 | 1 | use super::product_helper::*; |
2 | 2 | use super::schema::CommonSecurityAdvisoryFramework; |
3 | 3 | use crate::csaf::helpers::find_duplicates; |
4 | | -use crate::csaf::validation::{Test, Validatable, ValidationPreset}; |
| 4 | +use crate::csaf::validation::{test_6_01_35_contradicting_remediations, Test, Validatable, ValidationPreset}; |
5 | 5 | use std::collections::{HashMap, HashSet}; |
6 | 6 |
|
7 | 7 | impl Validatable<CommonSecurityAdvisoryFramework> for CommonSecurityAdvisoryFramework { |
8 | 8 | fn presets(&self) -> HashMap<ValidationPreset, Vec<&str>> { |
| 9 | + let basic_tests = Vec::from(["6.1.1", "6.1.2", "6.1.34", "6.1.35"]); |
| 10 | + // More tests may be added in extend() here later |
| 11 | + let extended_tests: Vec<&str> = basic_tests.clone(); |
| 12 | + // extended_tests.extend(["foo"].iter()); |
| 13 | + let full_tests: Vec<&str> = extended_tests.clone(); |
| 14 | + // full_tests.extend(["bar"].iter()); |
9 | 15 | HashMap::from([ |
10 | | - ( |
11 | | - ValidationPreset::Basic, |
12 | | - Vec::from(["6.1.1", "6.1.2", "6.1.34"]), |
13 | | - ), |
14 | | - (ValidationPreset::Extended, Vec::from(["6.1.1", "6.1.2"])), |
15 | | - (ValidationPreset::Full, Vec::from(["6.1.1", "6.1.2"])), |
| 16 | + (ValidationPreset::Basic, basic_tests), |
| 17 | + (ValidationPreset::Extended, extended_tests), |
| 18 | + (ValidationPreset::Full, full_tests), |
16 | 19 | ]) |
17 | 20 | } |
18 | 21 |
|
19 | 22 | fn tests(&self) -> HashMap<&str, Test<CommonSecurityAdvisoryFramework>> { |
20 | | - HashMap::<&str, Test<CommonSecurityAdvisoryFramework>>::from([ |
21 | | - ("6.1.1", test_6_01_01_missing_definition_of_product_id), |
22 | | - ("6.1.2", test_6_01_02_multiple_definition_of_product_id), |
23 | | - ("6.1.34", test_6_01_34_branches_recursion_depth), |
24 | | - ] |
25 | | - as [(&str, Test<CommonSecurityAdvisoryFramework>); 3]) |
| 23 | + type CsafTest = Test<CommonSecurityAdvisoryFramework>; |
| 24 | + HashMap::from([ |
| 25 | + ("6.1.1", test_6_01_01_missing_definition_of_product_id as CsafTest), |
| 26 | + ("6.1.2", test_6_01_02_multiple_definition_of_product_id as CsafTest), |
| 27 | + ("6.1.34", test_6_01_34_branches_recursion_depth as CsafTest), |
| 28 | + ("6.1.35", test_6_01_35_contradicting_remediations as CsafTest), |
| 29 | + ]) |
26 | 30 | } |
27 | 31 |
|
28 | 32 | fn doc(&self) -> &CommonSecurityAdvisoryFramework { |
@@ -82,6 +86,7 @@ mod tests { |
82 | 86 | validation::test_6_01_02_multiple_definition_of_product_id, |
83 | 87 | validation::test_6_01_34_branches_recursion_depth, |
84 | 88 | }; |
| 89 | + use crate::csaf::validation::test_6_01_35_contradicting_remediations; |
85 | 90 |
|
86 | 91 | #[test] |
87 | 92 | fn test_test_6_01_01() { |
@@ -111,4 +116,13 @@ mod tests { |
111 | 116 | Err(String::from("Recursion depth too big: 31")) |
112 | 117 | ) |
113 | 118 | } |
| 119 | + |
| 120 | + #[test] |
| 121 | + fn test_test_6_01_35() { |
| 122 | + let doc = load_document("../csaf/csaf_2.1/test/validator/data/mandatory/oasis_csaf_tc-csaf_2_1-2024-6-1-35-01.json").unwrap(); |
| 123 | + assert_eq!( |
| 124 | + test_6_01_35_contradicting_remediations(&doc), |
| 125 | + Err(String::from("Product CSAFPID-9080700 has contradicting remediations: no_fix_planned and vendor_fix")) |
| 126 | + ) |
| 127 | + } |
114 | 128 | } |
0 commit comments