smtp-client
SMTP Client C Library
|
Test the smtp-client library. More...
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "test.h"
Go to the source code of this file.
Data Structures | |
struct | smtp_test_config |
struct | smtp_str_list |
struct | smtp_test_getdelimfd_fp |
struct | smtp_test |
Macros | |
#define | SMTP_INTERNAL_DEFINE |
#define | TMP_FILE_PATH "/tmp/test_smtp_file_get_contents.txt" |
#define | SMTP_TEST_SUBJECT_LEN 100 |
#define | SMTP_TEST_BODY_LEN 1000 |
#define | SMTP_MAX_SERVER_LEN 255 |
#define | SMTP_MAX_CAFILE_PATH 255 |
#define | SMTP_MAX_PORT_LEN 10 |
#define | SMTP_MAX_EMAIL_LEN 255 |
#define | SMTP_MAX_PASS_LEN 255 |
#define | SMTP_MAX_ATTACHMENT_NAME_LEN 100 |
#define | SMTP_TEST_DEFAULT_CONNECTION_SECURITY SMTP_SECURITY_NONE |
#define | SMTP_TEST_DEFAULT_AUTH_METHOD SMTP_AUTH_PLAIN |
#define | SMTP_TEST_DEFAULT_FLAGS |
#define | SMTP_TEST_DEFAULT_CAFILE NULL |
#define | SMTP_TEST_DEFAULT_FROM_NAME "From Name" |
#define | SMTP_TEST_DEFAULT_TO_NAME "To Name" |
#define | SMTP_TEST_DEFAULT_CC_NAME "Cc Name" |
#define | SMTP_TEST_DEFAULT_BCC_NAME "Bcc Name" |
#define | STR_ALPHABET_LOWERCASE "abcdefghijklmnopqrstuvwxyz" |
Enumerations | |
enum | smtp_test_flags { SMTP_TEST_UNIT_TESTING_ONLY = 1 << 0 } |
Functions | |
static size_t | smtp_strlcpy (char *dest, const char *src, size_t destsz) |
static char * | smtp_strndup (const char *s, size_t n) |
static char * | smtp_str_repeat (const char *const s, size_t n) |
static int | smtp_str_list_append (struct smtp_str_list *const slist, const char *const s, size_t n) |
static void | smtp_str_list_free (struct smtp_str_list *const list) |
static int | smtp_str_split (const char *const s, size_t slen, const char *const delimiter, int limit, struct smtp_str_list *slist) |
static size_t | smtp_ffile_put_contents (FILE *stream, const void *const data, size_t datasz) |
static size_t | smtp_file_put_contents (const char *const filename, const void *const data, size_t datasz, int flags) |
static void | smtp_test_sleep (unsigned int seconds) |
static void | smtp_unit_test_si_size_t (int(*si_fp)(const size_t a, const size_t b, size_t *const result), size_t a, size_t b, size_t *result, size_t expect_result, int expect_wrap) |
static void | smtp_unit_test_all_si (void) |
static void | smtp_unit_test_base64_decode (const char *const buf, const char *const expect_str, size_t expect_str_len) |
static void | smtp_unit_test_all_base64_decode (void) |
static void | smtp_unit_test_base64_encode (const char *const buf, size_t buflen, const char *const expect) |
static void | smtp_unit_test_all_base64_encode (void) |
static void | smtp_unit_test_bin2hex (const char *const s, size_t slen, const char *const expect) |
static void | smtp_unit_test_all_bin2hex (void) |
static void | smtp_unit_test_stpcpy (const char *const init, const char *const s2, const char *const expect) |
static void | smtp_unit_test_all_stpcpy (void) |
static void | smtp_unit_test_reallocarray (void *ptr, size_t nmemb, size_t size, int expect_alloc) |
static void | smtp_unit_test_all_reallocarray (void) |
static void | smtp_unit_test_strdup (const char *const s, const char *const expect) |
static void | smtp_unit_test_all_strdup (void) |
static void | smtp_unit_test_str_replace (const char *const search, const char *const replace, const char *const s, const char *const expect) |
static void | smtp_unit_test_all_str_replace (void) |
static void | smtp_unit_test_all_smtp_utf8_charlen (void) |
static void | smtp_unit_test_all_smtp_str_has_nonascii_utf8 (void) |
static void | smtp_unit_test_strnlen_utf8 (const char *s, size_t maxlen, size_t expect) |
static void | smtp_unit_test_all_strnlen_utf8 (void) |
static void | smtp_unit_test_fold_whitespace_get_offset (const char *const s, unsigned int maxlen, size_t expect) |
static void | smtp_unit_test_all_fold_whitespace_get_offset (void) |
static void | smtp_unit_test_fold_whitespace (const char *const s, unsigned int maxlen, const char *const expect) |
static void | smtp_unit_test_all_fold_whitespace (void) |
static void | smtp_unit_test_chunk_split (const char *const s, size_t chunklen, const char *const end, const char *const expect) |
static void | smtp_unit_test_all_chunk_split (void) |
static void | smtp_unit_test_file_get_contents (const char *const s, size_t nbytes, const char *const expect) |
static void | smtp_unit_test_all_file_get_contents (void) |
static void | smtp_unit_test_parse_cmd_line (const char *const line, enum smtp_result_code expect_code, int expect_more, const char *const expect_text) |
static void | smtp_unit_test_all_parse_cmd_line (void) |
static void | smtp_unit_test_date_rfc_2822 (time_t t, const char *const expect, int expect_rc) |
static void | smtp_unit_test_all_date_rfc_2822 (void) |
static void | smtp_unit_test_all_smtp_address_validate_email (void) |
static void | smtp_unit_test_all_smtp_address_validate_name (void) |
static void | smtp_unit_test_all_smtp_attachment_validate_name (void) |
static void | smtp_unit_test_all_smtp_header_key_validate (void) |
static void | smtp_unit_test_all_smtp_header_value_validate (void) |
static void | smtp_unit_test_smtp_status_code_errstr (enum smtp_status_code status_code, const char *const expect) |
static void | smtp_unit_test_all_smtp_status_code_errstr (void) |
static long | smtp_unit_test_getdelimfd_fp (struct str_getdelimfd *const gdfd, void *buf, size_t count) |
static void | smtp_unit_test_str_getdelimfd (const char *const input_string, size_t nbytes, int delim, enum str_getdelim_retcode expect_rc, int null_fp, const char *expect_pieces,...) |
static void | smtp_unit_test_getdelimfd_set_line_and_buf (struct str_getdelimfd *const gdfd, size_t copy_len, int expect_result) |
static void | smtp_unit_test_all_str_getdelimfd (void) |
static void | smtp_unit_test_all (void) |
static int | smtp_test_config_load_from_file (const char *const config_path) |
static void | smtp_auth_check (const enum smtp_authentication_method auth_method, const char *const user, const char *const pass, const enum smtp_status_code expect_status) |
static void | smtp_address_add_check (const enum smtp_address_type type, const char *const email, const char *const name, const enum smtp_status_code expect_status) |
static void | smtp_header_add_check (const char *const key, const char *const value, const enum smtp_status_code expect_status) |
static void | smtp_mail_check (const char *const body, const enum smtp_status_code expect_status) |
static void | smtp_close_check (const enum smtp_status_code expect_status) |
static void | test_smtp_open_default (void) |
static void | smtp_func_test_all_status_code_get (void) |
static void | smtp_func_test_send_email (const char *const port, enum smtp_connection_security connection_security, enum smtp_flag flags, enum smtp_authentication_method auth_method, const char *const cafile, const char *const subject, const char *const body) |
static void | smtp_func_test_connection_security (const char *const server_port, enum smtp_connection_security con_security, const char *const security_description) |
static void | smtp_func_test_all_connection_security (void) |
static void | smtp_func_test_all_cafile (void) |
static void | smtp_func_test_auth (enum smtp_authentication_method auth_method, const char *const auth_description) |
static void | smtp_func_test_all_auth_methods (void) |
static void | smtp_func_test_attachment_path (const char *const name, const char *const path, enum smtp_status_code expect_rc) |
static void | smtp_func_test_attachment_fp (const char *const name, const char *const path, enum smtp_status_code expect_rc) |
static void | smtp_func_test_attachment_mem (size_t num_attachment) |
static void | smtp_func_test_attachment_pdf (const size_t num_attachments) |
static void | smtp_func_test_attachment_long_text (void) |
static void | smtp_func_test_all_attachments_mem (void) |
static void | smtp_func_test_all_attachments_path (void) |
static void | smtp_func_test_all_attachments_fp (void) |
static void | smtp_func_test_all_attachments (void) |
static void | smtp_func_test_all_address (void) |
static void | smtp_func_test_all_names (void) |
static void | smtp_func_test_header_custom_date (void) |
static void | smtp_func_test_header_null_no_date (void) |
static void | smtp_func_test_header_long (void) |
static void | smtp_func_test_all_headers (void) |
static void | smtp_func_test_all_body (void) |
static void | smtp_func_test_all_write (void) |
static void | smtp_func_test_all_nodebug (void) |
static void | smtp_func_test_html (void) |
static void | smtp_func_test_html_with_plaintext (void) |
static void | smtp_func_test_all_html (void) |
static void | test_failure_misc (void) |
static void | test_failure_open (void) |
static void | test_failure_address_add (void) |
static void | test_failure_attachment_add (void) |
static void | test_failure_header_add (void) |
static void | test_failure_status_code_set (void) |
static void | test_failure_mail (void) |
static void | test_failure_close (void) |
static void | test_failure_auth (void) |
static void | test_failure_timeout (void) |
static void | test_all_failure_modes (void) |
static void | smtp_func_test_server_postfix (void) |
static void | smtp_func_test_server_secureserver (void) |
static void | smtp_func_test_gmail_attachment (void) |
static void | smtp_func_test_server_gmail (void) |
static void | smtp_func_test_all (void) |
int | main (int argc, char *argv[]) |
Variables | |
static enum smtp_status_code | g_rc |
static struct smtp_test_config | g_config |
static int | g_smtp_test_getdelimfd_fp_fail = 0 |
Test the smtp-client library.
This smtp-client testing framework has 100% branch coverage on POSIX systems. It requires a Postfix SMTP server that supports all of the connection security and authentication methods. These functional tests also require the user to manually check and ensure that the destination addresses received all of the test emails.
This software has been placed into the public domain using CC0.
Definition in file test.c.
#define SMTP_INTERNAL_DEFINE |
Get access to the smtp_result_code and smtp_command definitions.
#define SMTP_MAX_ATTACHMENT_NAME_LEN 100 |
Maximum file attachment name buffer length.
Definition at line 73 of file test.c.
Referenced by smtp_func_test_attachment_mem(), and smtp_func_test_attachment_pdf().
#define SMTP_MAX_CAFILE_PATH 255 |
#define SMTP_MAX_PASS_LEN 255 |
#define SMTP_MAX_PORT_LEN 10 |
#define SMTP_MAX_SERVER_LEN 255 |
#define SMTP_TEST_BODY_LEN 1000 |
#define SMTP_TEST_DEFAULT_AUTH_METHOD SMTP_AUTH_PLAIN |
This default authentication method will get used for most test connections with the SMTP server.
Definition at line 85 of file test.c.
Referenced by smtp_func_test_all_cafile(), smtp_func_test_attachment_long_text(), smtp_func_test_attachment_mem(), smtp_func_test_attachment_path(), smtp_func_test_attachment_pdf(), and smtp_func_test_connection_security().
#define SMTP_TEST_DEFAULT_BCC_NAME "Bcc Name" |
Default name used by all BCC addresses.
Definition at line 118 of file test.c.
Referenced by smtp_func_test_all_address().
#define SMTP_TEST_DEFAULT_CAFILE NULL |
Use the default certificate path for OpenSSL.
Definition at line 98 of file test.c.
Referenced by smtp_func_test_all_address(), smtp_func_test_all_body(), smtp_func_test_all_names(), smtp_func_test_all_nodebug(), smtp_func_test_all_status_code_get(), smtp_func_test_all_write(), smtp_func_test_attachment_fp(), smtp_func_test_attachment_long_text(), smtp_func_test_attachment_mem(), smtp_func_test_attachment_path(), smtp_func_test_attachment_pdf(), smtp_func_test_auth(), smtp_func_test_connection_security(), smtp_func_test_header_custom_date(), smtp_func_test_header_long(), smtp_func_test_header_null_no_date(), smtp_func_test_html(), smtp_func_test_html_with_plaintext(), smtp_func_test_server_gmail(), test_failure_address_add(), test_failure_attachment_add(), test_failure_close(), test_failure_header_add(), test_failure_misc(), test_failure_open(), test_failure_status_code_set(), test_failure_timeout(), and test_smtp_open_default().
#define SMTP_TEST_DEFAULT_CC_NAME "Cc Name" |
Default name used by all addresses in the Cc: header.
Definition at line 113 of file test.c.
Referenced by smtp_func_test_all_address(), and test_smtp_open_default().
#define SMTP_TEST_DEFAULT_CONNECTION_SECURITY SMTP_SECURITY_NONE |
This default connection security method will get used for most test connections with the SMTP server.
Definition at line 79 of file test.c.
Referenced by smtp_func_test_all_address(), smtp_func_test_all_body(), smtp_func_test_all_names(), smtp_func_test_all_nodebug(), smtp_func_test_all_status_code_get(), smtp_func_test_all_write(), smtp_func_test_attachment_fp(), smtp_func_test_attachment_long_text(), smtp_func_test_attachment_mem(), smtp_func_test_attachment_path(), smtp_func_test_attachment_pdf(), smtp_func_test_auth(), smtp_func_test_header_custom_date(), smtp_func_test_header_long(), smtp_func_test_header_null_no_date(), smtp_func_test_html(), smtp_func_test_html_with_plaintext(), test_failure_address_add(), test_failure_attachment_add(), test_failure_close(), test_failure_header_add(), test_failure_misc(), test_failure_open(), test_failure_status_code_set(), test_failure_timeout(), and test_smtp_open_default().
#define SMTP_TEST_DEFAULT_FLAGS |
These default flags will get used for most test connections with the SMTP server.
Definition at line 91 of file test.c.
Referenced by smtp_func_test_all_address(), smtp_func_test_all_body(), smtp_func_test_all_names(), smtp_func_test_all_status_code_get(), smtp_func_test_attachment_fp(), smtp_func_test_attachment_long_text(), smtp_func_test_attachment_mem(), smtp_func_test_attachment_path(), smtp_func_test_attachment_pdf(), smtp_func_test_auth(), smtp_func_test_connection_security(), smtp_func_test_header_custom_date(), smtp_func_test_header_long(), smtp_func_test_header_null_no_date(), smtp_func_test_html(), smtp_func_test_html_with_plaintext(), test_failure_address_add(), test_failure_attachment_add(), test_failure_close(), test_failure_header_add(), test_failure_misc(), test_failure_open(), test_failure_status_code_set(), test_failure_timeout(), and test_smtp_open_default().
#define SMTP_TEST_DEFAULT_FROM_NAME "From Name" |
Default name used by the address in the From: header.
Definition at line 103 of file test.c.
Referenced by smtp_func_test_all_address(), smtp_func_test_all_body(), smtp_func_test_all_names(), smtp_func_test_all_nodebug(), smtp_func_test_attachment_fp(), smtp_func_test_attachment_long_text(), smtp_func_test_attachment_mem(), smtp_func_test_attachment_path(), smtp_func_test_attachment_pdf(), smtp_func_test_gmail_attachment(), smtp_func_test_header_custom_date(), smtp_func_test_header_long(), smtp_func_test_header_null_no_date(), smtp_func_test_html(), smtp_func_test_html_with_plaintext(), smtp_func_test_send_email(), test_failure_address_add(), test_failure_timeout(), and test_smtp_open_default().
#define SMTP_TEST_DEFAULT_TO_NAME "To Name" |
Default name used by all addresses in the To: header.
Definition at line 108 of file test.c.
Referenced by smtp_func_test_all_address(), smtp_func_test_all_body(), smtp_func_test_all_nodebug(), smtp_func_test_attachment_fp(), smtp_func_test_attachment_long_text(), smtp_func_test_attachment_mem(), smtp_func_test_attachment_path(), smtp_func_test_attachment_pdf(), smtp_func_test_gmail_attachment(), smtp_func_test_header_custom_date(), smtp_func_test_header_long(), smtp_func_test_header_null_no_date(), smtp_func_test_html(), smtp_func_test_html_with_plaintext(), smtp_func_test_send_email(), and test_smtp_open_default().
#define SMTP_TEST_SUBJECT_LEN 100 |
#define STR_ALPHABET_LOWERCASE "abcdefghijklmnopqrstuvwxyz" |
Some unit tests use this for testing encoding or splitting long strings.
Definition at line 123 of file test.c.
Referenced by smtp_func_test_all_body(), smtp_func_test_all_names(), smtp_func_test_attachment_long_text(), smtp_func_test_header_long(), smtp_unit_test_all_base64_decode(), smtp_unit_test_all_base64_encode(), smtp_unit_test_all_bin2hex(), smtp_unit_test_all_chunk_split(), smtp_unit_test_all_file_get_contents(), smtp_unit_test_all_fold_whitespace(), smtp_unit_test_all_smtp_address_validate_email(), smtp_unit_test_all_smtp_address_validate_name(), smtp_unit_test_all_smtp_attachment_validate_name(), smtp_unit_test_all_smtp_header_key_validate(), and smtp_unit_test_all_smtp_header_value_validate().
#define TMP_FILE_PATH "/tmp/test_smtp_file_get_contents.txt" |
Temporary file path to use for testing the smtp_file_get_contents function.
Definition at line 33 of file test.c.
Referenced by smtp_unit_test_all_file_get_contents(), smtp_unit_test_file_get_contents(), and smtp_unit_test_str_getdelimfd().
enum smtp_test_flags |
Configuration flags for the smtp testing framework.
Enumerator | |
---|---|
SMTP_TEST_UNIT_TESTING_ONLY | Only run the unit tests, skipping all functional testing. |
Definition at line 4913 of file test.c.
int main | ( | int | argc, |
char * | argv[] | ||
) |
Main testing program entry point for testing the smtp-client library.
This program supports the following options:
[in] | argc | Number of arguments in argv . |
[in] | argv | String array containing the program name and any optional parameters described above. |
0 | All tests passed. |
1 | Error. |
Definition at line 4942 of file test.c.
References smtp_test::flags, smtp_func_test_all(), SMTP_TEST_UNIT_TESTING_ONLY, and smtp_unit_test_all().
|
static |
Call smtp_address_add and check the result.
[in] | type | See smtp_address_type. |
[in] | Email address. | |
[in] | name | Name corresponding to email . |
[in] | expect_status | Expected return code from smtp_address_add. |
Definition at line 2189 of file test.c.
References g_config, g_rc, smtp_test_config::smtp, and smtp_address_add().
Referenced by smtp_func_test_all_address(), smtp_func_test_all_body(), smtp_func_test_all_names(), smtp_func_test_all_nodebug(), smtp_func_test_attachment_fp(), smtp_func_test_attachment_long_text(), smtp_func_test_attachment_mem(), smtp_func_test_attachment_path(), smtp_func_test_attachment_pdf(), smtp_func_test_gmail_attachment(), smtp_func_test_header_custom_date(), smtp_func_test_header_long(), smtp_func_test_header_null_no_date(), smtp_func_test_html(), smtp_func_test_html_with_plaintext(), smtp_func_test_send_email(), test_failure_address_add(), test_failure_timeout(), and test_smtp_open_default().
|
static |
Call smtp_auth and check the result.
[in] | auth_method | See smtp_authentication_method |
[in] | user | Username. |
[in] | pass | Password. |
[in] | expect_status | Expected return code from smtp_auth. |
Definition at line 2172 of file test.c.
References g_config, g_rc, smtp_test_config::smtp, and smtp_auth().
Referenced by smtp_func_test_attachment_long_text(), smtp_func_test_attachment_mem(), smtp_func_test_attachment_path(), smtp_func_test_attachment_pdf(), smtp_func_test_gmail_attachment(), smtp_func_test_send_email(), and test_failure_auth().
|
static |
Call smtp_close and check the result.
[in] | expect_status | Expected return code from smtp_close. |
Definition at line 2231 of file test.c.
References g_config, g_rc, smtp_test_config::smtp, and smtp_close().
Referenced by smtp_func_test_all_address(), smtp_func_test_all_body(), smtp_func_test_all_names(), smtp_func_test_all_nodebug(), smtp_func_test_all_status_code_get(), smtp_func_test_all_write(), smtp_func_test_attachment_fp(), smtp_func_test_attachment_long_text(), smtp_func_test_attachment_mem(), smtp_func_test_attachment_path(), smtp_func_test_attachment_pdf(), smtp_func_test_gmail_attachment(), smtp_func_test_header_custom_date(), smtp_func_test_header_long(), smtp_func_test_header_null_no_date(), smtp_func_test_html(), smtp_func_test_html_with_plaintext(), smtp_func_test_send_email(), test_failure_address_add(), test_failure_attachment_add(), test_failure_auth(), test_failure_close(), test_failure_header_add(), test_failure_mail(), test_failure_misc(), test_failure_open(), test_failure_status_code_set(), and test_failure_timeout().
|
static |
Write bytes to an open file stream.
[in] | stream | The file stream to write bytes to. |
[in] | data | The buffer containing the contents to write to the file stream. |
[in] | datasz | Number of bytes in data . |
Definition at line 474 of file test.c.
References SIZE_MAX, and strlen.
Referenced by smtp_file_put_contents().
|
static |
Write a byte string to a file.
This interface handles safely opening, writing, and closing the file.
A return of 0 can either indicate an error or it could indicate that the string did not have any bytes to write. Check errno for if further details required.
[in] | filename | Path to file for writing the contents. |
[in] | data | The buffer contents to write to file. |
[in] | datasz | Number of bytes in data , or -1 if data consists of a null-terminated string. |
[in] | flags | Set to 0 for write mode or O_APPEND for append mode. |
0 | Failed to write any bytes to the file. |
>0 | Number of bytes written to file. |
Definition at line 512 of file test.c.
References fclose, and smtp_ffile_put_contents().
Referenced by smtp_unit_test_file_get_contents(), and smtp_unit_test_str_getdelimfd().
|
static |
Run through all functional/integration tests for each test SMTP server.
Definition at line 4904 of file test.c.
References smtp_func_test_server_gmail(), smtp_func_test_server_postfix(), and smtp_func_test_server_secureserver().
Referenced by main().
|
static |
Test multiple ways of sending to different recipients.
Definition at line 2760 of file test.c.
References smtp_test_config::email_from, smtp_test_config::email_to, smtp_test_config::email_to_2, smtp_test_config::email_to_3, g_config, g_rc, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_BCC, SMTP_ADDRESS_CC, smtp_address_clear_all(), SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_close_check(), smtp_header_add_check(), smtp_header_clear_all(), smtp_mail_check(), smtp_open(), smtp_status_code_clear(), SMTP_STATUS_OK, SMTP_STATUS_PARAM, SMTP_TEST_DEFAULT_BCC_NAME, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CC_NAME, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, SMTP_TEST_DEFAULT_FROM_NAME, and SMTP_TEST_DEFAULT_TO_NAME.
Referenced by smtp_func_test_server_postfix().
|
static |
Test different ways of loading file attachments onto an SMTP context.
Definition at line 2750 of file test.c.
References smtp_func_test_all_attachments_fp(), smtp_func_test_all_attachments_mem(), and smtp_func_test_all_attachments_path().
Referenced by smtp_func_test_server_postfix().
|
static |
Run all tests for smtp_attachment_add_fp.
Definition at line 2740 of file test.c.
References smtp_func_test_attachment_fp(), and SMTP_STATUS_OK.
Referenced by smtp_func_test_all_attachments().
|
static |
Run all tests for smtp_attachment_add_mem.
Definition at line 2707 of file test.c.
References smtp_func_test_attachment_long_text(), smtp_func_test_attachment_mem(), and smtp_func_test_attachment_pdf().
Referenced by smtp_func_test_all_attachments().
|
static |
Run all tests for smtp_attachment_add_path.
Definition at line 2724 of file test.c.
References smtp_func_test_attachment_path(), SMTP_STATUS_FILE, and SMTP_STATUS_OK.
Referenced by smtp_func_test_all_attachments().
|
static |
Run through all types of SMTP authentication methods provided in the smtp_authentication_method.
Definition at line 2437 of file test.c.
References SMTP_AUTH_CRAM_MD5, SMTP_AUTH_LOGIN, SMTP_AUTH_NONE, SMTP_AUTH_PLAIN, and smtp_func_test_auth().
Referenced by smtp_func_test_server_postfix().
|
static |
Test different scenarios with email bodies.
Definition at line 3150 of file test.c.
References smtp_test_config::email_from, smtp_test_config::email_to, g_config, g_rc, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_close_check(), smtp_header_add_check(), smtp_mail_check(), smtp_open(), SMTP_STATUS_OK, smtp_str_repeat(), SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, SMTP_TEST_DEFAULT_FROM_NAME, SMTP_TEST_DEFAULT_TO_NAME, and STR_ALPHABET_LOWERCASE.
Referenced by smtp_func_test_server_postfix().
|
static |
Send a test email with a self-signed certificate file specified in the cafile parameter.
Definition at line 2397 of file test.c.
References smtp_test_config::cafile, g_config, smtp_test_config::port, SMTP_DEBUG, smtp_func_test_send_email(), SMTP_SECURITY_STARTTLS, and SMTP_TEST_DEFAULT_AUTH_METHOD.
Referenced by smtp_func_test_server_postfix().
|
static |
Run through all types of SMTP connections provided in the smtp_connection_security.
Definition at line 2380 of file test.c.
References g_config, smtp_test_config::port, smtp_test_config::port_tls, smtp_func_test_connection_security(), SMTP_SECURITY_NONE, SMTP_SECURITY_STARTTLS, and SMTP_SECURITY_TLS.
Referenced by smtp_func_test_server_postfix().
|
static |
Test multiple ways of sending to different headers.
Definition at line 3140 of file test.c.
References smtp_func_test_header_custom_date(), smtp_func_test_header_long(), and smtp_func_test_header_null_no_date().
Referenced by smtp_func_test_server_postfix().
|
static |
Send HTML emails, overriding the Content-Type.
Definition at line 3373 of file test.c.
References smtp_func_test_html(), and smtp_func_test_html_with_plaintext().
Referenced by smtp_func_test_server_postfix().
|
static |
Test different methods of adding names to emails when calling smtp_address_add.
Definition at line 2895 of file test.c.
References smtp_test_config::email_from, smtp_test_config::email_to, smtp_test_config::email_to_2, smtp_test_config::email_to_3, g_config, g_rc, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_address_add_check(), smtp_address_clear_all(), SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_close_check(), smtp_header_add_check(), smtp_header_clear_all(), smtp_mail_check(), smtp_open(), SMTP_STATUS_OK, smtp_str_repeat(), SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, SMTP_TEST_DEFAULT_FROM_NAME, and STR_ALPHABET_LOWERCASE.
Referenced by smtp_func_test_server_postfix().
|
static |
Send a test email with debug mode disabled.
Definition at line 3206 of file test.c.
References smtp_test_config::email_from, smtp_test_config::email_to, g_config, g_rc, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_close_check(), smtp_header_add_check(), smtp_header_clear_all(), smtp_mail_check(), SMTP_NO_CERT_VERIFY, smtp_open(), SMTP_STATUS_OK, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FROM_NAME, and SMTP_TEST_DEFAULT_TO_NAME.
Referenced by smtp_func_test_server_postfix().
|
static |
Test the smtp_status_code_get function.
Definition at line 2279 of file test.c.
References g_config, g_rc, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_close_check(), smtp_open(), smtp_status_code_clear(), smtp_status_code_get(), smtp_status_code_set(), SMTP_STATUS_NOMEM, SMTP_STATUS_OK, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, and SMTP_TEST_DEFAULT_FLAGS.
Referenced by smtp_func_test_server_postfix().
|
static |
Manipulate the number of bytes sent over the network at a time.
Definition at line 3189 of file test.c.
References g_config, g_rc, g_smtp_test_send_one_byte, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_close_check(), SMTP_NO_CERT_VERIFY, smtp_open(), SMTP_STATUS_OK, SMTP_TEST_DEFAULT_CAFILE, and SMTP_TEST_DEFAULT_CONNECTION_SECURITY.
Referenced by smtp_func_test_server_postfix().
|
static |
Test harness for smtp_attachment_add_fp.
[in] | name | Name of the file to display to the recipient. |
[in] | path | Local file path to use as the attachment. |
[in] | expect_rc | Expected return code for the attachment function and every function after that. |
Definition at line 2501 of file test.c.
References smtp_test_config::body, smtp_test_config::email_from, smtp_test_config::email_to, fclose, g_config, g_rc, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_attachment_add_fp(), smtp_close_check(), smtp_header_add_check(), smtp_mail_check(), smtp_open(), SMTP_STATUS_OK, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, SMTP_TEST_DEFAULT_FROM_NAME, SMTP_TEST_DEFAULT_TO_NAME, and smtp_test_config::subject.
Referenced by smtp_func_test_all_attachments_fp().
|
static |
Test sending long text attachments.
Definition at line 2657 of file test.c.
References smtp_test_config::email_from, smtp_test_config::email_to, g_config, g_rc, smtp_test_config::pass, smtp_test_config::port, smtp_test_config::server, SIZE_MAX, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_attachment_add_mem(), smtp_auth_check(), smtp_close_check(), smtp_header_add_check(), smtp_mail_check(), smtp_open(), SMTP_STATUS_OK, smtp_str_repeat(), SMTP_TEST_DEFAULT_AUTH_METHOD, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, SMTP_TEST_DEFAULT_FROM_NAME, SMTP_TEST_DEFAULT_TO_NAME, STR_ALPHABET_LOWERCASE, and smtp_test_config::user.
Referenced by smtp_func_test_all_attachments_mem().
|
static |
Test harness for smtp_attachment_add_mem.
[in] | num_attachment | Number of attachments to send. |
Definition at line 2550 of file test.c.
References smtp_test_config::body, smtp_test_config::email_from, smtp_test_config::email_to, g_config, g_rc, smtp_test_config::pass, smtp_test_config::port, smtp_test_config::server, SIZE_MAX, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_attachment_add_mem(), smtp_auth_check(), smtp_close_check(), smtp_header_add_check(), smtp_mail_check(), SMTP_MAX_ATTACHMENT_NAME_LEN, smtp_open(), SMTP_STATUS_OK, SMTP_TEST_DEFAULT_AUTH_METHOD, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, SMTP_TEST_DEFAULT_FROM_NAME, SMTP_TEST_DEFAULT_TO_NAME, sprintf, smtp_test_config::subject, and smtp_test_config::user.
Referenced by smtp_func_test_all_attachments_mem().
|
static |
Test harness for smtp_attachment_add_path.
[in] | name | Name of the file to display to the recipient. |
[in] | path | Local file path to use as the attachment. |
[in] | expect_rc | Expected return code for the attachment function and every function after that. |
Definition at line 2453 of file test.c.
References smtp_test_config::body, smtp_test_config::email_from, smtp_test_config::email_to, g_config, g_rc, smtp_test_config::pass, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_attachment_add_path(), smtp_auth_check(), smtp_close_check(), smtp_header_add_check(), smtp_mail_check(), smtp_open(), SMTP_STATUS_OK, SMTP_TEST_DEFAULT_AUTH_METHOD, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, SMTP_TEST_DEFAULT_FROM_NAME, SMTP_TEST_DEFAULT_TO_NAME, smtp_test_config::subject, and smtp_test_config::user.
Referenced by smtp_func_test_all_attachments_path().
|
static |
Send multiple PDF attachments.
[in] | num_attachments | Number of attachments to send. |
Definition at line 2610 of file test.c.
References smtp_test_config::body, smtp_test_config::email_from, smtp_test_config::email_to, g_config, g_rc, smtp_test_config::pass, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_attachment_add_path(), smtp_auth_check(), smtp_close_check(), smtp_header_add_check(), smtp_mail_check(), SMTP_MAX_ATTACHMENT_NAME_LEN, smtp_open(), SMTP_STATUS_OK, SMTP_TEST_DEFAULT_AUTH_METHOD, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, SMTP_TEST_DEFAULT_FROM_NAME, SMTP_TEST_DEFAULT_TO_NAME, sprintf, smtp_test_config::subject, and smtp_test_config::user.
Referenced by smtp_func_test_all_attachments_mem().
|
static |
Send a test email with a specific authentication method.
[in] | auth_method | See smtp_authentication_method. |
[in] | auth_description | Description of auth_method . |
Definition at line 2414 of file test.c.
References smtp_test_config::body, g_config, smtp_test_config::port, smtp_func_test_send_email(), SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, sprintf, and smtp_test_config::subject.
Referenced by smtp_func_test_all_auth_methods().
|
static |
Send a test email with a specific connection security method.
[in] | server_port | Server port number to connect to. |
[in] | con_security | See smtp_connection_security. |
[in] | security_description | Description of connection_security . |
Definition at line 2356 of file test.c.
References smtp_test_config::body, g_config, smtp_func_test_send_email(), SMTP_TEST_DEFAULT_AUTH_METHOD, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_FLAGS, sprintf, and smtp_test_config::subject.
Referenced by smtp_func_test_all_connection_security().
|
static |
Send attachment to test gmail account.
Definition at line 4835 of file test.c.
References smtp_test_config::body, smtp_test_config::email_from, smtp_test_config::email_to, g_config, g_rc, smtp_test_config::pass, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_attachment_add_path(), smtp_auth_check(), SMTP_AUTH_PLAIN, smtp_close_check(), SMTP_DEBUG, smtp_header_add_check(), smtp_mail_check(), smtp_open(), SMTP_SECURITY_STARTTLS, SMTP_STATUS_OK, SMTP_TEST_DEFAULT_FROM_NAME, SMTP_TEST_DEFAULT_TO_NAME, smtp_test_config::subject, and smtp_test_config::user.
Referenced by smtp_func_test_server_gmail().
|
static |
Test scenario where the caller provides a custom date value in the header.
This should override the default date implementation which uses the current local date.
Definition at line 3020 of file test.c.
References smtp_test_config::email_from, smtp_test_config::email_to, g_config, g_rc, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_close_check(), smtp_header_add_check(), smtp_header_clear_all(), smtp_mail_check(), smtp_open(), SMTP_STATUS_OK, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, SMTP_TEST_DEFAULT_FROM_NAME, and SMTP_TEST_DEFAULT_TO_NAME.
Referenced by smtp_func_test_all_headers().
|
static |
Test sending long headers.
Definition at line 3098 of file test.c.
References smtp_test_config::email_from, smtp_test_config::email_to, g_config, g_rc, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_close_check(), smtp_header_add_check(), smtp_header_clear_all(), smtp_mail_check(), smtp_open(), SMTP_STATUS_OK, smtp_str_repeat(), SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, SMTP_TEST_DEFAULT_FROM_NAME, SMTP_TEST_DEFAULT_TO_NAME, and STR_ALPHABET_LOWERCASE.
Referenced by smtp_func_test_all_headers().
|
static |
Test scenario where the caller provides a NULL value for a header.
This should prevent that header from generating in the email.
Definition at line 3061 of file test.c.
References smtp_test_config::email_from, smtp_test_config::email_to, g_config, g_rc, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_close_check(), smtp_header_add_check(), smtp_header_clear_all(), smtp_mail_check(), smtp_open(), SMTP_STATUS_OK, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, SMTP_TEST_DEFAULT_FROM_NAME, and SMTP_TEST_DEFAULT_TO_NAME.
Referenced by smtp_func_test_all_headers().
|
static |
Send an HTML email.
Definition at line 3241 of file test.c.
References smtp_test_config::email_from, smtp_test_config::email_to, g_config, g_rc, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_close_check(), smtp_header_add_check(), smtp_header_clear_all(), smtp_mail_check(), smtp_open(), SMTP_STATUS_OK, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, SMTP_TEST_DEFAULT_FROM_NAME, and SMTP_TEST_DEFAULT_TO_NAME.
Referenced by smtp_func_test_all_html().
|
static |
Send an HTML email with a plaintext fallback.
Definition at line 3303 of file test.c.
References smtp_test_config::email_from, smtp_test_config::email_to, g_config, g_rc, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_close_check(), smtp_header_add_check(), smtp_header_clear_all(), smtp_mail_check(), smtp_open(), SMTP_STATUS_OK, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, SMTP_TEST_DEFAULT_FROM_NAME, and SMTP_TEST_DEFAULT_TO_NAME.
Referenced by smtp_func_test_all_html().
|
static |
Send a test email with the given parameters.
See smtp_open and smtp_auth for more information about this functions parameters.
[in] | port | Server connection port. |
[in] | connection_security | Connection security settings. |
[in] | flags | Miscellaneous configuration flags. |
[in] | auth_method | Authentication method. |
[in] | cafile | Path to certificate file. |
[in] | subject | Email subject line. |
[in] | body | Email body. |
Definition at line 2314 of file test.c.
References smtp_test_config::email_from, smtp_test_config::email_to, g_config, g_rc, smtp_test_config::pass, smtp_test_config::server, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_auth_check(), smtp_close_check(), smtp_header_add_check(), smtp_mail_check(), smtp_open(), SMTP_STATUS_OK, SMTP_TEST_DEFAULT_FROM_NAME, SMTP_TEST_DEFAULT_TO_NAME, and smtp_test_config::user.
Referenced by smtp_func_test_all_cafile(), smtp_func_test_auth(), smtp_func_test_connection_security(), and smtp_func_test_server_gmail().
|
static |
Run the functional tests on the test SMTP gmail account.
This only sends one email using a test gmail account. Most of the tests have been designed to work with a local postfix server instance.
Definition at line 4882 of file test.c.
References g_config, smtp_test_config::port, SMTP_AUTH_PLAIN, SMTP_DEBUG, smtp_func_test_gmail_attachment(), smtp_func_test_send_email(), SMTP_SECURITY_STARTTLS, smtp_test_config_load_from_file(), and SMTP_TEST_DEFAULT_CAFILE.
Referenced by smtp_func_test_all().
|
static |
Run the functional tests on local postfix server.
This configuration handles most of the functional testing and includes:
Definition at line 4768 of file test.c.
References smtp_func_test_all_address(), smtp_func_test_all_attachments(), smtp_func_test_all_auth_methods(), smtp_func_test_all_body(), smtp_func_test_all_cafile(), smtp_func_test_all_connection_security(), smtp_func_test_all_headers(), smtp_func_test_all_html(), smtp_func_test_all_names(), smtp_func_test_all_nodebug(), smtp_func_test_all_status_code_get(), smtp_func_test_all_write(), smtp_test_config_load_from_file(), smtp_test_sleep(), and test_all_failure_modes().
Referenced by smtp_func_test_all().
|
static |
Open and close a connection to secureserver.net.
Definition at line 4796 of file test.c.
References g_rc, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_close(), SMTP_DEBUG, smtp_open(), SMTP_SECURITY_STARTTLS, SMTP_SECURITY_TLS, SMTP_STATUS_OK, and smtp_test_sleep().
Referenced by smtp_func_test_all().
|
static |
Call smtp_header_add and check the result.
[in] | key | Key name for new header. |
[in] | value | Value for new header. |
[in] | expect_status | Expected return code from smtp_header_add. |
Definition at line 2205 of file test.c.
References g_config, g_rc, smtp_test_config::smtp, and smtp_header_add().
Referenced by smtp_func_test_all_address(), smtp_func_test_all_body(), smtp_func_test_all_names(), smtp_func_test_all_nodebug(), smtp_func_test_attachment_fp(), smtp_func_test_attachment_long_text(), smtp_func_test_attachment_mem(), smtp_func_test_attachment_path(), smtp_func_test_attachment_pdf(), smtp_func_test_gmail_attachment(), smtp_func_test_header_custom_date(), smtp_func_test_header_long(), smtp_func_test_header_null_no_date(), smtp_func_test_html(), smtp_func_test_html_with_plaintext(), smtp_func_test_send_email(), and test_failure_header_add().
|
static |
Call smtp_mail and check the result.
[in] | body | Email body text. |
[in] | expect_status | Expected return code from smtp_mail. |
Definition at line 2219 of file test.c.
References g_config, g_rc, smtp_test_config::smtp, and smtp_mail().
Referenced by smtp_func_test_all_address(), smtp_func_test_all_body(), smtp_func_test_all_names(), smtp_func_test_all_nodebug(), smtp_func_test_attachment_fp(), smtp_func_test_attachment_long_text(), smtp_func_test_attachment_mem(), smtp_func_test_attachment_path(), smtp_func_test_attachment_pdf(), smtp_func_test_gmail_attachment(), smtp_func_test_header_custom_date(), smtp_func_test_header_long(), smtp_func_test_header_null_no_date(), smtp_func_test_html(), smtp_func_test_html_with_plaintext(), smtp_func_test_send_email(), test_failure_mail(), and test_failure_timeout().
|
static |
Append a string to the string list.
[in] | slist | String list to append to. |
[in] | s | The new string to append to the list. |
[in] | n | Maximum number of bytes to copy in the string. |
0 | Successfully appended the string to the list. |
-1 | Memory allocation failure. |
Definition at line 348 of file test.c.
References smtp_str_list::n, realloc, smtp_str_list::slist, and smtp_strndup().
Referenced by smtp_str_split(), and smtp_unit_test_str_getdelimfd().
|
static |
Free all memory associated to the string list.
[in] | list | The string list to free. |
Definition at line 374 of file test.c.
References smtp_str_list::n, and smtp_str_list::slist.
Referenced by smtp_str_split(), smtp_test_config_load_from_file(), and smtp_unit_test_str_getdelimfd().
|
static |
Repeat a string multiple times and copy into new buffer.
Used to test large inputs.
[in] | s | String to repeat. |
[in] | n | Number of times to repeat s . |
char* | New buffer with text repeating s n times. |
NULL | Memory allocation failure. |
Definition at line 294 of file test.c.
References malloc, smtp_strdup(), and strlen.
Referenced by smtp_func_test_all_body(), smtp_func_test_all_names(), smtp_func_test_attachment_long_text(), and smtp_func_test_header_long().
|
static |
Split a string with delimiters into a list.
[in] | s | The string to split. |
[in] | slen | Length of string s to split, or -1 to split the entire string. |
[in] | delimiter | Split the string at every delimiter location. |
[in] | limit | A positive limit will limit the maximum number of split strings to limit with the last string containing the rest of the string. A value of 0 has the same meaning as 1. A negative value will cut off the last limit strings from the result. |
[out] | slist | See smtp_str_list. |
0 | Successfully split the string and stored the results into slist . |
-1 | Memory allocation failure. |
Definition at line 403 of file test.c.
References smtp_str_list::n, SIZE_MAX, smtp_str_list::slist, smtp_str_list_append(), smtp_str_list_free(), and strlen.
Referenced by smtp_test_config_load_from_file().
|
static |
Copy a string and guarantee that the destination string has been null-terminated based on the given size.
This function has a safer interface than strncpy because it always null terminates the destination string and it returns the total number of bytes in src
which makes it easier to determine if the src tried to overflow the buffer.
[out] | dest | Destination string buffer. |
[in] | src | Source string buffer. |
[in] | destsz | Number of bytes available in dest . |
src
. Definition at line 231 of file test.c.
Referenced by smtp_strndup(), and smtp_test_config_load_from_file().
|
static |
Duplicate a string only up to a maximum number of bytes.
[in] | s | String to duplicate. |
[in] | n | Maximum number of bytes to copy. |
char* | Duplicate of string s with at most n bytes. |
NULL | Memory allocation failure. |
Definition at line 269 of file test.c.
References malloc, and smtp_strlcpy().
Referenced by smtp_str_list_append().
|
static |
Load server configuration file containing server connection information.
The server connection information contains sensitive information, so we need to load it in from a separate configuration file that does not get saved in the repository. This stores the parsed results into a smtp_test_config data structure.
[in] | config_path | Path to the server configuration file. |
0 | Successfully parsed and saved the server configuration into the data structure. |
-1 | Failed to read file or memory allocation failure. |
Definition at line 2082 of file test.c.
References smtp_test_config::cafile, smtp_test_config::email_from, smtp_test_config::email_to, smtp_test_config::email_to_2, smtp_test_config::email_to_3, g_config, smtp_str_list::n, smtp_test_config::pass, smtp_test_config::port, smtp_test_config::port_tls, realloc, smtp_test_config::server, smtp_str_list::slist, smtp_file_get_contents(), smtp_str_list_free(), smtp_str_split(), smtp_strlcpy(), and smtp_test_config::user.
Referenced by smtp_func_test_server_gmail(), and smtp_func_test_server_postfix().
|
static |
Sleep for number of seconds.
Useful for testing failure scenarios because a timeout will occur after too many failed login attempts.
[in] | seconds | The number of seconds to pause execution. |
Definition at line 553 of file test.c.
Referenced by smtp_func_test_server_postfix(), smtp_func_test_server_secureserver(), and test_failure_auth().
|
static |
Unit test functions which do not require an SMTP client context.
Definition at line 2041 of file test.c.
References smtp_unit_test_all_base64_decode(), smtp_unit_test_all_base64_encode(), smtp_unit_test_all_bin2hex(), smtp_unit_test_all_chunk_split(), smtp_unit_test_all_date_rfc_2822(), smtp_unit_test_all_file_get_contents(), smtp_unit_test_all_fold_whitespace(), smtp_unit_test_all_fold_whitespace_get_offset(), smtp_unit_test_all_parse_cmd_line(), smtp_unit_test_all_reallocarray(), smtp_unit_test_all_si(), smtp_unit_test_all_smtp_address_validate_email(), smtp_unit_test_all_smtp_address_validate_name(), smtp_unit_test_all_smtp_attachment_validate_name(), smtp_unit_test_all_smtp_header_key_validate(), smtp_unit_test_all_smtp_header_value_validate(), smtp_unit_test_all_smtp_status_code_errstr(), smtp_unit_test_all_smtp_str_has_nonascii_utf8(), smtp_unit_test_all_smtp_utf8_charlen(), smtp_unit_test_all_stpcpy(), smtp_unit_test_all_str_getdelimfd(), smtp_unit_test_all_str_replace(), smtp_unit_test_all_strdup(), and smtp_unit_test_all_strnlen_utf8().
Referenced by main().
|
static |
Run all test cases for base64 decoding.
Definition at line 667 of file test.c.
References g_smtp_test_err_calloc_ctr, g_smtp_test_err_si_add_size_t_ctr, SIZE_MAX, smtp_unit_test_base64_decode(), and STR_ALPHABET_LOWERCASE.
Referenced by smtp_unit_test_all().
|
static |
Run all test cases for base64 encoding.
Definition at line 722 of file test.c.
References g_smtp_test_err_calloc_ctr, g_smtp_test_strlen_custom_ret, g_smtp_test_strlen_ret_value, SIZE_MAX, smtp_unit_test_base64_encode(), and STR_ALPHABET_LOWERCASE.
Referenced by smtp_unit_test_all().
|
static |
Run all test cases for smtp_bin2hex.
Definition at line 778 of file test.c.
References g_smtp_test_err_malloc_ctr, g_smtp_test_err_si_add_size_t_ctr, g_smtp_test_err_sprintf_ctr, g_smtp_test_err_sprintf_rc, SIZE_MAX, smtp_unit_test_bin2hex(), and STR_ALPHABET_LOWERCASE.
Referenced by smtp_unit_test_all().
|
static |
Run all tests for smtp_chunk_split.
Definition at line 1366 of file test.c.
References g_smtp_test_err_calloc_ctr, g_smtp_test_err_si_add_size_t_ctr, g_smtp_test_err_si_mul_size_t_ctr, smtp_unit_test_chunk_split(), and STR_ALPHABET_LOWERCASE.
Referenced by smtp_unit_test_all().
|
static |
Run all tests for smtp_date_rfc_2822.
Definition at line 1596 of file test.c.
References g_smtp_test_err_gmtime_r_ctr, g_smtp_test_err_localtime_r_ctr, g_smtp_test_err_mktime_ctr, g_smtp_test_err_sprintf_ctr, g_smtp_test_err_sprintf_rc, and smtp_unit_test_date_rfc_2822().
Referenced by smtp_unit_test_all().
|
static |
Run all tests for smtp_file_get_contents.
Definition at line 1457 of file test.c.
References g_smtp_test_err_fclose_ctr, g_smtp_test_err_ferror_ctr, g_smtp_test_err_realloc_ctr, g_smtp_test_err_si_add_size_t_ctr, SIZE_MAX, smtp_file_get_contents(), smtp_unit_test_file_get_contents(), STR_ALPHABET_LOWERCASE, strlen, and TMP_FILE_PATH.
Referenced by smtp_unit_test_all().
|
static |
Run all tests for smtp_fold_whitespace.
Definition at line 1272 of file test.c.
References g_smtp_test_err_realloc_ctr, g_smtp_test_err_si_add_size_t_ctr, smtp_unit_test_fold_whitespace(), and STR_ALPHABET_LOWERCASE.
Referenced by smtp_unit_test_all().
|
static |
Run all tests for smtp_fold_whitespace_get_offset.
Definition at line 1137 of file test.c.
References smtp_unit_test_fold_whitespace_get_offset().
Referenced by smtp_unit_test_all().
|
static |
Run all tests for smtp_parse_cmd_line.
Definition at line 1533 of file test.c.
References SMTP_INTERNAL_ERROR, SMTP_READY, and smtp_unit_test_parse_cmd_line().
Referenced by smtp_unit_test_all().
|
static |
Run all test cases for smtp_reallocarray.
Definition at line 895 of file test.c.
References g_smtp_test_err_realloc_ctr, SIZE_MAX, and smtp_unit_test_reallocarray().
Referenced by smtp_unit_test_all().
|
static |
Run all test cases for integer wrapping.
Definition at line 591 of file test.c.
References SIZE_MAX, smtp_si_add_size_t(), smtp_si_mul_size_t(), smtp_si_sub_size_t(), and smtp_unit_test_si_size_t().
Referenced by smtp_unit_test_all().
|
static |
Run all tests for smtp_address_validate_email.
Definition at line 1630 of file test.c.
References smtp_address_validate_email(), and STR_ALPHABET_LOWERCASE.
Referenced by smtp_unit_test_all().
|
static |
Run all tests for smtp_address_validate_name.
Definition at line 1644 of file test.c.
References smtp_address_validate_name(), and STR_ALPHABET_LOWERCASE.
Referenced by smtp_unit_test_all().
|
static |
Run all tests for smtp_attachment_validate_name.
Definition at line 1658 of file test.c.
References smtp_attachment_validate_name(), and STR_ALPHABET_LOWERCASE.
Referenced by smtp_unit_test_all().
|
static |
Run all tests for smtp_header_key_validate.
Definition at line 1673 of file test.c.
References smtp_header_key_validate(), and STR_ALPHABET_LOWERCASE.
Referenced by smtp_unit_test_all().
|
static |
Run all tests for smtp_header_value_validate.
Definition at line 1687 of file test.c.
References smtp_header_value_validate(), and STR_ALPHABET_LOWERCASE.
Referenced by smtp_unit_test_all().
|
static |
Run all tests for smtp_status_code_errstr.
Definition at line 1714 of file test.c.
References SMTP_STATUS_NOMEM, SMTP_STATUS_OK, and smtp_unit_test_smtp_status_code_errstr().
Referenced by smtp_unit_test_all().
|
static |
Run all tests for smtp_str_has_nonascii_utf8.
Definition at line 1047 of file test.c.
References smtp_str_has_nonascii_utf8().
Referenced by smtp_unit_test_all().
|
static |
Run all tests for smtp_utf8_charlen.
Definition at line 1028 of file test.c.
References smtp_utf8_charlen().
Referenced by smtp_unit_test_all().
|
static |
Run all test cases for smtp_stpcpy.
Definition at line 851 of file test.c.
References smtp_unit_test_stpcpy().
Referenced by smtp_unit_test_all().
|
static |
Run all tests for smtp_str_getdelimfd.
Definition at line 1863 of file test.c.
References str_getdelimfd::_buf, g_smtp_test_err_calloc_ctr, g_smtp_test_err_realloc_ctr, g_smtp_test_err_si_add_size_t_ctr, g_smtp_test_err_si_sub_size_t_ctr, SIZE_MAX, smtp_unit_test_getdelimfd_set_line_and_buf(), smtp_unit_test_str_getdelimfd(), STRING_GETDELIMFD_DONE, STRING_GETDELIMFD_ERROR, and strlen.
Referenced by smtp_unit_test_all().
|
static |
Run all tests for smtp_str_replace.
Definition at line 981 of file test.c.
References g_smtp_test_err_realloc_ctr, g_smtp_test_err_si_add_size_t_ctr, g_smtp_test_strlen_custom_ret, g_smtp_test_strlen_ret_value, SIZE_MAX, and smtp_unit_test_str_replace().
Referenced by smtp_unit_test_all().
|
static |
Run all test cases for smtp_strdup.
Definition at line 934 of file test.c.
References g_smtp_test_err_malloc_ctr, g_smtp_test_strlen_custom_ret, g_smtp_test_strlen_ret_value, SIZE_MAX, and smtp_unit_test_strdup().
Referenced by smtp_unit_test_all().
|
static |
Run all tests for smtp_strnlen_utf8.
Definition at line 1076 of file test.c.
References SIZE_MAX, and smtp_unit_test_strnlen_utf8().
Referenced by smtp_unit_test_all().
|
static |
Test harness for smtp_base64_decode.
[in] | buf | Null-terminated base64 string. |
[in] | expect_str | Decoded binary data. |
[in] | expect_str_len | Length of expect_str . |
Definition at line 646 of file test.c.
References smtp_base64_decode().
Referenced by smtp_unit_test_all_base64_decode().
|
static |
Test harness for smtp_base64_encode.
[in] | buf | Binary data to encode in base64. |
[in] | buflen | Number of bytes in the buf parameter. |
[in] | expect | The expected base64 string that would get returned. |
Definition at line 703 of file test.c.
References smtp_base64_encode().
Referenced by smtp_unit_test_all_base64_encode().
|
static |
Test harness for smtp_bin2hex.
[in] | s | Buffer containing binary data to convert. |
[in] | slen | Number of bytes in s . |
[in] | expect | Expected hex string output returned by smtp_bin2hex. |
Definition at line 759 of file test.c.
References smtp_bin2hex().
Referenced by smtp_unit_test_all_bin2hex().
|
static |
Test harness for smtp_chunk_split.
[in] | s | The string to chunk. |
[in] | chunklen | Number of bytes for each chunk in the string. |
[in] | end | Terminating string placed at the end of each chunk. |
[in] | expect | Expected chunk string. |
Definition at line 1346 of file test.c.
References smtp_chunk_split().
Referenced by smtp_unit_test_all_chunk_split().
|
static |
Test harness for smtp_date_rfc_2822.
[in] | t | Force the time() function to return this time_t value. |
[in] | expect | Expected date string. |
[in] | expect_rc | Expected return code. |
Definition at line 1572 of file test.c.
References g_smtp_test_time_custom_ret, g_smtp_test_time_ret_value, and smtp_date_rfc_2822().
Referenced by smtp_unit_test_all_date_rfc_2822().
|
static |
Test harness for smtp_file_get_contents.
[in] | s | The string to write to the temp file before reading. |
[in] | nbytes | Number of bytes in s . |
[in] | expect | Expected string after reading the file. |
Definition at line 1437 of file test.c.
References smtp_file_get_contents(), smtp_file_put_contents(), strlen, and TMP_FILE_PATH.
Referenced by smtp_unit_test_all_file_get_contents().
|
static |
Test harness for smtp_fold_whitespace.
[in] | s | String to fold. |
[in] | maxlen | Number of bytes for each line in the string (soft limit). |
[in] | expect | Expected folded string. |
Definition at line 1253 of file test.c.
References smtp_fold_whitespace().
Referenced by smtp_unit_test_all_fold_whitespace().
|
static |
Test harness for smtp_fold_whitespace_get_offset.
[in] | s | String to fold. |
[in] | maxlen | Number of bytes for each line in the string (soft limit). |
[in] | expect | Expected folded string. |
Definition at line 1124 of file test.c.
References smtp_fold_whitespace_get_offset().
Referenced by smtp_unit_test_all_fold_whitespace_get_offset().
|
static |
Read function used by the smtp_str_getdelimfd interface.
[in] | gdfd | See str_getdelimfd. |
[out] | buf | Pointer to buffer for storing bytes read. |
[in] | count | Maximum number of bytes to try reading. |
>=0 | Number of bytes read. |
-1 | Failed to read from the socket. |
Definition at line 1752 of file test.c.
References smtp_test_getdelimfd_fp::fp, and str_getdelimfd::user_data.
Referenced by smtp_unit_test_str_getdelimfd().
|
static |
Test harness for smtp_str_getdelimfd_set_line_and_buf.
[in] | gdfd | See str_getdelimfd. |
[in] | copy_len | Number of bytes to copy to the internal line buffer. |
[in] | expect_result | Expected result code (0 or -1) from smtp_str_getdelimfd_set_line_and_buf. |
Definition at line 1850 of file test.c.
References smtp_str_getdelimfd_set_line_and_buf().
Referenced by smtp_unit_test_all_str_getdelimfd().
|
static |
Test harness for smtp_parse_cmd_line.
[in] | line | The server response line to parse. |
[in] | expect_code | Expected server response code. |
[in] | expect_more | Set to 1 if more lines will get returned or 0 if no more lines. |
[in] | expect_text | Expected text shown after the response code. |
Definition at line 1509 of file test.c.
References smtp_command::code, smtp_command::more, smtp_parse_cmd_line(), smtp_strdup(), and smtp_command::text.
Referenced by smtp_unit_test_all_parse_cmd_line().
|
static |
Test harness for smtp_reallocarray.
[in] | ptr | Existing allocation buffer, or NULL when allocating a new buffer. |
[in] | nmemb | Number of elements to allocate. |
[in] | size | Size of each element in nmemb . |
[in] | expect_alloc | Set to 0 if expecting NULL return, or set to any other value when expecting successful allocation. |
Definition at line 875 of file test.c.
References smtp_reallocarray().
Referenced by smtp_unit_test_all_reallocarray().
|
static |
Test harness for smtp_si_add_size_t, smtp_si_sub_size_t, and smtp_si_mul_size_t.
[in] | si_fp | One of the si wrapping functions for size_t types. |
[in] | a | Add this value with b . |
[in] | b | Add this value with a . |
[out] | result | Memory location to store the result. |
[in] | expect_result | Expected result of adding a and b . |
[in] | expect_wrap | Expectation on whether the addition will wrap. |
Definition at line 570 of file test.c.
Referenced by smtp_unit_test_all_si().
|
static |
Test harness for smtp_status_code_errstr.
[in] | status_code | See smtp_status_code. |
[in] | expect | Expected error string. |
Definition at line 1702 of file test.c.
References smtp_status_code_errstr().
Referenced by smtp_unit_test_all_smtp_status_code_errstr().
|
static |
Test harness for smtp_stpcpy.
[in] | init | Set the destination buffer to this initial string. |
[in] | s2 | Concatenate this string into the destination buffer. |
[in] | expect | Expected string result. |
Definition at line 824 of file test.c.
References malloc, smtp_stpcpy(), and strlen.
Referenced by smtp_unit_test_all_stpcpy().
|
static |
Test harness for smtp_str_getdelimfd.
[in] | input_string | Test string used in delimeter parsing. |
[in] | nbytes | Number of bytes in input_string . |
[in] | delim | Delimiter used to split the string. |
[in] | expect_rc | Expected return code. |
[in] | null_fp | If set, use a NULL read function pointer. Useful for testing that error condition. |
[in] | expect_pieces | Expected list of strings parsed from the file. |
Definition at line 1778 of file test.c.
References str_getdelimfd::delim, fclose, smtp_test_getdelimfd_fp::fp, str_getdelimfd::getdelimfd_read, str_getdelimfd::line, str_getdelimfd::line_len, smtp_str_list::n, smtp_str_list::slist, smtp_file_put_contents(), smtp_str_getdelimfd(), smtp_str_getdelimfd_free(), smtp_str_list_append(), smtp_str_list_free(), smtp_unit_test_getdelimfd_fp(), STRING_GETDELIMFD_DONE, STRING_GETDELIMFD_ERROR, TMP_FILE_PATH, and str_getdelimfd::user_data.
Referenced by smtp_unit_test_all_str_getdelimfd().
|
static |
Test harness for smtp_str_replace.
[in] | search | Substring to search for in s . |
[in] | replace | Replace each instance of the search string with this. |
[in] | s | Null-terminated string to search and replace. |
[in] | expect | Expected result. |
Definition at line 961 of file test.c.
References smtp_str_replace().
Referenced by smtp_unit_test_all_str_replace().
|
static |
Test harness for smtp_strdup.
[in] | s | String to duplicate. |
[in] | expect | Expected string result. |
Definition at line 916 of file test.c.
References smtp_strdup().
Referenced by smtp_unit_test_all_strdup().
|
static |
Test harness for smtp_strnlen_utf8.
[in] | s | UTF-8 string. |
[in] | maxlen | Do not check more than maxlen bytes of string s . |
[in] | expect | Expected string length. |
Definition at line 1063 of file test.c.
References smtp_strnlen_utf8().
Referenced by smtp_unit_test_all_strnlen_utf8().
|
static |
Test multiple failure modes when using the high-level interfaces.
Definition at line 4745 of file test.c.
References test_failure_address_add(), test_failure_attachment_add(), test_failure_auth(), test_failure_close(), test_failure_header_add(), test_failure_mail(), test_failure_misc(), test_failure_open(), test_failure_status_code_set(), and test_failure_timeout().
Referenced by smtp_func_test_server_postfix().
|
static |
Test different error results in the address functions, including memory allocation failures.
Definition at line 3706 of file test.c.
References smtp_test_config::email_from, g_config, g_rc, g_smtp_test_err_malloc_ctr, g_smtp_test_err_realloc_ctr, g_smtp_test_err_si_add_size_t_ctr, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_FROM, smtp_close_check(), smtp_open(), smtp_status_code_clear(), smtp_status_code_set(), SMTP_STATUS_NOMEM, SMTP_STATUS_OK, SMTP_STATUS_PARAM, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, and SMTP_TEST_DEFAULT_FROM_NAME.
Referenced by test_all_failure_modes().
|
static |
Test different error results in the attachment functions, including memory allocation failures.
Definition at line 3780 of file test.c.
References fclose, g_config, g_rc, g_smtp_test_err_calloc_ctr, g_smtp_test_err_ferror_ctr, g_smtp_test_err_malloc_ctr, g_smtp_test_err_realloc_ctr, g_smtp_test_err_si_add_size_t_ctr, smtp_test_config::port, smtp_test_config::server, SIZE_MAX, smtp_test_config::smtp, smtp_attachment_add_fp(), smtp_attachment_add_mem(), smtp_attachment_add_path(), smtp_close_check(), smtp_open(), smtp_status_code_clear(), smtp_status_code_set(), SMTP_STATUS_FILE, SMTP_STATUS_NOMEM, SMTP_STATUS_OK, SMTP_STATUS_PARAM, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, and SMTP_TEST_DEFAULT_FLAGS.
Referenced by test_all_failure_modes().
|
static |
Test different error results in the auth functions, including memory allocation failures and invalid credentials.
Definition at line 4310 of file test.c.
References g_config, g_smtp_test_err_calloc_ctr, g_smtp_test_err_hmac_ctr, g_smtp_test_err_malloc_ctr, g_smtp_test_err_recv_bytes, g_smtp_test_err_recv_ctr, g_smtp_test_err_send_ctr, g_smtp_test_err_si_add_size_t_ctr, g_smtp_test_err_ssl_read_ctr, g_smtp_test_err_ssl_write_ctr, smtp_test_config::pass, smtp_test_config::smtp, smtp_auth_check(), SMTP_AUTH_CRAM_MD5, SMTP_AUTH_LOGIN, SMTP_AUTH_NONE, SMTP_AUTH_PLAIN, smtp_close_check(), SMTP_STATUS_AUTH, smtp_status_code_set(), SMTP_STATUS_NOMEM, SMTP_STATUS_PARAM, smtp_test_sleep(), test_smtp_open_default(), and smtp_test_config::user.
Referenced by test_all_failure_modes().
|
static |
Test different error conditions in the smtp_close function.
Definition at line 4261 of file test.c.
References g_config, g_rc, g_smtp_test_err_close_ctr, g_smtp_test_err_send_ctr, g_smtp_test_err_ssl_write_ctr, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_close_check(), smtp_open(), SMTP_STATUS_CLOSE, SMTP_STATUS_OK, SMTP_STATUS_SEND, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, and SMTP_TEST_DEFAULT_FLAGS.
Referenced by test_all_failure_modes().
|
static |
Test different error results in the smtp_header_add function, including memory allocation failures.
Definition at line 3904 of file test.c.
References g_config, g_rc, g_smtp_test_err_malloc_ctr, g_smtp_test_err_realloc_ctr, g_smtp_test_err_si_add_size_t_ctr, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_close_check(), smtp_header_add_check(), smtp_open(), smtp_status_code_clear(), smtp_status_code_set(), SMTP_STATUS_NOMEM, SMTP_STATUS_OK, SMTP_STATUS_PARAM, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, and SMTP_TEST_DEFAULT_FLAGS.
Referenced by test_all_failure_modes().
|
static |
Test different error conditions in the smtp_mail function.
Definition at line 3984 of file test.c.
References g_config, g_smtp_test_err_localtime_r_ctr, g_smtp_test_err_malloc_ctr, g_smtp_test_err_realloc_ctr, g_smtp_test_err_recv_ctr, g_smtp_test_err_send_ctr, g_smtp_test_err_si_add_size_t_ctr, g_smtp_test_err_ssl_read_ctr, g_smtp_test_err_ssl_write_ctr, g_smtp_test_strlen_custom_ret, g_smtp_test_strlen_ret_value, SIZE_MAX, smtp_test_config::smtp, smtp_close_check(), smtp_mail_check(), smtp_status_code_set(), SMTP_STATUS_DATE, SMTP_STATUS_NOMEM, SMTP_STATUS_RECV, SMTP_STATUS_SEND, SMTP_STATUS_SERVER_RESPONSE, and test_smtp_open_default().
Referenced by test_all_failure_modes().
|
static |
Test failure or error conditions not covered by any of the other failure tests.
Definition at line 3383 of file test.c.
References g_config, g_rc, g_smtp_test_err_malloc_ctr, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_close_check(), smtp_open(), SMTP_STATUS_OK, SMTP_STATUS_SEND, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, and smtp_write().
Referenced by test_all_failure_modes().
|
static |
Test failure points in the smtp_open function.
Definition at line 3413 of file test.c.
References smtp_test_config::cafile, g_config, g_rc, g_smtp_test_err_bio_new_socket_ctr, g_smtp_test_err_bio_should_retry_ctr, g_smtp_test_err_bio_should_retry_rc, g_smtp_test_err_calloc_ctr, g_smtp_test_err_connect_ctr, g_smtp_test_err_err_peek_error_ctr, g_smtp_test_err_recv_ctr, g_smtp_test_err_recv_rc, g_smtp_test_err_send_ctr, g_smtp_test_err_socket_ctr, g_smtp_test_err_ssl_connect_ctr, g_smtp_test_err_ssl_ctx_new_ctr, g_smtp_test_err_ssl_do_handshake_ctr, g_smtp_test_err_ssl_get_peer_certificate_ctr, g_smtp_test_err_ssl_new_ctr, g_smtp_test_err_ssl_read_ctr, g_smtp_test_err_ssl_write_ctr, g_smtp_test_err_x509_check_host_ctr, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_close_check(), SMTP_DEBUG, smtp_open(), SMTP_SECURITY_STARTTLS, SMTP_SECURITY_TLS, SMTP_STATUS_CONNECT, SMTP_STATUS_HANDSHAKE, SMTP_STATUS_NOMEM, SMTP_STATUS_OK, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, and SMTP_TEST_DEFAULT_FLAGS.
Referenced by test_all_failure_modes().
|
static |
Test different error results smtp_status_code_set function.
Definition at line 3956 of file test.c.
References g_config, g_rc, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_close_check(), smtp_open(), SMTP_STATUS__LAST, smtp_status_code_clear(), smtp_status_code_get(), smtp_status_code_set(), SMTP_STATUS_OK, SMTP_STATUS_PARAM, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, and SMTP_TEST_DEFAULT_FLAGS.
Referenced by test_all_failure_modes().
|
static |
Simulate a timeout when reading server response.
Definition at line 4720 of file test.c.
References smtp_test_config::email_from, g_config, g_rc, g_smtp_test_err_select_ctr, smtp_test_config::port, smtp_test_config::server, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_FROM, smtp_close_check(), smtp_mail_check(), smtp_open(), SMTP_STATUS_OK, SMTP_STATUS_RECV, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, and SMTP_TEST_DEFAULT_FROM_NAME.
Referenced by test_all_failure_modes().
|
static |
Opens an smtp connection using smtp_open and adds default addresses.
Uses default connection and flag parameters and ensures the return status gets set to SMTP_STATUS_OK. Adds the FROM, TO, and CC email addresses given in the config file. This function should always succeed.
Definition at line 2244 of file test.c.
References smtp_test_config::email_from, smtp_test_config::email_to, smtp_test_config::email_to_2, g_config, g_rc, smtp_test_config::port, smtp_test_config::server, SIZE_MAX, smtp_test_config::smtp, smtp_address_add_check(), SMTP_ADDRESS_CC, SMTP_ADDRESS_FROM, SMTP_ADDRESS_TO, smtp_attachment_add_mem(), smtp_open(), SMTP_STATUS_OK, SMTP_TEST_DEFAULT_CAFILE, SMTP_TEST_DEFAULT_CC_NAME, SMTP_TEST_DEFAULT_CONNECTION_SECURITY, SMTP_TEST_DEFAULT_FLAGS, SMTP_TEST_DEFAULT_FROM_NAME, and SMTP_TEST_DEFAULT_TO_NAME.
Referenced by test_failure_auth(), and test_failure_mail().
|
static |
Convenience global that allows test harnesses to access configuration data for the test email server.
Definition at line 213 of file test.c.
Referenced by smtp_address_add_check(), smtp_auth_check(), smtp_close_check(), smtp_func_test_all_address(), smtp_func_test_all_body(), smtp_func_test_all_cafile(), smtp_func_test_all_connection_security(), smtp_func_test_all_names(), smtp_func_test_all_nodebug(), smtp_func_test_all_status_code_get(), smtp_func_test_all_write(), smtp_func_test_attachment_fp(), smtp_func_test_attachment_long_text(), smtp_func_test_attachment_mem(), smtp_func_test_attachment_path(), smtp_func_test_attachment_pdf(), smtp_func_test_auth(), smtp_func_test_connection_security(), smtp_func_test_gmail_attachment(), smtp_func_test_header_custom_date(), smtp_func_test_header_long(), smtp_func_test_header_null_no_date(), smtp_func_test_html(), smtp_func_test_html_with_plaintext(), smtp_func_test_send_email(), smtp_func_test_server_gmail(), smtp_header_add_check(), smtp_mail_check(), smtp_test_config_load_from_file(), test_failure_address_add(), test_failure_attachment_add(), test_failure_auth(), test_failure_close(), test_failure_header_add(), test_failure_mail(), test_failure_misc(), test_failure_open(), test_failure_status_code_set(), test_failure_timeout(), and test_smtp_open_default().
|
static |
Convenience global that allows test harnesses to easily check for return code of smtp function calls.
Definition at line 206 of file test.c.
Referenced by smtp_address_add_check(), smtp_auth_check(), smtp_close_check(), smtp_func_test_all_address(), smtp_func_test_all_body(), smtp_func_test_all_names(), smtp_func_test_all_nodebug(), smtp_func_test_all_status_code_get(), smtp_func_test_all_write(), smtp_func_test_attachment_fp(), smtp_func_test_attachment_long_text(), smtp_func_test_attachment_mem(), smtp_func_test_attachment_path(), smtp_func_test_attachment_pdf(), smtp_func_test_gmail_attachment(), smtp_func_test_header_custom_date(), smtp_func_test_header_long(), smtp_func_test_header_null_no_date(), smtp_func_test_html(), smtp_func_test_html_with_plaintext(), smtp_func_test_send_email(), smtp_func_test_server_secureserver(), smtp_header_add_check(), smtp_mail_check(), test_failure_address_add(), test_failure_attachment_add(), test_failure_close(), test_failure_header_add(), test_failure_misc(), test_failure_open(), test_failure_status_code_set(), test_failure_timeout(), and test_smtp_open_default().
|
static |
Set to a non-zero value to force an error return value in smtp_unit_test_getdelimfd_fp.