From cf3831f0b01d2e29f9e3a3946213a03cf3cea5bb Mon Sep 17 00:00:00 2001 From: occheung Date: Fri, 13 Nov 2020 17:30:47 +0800 Subject: [PATCH] cert dir_name: add union/intersect test --- src/certificate.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/certificate.rs b/src/certificate.rs index 9de4be8..3d20e75 100644 --- a/src/certificate.rs +++ b/src/certificate.rs @@ -1882,5 +1882,37 @@ mod test { expected_subtrees.push(specific_general_name.clone()); get_subtree_union(&mut state_subtrees, &cert_subtrees); assert_eq!(state_subtrees, expected_subtrees); + + // Intersection / Union with permutated name + state_subtrees.clear(); + cert_subtrees.clear(); + expected_subtrees.clear(); + state_subtrees.push(broad_general_name.clone()); + state_subtrees.push(specific_general_name.clone()); + cert_subtrees.push(permutated_general_name.clone()); + expected_subtrees.push(broad_general_name.clone()); + get_subtree_intersection(&mut state_subtrees, &cert_subtrees); + assert_eq!(state_subtrees, expected_subtrees); + + state_subtrees.clear(); + cert_subtrees.clear(); + expected_subtrees.clear(); + state_subtrees.push(broad_general_name.clone()); + cert_subtrees.push(permutated_general_name.clone()); + cert_subtrees.push(disjoint_general_name.clone()); + expected_subtrees.push(permutated_general_name.clone()); + expected_subtrees.push(disjoint_general_name.clone()); + get_subtree_union(&mut state_subtrees, &cert_subtrees); + assert_eq!(state_subtrees, expected_subtrees); + + // DirectoryName operation with empty list + state_subtrees.clear(); + cert_subtrees.clear(); + expected_subtrees.clear(); + state_subtrees.push(broad_general_name.clone()); + state_subtrees.push(specific_general_name.clone()); + expected_subtrees.push(broad_general_name.clone()); + get_subtree_intersection(&mut state_subtrees, &cert_subtrees); + assert_eq!(state_subtrees, expected_subtrees); } }