monotone

monotone Mtn Source Tree

Root/tests/t_smtp.at

1# -*- Autoconf -*-
2
3# this script uses the 'qmail' mail server and the 'tcpserver' network package
4# from ucspi-tcp. if you do not have them installed, it will fail.
5
6AT_SETUP([communicating with a mail server])
7
8MONOTONE_SETUP
9AT_CHECK(cp test.db test2.db)
10
11AT_DATA(smtp.lua, [
12function get_post_targets(groupname)
13return { "mailto:test@127.0.0.1:8025" }
14end
15
16function get_fetch_sources(groupname)
17return { "mailto:test@127.0.0.1:8025" }
18end
19
20function get_mail_hostname(url)
21return "self"
22end
23
24function get_mail_sender(url)
25return "tester@test.net"
26end
27])
28
29AT_DATA(testfile, [version 0 of test file
30])
31AT_CHECK(MONOTONE add testfile, [], [ignore], [ignore])
32AT_CHECK(MONOTONE --branch=testbranch --rcfile=smtp.lua commit blah-blah, [], [ignore], [ignore])
33VER0=`SHA1(MT/manifest)`
34
35AT_DATA(testfile, [version 1 of test file
36])
37AT_CHECK(MONOTONE --rcfile=smtp.lua commit blah-blah, [], [ignore], [ignore])
38VER1=`SHA1(MT/manifest)`
39
40QMAILROOT=`pwd`/qmailroot
41PORT=8025
42HOST=127.0.0.1
43GROUP=monotone.test.packets
44
45export PATH=$QMAILROOT:/usr/local/sbin:$PATH
46TCPSERVER=`which tcpserver`
47SMTPD=`which qmail-smtpd`
48
49# if no tcpserver or smtpd, skip the test
50if test -z "$TCPSERVER" || test -z "$SMTPD"; then
51 exit 77
52fi
53
54# /var/qmail/control/me must be set. crazy.
55AT_CHECK(test -e /var/qmail/control/me)
56AT_CHECK(test -x $TCPSERVER)
57AT_CHECK(test -x $SMTPD)
58AT_CHECK(mkdir -p $QMAILROOT)
59
60# write a fake "qmail-queue" program
61QQ=$QMAILROOT/qmail-queue
62AT_DATA($QQ, [#!/bin/sh
63cat >QROOT/received-mail
64exit 0
65])
66AT_CHECK(perl -i -pe "s@QROOT@$QMAILROOT@" $QQ)
67AT_CHECK(chmod 0755 $QQ)
68
69# autotest knows no way of doing background processes
70
71AT_CHECK(cp $TCPSERVER ./smtp-test-tcpserver)
72AT_CHECK(chmod 0755 ./smtp-test-tcpserver)
73killall -q -TERM smtp-test-tcpserver
74killall -q -KILL qmail-smtpd
75./smtp-test-tcpserver -H -R -P -l 0 $HOST $PORT env QMAILQUEUE=$QQ qmail-smtpd & >/dev/null 2>&1
76sleep 2
77
78AT_CHECK(MONOTONE --rcfile=smtp.lua --verbose post, [], [ignore], [ignore])
79AT_CHECK(grep mdata $QMAILROOT/received-mail, [], [stdout])
80AT_CHECK(grep $VER0 $QMAILROOT/received-mail, [], [ignore])
81
82killall -q -TERM smtp-test-tcpserver
83killall -q -KILL qmail-smtpd
84
85AT_CLEANUP

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status