aboutsummaryrefslogtreecommitdiffstats
path: root/tests/list-mailbox
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2019-11-13 06:24:07 +0100
committerGuilhem Moulin <guilhem@fripost.org>2019-11-13 06:24:07 +0100
commitc6bbdd8aa697b2d42be1ac0839189da32d437a8f (patch)
treecd1b8d19d99557fbebe33344d0d23f6ac826da57 /tests/list-mailbox
parent87d947df1b837514a0f1efa3bc36b58088bd2564 (diff)
parentdac4ab1c9306bf2035bc1547d2ed27ab09850120 (diff)
Merge branch 'master' into debian
Diffstat (limited to 'tests/list-mailbox')
-rw-r--r--tests/list-mailbox/interimap.conf1
-rw-r--r--tests/list-mailbox/local.conf3
-rw-r--r--tests/list-mailbox/remote.conf3
-rw-r--r--tests/list-mailbox/t57
4 files changed, 64 insertions, 0 deletions
diff --git a/tests/list-mailbox/interimap.conf b/tests/list-mailbox/interimap.conf
new file mode 100644
index 0000000..6702107
--- /dev/null
+++ b/tests/list-mailbox/interimap.conf
@@ -0,0 +1 @@
+list-mailbox = foo "foo bar" "f\\\"o\x21o.*" "f\0o\0o"
diff --git a/tests/list-mailbox/local.conf b/tests/list-mailbox/local.conf
new file mode 100644
index 0000000..b56cc70
--- /dev/null
+++ b/tests/list-mailbox/local.conf
@@ -0,0 +1,3 @@
+namespace inbox {
+ separator = .
+}
diff --git a/tests/list-mailbox/remote.conf b/tests/list-mailbox/remote.conf
new file mode 100644
index 0000000..2d6b9e0
--- /dev/null
+++ b/tests/list-mailbox/remote.conf
@@ -0,0 +1,3 @@
+namespace inbox {
+ separator = ?
+}
diff --git a/tests/list-mailbox/t b/tests/list-mailbox/t
new file mode 100644
index 0000000..e905537
--- /dev/null
+++ b/tests/list-mailbox/t
@@ -0,0 +1,57 @@
+# create and populate some mailboxes locally
+declare -a MAILBOXES=( "foo" "foo bar" "f\\\"o!o.bar" "f.o.o" )
+doveadm -u "local" mailbox create -- "${MAILBOXES[@]}" "foobad" "baz" "INBOX"
+for ((i = 0; i < 32; i++)); do
+ m="$(shuf -n1 -e -- "${MAILBOXES[@]}" "foobad" "baz" "INBOX")"
+ sample_message | deliver -u "local" -- -m "$m"
+done
+
+interimap_init
+for m in "${MAILBOXES[@]}"; do
+ grep -Fx "remote: Created mailbox ${m//./?}" <"$STDERR" || error "${m//./?}"
+ grep -Fx "database: Created mailbox $m" <"$STDERR" || error
+done
+
+# also check inferiors in the list, but exclude "foobad" and "baz"
+check_mailbox_list "${MAILBOXES[@]}" "INBOX" "f\\\"o!o" "f" "f.o"
+check_mailboxes_status "${MAILBOXES[@]}" || error
+
+# double check that "foobad" and "baz" weren't created
+! doveadm -u "remote" mailbox status uidvalidity "foobad" || error
+! doveadm -u "remote" mailbox status uidvalidity "baz" || error
+
+# check that "foobad" and "INBOX" aren't in the database
+sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/count" <<-EOF
+ SELECT COUNT(*)
+ FROM mailboxes
+ WHERE mailbox = x'$(printf "%s" "foobad" | xxd -u -ps)'
+ OR mailbox = x'$(printf "%s" "INBOX" | xxd -u -ps)'
+ OR mailbox = x'$(printf "%s" "baz" | xxd -u -ps)'
+EOF
+[ $(< "$TMPDIR/count") -eq 0 ] || error
+
+
+# mailbox given on the command line overrides list-mailbox
+sample_message | deliver -u "local" -- -m "foobad"
+sample_message | deliver -u "local" -- -m "foo"
+interimap "foobad" || error
+! grep -F "remote(foo): Added 1 UID(s)" <"$STDERR" || error
+check_mailbox_list "foobad"
+check_mailbox_status "foobad"
+
+interimap "foo" || error
+grep -F "remote(foo): Added 1 UID(s)" <"$STDERR" || error
+check_mailbox_status "foo"
+! check_mailbox_list "baz"
+
+
+# finally, try a bunch of invalid 'list-mailbox' values to test the parser:
+# empty string, missing space between values, unterminated string
+for v in '""' '"f o o""bar"' '"f o o" "bar" "baz\" x'; do
+ sed -ri "s/^(list-mailbox\\s*=\\s*).*/\\1${v//\\/\\\\}/" \
+ "$XDG_CONFIG_HOME/interimap/config"
+ ! interimap || error
+ grep -xF "Invalid value for list-mailbox: $v" <"$STDERR"
+done
+
+# vim: set filetype=sh :