]> diplodocus.org Git - nmh/blob - test/oauth/test-sendfrom
new.c: Order two return statements to match comment.
[nmh] / test / oauth / test-sendfrom
1 #!/bin/sh
2 #
3 # Test the XOAUTH2 support with sendfrom
4 #
5
6 if test -z "${MH_OBJ_DIR}"; then
7 srcdir=`dirname "$0"`/../..
8 MH_OBJ_DIR=`cd "${srcdir}" && pwd`; export MH_OBJ_DIR
9 fi
10
11 . "${srcdir}/test/oauth/common.sh"
12
13 # fakesmtp uses the XOAUTH environment variable
14 export XOAUTH
15 XOAUTH='dXNlcj11c2VyQGV4YW1wbGUuY29tAWF1dGg9QmVhcmVyIHRlc3QtYWNjZXNzAQE='
16
17 # TEST
18 start_test 'with sendfrom'
19
20 setup_draft
21
22 fake_creds <<EOF
23 access-user@example.com: test-access
24 refresh-user@example.com: test-refresh
25 expire-user@example.com: 2000000000
26 EOF
27
28 #### Set up profile to use sendfrom by adding a sendfrom-addr. This one adds
29 #### the oauth switches, which are necessary for this test.
30 sendfrom="$MH_INST_DIR${datarootdir}/doc/nmh/contrib/sendfrom"
31 cat >> "$MH" <<EOF
32 sendfrom-nobody@example.com: -server 127.0.0.1 -port ${smtp_port}
33 -client localhost -sasl -saslmech xoauth2 -authservice test -user user@example.com
34 EOF
35
36 cat > "${testname}.expected" <<EOF
37 EHLO localhost
38 AUTH XOAUTH2 dXNlcj11c2VyQGV4YW1wbGUuY29tAWF1dGg9QmVhcmVyIHRlc3QtYWNjZXNzAQE=
39 MAIL FROM:<nobody@example.com>
40 RCPT TO:<somebody@example.com>
41 DATA
42 From: Mr Nobody <nobody@example.com>
43 To: Somebody Else <somebody@example.com>
44 Subject: Test
45 MIME-Version: 1.0
46 Content-Type: text/plain; charset="us-ascii"
47 Date:
48
49 This is a test
50 .
51 QUIT
52 EOF
53
54 start_fakesmtp
55 run_test "send -draft"
56 sed 's/^Date:.*/Date:/' "${testname}.smtp-req" > "${testname}.smtp-req".clean
57 check "${testname}.smtp-req".clean "${testname}.expected"
58
59
60 clean_fakesmtp
61 clean_fakehttp
62 finish_test
63
64 exit ${failed:-0}