Loading tests/data/Makefile.inc +2 −0 Original line number Diff line number Diff line Loading @@ -149,6 +149,8 @@ test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \ test1508 test1509 test1510 test1511 test1512 test1513 test1514 test1515 \ test1516 \ \ test1520 \ \ test1525 test1526 test1527 test1528 \ \ test1800 test1801 \ Loading tests/data/test1520 0 → 100644 +59 −0 Original line number Diff line number Diff line <testcase> # Based off test 901 after bug report #1456 <info> <keywords> SMTP </keywords> </info> # # Client-side <client> <server> smtp </server> <tool> lib1520 </tool> <name> SMTP with CRLF-dot-CRLF in data </name> <stdin> From: different To: another . . . body </stdin> <command> smtp://%HOSTIP:%SMTPPORT/1520 </command> </client> # # Verify data after the test has been "shot" <verify> <protocol> EHLO 1520 MAIL FROM:<sender@example.com> RCPT TO:<recipient@example.com> DATA From: different To: another .. .. .. body </protocol> </verify> </testcase> tests/libtest/Makefile.inc +4 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \ lib583 lib585 lib586 lib587 lib590 lib591 lib597 lib598 lib599 \ lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508 \ lib1509 lib1510 lib1511 lib1512 lib1513 lib1514 lib1515 \ lib1520 \ lib1525 lib1526 lib1527 lib1528 \ lib1900 \ lib2033 Loading Loading @@ -356,6 +357,9 @@ lib1515_SOURCES = lib1515.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib1515_LDADD = $(TESTUTIL_LIBS) lib1515_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1515 lib1520_SOURCES = lib1520.c $(SUPPORTFILES) lib1520_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1520 lib1525_SOURCES = lib1525.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib1525_LDADD = $(TESTUTIL_LIBS) lib1525_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1525 Loading tests/libtest/lib1520.c 0 → 100644 +110 −0 Original line number Diff line number Diff line /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 2014, Steve Holme, <steve_holme@hotmail.com>. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://curl.haxx.se/docs/copyright.html. * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is * furnished to do so, under the terms of the COPYING file. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * ***************************************************************************/ #include "test.h" #include "memdebug.h" /* * This is the list of basic details you need to tweak to get things right. */ #define TO "recipient@example.com>" #define FROM "<sender@example.com>" static const char *payload_text[] = { "From: different\r\n", "To: another\r\n", "\r\n", "\r\n", ".\r\n", ".\r\n", "\r\n", ".\r\n", "\r\n", "body" }; struct upload_status { int lines_read; }; static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) { struct upload_status *upload_ctx = (struct upload_status *)userp; const char *data; if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) { return 0; } data = payload_text[upload_ctx->lines_read]; if(data) { size_t len = strlen(data); memcpy(ptr, data, len); upload_ctx->lines_read++; return len; } return 0; } int test(char *URL) { CURLcode result; CURL *curl; if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } rcpt_list = curl_slist_append(rcpt_list, TO); /* more addresses can be added here rcpt_list = curl_slist_append(rcpt_list, "<others@example.com>"); */ test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_UPLOAD, 1L); test_setopt(curl, CURLOPT_READFUNCTION, read_callback); test_setopt(curl, CURLOPT_READDATA, &upload_ctx); test_setopt(curl, CURLOPT_MAIL_FROM, FROM); test_setopt(curl, CURLOPT_MAIL_RCPT, rcpt_list); test_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); test_cleanup: curl_easy_cleanup(curl); curl_global_cleanup(); return (int)res; } Loading
tests/data/Makefile.inc +2 −0 Original line number Diff line number Diff line Loading @@ -149,6 +149,8 @@ test1500 test1501 test1502 test1503 test1504 test1505 test1506 test1507 \ test1508 test1509 test1510 test1511 test1512 test1513 test1514 test1515 \ test1516 \ \ test1520 \ \ test1525 test1526 test1527 test1528 \ \ test1800 test1801 \ Loading
tests/data/test1520 0 → 100644 +59 −0 Original line number Diff line number Diff line <testcase> # Based off test 901 after bug report #1456 <info> <keywords> SMTP </keywords> </info> # # Client-side <client> <server> smtp </server> <tool> lib1520 </tool> <name> SMTP with CRLF-dot-CRLF in data </name> <stdin> From: different To: another . . . body </stdin> <command> smtp://%HOSTIP:%SMTPPORT/1520 </command> </client> # # Verify data after the test has been "shot" <verify> <protocol> EHLO 1520 MAIL FROM:<sender@example.com> RCPT TO:<recipient@example.com> DATA From: different To: another .. .. .. body </protocol> </verify> </testcase>
tests/libtest/Makefile.inc +4 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ noinst_PROGRAMS = chkhostname libauthretry libntlmconnect \ lib583 lib585 lib586 lib587 lib590 lib591 lib597 lib598 lib599 \ lib1500 lib1501 lib1502 lib1503 lib1504 lib1505 lib1506 lib1507 lib1508 \ lib1509 lib1510 lib1511 lib1512 lib1513 lib1514 lib1515 \ lib1520 \ lib1525 lib1526 lib1527 lib1528 \ lib1900 \ lib2033 Loading Loading @@ -356,6 +357,9 @@ lib1515_SOURCES = lib1515.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib1515_LDADD = $(TESTUTIL_LIBS) lib1515_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1515 lib1520_SOURCES = lib1520.c $(SUPPORTFILES) lib1520_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1520 lib1525_SOURCES = lib1525.c $(SUPPORTFILES) $(TESTUTIL) $(WARNLESS) lib1525_LDADD = $(TESTUTIL_LIBS) lib1525_CPPFLAGS = $(AM_CPPFLAGS) -DLIB1525 Loading
tests/libtest/lib1520.c 0 → 100644 +110 −0 Original line number Diff line number Diff line /*************************************************************************** * _ _ ____ _ * Project ___| | | | _ \| | * / __| | | | |_) | | * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 2014, Steve Holme, <steve_holme@hotmail.com>. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms * are also available at http://curl.haxx.se/docs/copyright.html. * * You may opt to use, copy, modify, merge, publish, distribute and/or sell * copies of the Software, and permit persons to whom the Software is * furnished to do so, under the terms of the COPYING file. * * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY * KIND, either express or implied. * ***************************************************************************/ #include "test.h" #include "memdebug.h" /* * This is the list of basic details you need to tweak to get things right. */ #define TO "recipient@example.com>" #define FROM "<sender@example.com>" static const char *payload_text[] = { "From: different\r\n", "To: another\r\n", "\r\n", "\r\n", ".\r\n", ".\r\n", "\r\n", ".\r\n", "\r\n", "body" }; struct upload_status { int lines_read; }; static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp) { struct upload_status *upload_ctx = (struct upload_status *)userp; const char *data; if((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) { return 0; } data = payload_text[upload_ctx->lines_read]; if(data) { size_t len = strlen(data); memcpy(ptr, data, len); upload_ctx->lines_read++; return len; } return 0; } int test(char *URL) { CURLcode result; CURL *curl; if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } rcpt_list = curl_slist_append(rcpt_list, TO); /* more addresses can be added here rcpt_list = curl_slist_append(rcpt_list, "<others@example.com>"); */ test_setopt(curl, CURLOPT_URL, URL); test_setopt(curl, CURLOPT_UPLOAD, 1L); test_setopt(curl, CURLOPT_READFUNCTION, read_callback); test_setopt(curl, CURLOPT_READDATA, &upload_ctx); test_setopt(curl, CURLOPT_MAIL_FROM, FROM); test_setopt(curl, CURLOPT_MAIL_RCPT, rcpt_list); test_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); test_cleanup: curl_easy_cleanup(curl); curl_global_cleanup(); return (int)res; }