]> diplodocus.org Git - nmh/blob - test/format/test-mymbox
Merge branch 'master' of ssh://git.sv.gnu.org/srv/git/nmh
[nmh] / test / format / test-mymbox
1 #!/bin/sh
2 #
3 # Test that the %(mymbox) function correctly determines whether or not
4 # a particular email address is "mine" or not
5 #
6
7 if test -z "${MH_OBJ_DIR}"; then
8 srcdir=`dirname "$0"`/../..
9 MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
10 fi
11
12 . "$MH_OBJ_DIR/test/common.sh"
13
14 setup_test
15
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
19 #### needed.
20 user=`run_prog ${MH_LIBEXEC_DIR}/ap -format '%(me)' 0`
21 host=`${MH_OBJ_DIR}/test/getcanon`
22
23 output=`run_prog ${MH_LIBEXEC_DIR}/ap -format '%(mymbox{text})' "${user}"`
24 run_test "echo $output" 1 "Basic user test"
25 output=`run_prog ${MH_LIBEXEC_DIR}/ap -format '%(mymbox{text})' "${user}@${host}"`
26 run_test "echo $output" 1 "Basic user@host test"
27 run_test "${MH_LIBEXEC_DIR}/ap -format %(mymbox{text}) nosuchuser@nosuchhost.blah" \
28 0 "Basic non-matching test"
29
30 myname="Random User <random@user.something.com>"
31
32 #### Remove existing Local-Mailbox: profile component, if any. Then
33 #### add one.
34 grep -v 'Local-Mailbox: ' ${MH} > ${MH}.new
35 mv -f ${MH}.new ${MH}
36 echo "Local-Mailbox: ${myname}" >> ${MH}
37
38 run_test "echo \
39 `run_prog ${MH_LIBEXEC_DIR}/ap -format '%(mymbox{text})' "${myname}"`" \
40 1 "Local-Mailbox test"
41
42 output=`run_prog ${MH_LIBEXEC_DIR}/ap -format '%(mymbox{text})' "${user}@${host}"`
43 run_test "echo $output" 0 "Local-mailbox overriding user@host test"
44
45 # Add an Alternate-Mailbox. This caused ismymbox() to lose the
46 # Local-Mailbox, Bug #36635: -nocc me doesn't account for
47 # Alternate-Mailboxes.
48 printf 'Alternate-Mailboxes: user@example.com\n' >> $MH
49 run_test "echo \
50 `run_prog ${MH_LIBEXEC_DIR}/ap -format '%(mymbox{text})' "${myname}"`" \
51 1 "Local-Mailbox with Alternate-Mailbox test"
52
53 exit $failed