aboutsummaryrefslogtreecommitdiffstats
path: root/tests/03-sync-mailbox-list-partial
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2019-05-26 23:28:04 +0200
committerGuilhem Moulin <guilhem@fripost.org>2019-05-27 00:39:49 +0200
commit8e379c62a48d68cd5ab2a32c6fc9244b1ae94084 (patch)
treedd3656ac60fe10c1e1739a88350f77c2f2a417f9 /tests/03-sync-mailbox-list-partial
parent456946609aa1e64a42578ff1c4962ea939d31da4 (diff)
Add test-suite (requires dovecot-imapd).
Diffstat (limited to 'tests/03-sync-mailbox-list-partial')
-rw-r--r--tests/03-sync-mailbox-list-partial/interimap.conf1
-rw-r--r--tests/03-sync-mailbox-list-partial/local.conf6
-rw-r--r--tests/03-sync-mailbox-list-partial/remote.conf6
-rw-r--r--tests/03-sync-mailbox-list-partial/run57
4 files changed, 70 insertions, 0 deletions
diff --git a/tests/03-sync-mailbox-list-partial/interimap.conf b/tests/03-sync-mailbox-list-partial/interimap.conf
new file mode 100644
index 0000000..4970867
--- /dev/null
+++ b/tests/03-sync-mailbox-list-partial/interimap.conf
@@ -0,0 +1 @@
+list-mailbox = *
diff --git a/tests/03-sync-mailbox-list-partial/local.conf b/tests/03-sync-mailbox-list-partial/local.conf
new file mode 100644
index 0000000..93497d9
--- /dev/null
+++ b/tests/03-sync-mailbox-list-partial/local.conf
@@ -0,0 +1,6 @@
+namespace inbox {
+ separator = .
+ location = maildir:~/inbox:LAYOUT=index
+ inbox = yes
+ list = yes
+}
diff --git a/tests/03-sync-mailbox-list-partial/remote.conf b/tests/03-sync-mailbox-list-partial/remote.conf
new file mode 100644
index 0000000..352cdd4
--- /dev/null
+++ b/tests/03-sync-mailbox-list-partial/remote.conf
@@ -0,0 +1,6 @@
+namespace inbox {
+ separator = ~
+ location = maildir:~/inbox:LAYOUT=index
+ inbox = yes
+ list = yes
+}
diff --git a/tests/03-sync-mailbox-list-partial/run b/tests/03-sync-mailbox-list-partial/run
new file mode 100644
index 0000000..449115d
--- /dev/null
+++ b/tests/03-sync-mailbox-list-partial/run
@@ -0,0 +1,57 @@
+# try a bunch of invalid 'list-mailbox' values:
+# 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
+ xgrep -xF "Invalid value for list-mailbox: $v" <"$STDERR"
+done
+
+# create some mailboxes
+doveadm -u "local" mailbox create "foo" "foo bar" "f\\\"o!o.bar" "f.o.o" "bad"
+for m in "foo" "foo bar" "f\\\"o!o.bar" "f.o.o" "bad" "INBOX"; do
+ sample_message | deliver -u "local" -- -m "$m"
+done
+
+# restrict 'list-mailbox' to the above minus "bad"
+sed -ri 's/^(list-mailbox\s*=\s*).*/\1foo "foo bar" "f\\\\\\"o\\x21o.*" "f\\0o\\0o"/' \
+ "$XDG_CONFIG_HOME/interimap/config"
+
+# run partial sync
+interimap
+check_mailbox_list "foo" "foo bar" "f\\\"o!o.bar" "f.o.o" "INBOX" "f\\\"o!o" "f" "f.o"
+check_mailboxes_status "foo" "foo bar" "f\\\"o!o.bar" "f.o.o"
+
+# check that "bad" isn't in the remote imap server
+! doveadm -u "remote" mailbox status uidvalidity "bad"
+
+# check that "bad" 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" "bad" | xxd -ps)'
+ OR mailbox = x'$(printf "%s" "INBOX" | xxd -ps)'
+EOF
+[ $(< "$TMPDIR/count") -eq 0 ]
+
+
+# run partial sync
+doveadm -u "remote" mailbox create "f\\\"o!o~baz" "f\\\"o!o~bad"
+for m in "f\\\"o!o~baz" "f\\\"o!o~bad"; do
+ sample_message | deliver -u "remote" -- -m "$m"
+done
+interimap "f\\\"o!o.baz"
+
+check_mailbox_list "foo" "foo bar" "f\\\"o!o.bar" "f.o.o" "INBOX" "f\\\"o!o" "f" "f.o" "f\\\"o!o.baz"
+check_mailboxes_status "foo" "foo bar" "f\\\"o!o.bar" "f.o.o" "f\\\"o!o.baz"
+
+# check that "bad", "f\\\"o!o.bad" 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" "bad" | xxd -ps)'
+ OR mailbox = x'$(printf "%s" "INBOX" | xxd -ps)'
+ OR mailbox = x'$(printf "%s\\0%s" "f\\\"o!o" "bad" | xxd -ps)'
+EOF
+[ $(< "$TMPDIR/count") -eq 0 ]
+
+# vim: set filetype=sh :