3 # Test the XOAUTH2 support in inc
6 if test -z "${MH_OBJ_DIR}"; then
7 srcdir
=`dirname "$0"`/..
/..
8 MH_OBJ_DIR
=`cd "${srcdir}" && pwd`; export MH_OBJ_DIR
11 .
"${srcdir}/test/oauth/common.sh"
20 start_test
'access token ready, pop server accepts message'
23 access-nobody@example.com: test-access
24 expire-nobody@example.com: 2000000000
32 start_test
'expired access token, refresh works, pop server accepts message'
35 access-nobody@example.com: old-access
36 refresh-nobody@example.com: test-refresh
37 expire-nobody@example.com: 1414303986
40 expect_http_post_refresh
42 fake_json_response
<<EOF
44 "access_token": "test-access",
45 "token_type": "Bearer",
62 start_test
'refresh gets proper error from http'
65 access-nobody@example.com: test-access
66 refresh-nobody@example.com: test-refresh
69 expect_http_post_refresh
71 fake_http_response
'400 Bad Request' <<EOF
72 Content-Type: application/json
75 "error": "invalid_request"
82 test_inc
'inc: error refreshing OAuth2 token
83 inc: bad OAuth request; re-run with -snoop and send REDACTED output to nmh-workers'
88 start_test
'pop server rejects token'
91 access-nobody@example.com: wrong-access
92 expire-nobody@example.com: 2000000000
97 test_inc
'inc: Authentication failed: -ERR [AUTH] Invalid credentials.'
100 start_test
"pop server doesn't support oauth"
103 access-nobody@example.com: test-access
104 expire-nobody@example.com: 2000000000
107 start_pop testuser testpass
109 test_inc
'inc: POP server does not support SASL'