]> diplodocus.org Git - nmh/commitdiff
Migrated the oauth tests to start_test()/finish_test() so that
authorDavid Levine <david.levine@gonift.com>
Sat, 26 Mar 2016 23:05:10 +0000 (19:05 -0400)
committerDavid Levine <david.levine@gonift.com>
Sat, 26 Mar 2016 23:05:10 +0000 (19:05 -0400)
they don't have any output on success, but do report the particular
test on failure.

test/oauth/test-inc
test/oauth/test-mhlogin
test/oauth/test-send
test/oauth/test-share

index 16b55b5865845f4ecd735d317165bc32817697e7..6fa5892ac88f5b6d0045de59f98cd6ff8a8af283 100755 (executable)
@@ -17,7 +17,7 @@ setup_pop
 #
 
 # TEST
 #
 
 # TEST
-echo 'access token ready, pop server accepts message'
+start_test 'access token ready, pop server accepts message'
 
 fake_creds <<EOF
 access: test-access
 
 fake_creds <<EOF
 access: test-access
@@ -29,7 +29,7 @@ start_pop_xoauth
 test_inc_success
 
 # TEST
 test_inc_success
 
 # TEST
-echo 'expired access token, refresh works, pop server accepts message'
+start_test 'expired access token, refresh works, pop server accepts message'
 
 fake_creds <<EOF
 access: old-access
 
 fake_creds <<EOF
 access: old-access
@@ -59,7 +59,7 @@ check_http_req
 #
 
 # TEST
 #
 
 # TEST
-echo 'refresh gets proper error from http'
+start_test 'refresh gets proper error from http'
 
 fake_creds <<EOF
 access: test-access
 
 fake_creds <<EOF
 access: test-access
@@ -84,7 +84,7 @@ inc: bad OAuth request; re-run with -snoop and send REDACTED output to nmh-worke
 check_http_req
 
 # TEST
 check_http_req
 
 # TEST
-echo 'pop server rejects token'
+start_test 'pop server rejects token'
 
 fake_creds <<EOF
 access: wrong-access
 
 fake_creds <<EOF
 access: wrong-access
@@ -96,7 +96,7 @@ start_pop_xoauth
 test_inc 'inc: -ERR [AUTH] Invalid credentials.'
 
 # TEST
 test_inc 'inc: -ERR [AUTH] Invalid credentials.'
 
 # TEST
-echo "pop server doesn't support oauth"
+start_test "pop server doesn't support oauth"
 
 fake_creds <<EOF
 access: test-access
 
 fake_creds <<EOF
 access: test-access
@@ -108,5 +108,6 @@ start_pop testuser testpass
 test_inc 'inc: POP server does not support SASL'
 
 clean_fakehttp
 test_inc 'inc: POP server does not support SASL'
 
 clean_fakehttp
+finish_test
 
 exit ${failed:-0}
 
 exit ${failed:-0}
index c6c026184fc4a38c5d9bdd75d091dc86eecde814..7f2bcc4ab6b69f9ead7731e9ec6c8ffa1d85f68b 100755 (executable)
@@ -39,7 +39,7 @@ mhlogin: invalid response'
 #
 
 # TEST
 #
 
 # TEST
-echo 'mhlogin receives access and expiration'
+start_test 'mhlogin receives access and expiration'
 
 expect_http_post_code
 
 
 expect_http_post_code
 
@@ -59,7 +59,7 @@ EOF
 test_mhlogin
 
 # TEST
 test_mhlogin
 
 # TEST
-echo 'mhlogin receives access and refresh'
+start_test 'mhlogin receives access and refresh'
 
 expect_http_post_code
 
 
 expect_http_post_code
 
@@ -77,7 +77,7 @@ EOF
 test_mhlogin
 
 # TEST
 test_mhlogin
 
 # TEST
-echo 'mhlogin receives access, expiration, and refresh'
+start_test 'mhlogin receives access, expiration, and refresh'
 
 expect_http_post_code
 
 
 expect_http_post_code
 
@@ -99,7 +99,7 @@ EOF
 test_mhlogin
 
 # TEST
 test_mhlogin
 
 # TEST
-echo 'mhlogin receives refresh only'
+start_test 'mhlogin receives refresh only'
 
 expect_http_post_code
 
 
 expect_http_post_code
 
@@ -117,7 +117,7 @@ EOF
 test_mhlogin
 
 # TEST
 test_mhlogin
 
 # TEST
-echo 'mhlogin receives token_type only'
+start_test 'mhlogin receives token_type only'
 
 expect_http_post_code
 
 
 expect_http_post_code
 
@@ -132,7 +132,7 @@ expect_no_creds
 test_mhlogin_invalid_response
 
 # TEST
 test_mhlogin_invalid_response
 
 # TEST
