From: David Levine Date: Sun, 2 Oct 2016 13:53:56 +0000 (-0400) Subject: Added test of SMTP server that doesn't support SMTPUTF8. X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/ab64de0644f2596657048ee6d62e03ea247ddbb4?ds=inline Added test of SMTP server that doesn't support SMTPUTF8. --- diff --git a/test/common.sh.in b/test/common.sh.in index 594d3dbe..5f3ccd14 100644 --- a/test/common.sh.in +++ b/test/common.sh.in @@ -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 diff --git a/test/fakesmtp.c b/test/fakesmtp.c index 449fdec0..35230957 100644 --- a/test/fakesmtp.c +++ b/test/fakesmtp.c @@ -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) { diff --git a/test/post/test-post-common.sh b/test/post/test-post-common.sh index 5692cc66..bfbe08db 100755 --- a/test/post/test-post-common.sh +++ b/test/post/test-post-common.sh @@ -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 diff --git a/test/post/test-rfc6531 b/test/post/test-rfc6531 index b86936bc..135d6f28 100755 --- a/test/post/test-rfc6531 +++ b/test/post/test-rfc6531 @@ -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" < "${testname}.expected.err" <"${testname}.err" +set -e +check "${testname}.err" "${testname}.expected.err" + + finish_test exit $failed diff --git a/test/send/test-sendfrom b/test/send/test-sendfrom index 0f2dda84..03d325f0 100755 --- a/test/send/test-sendfrom +++ b/test/send/test-sendfrom @@ -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: -<= 250-ready -<= 250-8BITMIME -<= 250-SMTPUTF8 <= 250 I'll buy that for a dollar! => RCPT TO: -<= 250-ready -<= 250-8BITMIME -<= 250-SMTPUTF8 <= 250 I'll buy that for a dollar! => DATA <= 354 Go ahead