diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile.am | 24 | ||||
-rw-r--r-- | test/Makefile.in | 294 | ||||
-rw-r--r-- | test/address-test.cc | 182 | ||||
-rw-r--r-- | test/address-trace.cc | 2 | ||||
-rw-r--r-- | test/tests/CVS/Entries | 3 | ||||
-rw-r--r-- | test/tests/CVS/Repository | 1 | ||||
-rw-r--r-- | test/tests/CVS/Root | 1 | ||||
-rw-r--r-- | test/tests/inject/CVS/Entries | 8 | ||||
-rw-r--r-- | test/tests/inject/CVS/Repository | 1 | ||||
-rw-r--r-- | test/tests/inject/CVS/Root | 1 | ||||
-rw-r--r-- | test/tests/inject/bad-headers | 15 | ||||
-rw-r--r-- | test/tests/inject/copy | 19 | ||||
-rw-r--r-- | test/tests/inject/date | 12 | ||||
-rw-r--r-- | test/tests/inject/from | 66 | ||||
-rw-r--r-- | test/tests/inject/headers | 22 | ||||
-rw-r--r-- | test/tests/inject/message-id | 24 | ||||
-rw-r--r-- | test/tests/inject/recips | 50 | ||||
-rw-r--r-- | test/tests/inject/return-path | 9 | ||||
-rw-r--r-- | test/tests/inject/sender | 76 | ||||
-rw-r--r-- | test/tests/protocols | 44 | ||||
-rw-r--r-- | test/tests/queue/CVS/Entries | 2 | ||||
-rw-r--r-- | test/tests/queue/CVS/Repository | 1 | ||||
-rw-r--r-- | test/tests/queue/CVS/Root | 1 | ||||
-rw-r--r-- | test/tests/queue/rewrite | 45 |
24 files changed, 903 insertions, 0 deletions
diff --git a/test/Makefile.am b/test/Makefile.am new file mode 100644 index 0000000..6899f8a --- /dev/null +++ b/test/Makefile.am @@ -0,0 +1,24 @@ +noinst_PROGRAMS = address-test +EXTRA_DIST = address-trace.cc + +CXXLINK = $(CC) $(CXXFLAGS) $(LDFLAGS) -o $@ +INCLUDES = -I../lib + +address_test_SOURCES = address-test.cc # address-trace.cc +address_test_LDADD = ../lib/libnullmailer.a + +# The following makes sure that we can't produce a package without the +# tests executing properly +dist-hook: test + cp -r tests $(distdir) + +test: all + ./address-test + @failed=0; \ + for test in `find tests -type f | fgrep -v CVS`; do \ + echo Running test $$test...; \ + if env - SYSCONFDIR=$(sysconfdir)/nullmailer bash $$test; \ + then echo 'Done.'; \ + else echo '******************************Failed!******************************'; failed=1; \ + fi; \ + done 2>&1; exit $$failed diff --git a/test/Makefile.in b/test/Makefile.in new file mode 100644 index 0000000..5dac8f7 --- /dev/null +++ b/test/Makefile.in @@ -0,0 +1,294 @@ +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +CC = @CC@ +CXX = @CXX@ +MAKEINFO = @MAKEINFO@ +MKDIR = @MKDIR@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +RM = @RM@ +STRIP = @STRIP@ +VERSION = @VERSION@ + +noinst_PROGRAMS = address-test +EXTRA_DIST = address-trace.cc + +CXXLINK = $(CC) $(CXXFLAGS) $(LDFLAGS) -o $@ +INCLUDES = -I../lib + +address_test_SOURCES = address-test.cc # address-trace.cc +address_test_LDADD = ../lib/libnullmailer.a +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = ../config.h +CONFIG_CLEAN_FILES = +PROGRAMS = $(noinst_PROGRAMS) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I.. +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +address_test_OBJECTS = address-test.o +address_test_DEPENDENCIES = ../lib/libnullmailer.a +address_test_LDFLAGS = +CXXFLAGS = @CXXFLAGS@ +CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +DIST_COMMON = Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +SOURCES = $(address_test_SOURCES) +OBJECTS = $(address_test_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .cc .o .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --gnu --include-deps test/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-noinstPROGRAMS: + +clean-noinstPROGRAMS: + -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) + +distclean-noinstPROGRAMS: + +maintainer-clean-noinstPROGRAMS: + +.c.o: + $(COMPILE) -c $< + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +address-test: $(address_test_OBJECTS) $(address_test_DEPENDENCIES) + @rm -f address-test + $(CXXLINK) $(address_test_LDFLAGS) $(address_test_OBJECTS) $(address_test_LDADD) $(LIBS) +.cc.o: + $(CXXCOMPILE) -c $< + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = test + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + $(MAKE) $(AM_MAKEFLAGS) top_distdir="$(top_distdir)" distdir="$(distdir)" dist-hook +address-test.o: address-test.cc ../config.h ../lib/canonicalize.h \ + ../lib/mystring/mystring.h ../lib/mystring/rep.h \ + ../lib/mystring/iter.h ../lib/mystring/join.h ../lib/address.h \ + ../lib/fdbuf/fdbuf.h ../lib/fdbuf/fdibuf.h \ + ../lib/fdbuf/fdobuf.h ../lib/itoa.h +address-trace.o: address-trace.cc ../lib/address.cc ../config.h \ + ../lib/canonicalize.h ../lib/mystring/mystring.h \ + ../lib/mystring/rep.h ../lib/mystring/iter.h \ + ../lib/mystring/join.h ../lib/list.h ../lib/fdbuf/fdbuf.h \ + ../lib/fdbuf/fdibuf.h ../lib/fdbuf/fdobuf.h + +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile $(PROGRAMS) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-noinstPROGRAMS mostlyclean-compile \ + mostlyclean-tags mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-noinstPROGRAMS clean-compile clean-tags clean-generic \ + mostlyclean-am + +clean: clean-am + +distclean-am: distclean-noinstPROGRAMS distclean-compile distclean-tags \ + distclean-generic clean-am + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-noinstPROGRAMS \ + maintainer-clean-compile maintainer-clean-tags \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-noinstPROGRAMS distclean-noinstPROGRAMS \ +clean-noinstPROGRAMS maintainer-clean-noinstPROGRAMS \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile tags mostlyclean-tags distclean-tags \ +clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \ +check-am installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# The following makes sure that we can't produce a package without the +# tests executing properly +dist-hook: test + cp -r tests $(distdir) + +test: all + ./address-test + @failed=0; \ + for test in `find tests -type f | fgrep -v CVS`; do \ + echo Running test $$test...; \ + if env - SYSCONFDIR=$(sysconfdir)/nullmailer bash $$test; \ + then echo 'Done.'; \ + else echo '******************************Failed!******************************'; failed=1; \ + fi; \ + done 2>&1; exit $$failed + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/test/address-test.cc b/test/address-test.cc new file mode 100644 index 0000000..3760817 --- /dev/null +++ b/test/address-test.cc @@ -0,0 +1,182 @@ +#include "config.h" +#include <ctype.h> +#include "canonicalize.h" +#include "mystring/mystring.h" +#include "address.h" + +#include "fdbuf/fdbuf.h" +#include "itoa.h" + +static bool test(const mystring& in, + const mystring& out, + const mystring& list) +{ + mystring line = in; + mystring tmplist; + if(!parse_addresses(line, tmplist)) { + fout << "Parsing of '" << in << "' failed." << endl; + return false; + } + bool status = true; + if(!!list && tmplist != list) { + fout << "Parsing of '" << in << "' failed: bad result list, was:\n" + << tmplist + << "should be:\n" + << list; + status = false; + } + if(!!out && line != out) { + fout << "Parsing of '" << in << "' failed: bad result string, was:\n" + << line + << "should be:\n" + << out; + status = false; + } + return status; +} + +#define TEST(X,Y,Z) do{ ++count; if(!test(X,Y,Z)) ++failed; }while(0) + +mystring defaulthost = "a"; +mystring defaultdomain = "b.c"; + +int main() +{ + int count = 0; + int failed = 0; + // periods in local + TEST("a.b@c.d", + "a.b@c.d", + "a.b@c.d\n"); + // quoted local + TEST("\"e\"@c.d", + "e@c.d", + "e@c.d\n"); + // missing host and domain + TEST("e", + "e@a.b.c", + "e@a.b.c\n"); + // missing domain + TEST("e@x", + "e@x.b.c", + "e@x.b.c\n"); + // trailing period + TEST("e@c.d.", + "e@c.d", + "e@c.d\n"); + // comment <address> style + TEST("x<y@a.b>", + "x <y@a.b>", + "y@a.b\n"); + TEST("<y@a.b>", + "<y@a.b>", + "y@a.b\n"); + // address (comment) style + TEST("y@a.b(x)", + "y@a.b (x)", + "y@a.b\n"); + // internal comments before local + TEST("(j)y@a.b", + "y@a.b (j)", + "y@a.b\n"); + // internal comments after local + TEST("y(j)@a.b", + "y@a.b (j)", + "y@a.b\n"); + // internal comments before domain + TEST("y@(j)a.b", + "y@a.b (j)", + "y@a.b\n"); + // internal comments before period + TEST("y@a(j).b", + "y@a.b (j)", + "y@a.b\n"); + // internal comments after period + TEST("y@a.(j)b", + "y@a.b (j)", + "y@a.b\n"); + // normal list + TEST("a@b.c,d@e.f", + "a@b.c, d@e.f", + "a@b.c\nd@e.f\n"); + // list with comments + TEST("a@b.c(j),d@e.f(k)", + "a@b.c (j), d@e.f (k)", + "a@b.c\nd@e.f\n"); + // list without commas + TEST("a@b.c d@e.f", + "a@b.c, d@e.f", + "a@b.c\nd@e.f\n"); + // list without commas with comments + TEST("a@b.c(j) d@e.f(k)", + "a@b.c (j), d@e.f (k)", + "a@b.c\nd@e.f\n"); + // simple group + TEST("g: a@b.c, d@e.f;", + "g: a@b.c, d@e.f;", + "a@b.c\nd@e.f\n"); + // group with spaces in name + TEST("g h: a@b.c, d@e.f;", + "g h: a@b.c, d@e.f;", + "a@b.c\nd@e.f\n"); + // empty group + TEST("g: ;", + "g: ;", + ""); + // group with a comment + TEST("g: a@b.c(j);", + "g: a@b.c (j);", + "a@b.c\n"); + // group with comments + TEST("g:a@b.c(j),d@e.f(k);", + "g: a@b.c (j), d@e.f (k);", + "a@b.c\nd@e.f\n"); + // group with no commas + TEST("g:a@b.c d@e.f;", + "g: a@b.c, d@e.f;", + "a@b.c\nd@e.f\n"); + // group with route addresses + TEST("g:foo<a@b.c>;", + "g: foo <a@b.c>;", + "a@b.c\n"); + // route-path syntax (stripped) + TEST("f<@g.h:a@b.c>", + "f <a@b.c>", + "a@b.c\n"); + // multiple route-path syntax + TEST("f<@g.h@i.j:a@b.c>", + "f <a@b.c>", + "a@b.c\n"); + // comments with quoted brackets + TEST("(f\\)\\()a@b.c", + "a@b.c (f\\)\\()", + "a@b.c\n"); + // nested comments + TEST("(f(g)h)a@b.c", + "a@b.c (f(g)h)", + "a@b.c\n"); + // simple quoted addresses + TEST("\"a\"@b.c", + "a@b.c", + "a@b.c\n"); + // quoted parts of address + TEST("a.\"b\".c@d.e", + "a.b.c@d.e", + "a.b.c@d.e\n"); + // escaped characters within quotes + TEST("\"s\\'b\"@d.e", + "s'b@d.e", + "s'b@d.e\n"); + // escaped specials + TEST("\"s\\\"a\\\"b\"@d.e", + "\"s\\\"a\\\"b\"@d.e", + "s\"a\"b@d.e\n"); + // twisted syntax + //TEST("\"\\\"d\\\" <\"<@_._:e@f.g>", + // "who knows", + // "e@f.g\n"); + + fout << itoa(count) << " tests run, "; + fout << itoa(failed) << " failed." << endl; + return failed; +} diff --git a/test/address-trace.cc b/test/address-trace.cc new file mode 100644 index 0000000..f9957db --- /dev/null +++ b/test/address-trace.cc @@ -0,0 +1,2 @@ +#define TRACE +#include "address.cc" diff --git a/test/tests/CVS/Entries b/test/tests/CVS/Entries new file mode 100644 index 0000000..bd5c58c --- /dev/null +++ b/test/tests/CVS/Entries @@ -0,0 +1,3 @@ +/protocols/1.1/Wed Feb 16 18:24:38 2000// +D/inject//// +D/queue//// diff --git a/test/tests/CVS/Repository b/test/tests/CVS/Repository new file mode 100644 index 0000000..c57efaa --- /dev/null +++ b/test/tests/CVS/Repository @@ -0,0 +1 @@ +nullmailer/test/tests diff --git a/test/tests/CVS/Root b/test/tests/CVS/Root new file mode 100644 index 0000000..a644f54 --- /dev/null +++ b/test/tests/CVS/Root @@ -0,0 +1 @@ +/CVS diff --git a/test/tests/inject/CVS/Entries b/test/tests/inject/CVS/Entries new file mode 100644 index 0000000..435fbdb --- /dev/null +++ b/test/tests/inject/CVS/Entries @@ -0,0 +1,8 @@ +/bad-headers/1.1/Wed Feb 16 18:24:41 2000// +/date/1.1/Wed Feb 16 18:24:41 2000// +/from/1.1/Wed Feb 16 18:24:41 2000// +/message-id/1.1/Wed Feb 16 18:24:41 2000// +/recips/1.1/Wed Feb 16 18:24:41 2000// +/return-path/1.1/Wed Feb 16 18:24:41 2000// +/sender/1.1/Wed Feb 16 18:24:41 2000// +D diff --git a/test/tests/inject/CVS/Repository b/test/tests/inject/CVS/Repository new file mode 100644 index 0000000..fcad062 --- /dev/null +++ b/test/tests/inject/CVS/Repository @@ -0,0 +1 @@ +nullmailer/test/tests/inject diff --git a/test/tests/inject/CVS/Root b/test/tests/inject/CVS/Root new file mode 100644 index 0000000..a644f54 --- /dev/null +++ b/test/tests/inject/CVS/Root @@ -0,0 +1 @@ +/CVS diff --git a/test/tests/inject/bad-headers b/test/tests/inject/bad-headers new file mode 100644 index 0000000..c65d5a7 --- /dev/null +++ b/test/tests/inject/bad-headers @@ -0,0 +1,15 @@ +. functions + +injtest() { echo "$@" | not inject >/dev/null } + +echo "Checking that inject rejects leading continuation lines." +injtest " foo..." + +echo "Checking that inject rejects malformed RFC headers." +injtest "foo : bar" +injtest ":foo bar" +injtest "foo" + +echo "Checking that inject rejects bad addresses." +injtest "from: foo<bar" + diff --git a/test/tests/inject/copy b/test/tests/inject/copy new file mode 100644 index 0000000..9e99c85 --- /dev/null +++ b/test/tests/inject/copy @@ -0,0 +1,19 @@ +. functions + +tst() { + { + echo "To: bruceg@em.ca" + echo + dd if=/dev/urandom bs=1k count=$1 2>/dev/null | uuencode data + } >testmessage.in + inject -n <testmessage.in | \ + sed -e '/^Message-Id:/d' -e '/^Date:/d' -e '/^From:/d' >testmessage.out + cmp testmessage.in testmessage.out +} + +for k in 1 2 4 8 10 20 40 80 100; do + echo "Testing inject with ${k}KB of uuencoded data" + tst $k +done + +rm -f testmessage.{in,out} diff --git a/test/tests/inject/date b/test/tests/inject/date new file mode 100644 index 0000000..5925ab4 --- /dev/null +++ b/test/tests/inject/date @@ -0,0 +1,12 @@ +. functions + +inj() { injectfield date 'to: nobody' "$@" } + +echo "Checking that inject inserts a date line." +test -n "`inj`" + +echo "Checking that inject preserves an existing date line." +inj "date: foo" | grep '^ foo$' >/dev/null + +echo "Checking that inject does not add more date lines." +test 1 -eq `inj "date: foo" | wc -l` diff --git a/test/tests/inject/from b/test/tests/inject/from new file mode 100644 index 0000000..92dfdd2 --- /dev/null +++ b/test/tests/inject/from @@ -0,0 +1,66 @@ +. functions + +inj() { injectfield from 'to: nobody' "$@" } +testvar() { + set -e + echo "Checking that inject obeys $1." + export $1="$2" + inj | grep -q "$3" +} + +echo "Checking that inject inserts a from line." +test -n "`inj`" + +echo "Checking that inject preserves an existing from line." +inj "from: a@b.c" | grep -q '^ a@b\.c$' + +echo "Checking that inject does not add more from lines." +test 1 -eq `inj "from: a@b.c" | wc -l` + +echo "Checking that inject will strip from lines." +export NULLMAILER_FLAGS=f +inj "from: a@b.c" | not grep -q '^ a@b\.c$' +unset NULLMAILER_FLAGS + +echo "Checking that inject obeys hostname()" +hostname=`hostname` +inj | grep -q "@$hostname>$" + +echo "Checking that inject obeys config/defaulthost" +echo test.org >$SYSCONFDIR/defaulthost +inj | grep -q '@test.org>$' + +echo "Checking that inject obeys config/defaultdomain" +echo test >$SYSCONFDIR/defaulthost +echo domain.org >$SYSCONFDIR/defaultdomain +inj | grep -q '@test.domain.org>$' + +testvar HOSTNAME test1.org '@test1.org>$' + +testvar MAILHOST test2.org '@test2.org>$' + +testvar NULLMAILER_HOST test3.org '@test3.org>$' + +echo "Checking that inject uses 'unknown'" +inj | grep -q ' <unknown@' + +testvar LOGNAME name1 ' <name1@' + +testvar USER name2 ' <name2@' + +testvar MAILUSER name3 ' <name3@' + +testvar NULLMAILER_USER name4 ' <name4@' + +echo "Checking that inject uses a blank name." +inj | grep -q '^ <' + +testvar NAME full1 '^ full1 <' + +testvar MAILNAME full2 '^ full2 <' + +testvar NULLMAILER_NAME full3 '^ full3 <' + +echo "Checking that inject will use address-comment form." +export NULLMAILER_FLAGS=c +inj | grep -q '^ name4@test3.org (full3)$' diff --git a/test/tests/inject/headers b/test/tests/inject/headers new file mode 100644 index 0000000..7c052b8 --- /dev/null +++ b/test/tests/inject/headers @@ -0,0 +1,22 @@ +. functions + +tst() { + injectlines "$@" | \ + sed -e '/^Message-Id:/d' -e '/^Date:/d' -e '/^From:/d' >testmessage.out + cmp testmessage.in testmessage.out +} + +cat <<EOF >testmessage.in +To: bruceg@em.ca + +data +done +EOF + +echo Testing header seperation with a blank line +tst 'To: bruceg@em.ca' '' 'data' 'done' + +echo Testing header seperation without a blank line +tst 'To: bruceg@em.ca' 'data' 'done' + +rm -f testmessage.{in,out} diff --git a/test/tests/inject/message-id b/test/tests/inject/message-id new file mode 100644 index 0000000..d0f6d62 --- /dev/null +++ b/test/tests/inject/message-id @@ -0,0 +1,24 @@ +. functions + +inj() { injectfield message-id 'to: n' "$@" } + +echo "Checking that inject inserts a message-id." +test -n "`inj`" + +echo "Checking that inject preserves an existing message-id." +inj "Message-Id: <mid@mid>" | grep -q '^ <mid@mid>$' + +echo "Checking that inject does not add more message-ids." +test 1 -eq `inj "Message-Id: <mid@mid>" | wc -l` + +echo "Checking that inject will ignore an existing message-id." +export NULLMAILER_FLAGS=i +inj "Message-Id: <mid@mid>" | not grep -q '^ <mid@mid>$' + +echo "Checking that inject obeys hostname()" +hostname=`hostname` +inj | grep -q "@$hostname>$" + +echo "Checking that inject obeys config/idhost" +echo test1.org >$SYSCONFDIR/idhost +inj | grep -q '@test1.org>$' diff --git a/test/tests/inject/recips b/test/tests/inject/recips new file mode 100644 index 0000000..c0d3f11 --- /dev/null +++ b/test/tests/inject/recips @@ -0,0 +1,50 @@ +. functions + +inj() { inject -n -v "$@" | tail +2 | sed '/^$/,$d' } +inj-find() { echo to: a@b.c | inj "$1" d@e.f | grep -q "$2" } +inj-notfind() { echo to: a@b.c | inj "$1" d@e.f | not grep -q "$2" } + +hdrline='^a@b.c$' +cmdline='^d@e.f$' + +echo "Checking that inject uses command line with -a." +inj-find -a $cmdline + +echo "Checking that inject ignores header lines with -a." +inj-notfind -a $hdrline + +echo "Checking that inject uses command line with -b." +inj-find -b $cmdline + +echo "Checking that inject uses header lines with -b." +inj-find -b $hdrline + +echo "Checking that inject ignores command line with -h." +inj-notfind -h $cmdline + +echo "Checking that inject uses header lines with -h." +inj-find -h $hdrline + +echo "Checking that inject uses command line with -e and no header." +echo | inj -e d@e.f | grep -q $cmdline + +echo "Checking that inject uses command line with -e and header." +inj-find -e $cmdline + +echo "Checking that inject uses header with -e and no command line." +echo to: a@b.c | inj -e | grep -q $hdrline + +echo "Checking that inject ignores header with -e and command line." +inj-notfind -e $hdrline + +echo "Checking that inject uses command line with no header by default." +echo | inj -e d@e.f | grep -q $cmdline + +echo "Checking that inject uses command line with header by default." +inj-find -e $cmdline + +echo "Checking that inject uses header with no command line by default." +echo to: a@b.c | inj -e | grep -q $hdrline + +echo "Checking that inject ignores header with command line by default." +inj-notfind -e $hdrline diff --git a/test/tests/inject/return-path b/test/tests/inject/return-path new file mode 100644 index 0000000..280838a --- /dev/null +++ b/test/tests/inject/return-path @@ -0,0 +1,9 @@ +. functions + +inj() { injectfield return-path 'to: n' "$@" } + +echo "Checking that inject does not inserts a return-path." +test -z "`inj`" + +echo "Checking that inject strips return-paths." +test -z "`inj return-path: blah`" diff --git a/test/tests/inject/sender b/test/tests/inject/sender new file mode 100644 index 0000000..e624e27 --- /dev/null +++ b/test/tests/inject/sender @@ -0,0 +1,76 @@ +. functions + +inj() { inject -n -v a </dev/null | head -1 } +testvar() { + set -e + echo "Checking that inject obeys $1." + export $1="$2" + inj | grep -q "$3" +} +testcanon() { + set -e + echo "Checking that inject canonicalizes $1." + export $1="$2" + inj | grep -q "$3" +} +testhdr() { + set -e + echo "Checking that inject $1 $2:" + echo $2: $3 | inject -n -v a | head -1 | grep -q "$4" +} +testign() { testhdr ignores "$@" } +testset() { testhdr uses "$@" } + +echo "Checking that inject obeys hostname()" +hostname=`hostname` +domainname=`hostname -d` +inj | grep -q "@$hostname$" + +echo "Checking that inject obeys config/defaulthost" +echo test.org >$SYSCONFDIR/defaulthost +inj | grep -q '@test.org$' + +echo "Checking that inject obeys domainname()" +echo test >$SYSCONFDIR/defaulthost +rm -f $SYSCONFDIR/defaultdomain +inj | grep -q "@test.$domainname$" + +echo "Checking that inject obeys config/defaultdomain" +echo test >$SYSCONFDIR/defaulthost +echo domain.org >$SYSCONFDIR/defaultdomain +inj | grep -q '@test.domain.org$' + +testvar HOSTNAME test1.org '@test1.org$' + +testcanon HOSTNAME test1 '@test1.domain.org$' + +testvar MAILHOST test2.org '@test2.org$' + +testcanon MAILHOST test2 '@test2.domain.org$' + +testvar NULLMAILER_HOST test3.org '@test3.org$' + +testcanon NULLMAILER_HOST test3 '@test3.domain.org$' + +echo "Checking that inject uses 'unknown'" +inj | grep -q '^unknown@' + +testvar LOGNAME name1 '^name1@' + +testvar USER name2 '^name2@' + +testvar MAILUSER name3 '^name3@' + +testvar NULLMAILER_USER name4 '^name4@' + +testign Errors-To a@b.c '^name4@test3' +testign From a@b.c '^name4@test3' +testign Reply-To a@b.c '^name4@test3' +testign Resent-From a@b.c '^name4@test3' +testign Resent-Reply-To a@b.c '^name4@test3' +testign Resent-Sender a@b.c '^name4@test3' +testign Return-Receipt-To a@b.c '^name4@test3' +testign Sender a@b.c '^name4@test3' +testset Return-Path name0@host0.org '^name0@host0.org$' +export NULLMAILER_FLAGS=s +testign Return-Path name0@host0.org '^name4@test3' diff --git a/test/tests/protocols b/test/tests/protocols new file mode 100644 index 0000000..f9d00e7 --- /dev/null +++ b/test/tests/protocols @@ -0,0 +1,44 @@ +. functions + +rm -f testmail +cat >testmail <<EOF +bruceg@em.ca +bruceg@em.ca + +From: <bruceg@em.ca> +To: <bruceg@em.ca> +Subject: Nullmailer automated test message + +Just testing, please ignore +EOF + +for p in smtp qmqp +do + echo "Testing host not found error with $p." + error 2 protocol $p this.host.can.not.exist <testmail + + echo "Testing connection refused error with $p." + error 7 protocol $p -p 24680 localhost <testmail + + echo "Testing usage error with $p (zero args)." + error 1 protocol $p <testmail + + echo "Testing usage error with $p (two args)." + error 1 protocol $p localhost foobar <testmail + + echo "Testing usage error with $p (unknown option)." + error 1 protocol $p -x localhost <testmail + + echo "Testing usage error with $p (invalid integer)." + error 1 protocol $p -p foo localhost <testmail + + tcpserver 0 24680 date & job=$! + sleep 1 + trap "kill $job" EXIT + echo "Testing protocol failure with $p." + error 11 protocol $p -p 24680 localhost <testmail + kill $job + trap - EXIT +done + +rm -f testmail diff --git a/test/tests/queue/CVS/Entries b/test/tests/queue/CVS/Entries new file mode 100644 index 0000000..0ade2cc --- /dev/null +++ b/test/tests/queue/CVS/Entries @@ -0,0 +1,2 @@ +/rewrite/1.1/Wed Feb 16 18:24:45 2000// +D diff --git a/test/tests/queue/CVS/Repository b/test/tests/queue/CVS/Repository new file mode 100644 index 0000000..a6ff493 --- /dev/null +++ b/test/tests/queue/CVS/Repository @@ -0,0 +1 @@ +nullmailer/test/tests/queue diff --git a/test/tests/queue/CVS/Root b/test/tests/queue/CVS/Root new file mode 100644 index 0000000..a644f54 --- /dev/null +++ b/test/tests/queue/CVS/Root @@ -0,0 +1 @@ +/CVS diff --git a/test/tests/queue/rewrite b/test/tests/queue/rewrite new file mode 100644 index 0000000..a7a0575 --- /dev/null +++ b/test/tests/queue/rewrite @@ -0,0 +1,45 @@ +. functions + +que() { + set -e + ../src/nullmailer-queue && \ + cat /tmp/nm/var/nullmailer/queue/* && \ + rm -f /tmp/nm/var/nullmailer/queue/* +} +que-recip() { + set -e + que | sed -e '2,2!d' | grep -q "$@" +} + +echo admin@remote >/tmp/nm/etc/nullmailer/adminaddr + +echo "Checking that queue rewrites user@localhost to adminaddr." +que-recip -q '^admin@remote$' <<EOF +bruceg@qcc.sk.ca +user@localhost + +header + +data +EOF + +echo "Checking that queue rewrites user@hostname to adminaddr." +hostname=`hostname -f` +que-recip -q '^admin@remote$' <<EOF +bruceg@qcc.sk.ca +user@$hostname + +header + +data +EOF + +echo "Checking that queue does not rewrite non-local users." +que-recip -q '^user@nowhere.org$' <<EOF +bruceg@qcc.sk.ca +user@nowhere.org + +header + +data +EOF |