-echo 'mhlogin ignores extra bits in successful response JSON'
+start_test 'mhlogin ignores extra bits in successful response JSON'
 
 expect_http_post_code
 
 
 expect_http_post_code
 
@@ -160,7 +160,7 @@ EOF
 test_mhlogin
 
 # TEST
 test_mhlogin
 
 # TEST
-echo 'mhlogin user enters bad code'
+start_test 'mhlogin user enters bad code'
 
 expect_http_post_code
 
 
 expect_http_post_code
 
@@ -181,7 +181,7 @@ test_mhlogin 'Code rejected; try again? '
 #
 
 # TEST
 #
 
 # TEST
-echo 'mhlogin response has no content-type'
+start_test 'mhlogin response has no content-type'
 
 expect_http_post_code
 
 
 expect_http_post_code
 
@@ -199,7 +199,7 @@ expect_no_creds
 test_mhlogin_invalid_response
 
 # TEST
 test_mhlogin_invalid_response
 
 # TEST
-echo 'mhlogin JSON array'
+start_test 'mhlogin JSON array'
 
 expect_http_post_code
 
 
 expect_http_post_code
 
@@ -212,7 +212,7 @@ expect_no_creds
 test_mhlogin_invalid_response
 
 # TEST
 test_mhlogin_invalid_response
 
 # TEST
-echo 'mhlogin JSON empty object'
+start_test 'mhlogin JSON empty object'
 
 expect_http_post_code
 
 
 expect_http_post_code
 
@@ -225,7 +225,7 @@ expect_no_creds
 test_mhlogin_invalid_response
 
 # TEST
 test_mhlogin_invalid_response
 
 # TEST
-echo 'mhlogin empty response body'
+start_test 'mhlogin empty response body'
 
 expect_http_post_code
 
 
 expect_http_post_code
 
@@ -237,7 +237,7 @@ expect_no_creds
 test_mhlogin_invalid_response
 
 # TEST
 test_mhlogin_invalid_response
 
 # TEST
-echo 'mhlogin gets proper error from http'
+start_test 'mhlogin gets proper error from http'
 
 expect_http_post_code
 
 
 expect_http_post_code
 
@@ -255,5 +255,6 @@ test_mhlogin 'mhlogin: error exchanging code for OAuth2 token
 mhlogin: bad OAuth request; re-run with -snoop and send REDACTED output to nmh-workers'
 
 clean_fakehttp
 mhlogin: bad OAuth request; re-run with -snoop and send REDACTED output to nmh-workers'
 
 clean_fakehttp
+finish_test
 
 exit ${failed:-0}
 
 exit ${failed:-0}
index 363debc64e8f047eaa15ea9963ed005874830055..4c7a335c8ae490fdf2c55606cf5764f303ee9447 100755 (executable)
@@ -24,7 +24,7 @@ export XOAUTH
 XOAUTH='dXNlcj1ub2JvZHlAZXhhbXBsZS5jb20BYXV0aD1CZWFyZXIgdGVzdC1hY2Nlc3MBAQ=='
 
 # TEST
 XOAUTH='dXNlcj1ub2JvZHlAZXhhbXBsZS5jb20BYXV0aD1CZWFyZXIgdGVzdC1hY2Nlc3MBAQ=='
 
 # TEST
-echo 'access token ready, smtp server accepts message'
+start_test 'access token ready, smtp server accepts message'
 
 setup_draft
 
 
 setup_draft
 
@@ -38,7 +38,7 @@ start_fakesmtp
 run_test "send -draft -server 127.0.0.1 -port ${smtp_port} -saslmech xoauth2 -authservice test -user nobody@example.com"
 
 # TEST
 run_test "send -draft -server 127.0.0.1 -port ${smtp_port} -saslmech xoauth2 -authservice test -user nobody@example.com"
 
 # TEST
-echo 'expired access token, refresh works, smtp server accepts message'
+start_test 'expired access token, refresh works, smtp server accepts message'
 
 setup_draft
 
 
 setup_draft
 
@@ -70,7 +70,7 @@ check_creds_private
 check_creds
 
 # TEST
 check_creds
 
 # TEST
-echo 'expired access token, refresh works and gets updated, smtp server accepts message'
+start_test 'expired access token, refresh works and gets updated, smtp server accepts message'
 
 setup_draft
 
 
 setup_draft
 
@@ -100,7 +100,7 @@ test_send
 check_creds
 
 # TEST
 check_creds
 
 # TEST
-echo 'access token has no expiration, refresh works, smtp server accepts message'
+start_test 'access token has no expiration, refresh works, smtp server accepts message'
 
 setup_draft
 
 
 setup_draft
 
@@ -128,7 +128,7 @@ test_send
 check_creds
 
 # TEST
 check_creds
 
 # TEST
