aboutsummaryrefslogtreecommitdiffstats
path: root/tests/run
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2019-11-13 04:16:48 +0100
committerGuilhem Moulin <guilhem@fripost.org>2019-11-13 06:23:57 +0100
commitdac4ab1c9306bf2035bc1547d2ed27ab09850120 (patch)
tree39d04c3d9c92ccf05f109b1123e69af407fe7a6d /tests/run
parent0a2558aabfefd6800fe74c24e5aff2b0d47cc5e2 (diff)
Test suite: add new test for pullimap(1).
This adds a dependency on Dovecot's LMTPd, which will bind to to TCP port 10024 on the loopback interface.
Diffstat (limited to 'tests/run')
-rwxr-xr-xtests/run38
1 files changed, 24 insertions, 14 deletions
diff --git a/tests/run b/tests/run
index 2903938..30d20f9 100755
--- a/tests/run
+++ b/tests/run
@@ -146,9 +146,10 @@ prepare() {
chmod +x -- "$home/.local/bin/doveadm"
done
- # copy interimap config
- mkdir -pm0700 -- "$HOME_local/.local/share/interimap"
- mkdir -pm0700 -- "$HOME_local/.config/interimap"
+ # copy interimap and pullimap configuration
+ mkdir -pm0700 -- "$HOME_local/.local/share/interimap" "$HOME_local/.local/share/pullimap"
+ mkdir -pm0700 -- "$HOME_local/.config/interimap" "$HOME_local/.config/pullimap"
+ echo "deliver-rcpt = local" >>"$HOME_local/.config/pullimap/config"
for u in "${REMOTES[@]}"; do
n="${u#remote}"
eval home="\$HOME_$u"
@@ -160,6 +161,9 @@ prepare() {
if [ -f "$TESTDIR/interimap$n.conf" ] || [ -L "$TESTDIR/interimap$n.conf" ]; then
cat <"$TESTDIR/interimap$n.conf" >>"$HOME_local/.config/interimap/config$n"
fi
+ if [ -f "$TESTDIR/pullimap.conf" ] || [ -L "$TESTDIR/pullimap.conf" ]; then
+ cat <"$TESTDIR/pullimap.conf" >>"$HOME_local/.config/pullimap/config"
+ fi
cat >>"$HOME_local/.config/interimap/config$n" <<-EOF
@@ -172,7 +176,6 @@ prepare() {
cat <"$TESTDIR/interimap$n.local" >>"$HOME_local/.config/interimap/config$n"
fi
- printf "\\n[remote]\\n" >>"$HOME_local/.config/interimap/config$n"
if [ -s "$home/.dovecot/users" ]; then
cat <<-EOF
username = $u
@@ -184,21 +187,26 @@ prepare() {
command = exec ${home@Q}/.local/bin/doveadm exec imap
null-stderr = NO
EOF
- fi >>"$HOME_local/.config/interimap/config$n"
+ fi >"$HOME_local/.$u.conf"
if [ -f "$TESTDIR/interimap$n.remote" ] || [ -L "$TESTDIR/interimap$n.remote" ]; then
- cat <"$TESTDIR/interimap$n.remote" >>"$HOME_local/.config/interimap/config$n"
+ cat <"$TESTDIR/interimap$n.remote" >>"$HOME_local/.$u.conf"
fi
+
+ { printf "\\n[remote]\\n"; cat <"$HOME_local/.$u.conf"; } >>"$HOME_local/.config/interimap/config$n"
+ { printf "\\n[%s]\\n" "$u"; cat <"$HOME_local/.$u.conf"; } >>"$HOME_local/.config/pullimap/config"
done
}
prepare
# Wrappers for interimap(1) and doveadm(1)
-interimap() {
+interimap() { _interimap_cmd "interimap" "$@"; }
+pullimap() { _interimap_cmd "pullimap" "$@"; }
+_interimap_cmd() {
declare -a ENVIRON=() r=0
+ local script="$1"
+ shift
environ_set "local"
- env -i "${ENVIRON[@]}" perl -I./lib -T ./interimap "$@" 2>"$STDERR" || r=$?
- cat "$STDERR" >&2
- return $r
+ env -i "${ENVIRON[@]}" perl -I./lib -T "./$script" "$@" 2> >(tee "$STDERR" >&2)
}
interimap_init() {
local u="${1-remote}"
@@ -227,8 +235,10 @@ sqlite3() {
# Sample (random) message
sample_message() {
local date="$(date +"%s.%N")"
+ # also try non-conventional addresses for pullimap
+ local sender="$(shuf -n1 -e "sender" "first.last" "foo-bar" \"\" "\"x\\\" #&\\\\y\"" )"
cat <<-EOF
- From: <sender@example.net>
+ From: <$sender@example.net>
To: <recipient@example.net>
Date: $(date -R -d@"$date")
Message-ID: <$date@example.net>
@@ -240,7 +250,7 @@ sample_message() {
# Wrapper for dovecot-lda(1)
deliver() {
- local -a argv
+ declare -a argv
while [ $# -gt 0 ] && [ "$1" != "--" ]; do
argv+=( "$1" )
shift
@@ -433,8 +443,8 @@ passed() {
declare -a ENVIRON=()
environ_set "local"
export TMPDIR TESTDIR STDERR "${ENVIRON[@]}"
-export -f environ_set doveadm interimap sqlite3 sample_message deliver
-export -f interimap_init ptree_abort step_start step_done passed
+export -f environ_set doveadm interimap interimap_init pullimap _interimap_cmd
+export -f sqlite3 sample_message deliver ptree_abort step_start step_done passed
export -f check_mailbox_status check_mailbox_status_values check_mailbox_status2
export -f check_mailboxes_status check_mailbox_list xcgrep error
[ "$TESTNAME" = "..." ] || printf "%s%s..." "${INDENT-}" "$TESTNAME"