diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-11-17 13:18:48 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2011-11-17 13:18:48 +0000 |
| commit | 445c436db6d8f52c771042e3e16f7a5ff101f882 (patch) | |
| tree | 884f44483e2eab7967eb3a1df8793a79ac28dd44 /plugins/managesieve/tests | |
| parent | e019ceea8f10f9be13be0da0cceb4df8f992d6b6 (diff) | |
- Added 'address' and 'envelope' tests support
- Added 'body' extension support (RFC5173)
- Added 'subaddress' extension support (RFC5233)
- Added comparators support
- Changed Sender/Recipient labels to From/To
- Fixed importing rule names from Ingo
- Fixed handling of extensions disabled in config
git-svn-id: https://svn.roundcube.net/trunk@5441 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'plugins/managesieve/tests')
| -rw-r--r-- | plugins/managesieve/tests/parser.phpt | 35 | ||||
| -rw-r--r-- | plugins/managesieve/tests/parser_body.phpt | 49 | ||||
| -rw-r--r-- | plugins/managesieve/tests/parser_imapflags.phpt | 2 | ||||
| -rw-r--r-- | plugins/managesieve/tests/parser_include.phpt | 30 | ||||
| -rw-r--r-- | plugins/managesieve/tests/parser_kep14.phpt | 2 | ||||
| -rw-r--r-- | plugins/managesieve/tests/parser_prefix.phpt | 25 | ||||
| -rw-r--r-- | plugins/managesieve/tests/parser_variables.phpt | 39 | ||||
| -rw-r--r-- | plugins/managesieve/tests/parset_subaddress.phpt | 38 |
8 files changed, 213 insertions, 7 deletions
diff --git a/plugins/managesieve/tests/parser.phpt b/plugins/managesieve/tests/parser.phpt index 32866335a..aec042187 100644 --- a/plugins/managesieve/tests/parser.phpt +++ b/plugins/managesieve/tests/parser.phpt @@ -6,7 +6,7 @@ Main test of script parser include '../lib/rcube_sieve_script.php'; $txt = ' -require ["fileinto","reject"]; +require ["fileinto","reject","envelope"]; # rule:[spam] if anyof (header :contains "X-DSPAM-Result" "Spam") { @@ -14,13 +14,13 @@ if anyof (header :contains "X-DSPAM-Result" "Spam") stop; } # rule:[test1] -if anyof (header :contains ["From","To"] "test@domain.tld") +if anyof (header :comparator "i;ascii-casemap" :contains ["From","To"] "test@domain.tld") { discard; stop; } # rule:[test2] -if anyof (not header :contains ["Subject"] "[test]", header :contains "Subject" "[test2]") +if anyof (not header :comparator "i;octet" :contains ["Subject"] "[test]", header :contains "Subject" "[test2]") { fileinto "test"; stop; @@ -46,14 +46,27 @@ if true stop; } fileinto "Test"; +# rule:[address test] +if address :all :is "From" "nagios@domain.tld" +{ + fileinto "domain.tld"; + stop; +} +# rule:[envelope test] +if envelope :domain :is "From" "domain.tld" +{ + fileinto "domain.tld"; + stop; +} '; $s = new rcube_sieve_script($txt); echo $s->as_text(); +// ------------------------------------------------------------------------------- ?> --EXPECT-- -require ["fileinto","reject"]; +require ["fileinto","reject","envelope"]; # rule:[spam] if header :contains "X-DSPAM-Result" "Spam" { @@ -67,7 +80,7 @@ if header :contains ["From","To"] "test@domain.tld" stop; } # rule:[test2] -if anyof (not header :contains "Subject" "[test]", header :contains "Subject" "[test2]") +if anyof (not header :comparator "i;octet" :contains "Subject" "[test]", header :contains "Subject" "[test2]") { fileinto "test"; stop; @@ -93,3 +106,15 @@ if true stop; } fileinto "Test"; +# rule:[address test] +if address :all :is "From" "nagios@domain.tld" +{ + fileinto "domain.tld"; + stop; +} +# rule:[envelope test] +if envelope :domain :is "From" "domain.tld" +{ + fileinto "domain.tld"; + stop; +} diff --git a/plugins/managesieve/tests/parser_body.phpt b/plugins/managesieve/tests/parser_body.phpt new file mode 100644 index 000000000..08ad54959 --- /dev/null +++ b/plugins/managesieve/tests/parser_body.phpt @@ -0,0 +1,49 @@ +--TEST-- +Test of Sieve body extension (RFC5173) +--SKIPIF-- +--FILE-- +<?php +include '../lib/rcube_sieve_script.php'; + +$txt = ' +require ["body","fileinto"]; +if body :raw :contains "MAKE MONEY FAST" +{ + stop; +} +if body :content "text" :contains ["missile","coordinates"] +{ + fileinto "secrets"; +} +if body :content "audio/mp3" :contains "" +{ + fileinto "jukebox"; +} +if body :text :contains "project schedule" +{ + fileinto "project/schedule"; +} +'; + +$s = new rcube_sieve_script($txt); +echo $s->as_text(); + +?> +--EXPECT-- +require ["body","fileinto"]; +if body :raw :contains "MAKE MONEY FAST" +{ + stop; +} +if body :content "text" :contains ["missile","coordinates"] +{ + fileinto "secrets"; +} +if body :content "audio/mp3" :contains "" +{ + fileinto "jukebox"; +} +if body :text :contains "project schedule" +{ + fileinto "project/schedule"; +} diff --git a/plugins/managesieve/tests/parser_imapflags.phpt b/plugins/managesieve/tests/parser_imapflags.phpt index 025927267..a4bc465a3 100644 --- a/plugins/managesieve/tests/parser_imapflags.phpt +++ b/plugins/managesieve/tests/parser_imapflags.phpt @@ -14,7 +14,7 @@ if header :matches "Subject" "^Test$" { } '; -$s = new rcube_sieve_script($txt); +$s = new rcube_sieve_script($txt, array('imapflags')); echo $s->as_text(); ?> diff --git a/plugins/managesieve/tests/parser_include.phpt b/plugins/managesieve/tests/parser_include.phpt new file mode 100644 index 000000000..addc0d449 --- /dev/null +++ b/plugins/managesieve/tests/parser_include.phpt @@ -0,0 +1,30 @@ +--TEST-- +Test of Sieve include extension +--SKIPIF-- +--FILE-- +<?php +include '../lib/rcube_sieve_script.php'; + +$txt = ' +require ["include"]; + +include "script.sieve"; +# rule:[two] +if true +{ + include :optional "second.sieve"; +} +'; + +$s = new rcube_sieve_script($txt, array(), array('variables')); +echo $s->as_text(); + +?> +--EXPECT-- +require ["include"]; +include "script.sieve"; +# rule:[two] +if true +{ + include :optional "second.sieve"; +} diff --git a/plugins/managesieve/tests/parser_kep14.phpt b/plugins/managesieve/tests/parser_kep14.phpt index 06beaeda1..dcdbd48a0 100644 --- a/plugins/managesieve/tests/parser_kep14.phpt +++ b/plugins/managesieve/tests/parser_kep14.phpt @@ -10,7 +10,7 @@ $txt = ' # EDITOR_VERSION 123 '; -$s = new rcube_sieve_script($txt, array()); +$s = new rcube_sieve_script($txt, array('body')); echo $s->as_text(); ?> diff --git a/plugins/managesieve/tests/parser_prefix.phpt b/plugins/managesieve/tests/parser_prefix.phpt new file mode 100644 index 000000000..c87e9658f --- /dev/null +++ b/plugins/managesieve/tests/parser_prefix.phpt @@ -0,0 +1,25 @@ +--TEST-- +Test of prefix comments handling +--SKIPIF-- +--FILE-- +<?php +include '../lib/rcube_sieve_script.php'; + +$txt = ' +# this is a comment +# and the second line + +require ["variables"]; +set "b" "c"; +'; + +$s = new rcube_sieve_script($txt, array(), array('variables')); +echo $s->as_text(); + +?> +--EXPECT-- +# this is a comment +# and the second line + +require ["variables"]; +set "b" "c"; diff --git a/plugins/managesieve/tests/parser_variables.phpt b/plugins/managesieve/tests/parser_variables.phpt new file mode 100644 index 000000000..cf1f8fcad --- /dev/null +++ b/plugins/managesieve/tests/parser_variables.phpt @@ -0,0 +1,39 @@ +--TEST-- +Test of Sieve variables extension +--SKIPIF-- +--FILE-- +<?php +include '../lib/rcube_sieve_script.php'; + +$txt = ' +require ["variables"]; +set "honorific" "Mr"; +set "vacation" text: +Dear ${HONORIFIC} ${last_name}, +I am out, please leave a message after the meep. +. +; +set :length "b" "${a}"; +set :lower "b" "${a}"; +set :upperfirst "b" "${a}"; +set :upperfirst :lower "b" "${a}"; +set :quotewildcard "b" "Rock*"; +'; + +$s = new rcube_sieve_script($txt, array(), array('variables')); +echo $s->as_text(); + +?> +--EXPECT-- +require ["variables"]; +set "honorific" "Mr"; +set "vacation" text: +Dear ${HONORIFIC} ${last_name}, +I am out, please leave a message after the meep. +. +; +set :length "b" "${a}"; +set :lower "b" "${a}"; +set :upperfirst "b" "${a}"; +set :upperfirst :lower "b" "${a}"; +set :quotewildcard "b" "Rock*"; diff --git a/plugins/managesieve/tests/parset_subaddress.phpt b/plugins/managesieve/tests/parset_subaddress.phpt new file mode 100644 index 000000000..6d4d03c6e --- /dev/null +++ b/plugins/managesieve/tests/parset_subaddress.phpt @@ -0,0 +1,38 @@ +--TEST-- +Test of Sieve subaddress extension (RFC5233) +--SKIPIF-- +--FILE-- +<?php +include '../lib/rcube_sieve_script.php'; + +$txt = ' +require ["envelope","subaddress","fileinto"]; +if envelope :user "To" "postmaster" +{ + fileinto "postmaster"; + stop; +} +if envelope :detail :is "To" "mta-filters" +{ + fileinto "mta-filters"; + stop; +} +'; + +$s = new rcube_sieve_script($txt); +echo $s->as_text(); + +// ------------------------------------------------------------------------------- +?> +--EXPECT-- +require ["envelope","subaddress","fileinto"]; +if envelope :user "To" "postmaster" +{ + fileinto "postmaster"; + stop; +} +if envelope :detail :is "To" "mta-filters" +{ + fileinto "mta-filters"; + stop; +} |
