aboutsummaryrefslogtreecommitdiffstats
path: root/tests/list-reference/t
blob: 12e112b348e36fbc93bee3bdb0778edfdabbc79a (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
# create and populate some mailboxes in and out the respective list references
doveadm -u "local"  mailbox create "foo" "foobar" "foo/bar/baz" "foo/baz" "bar" "bar/baz"
doveadm -u "remote" mailbox create "foo" "foobaz" "foo/baz" "foo\\baz" "bar\\baz" "bar\\!"

populate() {
    local i
    for ((i = 0; i < 32; i++)); do
        m="$(shuf -n1 -e -- "foo" "foobar" "foo/bar/baz" "foo/baz" "bar" "bar/baz")"
        sample_message | deliver -u "local" -- -m "$m"

        m="$(shuf -n1 -e -- "foo" "foobar" "foo/baz" "foo\\baz" "bar\\baz" "bar\\!")"
        sample_message | deliver -u "remote" -- -m "$m"
    done
}
populate

interimap_init
grep -Fx "database: Created mailbox bar/baz"     <"$STDERR" || error
grep -Fx "database: Created mailbox baz"         <"$STDERR" || error
grep -Fx "database: Created mailbox !"           <"$STDERR" || error
grep -Fx "local: Created mailbox foo/!"          <"$STDERR" || error
grep -Fx "remote: Created mailbox bar\\bar\\baz" <"$STDERR" || error

verify() {
    # check that the mailbox lists match
    diff -u --label="local/mailboxes" --label="remote/mailboxes" \
        <( doveadm -u "local"  mailbox list | sed -n 's,^foo/,,p'  |               sort ) \
        <( doveadm -u "remote" mailbox list | sed -n 's,^bar\\,,p' | tr '\\' '/' | sort ) \
        || error "mailbox lists differ"

    for m in "bar/baz" "baz" "!"; do
        blob="x'$(printf "%s" "$m" | tr "/" "\\0" | xxd -c256 -u -ps)'"
        check_mailbox_status2 "$blob" "foo/$m" "remote" "bar\\${m//\//\\}"
    done
}
verify

# add more messages and re-check
populate
interimap || error
verify

# double check that mailboxes outside references weren't created
! doveadm -u "local"  mailbox status uidvalidity "foobaz" || error
! doveadm -u "remote" mailbox status uidvalidity "foobar" || error

# vim: set filetype=bash :