#include "ostream.h"
#include "istream-crlf.h"
#include "iostream-temp.h"
+#include "iostream-ssl.h"
+#include "iostream-ssl-test.h"
+#ifdef HAVE_OPENSSL
+#include "iostream-openssl.h"
+#endif
#include "connection.h"
#include "test-common.h"
#include "http-url.h"
static bool debug = FALSE;
static const char *failure = NULL;
+static bool test_ssl = FALSE;
static bool blocking = FALSE;
static enum payload_handling server_payload_handling =
client->pool = pool;
client->http_conn = http_server_connection_create(http_server,
- fd, fd, FALSE, &http_callbacks, client);
+ fd, fd, test_ssl, &http_callbacks, client);
DLLIST_PREPEND(&clients, client);
}
t_strconcat("/download/", path, NULL),
test_client_download_response, tcreq);
http_client_request_set_port(hreq, bind_port);
+ http_client_request_set_ssl(hreq, test_ssl);
http_client_request_set_destroy_callback(hreq,
test_client_request_destroy, tcreq);
http_client_request_submit(hreq);
t_strconcat("/echo/", path, NULL),
test_client_echo_response, tcreq);
http_client_request_set_port(hreq, bind_port);
+ http_client_request_set_ssl(hreq, test_ssl);
http_client_request_set_payload
(hreq, fstream, request_100_continue);
http_client_request_set_destroy_callback(hreq,
{
struct http_server_settings http_server_set;
struct http_client_settings http_client_set;
+ struct ssl_iostream_settings ssl_server_set, ssl_client_set;
/* download files from blocking server */
+ /* ssl settings */
+ ssl_iostream_test_settings_server(&ssl_server_set);
+ ssl_server_set.verbose = debug;
+ ssl_iostream_test_settings_client(&ssl_client_set);
+ ssl_client_set.verbose = debug;
+
/* server settings */
i_zero(&http_server_set);
http_server_set.max_pipelined_requests = 0;
http_server_set.debug = debug;
+ http_server_set.ssl = &ssl_server_set;
http_server_set.request_limits.max_payload_size = (uoff_t)-1;
/* client settings */
http_client_set.max_pipelined_requests = 1;
http_client_set.max_redirects = 0;
http_client_set.max_attempts = 1;
+ http_client_set.ssl = &ssl_client_set;
http_client_set.debug = debug;
test_files_init();
{
struct http_server_settings http_server_set;
struct http_client_settings http_client_set;
+ struct ssl_iostream_settings ssl_server_set, ssl_client_set;
/* download files from blocking server */
+ /* ssl settings */
+ ssl_iostream_test_settings_server(&ssl_server_set);
+ ssl_server_set.verbose = debug;
+ ssl_iostream_test_settings_client(&ssl_client_set);
+ ssl_client_set.verbose = debug;
+
/* server settings */
i_zero(&http_server_set);
http_server_set.max_pipelined_requests = 4;
+ http_server_set.ssl = &ssl_server_set;
http_server_set.debug = debug;
http_server_set.request_limits.max_payload_size = (uoff_t)-1;
http_client_set.max_pipelined_requests = 8;
http_client_set.max_redirects = 0;
http_client_set.max_attempts = 1;
+ http_client_set.ssl = &ssl_client_set;
http_client_set.debug = debug;
test_files_init();
{
struct http_server_settings http_server_set;
struct http_client_settings http_client_set;
+ struct ssl_iostream_settings ssl_server_set, ssl_client_set;
/* download files from blocking server */
+ /* ssl settings */
+ ssl_iostream_test_settings_server(&ssl_server_set);
+ ssl_server_set.verbose = debug;
+ ssl_iostream_test_settings_client(&ssl_client_set);
+ ssl_client_set.verbose = debug;
+
/* server settings */
i_zero(&http_server_set);
http_server_set.max_pipelined_requests = 4;
+ http_server_set.ssl = &ssl_server_set;
http_server_set.debug = debug;
http_server_set.request_limits.max_payload_size = (uoff_t)-1;
http_client_set.max_pipelined_requests = 8;
http_client_set.max_redirects = 0;
http_client_set.max_attempts = 1;
+ http_client_set.ssl = &ssl_client_set;
http_client_set.debug = debug;
test_files_init();
test_unknown_size = FALSE;
read_server_partial = 0;
client_ioloop_nesting = 0;
+ test_ssl = FALSE;
server_payload_handling = PAYLOAD_HANDLING_FORWARD;
test_run_sequential(test_client_download);
test_run_pipeline(test_client_download);
test_unknown_size = FALSE;
read_server_partial = 0;
client_ioloop_nesting = 0;
+ test_ssl = FALSE;
test_run_sequential(test_client_download);
test_run_pipeline(test_client_download);
test_run_parallel(test_client_download);
read_server_partial = 0;
client_ioloop_nesting = 0;
server_payload_handling = PAYLOAD_HANDLING_FORWARD;
+ test_ssl = FALSE;
test_run_sequential(test_client_echo);
test_run_pipeline(test_client_echo);
test_run_parallel(test_client_echo);
read_server_partial = 0;
client_ioloop_nesting = 0;
server_payload_handling = PAYLOAD_HANDLING_LOW_LEVEL;
+ test_ssl = FALSE;
test_run_sequential(test_client_echo);
test_run_pipeline(test_client_echo);
test_run_parallel(test_client_echo);
read_server_partial = 0;
client_ioloop_nesting = 0;
server_payload_handling = PAYLOAD_HANDLING_HANDLER;
+ test_ssl = FALSE;
test_run_sequential(test_client_echo);
test_run_pipeline(test_client_echo);
test_run_parallel(test_client_echo);
test_unknown_size = FALSE;
read_server_partial = 0;
client_ioloop_nesting = 0;
+ test_ssl = FALSE;
test_run_sequential(test_client_echo);
test_run_pipeline(test_client_echo);
test_run_parallel(test_client_echo);
read_server_partial = 0;
client_ioloop_nesting = 0;
server_payload_handling = PAYLOAD_HANDLING_FORWARD;
+ test_ssl = FALSE;
test_run_sequential(test_client_echo);
test_run_pipeline(test_client_echo);
test_run_parallel(test_client_echo);
read_server_partial = 0;
client_ioloop_nesting = 0;
server_payload_handling = PAYLOAD_HANDLING_LOW_LEVEL;
+ test_ssl = FALSE;
test_run_sequential(test_client_echo);
test_run_pipeline(test_client_echo);
test_run_parallel(test_client_echo);
read_server_partial = 0;
client_ioloop_nesting = 0;
server_payload_handling = PAYLOAD_HANDLING_HANDLER;
+ test_ssl = FALSE;
test_run_sequential(test_client_echo);
test_run_pipeline(test_client_echo);
test_run_parallel(test_client_echo);
test_unknown_size = FALSE;
read_server_partial = 0;
client_ioloop_nesting = 0;
+ test_ssl = FALSE;
test_run_sequential(test_client_echo);
test_run_pipeline(test_client_echo);
test_run_parallel(test_client_echo);
read_server_partial = 1024;
client_ioloop_nesting = 0;
server_payload_handling = PAYLOAD_HANDLING_FORWARD;
+ test_ssl = FALSE;
test_run_sequential(test_client_echo);
test_run_pipeline(test_client_echo);
test_run_parallel(test_client_echo);
read_server_partial = 1024;
client_ioloop_nesting = 0;
server_payload_handling = PAYLOAD_HANDLING_LOW_LEVEL;
+ test_ssl = FALSE;
test_run_sequential(test_client_echo);
test_run_pipeline(test_client_echo);
test_run_parallel(test_client_echo);
read_server_partial = 1024;
client_ioloop_nesting = 0;
server_payload_handling = PAYLOAD_HANDLING_HANDLER;
+ test_ssl = FALSE;
test_run_sequential(test_client_echo);
test_run_pipeline(test_client_echo);
test_run_parallel(test_client_echo);
test_unknown_size = FALSE;
read_server_partial = 1024;
client_ioloop_nesting = 0;
+ test_ssl = FALSE;
test_run_sequential(test_client_echo);
test_run_pipeline(test_client_echo);
test_run_parallel(test_client_echo);
read_client_partial = 1024;
client_ioloop_nesting = 0;
server_payload_handling = PAYLOAD_HANDLING_FORWARD;
+ test_ssl = FALSE;
test_run_sequential(test_client_download);
test_run_pipeline(test_client_download);
test_run_parallel(test_client_download);
read_client_partial = 0;
client_ioloop_nesting = 10;
server_payload_handling = PAYLOAD_HANDLING_FORWARD;
+ test_ssl = FALSE;
test_run_parallel(test_client_echo);
test_end();
}
read_server_partial = 0;
client_ioloop_nesting = 0;
server_payload_handling = PAYLOAD_HANDLING_FORWARD;
+ test_ssl = FALSE;
parallel_clients = 4;
test_run_sequential(test_client_download);
parallel_clients = 4;
test_unknown_size = FALSE;
read_server_partial = 0;
client_ioloop_nesting = 0;
+ test_ssl = FALSE;
parallel_clients = 4;
test_run_sequential(test_client_download);
parallel_clients = 4;
read_server_partial = 0;
client_ioloop_nesting = 0;
server_payload_handling = PAYLOAD_HANDLING_FORWARD;
+ test_ssl = FALSE;
parallel_clients = 4;
test_run_sequential(test_client_echo);
parallel_clients = 4;
test_unknown_size = FALSE;
read_server_partial = 0;
client_ioloop_nesting = 0;
+ test_ssl = FALSE;
parallel_clients = 4;
test_run_sequential(test_client_echo);
parallel_clients = 4;
read_server_partial = 0;
client_ioloop_nesting = 0;
server_payload_handling = PAYLOAD_HANDLING_FORWARD;
+ test_ssl = FALSE;
parallel_clients = 4;
parallel_clients_global = TRUE;
test_run_sequential(test_client_echo);
test_end();
}
+static void test_echo_ssl(void)
+{
+ test_begin("http payload echo (ssl)");
+ blocking = FALSE;
+ request_100_continue = FALSE;
+ test_unknown_size = FALSE;
+ read_server_partial = 0;
+ client_ioloop_nesting = 0;
+ server_payload_handling = PAYLOAD_HANDLING_FORWARD;
+ test_ssl = TRUE;
+ test_run_sequential(test_client_echo);
+ test_run_pipeline(test_client_echo);
+ test_run_parallel(test_client_echo);
+ test_end();
+
+ test_begin("http payload echo (ssl; unknown size)");
+ blocking = FALSE;
+ request_100_continue = FALSE;
+ test_unknown_size = TRUE;
+ read_server_partial = 0;
+ client_ioloop_nesting = 0;
+ server_payload_handling = PAYLOAD_HANDLING_FORWARD;
+ test_ssl = TRUE;
+ test_run_sequential(test_client_echo);
+ test_run_pipeline(test_client_echo);
+ test_run_parallel(test_client_echo);
+ test_end();
+}
+
static void (*const test_functions[])(void) = {
test_download_server_nonblocking,
test_download_server_blocking,
test_download_client_partial,
test_download_client_nested_ioloop,
test_echo_client_shared,
+ test_echo_ssl,
NULL
};
{
int c;
+ lib_init();
+#ifdef HAVE_OPENSSL
+ ssl_iostream_openssl_init();
+#endif
+
atexit(test_atexit);
(void)signal(SIGCHLD, SIG_IGN);
(void)signal(SIGPIPE, SIG_IGN);
bind_ip.u.ip4.s_addr = htonl(INADDR_LOOPBACK);
test_run(test_functions);
+
+ ssl_iostream_context_cache_free();
+#ifdef HAVE_OPENSSL
+ ssl_iostream_openssl_deinit();
+#endif
+ lib_deinit();
}