]> diplodocus.org Git - nmh/blobdiff - test/oauth/test-send
Fixed memory corruption in post(1) and inc(1) when using XOAUTH2.
[nmh] / test / oauth / test-send
index 98efb2b59c756adbd7f4890db44d33568406d1d6..3d1a7bd6779c82353cbba31a714392f29c4ce61c 100755 (executable)
@@ -10,6 +10,8 @@ fi
 
 . "${srcdir}/test/oauth/common.sh"
 
+check_exit '-eq 1' send -
+
 test_send_only_fakehttp() {
     start_fakehttp
     test_send_no_servers "$@"
@@ -35,7 +37,7 @@ expire-nobody@example.com: 2000000000
 EOF
 
 start_fakesmtp
-run_test "send -draft -server 127.0.0.1 -port ${smtp_port} -saslmech xoauth2 -authservice test -user nobody@example.com"
+run_test "send -draft -server 127.0.0.1 -port ${smtp_port} -sasl -saslmech xoauth2 -authservice test -user nobody@example.com"
 
 # TEST
 start_test 'expired access token, refresh works, smtp server accepts message'
@@ -154,6 +156,65 @@ test_send
 
 check_creds
 
+# TEST
+start_test 'fill all slots in creds table'
+
+setup_draft
+
+fake_creds <<EOF
+access-nobody@example.com: test-access
+refresh-nobody@example.com: test-refresh
+expire-nobody@example.com: 2000000000
+access-nobody2@example.com: test-access
+refresh-nobody2@example.com: test-refresh
+expire-nobody2@example.com: 2000000000
+access-nobody3@example.com: test-access
+refresh-nobod3y@example.com: test-refresh
+expire-nobody3@example.com: 2000000000
+access-nobody4@example.com: test-access
+refresh-nobody4@example.com: test-refresh
+expire-nobody4@example.com: 2000000000
+access-nobody5@example.com: test-access
+refresh-nobody5@example.com: test-refresh
+expire-nobody5@example.com: 2000000000
+access-nobody6@example.com: test-access
+refresh-nobody6@example.com: test-refresh
+expire-nobody6@example.com: 2000000000
+access-nobody7@example.com: test-access
+refresh-nobody7@example.com: test-refresh
+expire-nobody7@example.com: 2000000000
+access-nobody8@example.com: test-access
+refresh-nobody8@example.com: test-refresh
+expire-nobody8@example.com: 2000000000
+access-nobody9@example.com: test-access
+refresh-nobody9@example.com: test-refresh
+expire-nobody9@example.com: 2000000000
+access-nobody10@example.com: test-access
+refresh-nobody10@example.com: test-refresh
+expire-nobody10@example.com: 2000000000
+access-nobody11@example.com: test-access
+refresh-nobody11@example.com: test-refresh
+expire-nobody11@example.com: 2000000000
+access-nobody12@example.com: test-access
+refresh-nobody12@example.com: test-refresh
+expire-nobody12@example.com: 2000000000
+access-nobody13@example.com: test-access
+refresh-nobody13@example.com: test-refresh
+expire-nobody13@example.com: 2000000000
+access-nobody14@example.com: test-access
+refresh-nobody14@example.com: test-refresh
+expire-nobody14@example.com: 2000000000
+access-nobody15@example.com: test-access
+refresh-nobody15@example.com: test-refresh
+expire-nobody15@example.com: 2000000000
+access-nobody16@example.com: test-access
+refresh-nobody16@example.com: test-refresh
+expire-nobody16@example.com: 2000000000
+EOF
+
+start_fakesmtp
+run_test "send -draft -server 127.0.0.1 -port ${smtp_port} -sasl -saslmech xoauth2 -authservice test -user nobody@example.com"
+
 #
 # fail cases
 #
@@ -163,7 +224,7 @@ setup_draft
 # TEST
 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: Unable to retrieve oauth profile entries: scope is missing'
+run_test "send -draft -server 127.0.0.1 -port ${smtp_port} -sasl -saslmech xoauth2 -authservice bogus -user nobody@example.com" 'send: Unable to retrieve oauth profile entries: scope is missing'
 
 # TEST
 start_test 'no creds file -- should tell user to mhlogin'
@@ -269,7 +330,7 @@ EOF
 
 start_fakesmtp
 run_prog send -draft -server 127.0.0.1 -port ${smtp_port} \
-  -saslmech xoauth2 -authservice test -user nobody@example.com > "${testname}.send-output" 2>&1 || true
+  -sasl -saslmech xoauth2 -authservice test -user nobody@example.com > "${testname}.send-output" 2>&1 || true
 # Clear out an error message we get from libcurl on some systems (seen at least
 # 3 different versions of this error message, on FreeBSD 10.1, Ubuntu 12.04, and
 # Ubuntu 14.04).
@@ -358,7 +419,7 @@ access-nobody@example.com: test-access
 expire-nobody@example.com: 2000000000
 EOF
 
-test_send_only_fakesmtp 'post: problem initializing server; [BHST] Not no way, not no how!
+test_send_only_fakesmtp 'post: problem initializing server; [BHST] Authentication failed: Not no way, not no how!
 send: message not delivered to anyone'
 
 # TEST
@@ -385,7 +446,7 @@ start_test "smtp server doesn't support oauth"
 
 unset XOAUTH
 
-test_send_only_fakesmtp 'post: problem initializing server; [BHST] SMTP server does not support SASL XOAUTH2
+test_send_only_fakesmtp 'post: problem initializing server; [BHST] SMTP server does not support SASL
 send: message not delivered to anyone'
 
 clean_fakesmtp