require "extlists"; require "variables"; require "envelope"; require "date"; test "Extlists - valid_ext_list" { if valid_ext_list [":addrbook:default", ":addrbook:personal"] { test_fail "Matched invalid list"; } test_config_set "sieve_valid_ext_list" ":addrbook:default"; if valid_ext_list [":addrbook:default", ":addrbook:personal"] { test_fail "Should not have matches all lists"; } test_config_set "sieve_valid_ext_list" ":addrbook:personal"; if not valid_ext_list [":addrbook:default", ":addrbook:personal"] { test_fail "Should have matches all lists"; } } test "Extlists - string" { set "a" "john@example.com"; set "b" "jane@example.com"; if string :list "${a}" ":addrbook:default" { test_fail "Invalid list string match"; } test_config_set "sieve_ext_list_item" ":addrbook:default" "${a}"; if not string :list "${a}" ":addrbook:default" { test_fail "Should have matched string"; } if not string :list ["${a}", "${b}"] ":addrbook:default" { test_fail "Should have matched string"; } } test_set "message" text: From: stephan@example.org To: sirius@friep.example.com To: sirius@frop.example.com Subject: Frop! Date: Mon, 20 Jul 2009 21:44:43 +0300 Delivery-Date: Mon, 22 Jul 2009 23:30:14 +0300 Wanna date? . ; test "Extlists - header" { if header :list "subject" "list:invalid-subjects" { test_fail "Invalid list header match"; } test_config_set "sieve_ext_list_item" "list:invalid-subjects" "Frop!"; if not header :list "subject" "list:invalid-subjects" { test_fail "Should have matched header"; } } test "Extlists - address" { if address :list "to" "list:invalid-recipients" { test_fail "Invalid list address match"; } test_config_set "sieve_ext_list_item" "list:invalid-recipients" "sirius@friep.example.com"; if not address :list "to" "list:invalid-recipients" { test_fail "Should have matched address"; } } test "Extlists - envelope" { test_set "envelope.from" "sirius@frop.example.com"; if envelope :all :list "from" "list:invalid-envelopes" { test_fail "Invalid list address match"; } test_config_set "sieve_ext_list_item" "list:invalid-envelopes" "sirius@frop.example.com"; if not envelope :all :list "from" "list:invalid-envelopes" { test_fail "Should have matched address"; } } test "Extlists - date" { if date :list :originalzone "date" "hour" "list:late-hours" { test_fail "Invalid list date match"; } test_config_set "sieve_ext_list_item" "list:late-hours" "21"; if not date :list :originalzone "date" "hour" "list:late-hours" { test_fail "Should have matched date"; } } test "Extlists - currentdate" { test_set "currentdate" "Mon, 20 Jul 2009 18:44:43 +0000 "; if currentdate :list "hour" "list:happy-hours" { test_fail "Invalid list currentdate match"; } test_config_set "sieve_ext_list_item" "list:happy-hours" "18"; if not currentdate :list "hour" "list:happy-hours" { test_fail "Should have matched currentdate"; } }