diff options
author | Thomas Schmid <schmid-thomas@gmx.net> | 2020-07-11 13:44:32 +0300 |
---|---|---|
committer | Thomas Schmid <schmid-thomas@gmx.net> | 2020-07-11 13:44:32 +0300 |
commit | 6f0e6a2015f87f4cb467986881074d5c90113756 (patch) | |
tree | 5605720a8a6c76ae77445d84ceb079674fb21edd /tests | |
parent | 2bcebbd0342f6d588e6437c7c708cb8b60a631cb (diff) |
Restructure libSieve
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tests/sieve/SieveDovecotTest.js | 317 | ||||
-rw-r--r-- | tests/tests/sieve/SieveFastMailTest.js | 181 | ||||
-rw-r--r-- | tests/tests/sieve/SieveTty1Test.js | 207 | ||||
-rwxr-xr-x | tests/tests/tests.js | 184 |
4 files changed, 92 insertions, 797 deletions
diff --git a/tests/tests/sieve/SieveDovecotTest.js b/tests/tests/sieve/SieveDovecotTest.js deleted file mode 100644 index 11a3a4ca..00000000 --- a/tests/tests/sieve/SieveDovecotTest.js +++ /dev/null @@ -1,317 +0,0 @@ -/* - * The contents of this file are licensed. You may obtain a copy of - * the license at https://github.com/thsmi/sieve/ or request it via - * email from the author. - * - * Do not remove or change this comment. - * - * The initial author of the code is: - * Thomas Schmid <schmid-thomas@gmx.net> - * - */ - -(function () { - - "use strict"; - - /* global net */ - - const suite = net.tschmid.yautt.test; - - if (!suite) - throw new Error("Could not initialize test suite"); - - - suite.description( - "Examples from Dovecot...", - "https://wiki2.dovecot.org/Pigeonhole/Sieve/Examples"); - - - suite.add("Dovecot - Mail filtering by various headers I", function () { - - const script = '' - + 'require ["fileinto", "envelope"];\r\n' - + '\r\n' - + 'if address :is "to" "dovecot@dovecot.org" {\r\n' - + ' fileinto "Dovecot-list";\r\n' - + '} elsif envelope :is "from" "owner-cipe-l@inka.de" {\r\n' - + ' fileinto "lists.cipe";\r\n' - + '} elsif anyof (header :contains "X-listname" "lugog@cip.rz.fh-offenburg.de",\r\n' - + ' header :contains "List-Id" "Linux User Group Offenburg") {\r\n' - + ' fileinto "ml.lugog";\r\n' - + '} else {\r\n' - + ' # The rest goes into INBOX\r\n' - + ' # default is "implicit keep", we do it explicitly here\r\n' - + ' keep;\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["fileinto", "envelope"]); - }); - - - suite.add("Mail filtering by various headers II", function () { - - const script = '' - + 'if header :contains "subject" ["order", "buy"] {\r\n' - + ' redirect "orders@company.dom";\r\n' - + '}\r\n'; - - suite.expectValidScript(script, []); - }); - - - suite.add("Flagging or Highlighting your mail I", function () { - - const script = '' - + 'require "imap4flags";\r\n' - + 'require "regex";\r\n' - + 'if anyof (exists "X-Cron-Env",\r\n' - + ' header :regex ["subject"] [".* security run output",\r\n' - + ' ".* monthly run output",\r\n' - + ' ".* daily run output",\r\n' - + ' ".* weekly run output"]) {\r\n' - + ' addflag "$label1"; # ie \'Important\'/red label within Thunderbird\r\n' - + '\r\n' - + '# Other flags:\r\n' - + '# addflag "$label1"; # Important: #ff0000 => red\r\n' - + '# addflag "$label2"; # Work: #ff9900 => orange\r\n' - + '# addflag "$label3"; # personal: #009900 => green\r\n' - + '# addflag "$label4"; # todo: #3333ff => blue\r\n' - + '# addflag "$label5"; # later: #993399 => violet\r\n' - + '#\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["imap4flags", "regex"]); - }); - - suite.add("Flagging or Highlighting your mail II", function () { - - const script = '' - + 'require ["envelope", "imap4flags"];\r\n' - + 'if envelope "from" "my_address@my_domain.com"\r\n' - + '{\r\n' - + ' setflag "\\\\seen";\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["envelope", "imap4flags"]); - }); - - - suite.add("Direct filtering using message header I", function () { - - const script = '' - + 'require "fileinto";\r\n' - + 'if header :contains "X-Spam-Flag" "YES" {\r\n' - + ' fileinto "Spam";\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["fileinto"]); - }); - - - suite.add("Direct filtering using message header II", function () { - - const script = '' - + 'if header :contains "X-Spam-Level" "**********" {\r\n' - + ' discard;\r\n' - + ' stop;\r\n' - + '}\r\n'; - - suite.expectValidScript(script, []); - }); - - - suite.add("Direct filtering using message header III", function () { - - const script = '' - + 'require ["comparator-i;ascii-numeric","relational"];\r\n' - + 'if allof (\r\n' - + ' not header :matches "x-spam-score" "-*",\r\n' - + ' header :value "ge" :comparator "i;ascii-numeric" "x-spam-score" "10" )\r\n' - + '{\r\n' - + ' discard;\r\n' - + ' stop;\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["comparator-i;ascii-numeric", "relational"]); - }); - - - suite.add("Filtering using the spamtest and virustest extensions I", () => { - - const script = '' - + 'require "spamtestplus";\r\n' - + 'require "fileinto";\r\n' - + 'require "relational";\r\n' - + 'require "comparator-i;ascii-numeric";\r\n' - + '\r\n' - + '/* If the spamtest fails for some reason, e.g. spam header is missing, file\r\n' - + ' * file it in a special folder.\r\n' - + ' */\r\n' - + 'if spamtest :value "eq" :comparator "i;ascii-numeric" "0" {\r\n' - + ' fileinto "Unclassified";\r\n' - + '\r\n' - + '/* If the spamtest score (in the range 1-10) is larger than or equal to 3,\r\n' - + ' * file it into the spam folder:\r\n' - + ' */\r\n' - + '} elsif spamtest :value "ge" :comparator "i;ascii-numeric" "3" {\r\n' - + ' fileinto "Spam";\r\n' - + '\r\n' - + '/* For more fine-grained score evaluation, the :percent tag can be used. The\r\n' - + ' * following rule discards all messages with a percent score\r\n' - + ' * (relative to maximum) of more than 85 %:\r\n' - + ' */\r\n' - + '} elsif spamtest :value "gt" :comparator "i;ascii-numeric" :percent "85" {\r\n' - + ' discard;\r\n' - + '}\r\n' - + '\r\n' - + '/* Other messages get filed into INBOX */\r\n'; - - suite.expectValidScript(script, - ["spamtestplus", "fileinto", "relational", "comparator-i;ascii-numeric"]); - }); - - - suite.add("Filtering using the spamtest and virustest extensions II", () => { - - const script = '' - + 'require "virustest";\r\n' - + 'require "fileinto";\r\n' - + 'require "relational";\r\n' - + 'require "comparator-i;ascii-numeric";\r\n' - + '\r\n' - + '/* Not scanned ? */\r\n' - + 'if virustest :value "eq" :comparator "i;ascii-numeric" "0" {\r\n' - + ' fileinto "Unscanned";\r\n' - + '\r\n' - + '/* Infected with high probability (value range in 1-5) */\r\n' - + '} if virustest :value "eq" :comparator "i;ascii-numeric" "4" {\r\n' - + ' /* Quarantine it in special folder (still somewhat dangerous) */\r\n' - + ' fileinto "Quarantine";\r\n' - + '\r\n' - + '/* Definitely infected */\r\n' - + '} elsif virustest :value "eq" :comparator "i;ascii-numeric" "5" {\r\n' - + ' /* Just get rid of it */\r\n' - + ' discard;\r\n' - + '}\r\n'; - - suite.expectValidScript(script, - ["virustest", "fileinto", "relational", "comparator-i;ascii-numeric"]); - }); - - - suite.add("Plus Addressed mail filtering I", function () { - - const script = '' - + 'require ["fileinto", "envelope", "subaddress"];\r\n' - + 'if envelope :detail "to" "spam"{\r\n' - + ' fileinto "Spam";\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["fileinto", "envelope", "subaddress"]); - }); - - - suite.add("Plus Addressed mail filtering II", function () { - - const script = '' - + 'require ["variables", "envelope", "fileinto", "subaddress"];\r\n' - + '\r\n' - + 'if envelope :is :user "to" "sales" {\r\n' - + ' if envelope :matches :detail "to" "*" {\r\n' - + ' /* Save name in ${name} in all lowercase except for the first letter.\r\n' - + ' * Joe, joe, jOe thus all become \'Joe\'.\r\n' - + ' */\r\n' - + ' set :lower :upperfirst "name" "${1}";\r\n' - + ' }\r\n' - + '\r\n' - + ' if string :is "${name}" "" {\r\n' - + ' /* Default case if no detail is specified */\r\n' - + ' fileinto "sales";\r\n' - + ' } else {\r\n' - + ' /* For sales+joe@ this will become users/Joe */\r\n' - + ' fileinto "users/${name}";\r\n' - + ' }\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["variables", "envelope", "fileinto", "subaddress"]); - }); - - - suite.add("Vacation auto-reply I", function () { - - const script = '' - + 'require ["fileinto", "vacation"];\r\n' - + '# Move spam to spam folder\r\n' - + 'if header :contains "X-Spam-Flag" "YES" {\r\n' - + ' fileinto "spam";\r\n' - + ' # Stop here so that we do not reply on spams\r\n' - + ' stop;\r\n' - + '}\r\n' - + 'vacation\r\n' - + ' # Reply at most once a day to a same sender\r\n' - + ' :days 1\r\n' - + ' :subject "Out of office reply"\r\n' - + ' # List of additional recipient addresses which are included in the auto replying.\r\n' - + ' # If a mail\'s recipient is not the envelope recipient and it\'s not on this list,\r\n' - + ' # no vacation reply is sent for it.\r\n' - + ' :addresses ["j.doe@company.dom", "john.doe@company.dom"]\r\n' - + '"I\'m out of office, please contact Joan Doe instead.\r\n' - + 'Best regards\r\n' - + 'John Doe";\r\n'; - - suite.expectValidScript(script, ["fileinto", "vacation"]); - }); - - - suite.add("Vacation auto-reply II", function () { - - const script = '' - + 'require ["variables", "vacation"];\r\n' - + '# Store old Subject line so it can be used in vacation message\r\n' - + 'if header :matches "Subject" "*" {\r\n' - + ' set "subjwas" ": ${1}";\r\n' - + '}\r\n' - + 'vacation\r\n' - + ' :days 1\r\n' - + ' :subject "Out of office reply${subjwas}"\r\n' - + ' :addresses ["j.doe@company.dom", "john.doe@company.dom"]\r\n' - + '"I\'m out of office, please contact Joan Doe instead.\r\n' - + 'Best regards\r\n' - + 'John Doe";\r\n'; - - - suite.expectValidScript(script, ["variables", "vacation"]); - }); - - - suite.add("Include scripts", function () { - - const script = '' - + 'require ["include"];\r\n' - + 'include :global "global-spam";\r\n' - + 'include :personal "my-own-spam";\r\n'; - - suite.expectValidScript(script, ["include"]); - }); - - - suite.add("Archiving a Mailinglist by Date", function () { - - const script = '' - + 'require ["variables","date","fileinto","mailbox"];\r\n' - + '\r\n' - + '# Extract date info\r\n' - + 'if currentdate :matches "year" "*" { set "year" "${1}"; }\r\n' - + 'if currentdate :matches "month" "*" { set "month" "${1}"; }\r\n' - + '\r\n' - + '# Archive Dovecot mailing list items by year and month.\r\n' - + '# Create folder when it does not exist.\r\n' - + 'if header :is "list-id" "dovecot.dovecot.org" {\r\n' - + ' fileinto :create "INBOX.Lists.${year}.${month}.dovecot";\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["variables", "date", "fileinto", "mailbox"]); - }); - -})(); diff --git a/tests/tests/sieve/SieveFastMailTest.js b/tests/tests/sieve/SieveFastMailTest.js deleted file mode 100644 index 2c30b04e..00000000 --- a/tests/tests/sieve/SieveFastMailTest.js +++ /dev/null @@ -1,181 +0,0 @@ -/* - * The contents of this file are licensed. You may obtain a copy of - * the license at https://github.com/thsmi/sieve/ or request it via - * email from the author. - * - * Do not remove or change this comment. - * - * The initial author of the code is: - * Thomas Schmid <schmid-thomas@gmx.net> - * - */ - -(function () { - - "use strict"; - - /* global net */ - - const suite = net.tschmid.yautt.test; - - if (!suite) - throw new Error("Could not initialize test suite"); - - suite.description( - "Examples from FastMail...", - "https://www.fastmail.com/help/technical/sieve-examples.html"); - - suite.add("FastMail - File all messages from a recipient into a folder", function () { - - const script = '' - + 'require ["fileinto"];\r\n' - + '\r\n' - + 'if address :is "From" "pal@mypals.org" {\r\n' - + ' fileinto "INBOX.My Best Pal";\r\n' - + ' stop;\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["fileinto"]); - }); - - - suite.add("FastMail - File all messages from a domain into a folder", function () { - - const script = '' - + 'require ["fileinto"];\r\n' - + '\r\n' - + 'if address :domain :is "From" "mypals.org" {\r\n' - + ' fileinto "INBOX.My Best Pal";\r\n' - + ' stop;\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["fileinto"]); - }); - - - suite.add("FastMail - File all undefined addresses at a virtual domain into a folder", function () { - - const script = '' - + 'require ["fileinto"];\r\n' - + '\r\n' - + 'if allof(\r\n' - + ' address :domain :is "X-Delivered-To" "mydomain.info",\r\n' - + ' not address :localpart :is "X-Delivered-To" ["address1", "address2", "address3"] # these are valid addresses\r\n' - + ') {\r\n' - + ' fileinto "INBOX.Possible spam";\r\n' - + ' stop;\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["fileinto"]); - }); - - - suite.add("FastMail - File messages to some aliases into alias-dependent folders", function () { - - const script = '' - + 'require ["fileinto", "imap4flags"];\r\n' - + '\r\n' - + 'if address :is "X-Delivered-To" "alias1@fastmail.fm" {\r\n' - + ' fileinto "INBOX.alias1";\r\n' - + ' stop;\r\n' - + '} elsif address :is "X-Delivered-To" "alias2@sent.com" {\r\n' - + ' setflag "\\\\Seen";\r\n' - + ' fileinto "INBOX.alias2";\r\n' - + ' stop;\r\n' - + '} elsif address :is "X-Delivered-To" "alias3@eml.cc" {\r\n' - + ' fileinto "INBOX.alias3";\r\n' - + ' stop;\r\n' - + '}\r\n' - + '\r\n' - + 'redirect "another@account.net";\r\n' - + '\r\n'; - - suite.expectValidScript(script, ["fileinto", "imap4flags"]); - }); - - suite.add("FastMail - Spam filtering for SpamAssassin score", function () { - - const script = '' - + 'require ["fileinto","relational", "comparator-i;ascii-numeric"];\r\n' - + '\r\n' - + 'if header :value "ge" :comparator "i;ascii-numeric" ["X-Spam-score"] ["20"] {\r\n' - + ' discard;\r\n' - + ' stop;\r\n' - + '}\r\n' - + 'if header :value "ge" :comparator "i;ascii-numeric" ["X-Spam-score"] ["8"] {\r\n' - + ' fileinto "INBOX.spam.spam";\r\n' - + ' stop;\r\n' - + '}\r\n' - + 'if header :value "ge" :comparator "i;ascii-numeric" ["X-Spam-score"] ["4"] {\r\n' - + ' fileinto "INBOX.spam";\r\n' - + ' stop;\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["fileinto", "relational", "comparator-i;ascii-numeric"]); - }); - - suite.add("FastMail - Spam filtering based on Bayesian filter)", function () { - - const script = '' - + 'require ["fileinto"];\r\n' - + '\r\n' - + 'if header :contains ["SPAM", "X-Spam-hits"] ["BAYES_40", "BAYES_44", "BAYES_50", "BAYES_56", "BAYES_60"]' - + '{\r\n' - + ' fileinto "INBOX.Junk Mail";\r\n' - + ' stop;\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["fileinto"]); - }); - - suite.add("FastMail - Filtering known messages as sent", function () { - - const script = '' - + 'require ["fileinto","imap4flags"];\r\n' - + '\r\n' - + 'if header :is ["X-Delivered-to"] "sent@domain.com" {\r\n' - + ' setflag "\\\\Seen";\r\n' - + ' fileinto "INBOX.Sent Items";\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["fileinto", "imap4flags"]); - }); - - suite.add("FastMail - Do not filter known senders", function () { - - const script = '' - + '\r\n' - + 'if not anyof(\r\n' - + ' header :contains ["X-Spam-known-sender"] "yes",\r\n' - + ' header :contains ["from"] ["amazon.co.uk", "myworkdomain.com"]\r\n' - + ') {\r\n' - + ' # ...filtering code goes here...\r\n' - + '}\r\n'; - - suite.expectValidScript(script); - }); - - suite.add("FastMail - Time-sensitive notification example", function () { - - const script = '' - + 'require ["regex"];\r\n' - + '\r\n' - + 'if allof (\r\n' - + ' header :contains "X-Spam-known-sender" "yes",\r\n' - + ' header :regex "date" "(08|09|10|11|12|13|14|15|16|17):..:..",\r\n' - + ' not header :regex "date" "(sat|sun)",\r\n' - + ' not header :contains "date" [\r\n' - + ' "31 Mar 2006",\r\n' - + ' "03 Apr 2006",\r\n' - + ' "04 Apr 2006",\r\n' - + ' "07 Apr 2006"\r\n' - + '] ) {\r\n' - // + ' notify :method "mailto" :options ["work.address@example.com"]\r\n' - // + ' :message "$from$ / $subject$ / $text$";\r\n' - // + ' keep;\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["regex"]); - }); - -})(); diff --git a/tests/tests/sieve/SieveTty1Test.js b/tests/tests/sieve/SieveTty1Test.js deleted file mode 100644 index ee8ab9f6..00000000 --- a/tests/tests/sieve/SieveTty1Test.js +++ /dev/null @@ -1,207 +0,0 @@ -/* - * The contents of this file are licensed. You may obtain a copy of - * the license at https://github.com/thsmi/sieve/ or request it via - * email from the author. - * - * Do not remove or change this comment. - * - * The initial author of the code is: - * Thomas Schmid <schmid-thomas@gmx.net> - * - */ - -(function () { - - "use strict"; - - /* global net */ - - const suite = net.tschmid.yautt.test; - - if (!suite) - throw new Error("Could not initialize test suite"); - - - suite.description( - "Examples from tty1.net...", - "http://www.tty1.net/blog/2011-07-16-sieve-tutorial_en.html"); - - - suite.add("TTY1 Example I", function () { - - const script = '' - + 'require ["fileinto", "reject"];\r\n' - + '\r\n' - + '# Daffy Duck is a good friend of mine.\r\n' - + 'if address :is "from" "daffy.duck@example.com"\r\n' - + '{\r\n' - + ' fileinto "friends";\r\n' - + '}\r\n' - + '\r\n' - + '# Reject mails from the hunting enthusiasts at example.com.\r\n' - + 'if header :contains "list-id" "<duck-hunting.example.com>"\r\n' - + '{\r\n' - + ' reject "No violence, please";\r\n' - + '}\r\n' - + '\r\n' - + '# The command "keep" is executed automatically, if no other action is taken.\r\n'; - - suite.expectValidScript(script, ["fileinto", "reject"]); - }); - - suite.add("TTY1 Example II", function () { - - const script = '' - + '# The hash character starts a one-line comment.\r\n' - + '# Everything after a # character until the end of line is ignored.\r\n' - + '\r\n' - + '/* this is a bracketed (C-style) comment. This type of comment can stretch\r\n' - + ' * over many lines. A bracketed comment begins with a forward slash, followed\r\n' - + ' * by an asterisk and ends with the inverse sequence: an asterisk followed\r\n' - + ' * by a forward slash. */\r\n'; - - suite.expectValidScript(script, []); - }); - - - suite.add("TTY1 Example III", function () { - - const script = '' - + 'require ["fileinto"];\r\n' - + '\r\n' - + '# The two test below are equivalent;\r\n' - + '# The first variant is clearer and probably also more efficient.\r\n' - + 'if address :is :domain "to" "example.com"\r\n' - + '{\r\n' - + ' fileinto "examplecom";\r\n' - + '}\r\n' - + 'if address :matches :all "to" "*@example.com"\r\n' - + '{\r\n' - + ' fileinto "examplecom";\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["fileinto"]); - }); - - - suite.add("TTY1 Example IV", function () { - - const script = '' - + 'require ["fileinto"];\r\n' - + '\r\n' - + '# File mails with a Spamassassin score of 4.0 or more\r\n' - + '# into the "junk" folder.\r\n' - + 'if header :contains "x-spam-level" "****"\r\n' - + '{\r\n' - + ' fileinto "junk";\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["fileinto"]); - }); - - - suite.add("TTY1 Example V", function () { - - const script = '' - + 'require ["reject"];\r\n' - + '\r\n' - + '# Reject all messages that contain the string "viagra"in the Subject.\r\n' - + 'if header :contains "subject" "viagra"\r\n' - + '{\r\n' - + ' reject "go away!";\r\n' - + '}\r\n' - + '# Silently discard all messages sent from the tax man\r\n' - + 'elsif address :matches :domain "from" "*hmrc.gov.uk"\r\n' - + '{\r\n' - + ' discard;\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["reject"]); - }); - - - suite.add("TTY1 Example VI", function () { - - const script = '' - + 'require ["fileinto"];\r\n' - + '\r\n' - + '# A mail to any of the recipients in the list of strings is filed to the folder "friends".\r\n' - + 'if address :is "from" ["daffy.duck@example.com", "porky.pig@example.com", "speedy.gonzales@example.com"]\r\n' - + '{\r\n' - + ' fileinto "friends";\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["fileinto"]); - }); - - - suite.add("TTY1 Example VII", function () { - - const script = '' - + 'require ["fileinto"];\r\n' - + '\r\n' - + '# Check if either the "from" or the "sender" header is from Porky.\r\n' - + 'if address :is ["from", "sender"] "porky.pig@example.com"\r\n' - + '{\r\n' - + ' fileinto "friends";\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["fileinto"]); - }); - - - suite.add("TTY1 Example VIII", function () { - - const script = '' - + 'require ["fileinto"];\r\n' - + '\r\n' - + '# Match "from" or the "sender" file with any of Daffy, Porky or Speedy.\r\n' - + 'if address :is ["from", "sender"] ["daffy.duck@example.com", "porky.pig@example.com", "speedy.gonzales@example.com"]\r\n' - + '{\r\n' - + ' fileinto "friends";\r\n' - + '}\r\n'; - - suite.expectValidScript(script, ["fileinto"]); - }); - - - suite.add("TTY1 Example IX", function () { - - const script = '' - + '# This test checks against Spamassassin\'s header fields:\r\n' - + '# If the spam level ls 4 or more and the Subject contains too\r\n' - + '# many illegal characters, then silently discard the mail.\r\n' - + 'if allof (header :contains "X-Spam-Level" "****",\r\n' - + ' header :contains "X-Spam-Report" "FROM_ILLEGAL_CHARS")\r\n' - + '{\r\n' - + ' discard;\r\n' - + '}\r\n' - + '# Discard mails that do not have a Date: or From: header field\r\n' - + '# or mails that are sent from the marketing department at example.com.\r\n' - + 'elsif anyof (not exists ["from", "date"],\r\n' - + ' header :contains "from" "marketing@example.com") {\r\n' - + ' discard;\r\n' - + '}\r\n'; - - suite.expectValidScript(script, []); - }); - - - suite.add("TTY1 Example X", function () { - - const script = '' - + '# Delete messages greater than half a MB\r\n' - + 'if size :over 500K\r\n' - + '{\r\n' - + ' discard;\r\n' - + '}\r\n' - + '# Also delete small mails, under 1k\r\n' - + 'if size :under 1K\r\n' - + '{\r\n' - + ' discard;\r\n' - + '}\r\n'; - - suite.expectValidScript(script, []); - }); - -})(); diff --git a/tests/tests/tests.js b/tests/tests/tests.js index 14dcd636..a1782fd4 100755 --- a/tests/tests/tests.js +++ b/tests/tests/tests.js @@ -20,256 +20,256 @@ tests.set("rfc5228", { require: [ - "./../common/libSieve/RFC5228/logic/SieveWhiteSpaces.js", - "./../common/libSieve/RFC5228/logic/SieveStrings.js", - "./../common/libSieve/RFC5228/logic/SieveMatchTypes.js", - "./../common/libSieve/RFC5228/logic/SieveComparators.js", - "./../common/libSieve/RFC5228/logic/SieveAddressParts.js", - "./../common/libSieve/RFC5228/logic/SieveNumbers.js", - "./../common/libSieve/RFC5228/logic/SieveBlocks.js", - "./../common/libSieve/RFC5228/logic/SieveTests.js", - "./../common/libSieve/RFC5228/logic/SieveOperators.js", - "./../common/libSieve/RFC5228/logic/SieveConditions.js", - "./../common/libSieve/RFC5228/logic/SieveActions.js", - "./../common/libSieve/RFC5228/logic/SieveImports.js", + "./../common/libSieve/extensions/RFC5228/logic/SieveWhiteSpaces.js", + "./../common/libSieve/extensions/RFC5228/logic/SieveStrings.js", + "./../common/libSieve/extensions/RFC5228/logic/SieveMatchTypes.js", + "./../common/libSieve/extensions/RFC5228/logic/SieveComparators.js", + "./../common/libSieve/extensions/RFC5228/logic/SieveAddressParts.js", + "./../common/libSieve/extensions/RFC5228/logic/SieveNumbers.js", + "./../common/libSieve/extensions/RFC5228/logic/SieveBlocks.js", + "./../common/libSieve/extensions/RFC5228/logic/SieveTests.js", + "./../common/libSieve/extensions/RFC5228/logic/SieveOperators.js", + "./../common/libSieve/extensions/RFC5228/logic/SieveConditions.js", + "./../common/libSieve/extensions/RFC5228/logic/SieveActions.js", + "./../common/libSieve/extensions/RFC5228/logic/SieveImports.js", "./validators/ScriptValidator.js" ], extend: "base" }); tests.set("sieve-scripts", { - script: "./../common/libSieve/RFC5228/tests/SieveRFC5228ScriptTest.js", + script: "./../common/libSieve/extensions/RFC5228/tests/SieveRFC5228ScriptTest.js", extend: "rfc5228" }); tests.set("sieve-elements", { - script: "./../common/libSieve/RFC5228/tests/SieveRFC5228SnippetTest.js", + script: "./../common/libSieve/extensions/RFC5228/tests/SieveRFC5228SnippetTest.js", extend: "rfc5228" }); tests.set("sieve-atoms", { - script: "./../common/libSieve/RFC5228/tests/SieveRFC5228AtomsTest.js", + script: "./../common/libSieve/extensions/RFC5228/tests/SieveRFC5228AtomsTest.js", extend: "rfc5228" }); // Specialized profiles which contain the tests... tests.set("matchTypes", { - script: "./../common/libSieve/RFC5228/tests/SieveMatchTypeTest.js", + script: "./../common/libSieve/extensions/RFC5228/tests/SieveMatchTypeTest.js", extend: "rfc5228" }); tests.set("variables", { - script: "./../common/libSieve/variables/tests/SieveVariablesTest.js", + script: "./../common/libSieve/extensions/variables/tests/SieveVariablesTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/variables/logic/SieveVariables.js" + "./../common/libSieve/extensions/variables/logic/SieveVariables.js" ] }); tests.set("regex", { - script: "./../common/libSieve/regex/tests/SieveRegExTest.js", + script: "./../common/libSieve/extensions/regex/tests/SieveRegExTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/regex/logic/SieveRegularExpression.js" + "./../common/libSieve/extensions/regex/logic/SieveRegularExpression.js" ] }); tests.set("reject", { - script: "./../common/libSieve/reject/tests/SieveRejectTest.js", + script: "./../common/libSieve/extensions/reject/tests/SieveRejectTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/reject/logic/SieveReject.js" + "./../common/libSieve/extensions/reject/logic/SieveReject.js" ] }); tests.set("body", { - script: "./../common/libSieve/body/tests/SieveBodyTest.js", + script: "./../common/libSieve/extensions/body/tests/SieveBodyTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/body/logic/SieveBody.js" + "./../common/libSieve/extensions/body/logic/SieveBody.js" ] }); tests.set("vacation", { - script: "./../common/libSieve/vacation/tests/SieveVacationTest.js", + script: "./../common/libSieve/extensions/vacation/tests/SieveVacationTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/vacation/logic/SieveVacation.js" + "./../common/libSieve/extensions/vacation/logic/SieveVacation.js" ] }); tests.set("vacation-seconds", { - script: "./../common/libSieve/vacation-seconds/tests/SieveVacationSecondsTest.js", + script: "./../common/libSieve/extensions/vacation-seconds/tests/SieveVacationSecondsTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/vacation/logic/SieveVacation.js", - "./../common/libSieve/vacation-seconds/logic/SieveVacationSeconds.js" + "./../common/libSieve/extensions/vacation/logic/SieveVacation.js", + "./../common/libSieve/extensions/vacation-seconds/logic/SieveVacationSeconds.js" ] }); tests.set("include", { - script: "./../common/libSieve/include/tests/SieveIncludeTest.js", + script: "./../common/libSieve/extensions/include/tests/SieveIncludeTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/include/logic/SieveInclude.js", - "./../common/libSieve/variables/logic/SieveVariables.js", - "./../common/libSieve/relational/logic/SieveRelational.js" + "./../common/libSieve/extensions/include/logic/SieveInclude.js", + "./../common/libSieve/extensions/variables/logic/SieveVariables.js", + "./../common/libSieve/extensions/relational/logic/SieveRelational.js" ] }); tests.set("relational", { - script: "./../common/libSieve/relational/tests/SieveRelationalTest.js", + script: "./../common/libSieve/extensions/relational/tests/SieveRelationalTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/relational/logic/SieveRelational.js" + "./../common/libSieve/extensions/relational/logic/SieveRelational.js" ] }); tests.set("mailbox", { - script: "./../common/libSieve/mailbox/tests/SieveMailboxTest.js", + script: "./../common/libSieve/extensions/mailbox/tests/SieveMailboxTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/mailbox/logic/SieveMailbox.js" + "./../common/libSieve/extensions/mailbox/logic/SieveMailbox.js" ] }); tests.set("subaddress", { - script: "./../common/libSieve/subaddress/tests/SieveSubaddressTest.js", + script: "./../common/libSieve/extensions/subaddress/tests/SieveSubaddressTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/subaddress/logic/SieveSubaddress.js" + "./../common/libSieve/extensions/subaddress/logic/SieveSubaddress.js" ] }); tests.set("copy", { - script: "./../common/libSieve/copy/tests/SieveCopyTest.js", + script: "./../common/libSieve/extensions/copy/tests/SieveCopyTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/copy/logic/SieveCopy.js" + "./../common/libSieve/extensions/copy/logic/SieveCopy.js" ] }); tests.set("imapflags", { - script: "./../common/libSieve/imapflags/tests/SieveImapFlagsTest.js", + script: "./../common/libSieve/extensions/imapflags/tests/SieveImapFlagsTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/imapflags/logic/SieveImapFlags.js", - "./../common/libSieve/variables/logic/SieveVariables.js", - "./../common/libSieve/relational/logic/SieveRelational.js" + "./../common/libSieve/extensions/imapflags/logic/SieveImapFlags.js", + "./../common/libSieve/extensions/variables/logic/SieveVariables.js", + "./../common/libSieve/extensions/relational/logic/SieveRelational.js" ] }); tests.set("editheader", { - script: "./../common/libSieve/editheader/tests/SieveEditheaderTest.js", + script: "./../common/libSieve/extensions/editheader/tests/SieveEditheaderTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/editheader/logic/SieveEditheader.js" + "./../common/libSieve/extensions/editheader/logic/SieveEditheader.js" ] }); tests.set("date", { - script: "./../common/libSieve/date/tests/SieveDateTest.js", + script: "./../common/libSieve/extensions/date/tests/SieveDateTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/variables/logic/SieveVariables.js", - "./../common/libSieve/vacation/logic/SieveVacation.js", - "./../common/libSieve/relational/logic/SieveRelational.js", - "./../common/libSieve/editheader/logic/SieveEditheader.js", - "./../common/libSieve/date/logic/SieveDate.js" + "./../common/libSieve/extensions/variables/logic/SieveVariables.js", + "./../common/libSieve/extensions/vacation/logic/SieveVacation.js", + "./../common/libSieve/extensions/relational/logic/SieveRelational.js", + "./../common/libSieve/extensions/editheader/logic/SieveEditheader.js", + "./../common/libSieve/extensions/date/logic/SieveDate.js" ] }); tests.set("duplicate", { - script: "./../common/libSieve/duplicate/tests/SieveDuplicateTest.js", + script: "./../common/libSieve/extensions/duplicate/tests/SieveDuplicateTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/variables/logic/SieveVariables.js", - "./../common/libSieve/notify/logic/SieveNotify.js", - "./../common/libSieve/mailbox/logic/SieveMailbox.js", - "./../common/libSieve/imapflags/logic/SieveImapFlags.js", - "./../common/libSieve/duplicate/logic/SieveDuplicate.js" + "./../common/libSieve/extensions/variables/logic/SieveVariables.js", + "./../common/libSieve/extensions/notify/logic/SieveNotify.js", + "./../common/libSieve/extensions/mailbox/logic/SieveMailbox.js", + "./../common/libSieve/extensions/imapflags/logic/SieveImapFlags.js", + "./../common/libSieve/extensions/duplicate/logic/SieveDuplicate.js" ] }); tests.set("spamtest", { - script: "./../common/libSieve/spamtest/tests/SpamtestTests.js", + script: "./../common/libSieve/extensions/spamtest/tests/SpamtestTests.js", extend: "rfc5228", require: [ - "./../common/libSieve/spamtest/logic/SieveSpamtest.js", - "./../common/libSieve/relational/logic/SieveRelational.js" + "./../common/libSieve/extensions/spamtest/logic/SieveSpamtest.js", + "./../common/libSieve/extensions/relational/logic/SieveRelational.js" ] }); tests.set("environment", { - script: "./../common/libSieve/environment/tests/SieveEnvironmentTest.js", + script: "./../common/libSieve/extensions/environment/tests/SieveEnvironmentTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/environment/logic/SieveEnvironment.js" + "./../common/libSieve/extensions/environment/logic/SieveEnvironment.js" ] }); tests.set("convert", { - script: "./../common/libSieve/convert/tests/SieveConvertTest.js", + script: "./../common/libSieve/extensions/convert/tests/SieveConvertTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/convert/logic/SieveConvert.js" + "./../common/libSieve/extensions/convert/logic/SieveConvert.js" ] }); tests.set("notify", { - script: "./../common/libSieve/notify/tests/SieveNotifyTest.js", + script: "./../common/libSieve/extensions/notify/tests/SieveNotifyTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/variables/logic/SieveVariables.js", - "./../common/libSieve/notify/logic/SieveNotify.js" + "./../common/libSieve/extensions/variables/logic/SieveVariables.js", + "./../common/libSieve/extensions/notify/logic/SieveNotify.js" ] }); tests.set("pipe", { - script: "./../common/libSieve/pipe/tests/SievePipeTest.js", + script: "./../common/libSieve/extensions/pipe/tests/SievePipeTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/copy/logic/SieveCopy.js", - "./../common/libSieve/variables/logic/SieveVariables.js", - "./../common/libSieve/subaddress/logic/SieveSubaddress.js", - "./../common/libSieve/vacation/logic/SieveVacation.js", - "./../common/libSieve/pipe/logic/SievePipe.js" + "./../common/libSieve/extensions/copy/logic/SieveCopy.js", + "./../common/libSieve/extensions/variables/logic/SieveVariables.js", + "./../common/libSieve/extensions/subaddress/logic/SieveSubaddress.js", + "./../common/libSieve/extensions/vacation/logic/SieveVacation.js", + "./../common/libSieve/extensions/pipe/logic/SievePipe.js" ] }); tests.set("examples-fastmail", { - script: "./sieve/SieveFastMailTest.js", + script: "./../common/libSieve/tests/SieveFastMailTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/imapflags/logic/SieveImapFlags.js", - "./../common/libSieve/relational/logic/SieveRelational.js", - "./../common/libSieve/regex/logic/SieveRegularExpression.js" + "./../common/libSieve/extensions/imapflags/logic/SieveImapFlags.js", + "./../common/libSieve/extensions/relational/logic/SieveRelational.js", + "./../common/libSieve/extensions/regex/logic/SieveRegularExpression.js" ] }); tests.set("examples-dovecot", { - script: "./sieve/SieveDovecotTest.js", + script: "./../common/libSieve/tests/SieveDovecotTest.js", extend: "rfc5228", require: [ - "./../common/libSieve/imapflags/logic/SieveImapFlags.js", - "./../common/libSieve/relational/logic/SieveRelational.js", - "./../common/libSieve/regex/logic/SieveRegularExpression.js", - "./../common/libSieve/include/logic/SieveInclude.js", - "./../common/libSieve/spamtest/logic/SieveSpamtest.js", - "./../common/libSieve/subaddress/logic/SieveSubaddress.js", - "./../common/libSieve/variables/logic/SieveVariables.js", - "./../common/libSieve/vacation/logic/SieveVacation.js", - "./../common/libSieve/date/logic/SieveDate.js", - "./../common/libSieve/mailbox/logic/SieveMailbox.js" + "./../common/libSieve/extensions/imapflags/logic/SieveImapFlags.js", + "./../common/libSieve/extensions/relational/logic/SieveRelational.js", + "./../common/libSieve/extensions/regex/logic/SieveRegularExpression.js", + "./../common/libSieve/extensions/include/logic/SieveInclude.js", + "./../common/libSieve/extensions/spamtest/logic/SieveSpamtest.js", + "./../common/libSieve/extensions/subaddress/logic/SieveSubaddress.js", + "./../common/libSieve/extensions/variables/logic/SieveVariables.js", + "./../common/libSieve/extensions/vacation/logic/SieveVacation.js", + "./../common/libSieve/extensions/date/logic/SieveDate.js", + "./../common/libSieve/extensions/mailbox/logic/SieveMailbox.js" ] }); tests.set("examples-tty1", { - script: "./sieve/SieveTty1Test.js", + script: "./../common/libSieve/tests/SieveTty1Test.js", extend: "rfc5228", require: [ - "./../common/libSieve/reject/logic/SieveReject.js" + "./../common/libSieve/extensions/reject/logic/SieveReject.js" ] }); |