]> diplodocus.org Git - nmh/commitdiff
Added test of SMTP server that doesn't support SMTPUTF8.
authorDavid Levine <levinedl@acm.org>
Sun, 2 Oct 2016 13:53:56 +0000 (09:53 -0400)
committerDavid Levine <levinedl@acm.org>
Sun, 2 Oct 2016 13:54:13 +0000 (09:54 -0400)
test/common.sh.in
test/fakesmtp.c
test/post/test-post-common.sh
test/post/test-rfc6531
test/send/test-sendfrom

index 594d3db..5f3ccd1 100644 (file)
@@ -44,7 +44,7 @@ HOME=$MH_TEST_DIR
 export HOME
 
 unset MAILDROP MHBUILD MHCONTEXT MHMTSUSERCONF MHN MHSHOW MHSTORE
-unset MHLDEBUG MHPDEBUG MHWDEBUG PAGER XOAUTH
+unset MHLDEBUG MHPDEBUG MHWDEBUG PAGER XOAUTH SMTPUTF8
 #### Set LC_ALL in individual tests as needed.  Unset these so
 #### that we don't depend on user's settings in other tests.
 unset LANG LC_ALL LC_CTYPE
index 449fdec..3523095 100644 (file)
@@ -41,6 +41,7 @@ main(int argc, char *argv[])
        int rc, conn, smtp_state;
        FILE *f;
        const char *xoauth = getenv("XOAUTH");
+       const char *smtputf8 = getenv("SMTPUTF8");
 
        if (argc != 3) {
                fprintf(stderr, "Usage: %s output-filename port\n", argv[0]);
@@ -101,17 +102,20 @@ main(int argc, char *argv[])
                        smtp_state = SMTP_DATA;
                        continue;
                }
-               if (xoauth == NULL) {
+               if (strncmp(line, "EHLO", 4) == 0) {
                        putcrlf(conn, "250-ready");
-                       putcrlf(conn, "250-8BITMIME");
-                       putcrlf(conn, "250-SMTPUTF8");
-               } else {
-                       /* XOAUTH2 support enabled; handle EHLO and AUTH. */
-                       if (strncmp(line, "EHLO", 4) == 0) {
-                               putcrlf(conn, "250-ready");
-                               putcrlf(conn, "250 AUTH XOAUTH2");
-                               continue;
+                       if (smtputf8 != NULL) {
+                               putcrlf(conn, "250-8BITMIME");
+                               putcrlf(conn, "250-SMTPUTF8");
+                       }
+                       if (xoauth != NULL) {
+                               putcrlf(conn, "250-AUTH XOAUTH2");
                        }
+                       putcrlf(conn, "250 I'll buy that for a dollar!");
+                       continue;
+               }
+               if (xoauth != NULL) {
+                       /* XOAUTH2 support enabled; handle AUTH (and EHLO above). */
                        if (strncmp(line, "AUTH", 4) == 0) {
                                if (strncmp(line, "AUTH XOAUTH2", 12) == 0
                                    && strstr(line, xoauth) != NULL) {
index 5692cc6..bfbe08d 100755 (executable)
@@ -29,7 +29,7 @@ echo "clientname: nosuchhost.example.com" >> ${MHMTSCONF}
 test_post ()
 { pid=`"${MH_OBJ_DIR}/test/fakesmtp" "$1" $localport`
 
-    run_prog send -draft -server 127.0.0.1 -port $localport $3 || exit 1
+    run_prog send -draft -server 127.0.0.1 -port $localport $3
 
     #
     # It's hard to calculate the exact Date: header post is going to
index b86936b..135d6f2 100755 (executable)
@@ -16,6 +16,7 @@ fi
 
 setup_test
 mhl="${MH_LIBEXEC_DIR}/mhl"
+SMTPUTF8=1; export SMTPUTF8
 
 #### Make sure that html-to-text conversion is what we expect.
 require_locale en_US.utf-8 en_US.utf8
@@ -69,5 +70,24 @@ EOF
 test_post "${testname}.actual" "${testname}.expected"
 
 
+start_test "smtp server doesn't support SMTPUTF8"
+unset SMTPUTF8
+cat > "${testname}.expected" <<EOF
+EHLO nosuchhost.example.com
+RSET
+QUIT
+EOF
+cat > "${testname}.expected.err" <<EOF
+post: problem initializing server; [BHST] ready; I'll buy that for a dollar!
+send: message not delivered to anyone
+EOF
+mv -f "${MH_TEST_DIR}/Mail/,draft" "${MH_TEST_DIR}/Mail/draft"
+
+set +e
+test_post "${testname}.actual" "${testname}.expected" 2>"${testname}.err"
+set -e
+check "${testname}.err" "${testname}.expected.err"
+
+
 finish_test
 exit $failed
index 0f2dda8..03d325f 100755 (executable)
@@ -56,18 +56,10 @@ Connecting to 127.0.0.1:${localport}...
 <= 220 Not really an ESMTP server
 => EHLO nosuchhost.example.com
 <= 250-ready
-<= 250-8BITMIME
-<= 250-SMTPUTF8
 <= 250 I'll buy that for a dollar!
 => MAIL FROM:<nobody@example.com>
-<= 250-ready
-<= 250-8BITMIME
-<= 250-SMTPUTF8
 <= 250 I'll buy that for a dollar!
 => RCPT TO:<somebody@example.com>
-<= 250-ready
-<= 250-8BITMIME
-<= 250-SMTPUTF8
 <= 250 I'll buy that for a dollar!
 => DATA
 <= 354 Go ahead