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 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
#!/bin/sh
#
# Test that inc, msgchck, and send share tokens.
#
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"
setup_pop
export XOAUTH
XOAUTH='dXNlcj1ub2JvZHlAZXhhbXBsZS5jb20BYXV0aD1CZWFyZXIgdGVzdC1hY2Nlc3MBAQ=='
# TEST
start_test 'mhlogin then all run with no refresh'
expect_http_post_code
fake_json_response <<EOF
{
"access_token": "test-access",
"token_type": "Bearer",
"expires_in": 3600
}
EOF
expect_creds <<EOF
access-nobody@example.com: test-access
expire-nobody@example.com:
EOF
start_fakehttp
run_test 'eval echo code | mhlogin -user nobody@example.com -saslmech xoauth2 -authservice test' \
"Load the following URL in your browser and authorize nmh to access test:
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
Enter the authorization code: "
start_pop_xoauth
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'
start_pop_xoauth
test_inc_success
setup_draft
test_send_only_fakesmtp
# TEST
start_test 'inc refreshes'
fake_creds <<EOF
access-nobody@example.com: old-access
refresh-nobody@example.com: test-refresh
expire-nobody@example.com: 1414303986
EOF
expect_http_post_refresh
fake_json_response <<EOF
{
"access_token": "test-access",
"token_type": "Bearer",
"expires_in": 3600
}
EOF
start_fakehttp
start_pop_xoauth
test_inc_success
start_pop_xoauth
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'
setup_draft
test_send_only_fakesmtp
# TEST
start_test 'msgchck refreshes'
fake_creds <<EOF
access-nobody@example.com: old-access
refresh-nobody@example.com: test-refresh
expire-nobody@example.com: 1414303986
EOF
expect_http_post_refresh
fake_json_response <<EOF
{
"access_token": "test-access",
"token_type": "Bearer",
"expires_in": 3600
}
EOF
start_fakehttp
start_pop_xoauth
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'
start_pop_xoauth
test_inc_success
setup_draft
test_send_only_fakesmtp
# TEST
start_test 'send refreshes'
fake_creds <<EOF
access-nobody@example.com: old-access
refresh-nobody@example.com: test-refresh
expire-nobody@example.com: 1414303986
EOF
expect_http_post_refresh
fake_json_response <<EOF
{
"access_token": "test-access",
"token_type": "Bearer",
"expires_in": 3600
}
EOF
setup_draft
test_send
start_pop_xoauth
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'
start_pop_xoauth
test_inc_success
clean_fakesmtp
clean_fakehttp
finish_test
exit ${failed:-0}
|