diff --git a/Makefile.am b/Makefile.am index c9638a16ab19f473e2f14c6f064974662ec7bcb5..fd136e063c842519ef6982c9f89711860f729f47 100644 --- a/Makefile.am +++ b/Makefile.am @@ -61,6 +61,7 @@ test_cases = \ tests/extensions/body/basic.svtest \ tests/extensions/body/match-values.svtest \ tests/extensions/regex/basic.svtest \ + tests/extensions/regex/match-values.svtest \ tests/extensions/regex/errors.svtest \ tests/extensions/reject/execute.svtest \ tests/extensions/relational/basic.svtest \ diff --git a/tests/extensions/regex/match-values.svtest b/tests/extensions/regex/match-values.svtest new file mode 100644 index 0000000000000000000000000000000000000000..04506a684d1955b8d41d7d2c31b188a0dd9efc46 --- /dev/null +++ b/tests/extensions/regex/match-values.svtest @@ -0,0 +1,68 @@ +require "vnd.dovecot.testsuite"; + +require "regex"; +require "variables"; + +test_set "message" text: +From: Andy Howell <AndyHowell@example.com> +Sender: antlr-interest-bounces@antlr.org +To: Stephan Bosch <stephan@rename-it.nl> +Subject: [Dovecot] Sieve regex match problem + +Hi, + +I is broken. +. +; + +test "Basic match values 1" { + if header :regex ["Sender"] ["([^-@]*)-([^-@]*)(-bounces)?@antlr.org"] { + + if not string :is "${1}" "antlr" { + test_fail "first match value is not correct"; + } + + if not string :is "${2}" "interest" { + test_fail "second match value is not correct"; + } + + if not string :is "${3}" "-bounces" { + test_fail "third match value is not correct"; + } + + if string :is "${4}" "-bounces" { + test_fail "fourth match contains third value"; + } + } +} + +test "Basic match values 2" { + if header :regex ["Sender"] ["(.*>[ \\t]*,?[ \\t]*)?([^-@]*)-([^-@]*)(-bounces)?@antlr.org"] { + + if not string :is "${1}" "" { + test_fail "first match value is not correct: ${1}"; + } + + if not string :is "${2}" "antlr" { + test_fail "second match value is not correct: ${2}"; + } + + if not string :is "${3}" "interest" { + test_fail "third match value is not correct: ${3}"; + } + + if not string :is "${4}" "-bounces" { + test_fail "fourth match value is not correct: ${4}"; + } + + if string :is "${5}" "-bounces" { + test_fail "fifth match contains fourth value: ${5}"; + } + } +} + + + + + +