aboutsummaryrefslogtreecommitdiff
path: root/tests/parse.at
diff options
context:
space:
mode:
Diffstat (limited to 'tests/parse.at')
-rw-r--r--tests/parse.at105
1 files changed, 105 insertions, 0 deletions
diff --git a/tests/parse.at b/tests/parse.at
new file mode 100644
index 0000000..950f1d0
--- /dev/null
+++ b/tests/parse.at
@@ -0,0 +1,105 @@
+# This file is part of GNU Anubis testsuite. -*- autotest -*-
+# Copyright (C) 2003-2024 The Anubis Team.
+#
+# GNU Anubis is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 3 of the License, or (at your option)
+# any later version.
+#
+# GNU Anubis is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with GNU Anubis. If not, see <http://www.gnu.org/licenses/>.
+AT_SETUP([configuration parser])
+AT_KEYWORDS([parse config])
+AT_ANUBIS_CONFIG([anubis.rc],
+[[BEGIN CONTROL
+logfile "anubis.log"
+remote-mta "localhost:25"
+use-pam no
+END
+
+BEGIN RULE
+remove [Lines]
+
+if command["mail from"] = ".*<?root@localhost>?"
+ STOP
+fi
+
+if header[Subject] = "(.*)" and not header[Subject] = :scase "URGENT"
+ add [X-Comment] "This message is not URGENT (\1)."
+ add [X-Comment] "GNU's Not Unix! (\1)"
+fi
+
+if header[X-Mailer] = "(.*)"
+ add [X-Comment] "My love \1"
+ modify [X-Mailer] "The lousy mailer \1"
+fi
+
+if header[Subject] = "signature"
+ signature-file-append yes
+fi
+
+if header[Subject] = :scase "external"
+ external-body-processor "/usr/bin/formail"
+fi
+
+if header[Subject] = "body-append"
+ body-append "misc/notes.txt"
+fi
+
+if header[Subject] = "ALL"
+ body-append "misc/notes.txt"
+fi
+END
+]])
+
+AT_DATA([expout],
+[[BEGIN SECTION CONTROL
+ ASGN: logfile = anubis.log
+ ASGN: remote-mta = localhost:25
+ ASGN: use-pam = no
+END SECTION CONTROL
+BEGIN SECTION RULE
+ REMOVE HEADER :exact [Lines]
+ COND: COMMAND[mail from] :posix [.*<?root@localhost>?]
+ IFTRUE:
+ STOP
+ END COND
+ COND: AND (HEADER[Subject] :posix [(.*)],NOT (HEADER[Subject] :posix :scase [URGENT]))
+ IFTRUE:
+ ADD HEADER[X-Comment] "This message is not URGENT (\1)."
+ ADD HEADER[X-Comment] "GNU's Not Unix! (\1)"
+ END COND
+ COND: HEADER[X-Mailer] :posix [(.*)]
+ IFTRUE:
+ ADD HEADER[X-Comment] "My love \1"
+ MODIFY HEADER :exact [X-Mailer] "The lousy mailer \1"
+ END COND
+ COND: HEADER[Subject] :posix [signature]
+ IFTRUE:
+ ASGN: signature-file-append = yes
+ END COND
+ COND: HEADER[Subject] :posix :scase [external]
+ IFTRUE:
+ ASGN: external-body-processor = /usr/bin/formail
+ END COND
+ COND: HEADER[Subject] :posix [body-append]
+ IFTRUE:
+ ASGN: body-append = misc/notes.txt
+ END COND
+ COND: HEADER[Subject] :posix [ALL]
+ IFTRUE:
+ ASGN: body-append = misc/notes.txt
+ END COND
+END SECTION RULE
+]])
+AT_CHECK([
+anubis --norc --relax-perm-check --altrc etc/anubis.rc --check-config=1
+],
+[0],
+[expout])
+AT_CLEANUP

Return to:

Send suggestions and report system problems to the System administrator.