File: test-sendfrom

package info (click to toggle)
nmh 1.8-4
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 7,860 kB
  • sloc: ansic: 50,445; sh: 22,697; makefile: 1,138; lex: 740; perl: 509; yacc: 265
file content (64 lines) | stat: -rwxr-xr-x 1,535 bytes parent folder | download | duplicates (5)
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
63
64
#!/bin/sh
#
# Test the XOAUTH2 support with sendfrom
#

if test -z "${MH_OBJ_DIR}"; then
    srcdir=`dirname "$0"`/../..
    MH_OBJ_DIR=`cd "${srcdir}" && pwd`; export MH_OBJ_DIR
fi

. "${srcdir}/test/oauth/common.sh"

# fakesmtp uses the XOAUTH environment variable
export XOAUTH
XOAUTH='dXNlcj11c2VyQGV4YW1wbGUuY29tAWF1dGg9QmVhcmVyIHRlc3QtYWNjZXNzAQE='

# TEST
start_test 'with sendfrom'

setup_draft

fake_creds <<EOF
access-user@example.com: test-access
refresh-user@example.com: test-refresh
expire-user@example.com: 2000000000
EOF

#### Set up profile to use sendfrom by adding a sendfrom-addr.  This one adds
#### the oauth switches, which are necessary for this test.
sendfrom="$MH_INST_DIR${datarootdir}/doc/nmh/contrib/sendfrom"
cat >> "$MH" <<EOF
sendfrom-nobody@example.com: -server 127.0.0.1 -port ${smtp_port}
  -client localhost -sasl -saslmech xoauth2 -authservice test -user user@example.com
EOF

cat > "${testname}.expected" <<EOF
EHLO localhost
AUTH XOAUTH2 dXNlcj11c2VyQGV4YW1wbGUuY29tAWF1dGg9QmVhcmVyIHRlc3QtYWNjZXNzAQE=
MAIL FROM:<nobody@example.com>
RCPT TO:<somebody@example.com>
DATA
From: Mr Nobody <nobody@example.com>
To: Somebody Else <somebody@example.com>
Subject: Test
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Date:

This is a test
.
QUIT
EOF

start_fakesmtp
run_test "send -draft"
sed 's/^Date:.*/Date:/' "${testname}.smtp-req" > "${testname}.smtp-req".clean
check "${testname}.smtp-req".clean "${testname}.expected"


clean_fakesmtp
clean_fakehttp
finish_test

exit ${failed:-0}