3 # Test that the %(mymbox) function correctly determines whether or not
4 # a particular email address is "mine" or not
7 if test -z "${MH_OBJ_DIR}"; then
8 srcdir=`dirname "$0"`/../..
9 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
12 . "$MH_OBJ_DIR/test/common.sh"
16 #### Use ap to get the username. That will either be what's in the
17 #### Local-Mailbox profile component, which we don't use in the test
18 #### suite, or the user's login name. ap will escape (quote) it if
20 user=`${MH_LIB_DIR}/ap -format '%(me)' 0`
21 host=`${MH_OBJ_DIR}/test/getfqdn`
23 output=`${MH_LIB_DIR}/ap -format '%(mymbox{text})' "${user}"`
24 run_test "echo $output" 1 "Basic user test"
25 output=`${MH_LIB_DIR}/ap -format '%(mymbox{text})' "${user}@${host}"`
26 run_test "echo $output" 1 "Basic user@host test"
27 run_test "${MH_LIB_DIR}/ap -format %(mymbox{text}) nosuchuser@nosuchhost.blah" \
28 0 "Basic non-matching test"
30 myname="Random User <random@user.something.com>"
32 #### Remove existing Local-Mailbox: profile component, if any. Then
34 grep -v 'Local-Mailbox: ' ${MH} > ${MH}.new
36 echo "Local-Mailbox: ${myname}" >> ${MH}
38 run_test "echo `${MH_LIB_DIR}/ap -format '%(mymbox{text})' "${myname}"`" \
39 1 "Local-Mailbox test"
41 output=`${MH_LIB_DIR}/ap -format '%(mymbox{text})' "${user}@${host}"`
42 run_test "echo $output" 0 "Local-mailbox overriding user@host test"
44 # Add an Alternate-Mailbox. This caused ismymbox() to lose the
45 # Local-Mailbox, Bug #36635: -nocc me doesn't account for
46 # Alternate-Mailboxes.
47 printf 'Alternate-Mailboxes: user@example.com\n' >> $MH
48 run_test "echo `${MH_LIB_DIR}/ap -format '%(mymbox{text})' "${myname}"`" \
49 1 "Local-Mailbox with Alternate-Mailbox test"