# 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=bash :