-echo 'no access token, refresh works, smtp server accepts message'
+start_test 'no access token, refresh works, smtp server accepts message'
 
 setup_draft
 
 
 setup_draft
 
@@ -161,26 +161,26 @@ check_creds
 setup_draft
 
 # TEST
 setup_draft
 
 # TEST
-echo 'no service definition'
+start_test 'no service definition'
 
 run_test "send -draft -server 127.0.0.1 -port ${smtp_port} -saslmech xoauth2 -authservice bogus -user nobody@example.com" 'send: incomplete OAuth2 service definition: scope is missing'
 
 # TEST
 
 run_test "send -draft -server 127.0.0.1 -port ${smtp_port} -saslmech xoauth2 -authservice bogus -user nobody@example.com" 'send: incomplete OAuth2 service definition: scope is missing'
 
 # TEST
-echo 'no creds file -- should tell user to mhlogin'
+start_test 'no creds file -- should tell user to mhlogin'
 
 rm -f "${MHTMPDIR}/oauth-test"
 
 test_send_no_servers 'send: no credentials -- run mhlogin -saslmech xoauth2 -authservice test'
 
 # TEST
 
 rm -f "${MHTMPDIR}/oauth-test"
 
 test_send_no_servers 'send: no credentials -- run mhlogin -saslmech xoauth2 -authservice test'
 
 # TEST
-echo 'empty creds file -- should tell user to mhlogin'
+start_test 'empty creds file -- should tell user to mhlogin'
 
 fake_creds < /dev/null
 
 test_send_no_servers 'send: no valid credentials -- run mhlogin -saslmech xoauth2 -authservice test'
 
 # TEST
 
 fake_creds < /dev/null
 
 test_send_no_servers 'send: no valid credentials -- run mhlogin -saslmech xoauth2 -authservice test'
 
 # TEST
-echo 'garbage creds file'
+start_test 'garbage creds file'
 
 echo bork | fake_creds
 
 
 echo bork | fake_creds
 
@@ -188,7 +188,7 @@ test_send_no_servers 'send: eof encountered in field "bork"
 send: error loading cred file'
 
 # TEST
 send: error loading cred file'
 
 # TEST
-echo 'unexpected field in creds file'
+start_test 'unexpected field in creds file'
 
 fake_creds <<EOF
 bork: bork
 
 fake_creds <<EOF
 bork: bork
@@ -198,7 +198,7 @@ EOF
 test_send_no_servers 'send: error loading cred file: unexpected field'
 
 # TEST
 test_send_no_servers 'send: error loading cred file: unexpected field'
 
 # TEST
-echo 'garbage expiration time'
+start_test 'garbage expiration time'
 
 fake_creds <<EOF
 access: test-access
 
 fake_creds <<EOF
 access: test-access
@@ -208,7 +208,7 @@ EOF
 test_send_no_servers 'send: error loading cred file: invalid expiration time'
 
 # TEST
 test_send_no_servers 'send: error loading cred file: invalid expiration time'
 
 # TEST
-echo 'refresh response has no access token'
+start_test 'refresh response has no access token'
 
 fake_creds <<EOF
 refresh: test-refresh
 
 fake_creds <<EOF
 refresh: test-refresh
@@ -227,7 +227,7 @@ test_send_only_fakehttp 'send: error refreshing OAuth2 token
 send: invalid response: no access token'
 
 # TEST
 send: invalid response: no access token'
 
 # TEST
-echo 'expired access token, no refresh token -- tell user to mhlogin'
+start_test 'expired access token, no refresh token -- tell user to mhlogin'
 
 fake_creds <<EOF
 access: test-access
 
 fake_creds <<EOF
 access: test-access
@@ -237,7 +237,7 @@ EOF
 test_send_no_servers 'send: no valid credentials -- run mhlogin -saslmech xoauth2 -authservice test'
 
 # TEST
 test_send_no_servers 'send: no valid credentials -- run mhlogin -saslmech xoauth2 -authservice test'
 
 # TEST
-echo 'access token has no expiration, no refresh token -- tell user to mhlogin'
+start_test 'access token has no expiration, no refresh token -- tell user to mhlogin'
 
 fake_creds <<EOF
 access: test-access
 
 fake_creds <<EOF
 access: test-access
@@ -246,7 +246,7 @@ EOF
 test_send_no_servers 'send: no valid credentials -- run mhlogin -saslmech xoauth2 -authservice test'
 
 # TEST
 test_send_no_servers 'send: no valid credentials -- run mhlogin -saslmech xoauth2 -authservice test'
 
 # TEST
-echo 'refresh finds no http server'
+start_test 'refresh finds no http server'
 
 fake_creds <<EOF
 access: test-access
 
 fake_creds <<EOF
 access: test-access
