11use super :: schema:: CommonSecurityAdvisoryFramework ;
2- use crate :: csaf:: validation:: { test_6_01_01_missing_definition_of_product_id, test_6_01_02_multiple_definition_of_product_id, test_6_01_34_branches_recursion_depth, test_6_01_35_contradicting_remediations, Test , Validatable , ValidationPreset } ;
2+ use crate :: csaf:: validation:: { Test , Validatable , ValidationPreset } ;
3+ use crate :: csaf:: validations:: test_6_1_01:: test_6_1_01_missing_definition_of_product_id;
4+ use crate :: csaf:: validations:: test_6_1_02:: test_6_1_02_multiple_definition_of_product_id;
5+ use crate :: csaf:: validations:: test_6_1_34:: test_6_1_34_branches_recursion_depth;
6+ use crate :: csaf:: validations:: test_6_1_35:: test_6_1_35_contradicting_remediations;
37use std:: collections:: HashMap ;
48
59impl Validatable < CommonSecurityAdvisoryFramework > for CommonSecurityAdvisoryFramework {
@@ -20,84 +24,14 @@ impl Validatable<CommonSecurityAdvisoryFramework> for CommonSecurityAdvisoryFram
2024 fn tests ( & self ) -> HashMap < & str , Test < CommonSecurityAdvisoryFramework > > {
2125 type CsafTest = Test < CommonSecurityAdvisoryFramework > ;
2226 HashMap :: from ( [
23- ( "6.1.1" , test_6_01_01_missing_definition_of_product_id as CsafTest ) ,
24- ( "6.1.2" , test_6_01_02_multiple_definition_of_product_id as CsafTest ) ,
25- ( "6.1.34" , test_6_01_34_branches_recursion_depth as CsafTest ) ,
26- ( "6.1.35" , test_6_01_35_contradicting_remediations as CsafTest ) ,
27+ ( "6.1.1" , test_6_1_01_missing_definition_of_product_id as CsafTest ) ,
28+ ( "6.1.2" , test_6_1_02_multiple_definition_of_product_id as CsafTest ) ,
29+ ( "6.1.34" , test_6_1_34_branches_recursion_depth as CsafTest ) ,
30+ ( "6.1.35" , test_6_1_35_contradicting_remediations as CsafTest ) ,
2731 ] )
2832 }
2933
3034 fn doc ( & self ) -> & CommonSecurityAdvisoryFramework {
3135 self
3236 }
3337}
34-
35- #[ cfg( test) ]
36- mod tests {
37- use crate :: csaf:: csaf2_1:: loader:: load_document;
38- use crate :: csaf:: validation:: { test_6_01_01_missing_definition_of_product_id, test_6_01_02_multiple_definition_of_product_id, test_6_01_34_branches_recursion_depth, test_6_01_35_contradicting_remediations} ;
39-
40- #[ test]
41- fn test_test_6_01_01 ( ) {
42- let doc = load_document ( "../csaf/csaf_2.1/test/validator/data/mandatory/oasis_csaf_tc-csaf_2_1-2024-6-1-01-01.json" ) . unwrap ( ) ;
43- assert_eq ! (
44- test_6_01_01_missing_definition_of_product_id( & doc) ,
45- Err ( String :: from( "Missing definitions: [\" CSAFPID-9080700\" , \" CSAFPID-9080701\" ]" ) )
46- )
47- }
48-
49- #[ test]
50- fn test_test_6_01_02 ( ) {
51- let doc = load_document ( "../csaf/csaf_2.1/test/validator/data/mandatory/oasis_csaf_tc-csaf_2_1-2024-6-1-02-01.json" ) . unwrap ( ) ;
52- assert_eq ! (
53- test_6_01_02_multiple_definition_of_product_id( & doc) ,
54- Err ( String :: from(
55- "Duplicate definitions: [\" CSAFPID-9080700\" ]"
56- ) )
57- )
58- }
59-
60- #[ test]
61- fn test_test_6_01_34 ( ) {
62- for x in [ "11" ] . iter ( ) {
63- let doc = load_document ( format ! ( "../csaf/csaf_2.1/test/validator/data/mandatory/oasis_csaf_tc-csaf_2_1-2024-6-1-34-{}.json" , x) . as_str ( ) ) . unwrap ( ) ;
64- assert_eq ! (
65- Ok ( ( ) ) ,
66- test_6_01_35_contradicting_remediations( & doc)
67- )
68- }
69- for ( x, err) in [
70- ( "01" , "Branches recursion depth too big (> 30)" ) ,
71- ( "02" , "Branches recursion depth too big (> 30)" ) ,
72- ] . iter ( ) {
73- let doc = load_document ( format ! ( "../csaf/csaf_2.1/test/validator/data/mandatory/oasis_csaf_tc-csaf_2_1-2024-6-1-34-{}.json" , x) . as_str ( ) ) . unwrap ( ) ;
74- assert_eq ! (
75- Err ( format!( "{}" , err) ) ,
76- test_6_01_34_branches_recursion_depth( & doc)
77- )
78- }
79- }
80-
81- #[ test]
82- fn test_test_6_01_35 ( ) {
83- for x in [ "11" , "12" , "13" , "14" ] . iter ( ) {
84- let doc = load_document ( format ! ( "../csaf/csaf_2.1/test/validator/data/mandatory/oasis_csaf_tc-csaf_2_1-2024-6-1-35-{}.json" , x) . as_str ( ) ) . unwrap ( ) ;
85- assert_eq ! (
86- Ok ( ( ) ) ,
87- test_6_01_35_contradicting_remediations( & doc)
88- )
89- }
90- for ( x, err) in [
91- ( "01" , "Product CSAFPID-9080700 has contradicting remediations: no_fix_planned and vendor_fix" ) ,
92- ( "02" , "Product CSAFPID-9080700 has contradicting remediations: none_available and mitigation" ) ,
93- ( "03" , "Product CSAFPID-9080702 has contradicting remediations: workaround, fix_planned and optional_patch" ) ,
94- ( "04" , "Product CSAFPID-9080701 has contradicting remediations: mitigation, fix_planned and optional_patch" ) ,
95- ] . iter ( ) {
96- let doc = load_document ( format ! ( "../csaf/csaf_2.1/test/validator/data/mandatory/oasis_csaf_tc-csaf_2_1-2024-6-1-35-{}.json" , x) . as_str ( ) ) . unwrap ( ) ;
97- assert_eq ! (
98- Err ( format!( "{}" , err) ) ,
99- test_6_01_35_contradicting_remediations( & doc)
100- )
101- }
102- }
103- }
0 commit comments