]> diplodocus.org Git - nmh/blob - test/oauth/test-share
Split some comma-operator terms into separate statements.
[nmh] / test / oauth / test-share
1 #!/bin/sh
2 #
3 # Test that inc, msgchck, and send share tokens.
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 setup_pop
14
15 export XOAUTH
16 XOAUTH='dXNlcj1ub2JvZHlAZXhhbXBsZS5jb20BYXV0aD1CZWFyZXIgdGVzdC1hY2Nlc3MBAQ=='
17
18 # TEST
19 start_test 'mhlogin then all run with no refresh'
20
21 expect_http_post_code
22
23 fake_json_response <<EOF
24 {
25 "access_token": "test-access",
26 "token_type": "Bearer",
27 "expires_in": 3600
28 }
29 EOF
30
31 expect_creds <<EOF
32 access-nobody@example.com: test-access
33 expire-nobody@example.com:
34 EOF
35
36 start_fakehttp
37 run_test 'eval echo code | mhlogin -user nobody@example.com -saslmech xoauth2 -authservice test' \
38 "Load the following URL in your browser and authorize nmh to access test:
39
40 http://127.0.0.1:${http_port}/oauth/auth?response_type=code&client_id=test-id&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=test-scope
41
42 Enter the authorization code: "
43
44 start_pop_xoauth
45 run_test "msgchk -host 127.0.0.1 -port ${pop_port} -sasl -saslmech xoauth2 -authservice test -user nobody@example.com" 'nobody@example.com has 1 message (178 bytes) on 127.0.0.1'
46
47 start_pop_xoauth
48 test_inc_success
49
50 setup_draft
51 test_send_only_fakesmtp
52
53 # TEST
54 start_test 'inc refreshes'
55
56 fake_creds <<EOF
57 access-nobody@example.com: old-access
58 refresh-nobody@example.com: test-refresh
59 expire-nobody@example.com: 1414303986
60 EOF
61
62 expect_http_post_refresh
63
64 fake_json_response <<EOF
65 {
66 "access_token": "test-access",
67 "token_type": "Bearer",
68 "expires_in": 3600
69 }
70 EOF
71
72 start_fakehttp
73 start_pop_xoauth
74 test_inc_success
75
76 start_pop_xoauth
77 run_test "msgchk -host 127.0.0.1 -port ${pop_port} -sasl -saslmech xoauth2 -authservice test -user nobody@example.com" 'nobody@example.com has 1 message (178 bytes) on 127.0.0.1'
78
79 setup_draft
80 test_send_only_fakesmtp
81
82 # TEST
83 start_test 'msgchck refreshes'
84
85 fake_creds <<EOF
86 access-nobody@example.com: old-access
87 refresh-nobody@example.com: test-refresh
88 expire-nobody@example.com: 1414303986
89 EOF
90
91 expect_http_post_refresh
92
93 fake_json_response <<EOF
94 {
95 "access_token": "test-access",
96 "token_type": "Bearer",
97 "expires_in": 3600
98 }
99 EOF
100
101 start_fakehttp
102 start_pop_xoauth
103 run_test "msgchk -host 127.0.0.1 -port ${pop_port} -sasl -saslmech xoauth2 -authservice test -user nobody@example.com" 'nobody@example.com has 1 message (178 bytes) on 127.0.0.1'
104
105 start_pop_xoauth
106 test_inc_success
107
108 setup_draft
109 test_send_only_fakesmtp
110
111 # TEST
112 start_test 'send refreshes'
113
114 fake_creds <<EOF
115 access-nobody@example.com: old-access
116 refresh-nobody@example.com: test-refresh
117 expire-nobody@example.com: 1414303986
118 EOF
119
120 expect_http_post_refresh
121
122 fake_json_response <<EOF
123 {
124 "access_token": "test-access",
125 "token_type": "Bearer",
126 "expires_in": 3600
127 }
128 EOF
129
130 setup_draft
131 test_send
132
133 start_pop_xoauth
134 run_test "msgchk -host 127.0.0.1 -port ${pop_port} -sasl -saslmech xoauth2 -authservice test -user nobody@example.com" 'nobody@example.com has 1 message (178 bytes) on 127.0.0.1'
135
136 start_pop_xoauth
137 test_inc_success
138
139 clean_fakesmtp
140 clean_fakehttp
141 finish_test
142
143 exit ${failed:-0}