@@ -269,7 +269,7 @@ check "$f".clean "${testname}.expected-send-output"
 rm "$f"
 
 # TEST
 rm "$f"
 
 # TEST
-echo 'refresh gets bogus 200 response from http server'
+start_test 'refresh gets bogus 200 response from http server'
 
 expect_http_post_refresh
 
 
 expect_http_post_refresh
 
@@ -283,7 +283,7 @@ test_send_only_fakehttp 'send: error refreshing OAuth2 token
 send: invalid response'
 
 # TEST
 send: invalid response'
 
 # TEST
-echo 'refresh gets 500 response from http server'
+start_test 'refresh gets 500 response from http server'
 
 expect_http_post_refresh
 
 
 expect_http_post_refresh
 
@@ -297,7 +297,7 @@ test_send_only_fakehttp 'send: error refreshing OAuth2 token
 send: invalid response'
 
 # TEST
 send: invalid response'
 
 # TEST
-echo 'refresh gets proper error from http'
+start_test 'refresh gets proper error from http'
 
 expect_http_post_refresh
 
 
 expect_http_post_refresh
 
@@ -312,7 +312,7 @@ EOF
 test_send_only_fakehttp 'send: credentials rejected -- run mhlogin -saslmech xoauth2 -authservice test'
 
 # TEST
 test_send_only_fakehttp 'send: credentials rejected -- run mhlogin -saslmech xoauth2 -authservice test'
 
 # TEST
-echo 'refresh gets response too big'
+start_test 'refresh gets response too big'
 
 fake_creds <<EOF
 refresh: test-refresh
 
 fake_creds <<EOF
 refresh: test-refresh
@@ -335,7 +335,7 @@ test_send_only_fakehttp 'send: error refreshing OAuth2 token
 send: refusing to process response body larger than 8192 bytes'
 
 # TEST
 send: refusing to process response body larger than 8192 bytes'
 
 # TEST
-echo 'smtp server rejects token'
+start_test 'smtp server rejects token'
 
 XOAUTH='not-that-one'
 
 
 XOAUTH='not-that-one'
 
@@ -348,7 +348,7 @@ test_send_only_fakesmtp 'post: problem initializing server; [BHST] Not no way, n
 send: message not delivered to anyone'
 
 # TEST
 send: message not delivered to anyone'
 
 # TEST
-echo "smtp server doesn't support oauth"
+start_test "smtp server doesn't support oauth"
 
 unset XOAUTH
 
 
 unset XOAUTH
 
@@ -357,5 +357,6 @@ send: message not delivered to anyone'
 
 clean_fakesmtp
 clean_fakehttp
 
 clean_fakesmtp
 clean_fakehttp
+finish_test
 
 exit ${failed:-0}
 
 exit ${failed:-0}
index cf5fca362ee76c00e743a3c97e87ff2b67839f42..76b0d3e2e76b549cadcf9e93c5f8ef63411fd5e1 100755 (executable)
@@ -16,7 +16,7 @@ export XOAUTH
 XOAUTH='dXNlcj1ub2JvZHlAZXhhbXBsZS5jb20BYXV0aD1CZWFyZXIgdGVzdC1hY2Nlc3MBAQ=='
 
 # TEST
 XOAUTH='dXNlcj1ub2JvZHlAZXhhbXBsZS5jb20BYXV0aD1CZWFyZXIgdGVzdC1hY2Nlc3MBAQ=='
 
 # TEST
-echo 'mhlogin then all run with no refresh'
+start_test 'mhlogin then all run with no refresh'
 
 expect_http_post_code
 
 
 expect_http_post_code
 
@@ -51,7 +51,7 @@ setup_draft
 test_send_only_fakesmtp
 
 # TEST
 test_send_only_fakesmtp
 
 # TEST
-echo 'inc refreshes'
+start_test 'inc refreshes'
 
 fake_creds <<EOF
 access: old-access
 
 fake_creds <<EOF
 access: old-access
@@ -80,7 +80,7 @@ setup_draft
 test_send_only_fakesmtp
 
 # TEST
 test_send_only_fakesmtp
 
 # TEST
-echo 'msgchck refreshes'
+start_test 'msgchck refreshes'
 
 fake_creds <<EOF
 access: old-access
 
 fake_creds <<EOF
 access: old-access
@@ -109,7 +109,7 @@ setup_draft
 test_send_only_fakesmtp
 
 # TEST
 test_send_only_fakesmtp
 
 # TEST
-echo 'send refreshes'
+start_test 'send refreshes'
 
 fake_creds <<EOF
 access: old-access
 
 fake_creds <<EOF
 access: old-access
@@ -138,5 +138,6 @@ test_inc_success
 
 clean_fakesmtp
 clean_fakehttp
 
 clean_fakesmtp
 clean_fakehttp
+finish_test
 
 exit ${failed:-0}
 
 exit ${failed:-0}