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"
81 test_inc
'inc: error refreshing OAuth2 token
82 inc: bad OAuth request; re-run with -snoop and send REDACTED output to nmh-workers'
87 start_test
'pop server rejects token'
90 access-nobody@example.com: wrong-access
91 expire-nobody@example.com: 2000000000
96 test_inc
'inc: -ERR [AUTH] Invalid credentials.'
99 start_test
"pop server doesn't support oauth"
102 access-nobody@example.com: test-access
103 expire-nobody@example.com: 2000000000
106 start_pop testuser testpass
108 test_inc
'inc: POP server does not support SASL'