+
+
+-- | Make sure we're dropping based on the address and not the goto.
+--
+test_dropby_mxlist_affects_address :: TestTree
+test_dropby_mxlist_affects_address =
+ testCase desc $ do
+ let fwds = [fwd "user1@example.com" "user2@example.net"]
+ let mx_set = Set.fromList [normalize_string "mx.example.net"]
+ let example_mx_pairs = [(normalize_string "example.net.", mx_set)]
+ let mx_map = Map.fromList example_mx_pairs
+ let droplist = ["mx.example.net", "mx2.example.net"]
+ let normal_droplist = map normalize_string droplist
+ let actual = dropby_mxlist normal_droplist mx_map fwds
+ let expected = fwds
+ actual @?= expected
+ where
+ desc = "dropby_mxlist affects the \"address\" and not the \"goto"
+
+
+-- | Use weird caps, and optional trailing dot all over the place to
+-- make sure everything is handled normalized.
+--
+test_dropby_mxlist_compares_normalized :: TestTree
+test_dropby_mxlist_compares_normalized =
+ testCase desc $ do
+ let fwds = [fwd "user1@exAmPle.com." "user2@examPle.net"]
+ let mx_set = Set.fromList [normalize_string "mx.EXAMPLE.com"]
+ let example_mx_pairs = [(normalize_string "Example.com", mx_set)]
+ let mx_map = Map.fromList example_mx_pairs
+ let droplist = ["mx.EXAMple.com", "mx2.example.COM"]
+ let normal_droplist = map normalize_string droplist
+ let actual = dropby_mxlist normal_droplist mx_map fwds
+ let expected = []
+ actual @?= expected
+ where
+ desc = "dropby_mxlist only performs comparisons on normalized names"
+
+
+
+-- | Check that if a forward has two MXes, only one of which appears
+-- in the list of excluded MXes, it doesn't get dropped.
+--
+test_dropby_mxlist_requires_subset :: TestTree
+test_dropby_mxlist_requires_subset =
+ testCase desc $ do
+ let fwds = [fwd "user1@example.com" "user2@example.net"]
+ let mx_set = Set.fromList ["mx1.example.com", "mx2.example.com"]
+ let normal_mx_set = Set.map normalize_string mx_set
+ let example_mx_pairs = [(normalize_string "example.com.", normal_mx_set)]
+ let mx_map = Map.fromList example_mx_pairs
+ let droplist = ["mx1.example.com"]
+ let normal_droplist = map normalize_string droplist
+ let actual = dropby_mxlist normal_droplist mx_map fwds
+ let expected = fwds
+ actual @?= expected
+ where
+ desc = "dropby_mxlist requires all mx to be in the exclude list"