]>
diplodocus.org Git - nmh/blob - test/format/test-mymbox
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
=`run_prog ${MH_LIBEXEC_DIR}/ap -format '%(me)' 0`
22 host=`${MH_OBJ_DIR}/test/getcanon`
25 output
=`run_prog ${MH_LIBEXEC_DIR}/ap -format '%(mymbox{text})' "${user}"`
26 run_test
"echo $output" 1 "Basic user test"
27 output
=`run_prog ${MH_LIBEXEC_DIR}/ap -format '%(mymbox{text})' "${user}@${host}"`
28 run_test
"echo $output" 1 "Basic user@host test"
29 run_test
"${MH_LIBEXEC_DIR}/ap -format %(mymbox{text}) nosuchuser@nosuchhost.blah" \
30 0 "Basic non-matching test"
32 myname
="Random User <random@user.something.com>"
34 #### Remove existing Local-Mailbox: profile component, if any. Then
36 grep -v 'Local-Mailbox: ' "$MH" > "$MH".new
38 echo "Local-Mailbox: ${myname}" >> "$MH"
41 `run_prog ${MH_LIBEXEC_DIR}/ap -format '%(mymbox{text})' "${myname}"`" \
42 1 "Local-Mailbox test"
44 output
=`run_prog ${MH_LIBEXEC_DIR}/ap -format '%(mymbox{text})' "${user}@${host}"`
45 run_test
"echo $output" 0 "Local-mailbox overriding user@host test"
47 # Add an Alternate-Mailbox. This caused ismymbox() to lose the
48 # Local-Mailbox, Bug #36635: -nocc me doesn't account for
49 # Alternate-Mailboxes.
50 printf 'Alternate-Mailboxes: user@example.com\n' >> $MH
52 `run_prog ${MH_LIBEXEC_DIR}/ap -format '%(mymbox{text})' "${myname}"`" \
53 1 "Local-Mailbox with Alternate-Mailbox test"
55 # check getmymbox, without match
56 run_test
'fmttest -message -format %(getmymbox{from}) first' ''
58 # check getmyaddr, without match
59 run_test
'fmttest -message -format %(getmyaddr{from}) first' ''
61 grep -v 'Alternate-Mailboxes: ' "$MH" > "$MH".new
64 Alternate-Mailboxes: test1@example.com
67 # check getmymbox, with match
68 run_test
'fmttest -message -format %(getmymbox{from}) first' \
69 'Test1 <test1@example.com>'
71 # check getmyaddr, with match
72 run_test
'fmttest -message -format %(getmyaddr{from}) first' \
75 # check getmymbox and getmyaddr, with match of other than first address in
77 cat >`mhpath new` <<'EOF'
78 From: Test11 <test11@example.com>
79 Cc: Test0 <test0@example.com>, Test3 <test3@example.com>,
80 Test1 <test1@example.com>, Test2 <test2@example.com>
81 To: Some User <user@example.com>
82 Date: Fri, 29 Sep 2006 00:00:00
83 Message-Id: 11@test.nmh
84 Subject: Testing message 11
86 This is message number 11
88 run_test
'fmttest -message -format %(getmymbox{cc}) last' \
89 'Test1 <test1@example.com>'
90 run_test
'fmttest -message -format %(getmyaddr{cc}) last' \