blob: f90227c727f9c3592b40a097e122a07a7cb66fc5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
doveadm -u "local" mailbox create "foo" -- "-virtual"
doveadm -u "remote" mailbox create "bar" -- "virtual-"
interimap_init
check_mailbox_list
sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/mailboxes.sql" <<-EOF
SELECT idx, mailbox FROM mailboxes ORDER BY idx
EOF
for ((i = 0; i < 16; i++)); do
u="$(shuf -n1 -e "local" "remote")" # choose target at random
m="$(shuf -n1 -e -- "INBOX" "foo" "bar")"
sample_message | deliver -u "$u" -- -m "$m"
done
# create new mailboxes matching 'ignore-mailbox'
doveadm -u "local" mailbox create "virtual" "virtual.foo"
doveadm -u "remote" mailbox create "virtual^bar"
for n in $(seq 1 "$(shuf -n1 -i1-8)"); do
sample_message | deliver -u "local" -- -m "virtual"
sample_message | deliver -u "local" -- -m "virtual.foo"
done
for n in $(seq 1 "$(shuf -n1 -i1-8)"); do
sample_message | deliver -u "remote" -- -m "virtual^bar"
done
# no new mailbox should be created
interimap || error
sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/mailboxes2.sql" <<-EOF
SELECT idx, mailbox FROM mailboxes ORDER BY idx
EOF
diff -u --label="a/mailboxes.sql" --label="b/mailboxes.sql" \
"$TMPDIR/mailboxes.sql" "$TMPDIR/mailboxes2.sql" || error "SQL dumps differ"
check_mailboxes_status "INBOX" "foo" "bar"
# double check the unsubscribed mailboxes weren't copied
! doveadm -u "remote" mailbox status uidvalidity "virtual" || error
! doveadm -u "remote" mailbox status uidvalidity "virtual^foo" || error
! doveadm -u "local" mailbox status uidvalidity "virtual.bar" || error
# ignored mailboxes are created when passed to the command line
interimap "virtual" "virtual.bar" || error
grep -Fx "database: Created mailbox virtual" <"$STDERR" || error
grep -Fx "database: Created mailbox virtual.bar" <"$STDERR" || error
grep -Fx "local: Created mailbox virtual.bar" <"$STDERR" || error
grep -Fx "remote: Created mailbox virtual" <"$STDERR" || error
sqlite3 "$XDG_DATA_HOME/interimap/remote.db" >"$TMPDIR/mailboxes.sql" <<-EOF
SELECT idx, mailbox FROM mailboxes
WHERE mailbox != x'$(printf "virtual" | xxd -ps)'
AND mailbox != x'$(printf "%s\\0%s" "virtual" "foo" | xxd -ps)'
ORDER BY idx
EOF
check_mailboxes_status "virtual" "virtual.bar" || error
# vim: set filetype=sh :
|