};
typedef void (*test_server_init_t)(unsigned int index);
-typedef bool (*test_client_init_t)
- (const struct smtp_client_settings *client_set);
+typedef bool
+(*test_client_init_t)(const struct smtp_client_settings *client_set);
typedef void (*test_dns_init_t)(void);
/*
static struct connection_list *server_conn_list;
static unsigned int server_index;
static void (*test_server_input)(struct server_connection *conn);
-static int (*test_server_input_line)(struct server_connection *conn,
- const char *line);
-static int (*test_server_input_data)(struct server_connection *conn,
- const unsigned char *data, size_t size);
+static int
+(*test_server_input_line)(struct server_connection *conn, const char *line);
+static int
+(*test_server_input_data)(struct server_connection *conn,
+ const unsigned char *data, size_t size);
static int (*test_server_init)(struct server_connection *conn);
static void (*test_server_deinit)(struct server_connection *conn);
/* server */
static void test_server_run(unsigned int index);
-static void
-server_connection_deinit(struct server_connection **_conn);
+static void server_connection_deinit(struct server_connection **_conn);
/* client */
-static void
-test_client_defaults(struct smtp_client_settings *smtp_set);
+static void test_client_defaults(struct smtp_client_settings *smtp_set);
static void test_client_deinit(void);
/* test*/
-static void test_run_client_server(
- const struct smtp_client_settings *client_set,
- test_client_init_t client_test,
- test_server_init_t server_test,
- unsigned int server_tests_count,
- test_dns_init_t dns_test)
- ATTR_NULL(3);
+static void
+test_run_client_server(const struct smtp_client_settings *client_set,
+ test_client_init_t client_test,
+ test_server_init_t server_test,
+ unsigned int server_tests_count,
+ test_dns_init_t dns_test) ATTR_NULL(3);
/*
* Unconfigured SSL
/* server */
static void
-test_server_unconfigured_ssl_input(
- struct server_connection *conn ATTR_UNUSED)
+test_server_unconfigured_ssl_input(struct server_connection *conn ATTR_UNUSED)
{
/* nothing */
}
-static void
-test_server_unconfigured_ssl(unsigned int index)
+static void test_server_unconfigured_ssl(unsigned int index)
{
sleep(100);
test_server_input = test_server_unconfigured_ssl_input;
static void
test_client_unconfigured_ssl_reply(const struct smtp_reply *reply,
- void *context)
+ void *context)
{
struct _unconfigured_ssl *ctx = (struct _unconfigured_ssl *)context;
smtp_client = smtp_client_init(client_set);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, "127.0.0.1", bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP, "127.0.0.1", bind_ports[0],
SMTP_CLIENT_SSL_MODE_IMMEDIATE, NULL);
smtp_client_connection_connect(sconn,
test_client_unconfigured_ssl_reply, ctx);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, "127.0.0.1", bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP, "127.0.0.1", bind_ports[0],
SMTP_CLIENT_SSL_MODE_IMMEDIATE, NULL);
- smtp_client_connection_connect(sconn,
- test_client_unconfigured_ssl_reply, ctx);
+ smtp_client_connection_connect(
+ sconn, test_client_unconfigured_ssl_reply, ctx);
return TRUE;
}
test_begin("unconfigured ssl");
test_run_client_server(&smtp_client_set,
- test_client_unconfigured_ssl,
- test_server_unconfigured_ssl, 1, NULL);
+ test_client_unconfigured_ssl,
+ test_server_unconfigured_ssl, 1, NULL);
test_end();
}
/* nothing */
}
-static void
-test_server_unconfigured_ssl_abort(unsigned int index)
+static void test_server_unconfigured_ssl_abort(unsigned int index)
{
sleep(100);
test_server_input = test_server_unconfigured_ssl_abort_input;
};
static void
-test_client_unconfigured_ssl_abort_reply1(const struct smtp_reply *reply,
+test_client_unconfigured_ssl_abort_reply1(
+ const struct smtp_reply *reply,
struct _unconfigured_ssl_abort *ctx ATTR_UNUSED)
{
if (debug)
static void
test_client_unconfigured_ssl_abort_reply2(const struct smtp_reply *reply,
- struct _unconfigured_ssl_abort *ctx)
+ struct _unconfigured_ssl_abort *ctx)
{
if (debug)
i_debug("REPLY: %s", smtp_reply_log(reply));
smtp_client = smtp_client_init(client_set);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, "127.0.0.1", bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP, "127.0.0.1", bind_ports[0],
SMTP_CLIENT_SSL_MODE_IMMEDIATE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_unconfigured_ssl_abort_reply1, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_unconfigured_ssl_abort_reply1, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
smtp_client_command_abort(&scmd);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, "127.0.0.1", bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP, "127.0.0.1", bind_ports[0],
SMTP_CLIENT_SSL_MODE_IMMEDIATE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_unconfigured_ssl_abort_reply2, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_unconfigured_ssl_abort_reply2, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
test_begin("unconfigured ssl abort");
test_run_client_server(&smtp_client_set,
- test_client_unconfigured_ssl_abort,
- test_server_unconfigured_ssl_abort, 1, NULL);
+ test_client_unconfigured_ssl_abort,
+ test_server_unconfigured_ssl_abort, 1, NULL);
test_end();
}
static void
test_client_host_lookup_failed_reply(const struct smtp_reply *reply,
- struct _host_lookup_failed *ctx)
+ struct _host_lookup_failed *ctx)
{
if (debug)
i_debug("REPLY: %s", smtp_reply_log(reply));
- test_assert(reply->status == SMTP_CLIENT_COMMAND_ERROR_HOST_LOOKUP_FAILED);
+ test_assert(reply->status ==
+ SMTP_CLIENT_COMMAND_ERROR_HOST_LOOKUP_FAILED);
if (--ctx->count == 0) {
i_free(ctx);
}
static bool
-test_client_host_lookup_failed(
- const struct smtp_client_settings *client_set)
+test_client_host_lookup_failed(const struct smtp_client_settings *client_set)
{
struct smtp_client_connection *sconn;
struct smtp_client_command *scmd;
smtp_client = smtp_client_init(client_set);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, "host.in-addr.arpa", 465,
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP, "host.in-addr.arpa", 465,
SMTP_CLIENT_SSL_MODE_IMMEDIATE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_host_lookup_failed_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_host_lookup_failed_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, "host.in-addr.arpa", 465,
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP, "host.in-addr.arpa", 465,
SMTP_CLIENT_SSL_MODE_IMMEDIATE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_host_lookup_failed_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_host_lookup_failed_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
test_begin("host lookup failed");
test_run_client_server(&smtp_client_set,
- test_client_host_lookup_failed,
- NULL, 0, NULL);
+ test_client_host_lookup_failed, NULL, 0, NULL);
test_end();
}
/* server */
-static void
-test_server_connection_refused(unsigned int index ATTR_UNUSED)
+static void test_server_connection_refused(unsigned int index ATTR_UNUSED)
{
i_close_fd(&fd_listen);
}
static void
test_client_connection_refused_reply(const struct smtp_reply *reply,
- struct _connection_refused *ctx)
+ struct _connection_refused *ctx)
{
if (debug)
i_debug("REPLY: %s", smtp_reply_log(reply));
}
static bool
-test_client_connection_refused(
- const struct smtp_client_settings *client_set)
+test_client_connection_refused(const struct smtp_client_settings *client_set)
{
struct smtp_client_connection *sconn;
struct smtp_client_command *scmd;
smtp_client = smtp_client_init(client_set);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[0],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_connection_refused_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_connection_refused_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[0],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_connection_refused_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_connection_refused_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
test_begin("connection refused");
test_run_client_server(&smtp_client_set,
- test_client_connection_refused,
- test_server_connection_refused, 1, NULL);
+ test_client_connection_refused,
+ test_server_connection_refused, 1, NULL);
test_end();
}
line = i_stream_read_next_line(conn->conn.input);
if (line == NULL) {
if (conn->conn.input->eof ||
- conn->conn.input->stream_errno != 0) {
+ conn->conn.input->stream_errno != 0) {
server_connection_deinit(&conn);
}
return;
server_connection_deinit(&conn);
}
-static int
-test_connection_lost_prematurely_init(struct server_connection *conn)
+static int test_connection_lost_prematurely_init(struct server_connection *conn)
{
o_stream_nsend_str(conn->conn.output,
"220 testserver ESMTP Testfix (Frop/GNU)\r\n");
};
static void
-test_client_connection_lost_prematurely_reply(const struct smtp_reply *reply,
+test_client_connection_lost_prematurely_reply(
+ const struct smtp_reply *reply,
struct _connection_lost_prematurely *ctx)
{
if (debug)
smtp_client = smtp_client_init(client_set);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[0],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_connection_lost_prematurely_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_connection_lost_prematurely_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[0],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_connection_lost_prematurely_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_connection_lost_prematurely_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
test_begin("connection lost prematurely");
test_run_client_server(&smtp_client_set,
- test_client_connection_lost_prematurely,
- test_server_connection_lost_prematurely, 1, NULL);
+ test_client_connection_lost_prematurely,
+ test_server_connection_lost_prematurely,
+ 1, NULL);
test_end();
}
static void
test_client_connection_timed_out_reply(const struct smtp_reply *reply,
- struct _connection_timed_out *ctx)
+ struct _connection_timed_out *ctx)
{
if (debug)
i_debug("REPLY: %s", smtp_reply_log(reply));
}
static bool
-test_client_connection_timed_out(
- const struct smtp_client_settings *client_set)
+test_client_connection_timed_out(const struct smtp_client_settings *client_set)
{
struct smtp_client_connection *sconn;
struct smtp_client_command *scmd;
smtp_client = smtp_client_init(client_set);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[0],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_connection_timed_out_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_connection_timed_out_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[0],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_connection_timed_out_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_connection_timed_out_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
test_begin("connection timed out");
test_run_client_server(&smtp_client_set,
- test_client_connection_timed_out,
- test_server_connection_timed_out, 1, NULL);
+ test_client_connection_timed_out,
+ test_server_connection_timed_out, 1, NULL);
test_end();
}
static int
test_broken_payload_input_line(struct server_connection *conn ATTR_UNUSED,
- const char *line ATTR_UNUSED)
+ const char *line ATTR_UNUSED)
{
return 0;
}
}
static int
-test_broken_payload_chunking_input_line(
- struct server_connection *conn, const char *line ATTR_UNUSED)
+test_broken_payload_chunking_input_line(struct server_connection *conn,
+ const char *line ATTR_UNUSED)
{
if (conn->state == SERVER_CONNECTION_STATE_EHLO) {
o_stream_nsend_str(conn->conn.output,
- "250-testserver\r\n"
- "250-PIPELINING\r\n"
- "250-CHUNKING\r\n"
- "250-ENHANCEDSTATUSCODES\r\n"
- "250 DSN\r\n");
+ "250-testserver\r\n"
+ "250-PIPELINING\r\n"
+ "250-CHUNKING\r\n"
+ "250-ENHANCEDSTATUSCODES\r\n"
+ "250 DSN\r\n");
return 1;
}
return 0;
static void
test_client_broken_payload_rcpt_to_cb(const struct smtp_reply *reply,
- void *context ATTR_UNUSED)
+ void *context ATTR_UNUSED)
{
test_assert(smtp_reply_is_success(reply));
}
static void
test_client_broken_payload_rcpt_data_cb(const struct smtp_reply *reply,
- void *context ATTR_UNUSED)
+ void *context ATTR_UNUSED)
{
if (debug)
i_debug("REPLY: %s", smtp_reply_log(reply));
static void
test_client_broken_payload_data_cb(const struct smtp_reply *reply,
- void *context ATTR_UNUSED)
+ void *context ATTR_UNUSED)
{
if (debug)
i_debug("REPLY: %s", smtp_reply_log(reply));
test_assert(reply->status == SMTP_CLIENT_COMMAND_ERROR_BROKEN_PAYLOAD);
}
-static void
-test_client_broken_payload_finished(void *context ATTR_UNUSED)
+static void test_client_broken_payload_finished(void *context ATTR_UNUSED)
{
io_loop_stop(ioloop);
}
static bool
-test_client_broken_payload(
- const struct smtp_client_settings *client_set)
+test_client_broken_payload(const struct smtp_client_settings *client_set)
{
struct smtp_client_connection *sconn;
struct smtp_client_transaction *strans;
smtp_client = smtp_client_init(client_set);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[0],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
- strans = smtp_client_transaction_create(sconn,
- &((struct smtp_address){.localpart = "sender",
- .domain = "example.com"}), NULL, 0,
+ strans = smtp_client_transaction_create(
+ sconn, &((struct smtp_address){
+ .localpart = "sender",
+ .domain = "example.com"}), NULL, 0,
test_client_broken_payload_finished, NULL);
smtp_client_connection_unref(&sconn);
- smtp_client_transaction_add_rcpt(strans,
- &((struct smtp_address){.localpart = "rcpt",
- .domain = "example.com"}), NULL,
+ smtp_client_transaction_add_rcpt(
+ strans, &((struct smtp_address){
+ .localpart = "rcpt",
+ .domain = "example.com"}), NULL,
test_client_broken_payload_rcpt_to_cb,
test_client_broken_payload_rcpt_data_cb, NULL);
- smtp_client_transaction_send(strans, input,
- test_client_broken_payload_data_cb, NULL);
+ smtp_client_transaction_send(
+ strans, input, test_client_broken_payload_data_cb, NULL);
i_stream_unref(&input);
return TRUE;
}
static bool
-test_client_broken_payload_later(
- const struct smtp_client_settings *client_set)
+test_client_broken_payload_later(const struct smtp_client_settings *client_set)
{
static const char *message =
"From: lucifer@example.com\r\n"
smtp_client = smtp_client_init(client_set);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[0],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
- strans = smtp_client_transaction_create(sconn,
- &((struct smtp_address){.localpart = "sender",
- .domain = "example.com"}), NULL, 0,
+ strans = smtp_client_transaction_create(
+ sconn, &((struct smtp_address){
+ .localpart = "sender",
+ .domain = "example.com"}), NULL, 0,
test_client_broken_payload_finished, NULL);
smtp_client_connection_unref(&sconn);
- smtp_client_transaction_add_rcpt(strans,
- &((struct smtp_address){.localpart = "rcpt",
- .domain = "example.com"}), NULL,
+ smtp_client_transaction_add_rcpt(
+ strans, &((struct smtp_address){
+ .localpart = "rcpt",
+ .domain = "example.com"}), NULL,
test_client_broken_payload_rcpt_to_cb,
test_client_broken_payload_rcpt_data_cb, NULL);
- smtp_client_transaction_send
- (strans, input, test_client_broken_payload_data_cb, NULL);
+ smtp_client_transaction_send(
+ strans, input, test_client_broken_payload_data_cb, NULL);
i_stream_unref(&input);
return TRUE;
test_begin("broken payload");
test_run_client_server(&smtp_client_set,
- test_client_broken_payload,
- test_server_broken_payload, 1, NULL);
+ test_client_broken_payload,
+ test_server_broken_payload, 1, NULL);
test_end();
test_begin("broken payload (later)");
test_run_client_server(&smtp_client_set,
- test_client_broken_payload_later,
- test_server_broken_payload, 1, NULL);
+ test_client_broken_payload_later,
+ test_server_broken_payload, 1, NULL);
test_end();
test_begin("broken payload (later, chunking)");
test_run_client_server(&smtp_client_set,
- test_client_broken_payload_later,
- test_server_broken_payload_chunking, 1, NULL);
+ test_client_broken_payload_later,
+ test_server_broken_payload_chunking, 1, NULL);
test_end();
}
static int
test_connection_lost_input_line(struct server_connection *conn,
- const char *line ATTR_UNUSED)
+ const char *line ATTR_UNUSED)
{
switch (conn->state) {
case SERVER_CONNECTION_STATE_EHLO:
static int
test_connection_lost_input_data(struct server_connection *conn,
- const unsigned char *data ATTR_UNUSED, size_t size ATTR_UNUSED)
+ const unsigned char *data ATTR_UNUSED,
+ size_t size ATTR_UNUSED)
{
sleep(1);
server_connection_deinit(&conn);
static void
test_client_connection_lost_rcpt_to_cb(const struct smtp_reply *reply,
- struct _connection_lost_peer *pctx)
+ struct _connection_lost_peer *pctx)
{
if (debug) {
i_debug("RCPT TO REPLY[%u]: %s",
switch (pctx->index) {
case 0:
test_assert(reply->status ==
- SMTP_CLIENT_COMMAND_ERROR_CONNECTION_LOST);
+ SMTP_CLIENT_COMMAND_ERROR_CONNECTION_LOST);
break;
case 1:
test_assert(reply->status ==
- SMTP_CLIENT_COMMAND_ERROR_CONNECTION_LOST);
+ SMTP_CLIENT_COMMAND_ERROR_CONNECTION_LOST);
break;
case 2:
test_assert(reply->status ==
- SMTP_CLIENT_COMMAND_ERROR_CONNECTION_LOST);
+ SMTP_CLIENT_COMMAND_ERROR_CONNECTION_LOST);
break;
case 3:
test_assert(smtp_reply_is_success(reply));
static void
test_client_connection_lost_rcpt_data_cb(const struct smtp_reply *reply,
- struct _connection_lost_peer *pctx)
+ struct _connection_lost_peer *pctx)
{
if (debug) {
i_debug("RCPT DATA REPLY[%u]: %s",
test_assert(FALSE);
break;
case 3:
- test_assert(reply->status == SMTP_CLIENT_COMMAND_ERROR_CONNECTION_LOST);
+ test_assert(reply->status ==
+ SMTP_CLIENT_COMMAND_ERROR_CONNECTION_LOST);
break;
}
}
static void
test_client_connection_lost_data_cb(const struct smtp_reply *reply,
- struct _connection_lost_peer *pctx)
+ struct _connection_lost_peer *pctx)
{
if (debug) {
i_debug("DATA REPLY[%u]: %s",
input = i_stream_create_from_data(message, strlen(message));
i_stream_set_name(input, "message");
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[index],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[index],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
- strans = smtp_client_transaction_create(sconn,
- &((struct smtp_address){.localpart = "sender",
- .domain = "example.com"}), NULL, 0,
+ strans = smtp_client_transaction_create(
+ sconn, &((struct smtp_address){
+ .localpart = "sender",
+ .domain = "example.com"}), NULL, 0,
test_client_connection_lost_finished, pctx);
smtp_client_connection_unref(&sconn);
- smtp_client_transaction_add_rcpt(strans,
- &((struct smtp_address){.localpart = "rcpt",
- .domain = "example.com"}), NULL,
+ smtp_client_transaction_add_rcpt(
+ strans, &((struct smtp_address){
+ .localpart = "rcpt",
+ .domain = "example.com"}), NULL,
test_client_connection_lost_rcpt_to_cb,
test_client_connection_lost_rcpt_data_cb, pctx);
- smtp_client_transaction_send
- (strans, input, test_client_connection_lost_data_cb, pctx);
+ smtp_client_transaction_send(
+ strans, input, test_client_connection_lost_data_cb, pctx);
i_stream_unref(&input);
}
static bool
-test_client_connection_lost(
- const struct smtp_client_settings *client_set)
+test_client_connection_lost(const struct smtp_client_settings *client_set)
{
struct _connection_lost *ctx;
unsigned int i;
test_begin("connection lost");
test_run_client_server(&smtp_client_set,
- test_client_connection_lost,
- test_server_connection_lost, 5, NULL);
+ test_client_connection_lost,
+ test_server_connection_lost, 5, NULL);
test_end();
}
test_unexpected_reply_init(struct server_connection *conn)
{
if (server_index == 5) {
- o_stream_nsend_str(conn->conn.output,
- "220 testserver ESMTP Testfix (Debian/GNU)\r\n");
- o_stream_nsend_str(conn->conn.output,
- "421 testserver Server shutting down for maintenance\r\n");
+ o_stream_nsend_str(conn->conn.output, "220 testserver "
+ "ESMTP Testfix (Debian/GNU)\r\n");
+ o_stream_nsend_str(conn->conn.output, "421 testserver "
+ "Server shutting down for maintenance\r\n");
sleep(4);
server_connection_deinit(&conn);
return 1;
case SERVER_CONNECTION_STATE_EHLO:
if (server_index == 4) {
o_stream_nsend_str(conn->conn.output,
- "250-testserver\r\n"
- "250-PIPELINING\r\n"
- "250-ENHANCEDSTATUSCODES\r\n"
- "250 DSN\r\n");
- o_stream_nsend_str(conn->conn.output,
- "421 testserver Server shutting down for maintenance\r\n");
+ "250-testserver\r\n"
+ "250-PIPELINING\r\n"
+ "250-ENHANCEDSTATUSCODES\r\n"
+ "250 DSN\r\n");
+ o_stream_nsend_str(
+ conn->conn.output, "421 testserver "
+ "Server shutting down for maintenance\r\n");
sleep(4);
server_connection_deinit(&conn);
return -1;
case SERVER_CONNECTION_STATE_MAIL_FROM:
if (server_index == 3) {
o_stream_nsend_str(conn->conn.output,
- "250 2.1.0 Ok\r\n");
- o_stream_nsend_str(conn->conn.output,
- "421 testserver Server shutting down for maintenance\r\n");
+ "250 2.1.0 Ok\r\n");
+ o_stream_nsend_str(
+ conn->conn.output, "421 testserver "
+ "Server shutting down for maintenance\r\n");
sleep(4);
server_connection_deinit(&conn);
return -1;
case SERVER_CONNECTION_STATE_RCPT_TO:
if (server_index == 2) {
o_stream_nsend_str(conn->conn.output,
- "250 2.1.5 Ok\r\n");
- o_stream_nsend_str(conn->conn.output,
- "421 testserver Server shutting down for maintenance\r\n");
+ "250 2.1.5 Ok\r\n");
+ o_stream_nsend_str(
+ conn->conn.output, "421 testserver "
+ "Server shutting down for maintenance\r\n");
sleep(4);
server_connection_deinit(&conn);
return -1;
break;
case SERVER_CONNECTION_STATE_DATA:
if (server_index == 1) {
- o_stream_nsend_str(conn->conn.output,
+ o_stream_nsend_str(
+ conn->conn.output,
"354 End data with <CR><LF>.<CR><LF>\r\n");
- o_stream_nsend_str(conn->conn.output,
- "421 testserver Server shutting down for maintenance\r\n");
+ o_stream_nsend_str(
+ conn->conn.output, "421 testserver "
+ "Server shutting down for maintenance\r\n");
sleep(4);
server_connection_deinit(&conn);
return -1;
static void
test_client_unexpected_reply_login_cb(const struct smtp_reply *reply,
- void *context)
+ void *context)
{
struct _unexpected_reply_peer *pctx =
(struct _unexpected_reply_peer *)context;
pctx->login_callback = TRUE;
- if (debug)
- i_debug("LOGIN REPLY[%u]: %s", pctx->index, smtp_reply_log(reply));
+ if (debug) {
+ i_debug("LOGIN REPLY[%u]: %s",
+ pctx->index, smtp_reply_log(reply));
+ }
switch (pctx->index) {
case 0: case 1: case 2: case 3: case 4:
static void
test_client_unexpected_reply_mail_from_cb(const struct smtp_reply *reply,
- struct _unexpected_reply_peer *pctx)
+ struct _unexpected_reply_peer *pctx)
{
- if (debug)
- i_debug("MAIL FROM REPLY[%u]: %s", pctx->index, smtp_reply_log(reply));
+ if (debug) {
+ i_debug("MAIL FROM REPLY[%u]: %s",
+ pctx->index, smtp_reply_log(reply));
+ }
pctx->mail_from_callback = TRUE;
static void
test_client_unexpected_reply_rcpt_to_cb(const struct smtp_reply *reply,
- struct _unexpected_reply_peer *pctx)
+ struct _unexpected_reply_peer *pctx)
{
- if (debug)
- i_debug("RCPT TO REPLY[%u]: %s", pctx->index, smtp_reply_log(reply));
+ if (debug) {
+ i_debug("RCPT TO REPLY[%u]: %s",
+ pctx->index, smtp_reply_log(reply));
+ }
pctx->rcpt_to_callback = TRUE;
static void
test_client_unexpected_reply_rcpt_data_cb(const struct smtp_reply *reply,
- struct _unexpected_reply_peer *pctx)
+ struct _unexpected_reply_peer *pctx)
{
- if (debug)
- i_debug("RCPT DATA REPLY[%u]: %s", pctx->index, smtp_reply_log(reply));
+ if (debug) {
+ i_debug("RCPT DATA REPLY[%u]: %s",
+ pctx->index, smtp_reply_log(reply));
+ }
pctx->rcpt_data_callback = TRUE;
static void
test_client_unexpected_reply_data_cb(const struct smtp_reply *reply,
- struct _unexpected_reply_peer *pctx)
+ struct _unexpected_reply_peer *pctx)
{
- if (debug)
- i_debug("DATA REPLY[%u]: %s", pctx->index, smtp_reply_log(reply));
+ if (debug) {
+ i_debug("DATA REPLY[%u]: %s",
+ pctx->index, smtp_reply_log(reply));
+ }
pctx->data_callback = TRUE;
input = i_stream_create_from_data(message, strlen(message));
i_stream_set_name(input, "message");
- smtp_client_transaction_send
- (strans, input, test_client_unexpected_reply_data_cb, pctx);
+ smtp_client_transaction_send(
+ strans, input, test_client_unexpected_reply_data_cb, pctx);
i_stream_unref(&input);
}
{
timeout_remove(&pctx->to);
- smtp_client_transaction_add_rcpt(pctx->trans,
- &((struct smtp_address){.localpart = "rcpt",
- .domain = "example.com"}), NULL,
+ smtp_client_transaction_add_rcpt(
+ pctx->trans, &((struct smtp_address){
+ .localpart = "rcpt",
+ .domain = "example.com"}), NULL,
test_client_unexpected_reply_rcpt_to_cb,
test_client_unexpected_reply_rcpt_data_cb, pctx);
- pctx->to = timeout_add_short(500,
- test_client_unexpected_reply_submit2, pctx);
+ pctx->to = timeout_add_short(
+ 500, test_client_unexpected_reply_submit2, pctx);
}
static void
test_client_unexpected_reply_submit(struct _unexpected_reply *ctx,
- unsigned int index)
+ unsigned int index)
{
struct _unexpected_reply_peer *pctx;
pctx->context = ctx;
pctx->index = index;
- pctx->conn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[index],
+ pctx->conn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[index],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
- pctx->trans = smtp_client_transaction_create(pctx->conn,
- &((struct smtp_address){.localpart = "sender",
- .domain = "example.com"}), NULL, 0,
+ pctx->trans = smtp_client_transaction_create(
+ pctx->conn, &((struct smtp_address){
+ .localpart = "sender",
+ .domain = "example.com"}), NULL, 0,
test_client_unexpected_reply_finished, pctx);
- smtp_client_connection_connect(pctx->conn,
- test_client_unexpected_reply_login_cb, (void *)pctx);
- smtp_client_transaction_start(pctx->trans,
- test_client_unexpected_reply_mail_from_cb, pctx);
+ smtp_client_connection_connect(
+ pctx->conn, test_client_unexpected_reply_login_cb,
+ (void *)pctx);
+ smtp_client_transaction_start(
+ pctx->trans, test_client_unexpected_reply_mail_from_cb, pctx);
smtp_client_connection_unref(&pctx->conn);
- pctx->to = timeout_add_short(500,
- test_client_unexpected_reply_submit1, pctx);
+ pctx->to = timeout_add_short(
+ 500, test_client_unexpected_reply_submit1, pctx);
}
static bool
-test_client_unexpected_reply(
- const struct smtp_client_settings *client_set)
+test_client_unexpected_reply(const struct smtp_client_settings *client_set)
{
struct _unexpected_reply *ctx;
unsigned int i;
test_begin("unexpected reply");
test_run_client_server(&smtp_client_set,
- test_client_unexpected_reply,
- test_server_unexpected_reply, 6, NULL);
+ test_client_unexpected_reply,
+ test_server_unexpected_reply, 6, NULL);
test_end();
}
static int
test_partial_reply_input_line(struct server_connection *conn,
- const char *line ATTR_UNUSED)
+ const char *line ATTR_UNUSED)
{
if (conn->state == SERVER_CONNECTION_STATE_EHLO)
return 0;
static void
test_client_partial_reply_reply(const struct smtp_reply *reply,
- struct _partial_reply *ctx)
+ struct _partial_reply *ctx)
{
if (debug)
i_debug("REPLY: %s", smtp_reply_log(reply));
}
static bool
-test_client_partial_reply(
- const struct smtp_client_settings *client_set)
+test_client_partial_reply(const struct smtp_client_settings *client_set)
{
struct smtp_client_connection *sconn;
struct smtp_client_command *scmd;
smtp_client = smtp_client_init(client_set);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[0],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_partial_reply_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_partial_reply_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[0],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_partial_reply_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_partial_reply_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
test_begin("partial reply");
test_run_client_server(&smtp_client_set,
- test_client_partial_reply,
- test_server_partial_reply, 1, NULL);
+ test_client_partial_reply,
+ test_server_partial_reply, 1, NULL);
test_end();
}
test_premature_reply_init(struct server_connection *conn)
{
if (server_index == 5) {
- o_stream_nsend_str(conn->conn.output,
+ o_stream_nsend_str(
+ conn->conn.output,
"220 testserver ESMTP Testfix (Debian/GNU)\r\n"
"250-testserver\r\n"
"250-PIPELINING\r\n"
i_debug("[%u] EHLO", server_index);
if (server_index == 4) {
o_stream_nsend_str(conn->conn.output,
- "250-testserver\r\n"
- "250-PIPELINING\r\n"
- "250-ENHANCEDSTATUSCODES\r\n"
- "250 DSN\r\n"
- "250 2.1.0 Ok\r\n");
+ "250-testserver\r\n"
+ "250-PIPELINING\r\n"
+ "250-ENHANCEDSTATUSCODES\r\n"
+ "250 DSN\r\n"
+ "250 2.1.0 Ok\r\n");
conn->state = SERVER_CONNECTION_STATE_MAIL_FROM;
return 1;
}
}
if (server_index == 3) {
o_stream_nsend_str(conn->conn.output,
- "250 2.1.0 Ok\r\n"
- "250 2.1.5 Ok\r\n");
+ "250 2.1.0 Ok\r\n"
+ "250 2.1.5 Ok\r\n");
sleep(4);
server_connection_deinit(&conn);
return -1;
break;
case SERVER_CONNECTION_STATE_RCPT_TO:
if (server_index == 2) {
- o_stream_nsend_str(conn->conn.output,
+ o_stream_nsend_str(
+ conn->conn.output,
"250 2.1.5 Ok\r\n"
"354 End data with <CR><LF>.<CR><LF>\r\n");
sleep(4);
break;
case SERVER_CONNECTION_STATE_DATA:
if (server_index == 1) {
- o_stream_nsend_str(conn->conn.output,
+ o_stream_nsend_str(
+ conn->conn.output,
"354 End data with <CR><LF>.<CR><LF>\r\n"
"250 2.0.0 Ok: queued as 35424ed4af24\r\n");
sleep(4);
static void
test_client_premature_reply_login_cb(const struct smtp_reply *reply,
- void *context)
+ void *context)
{
struct _premature_reply_peer *pctx =
(struct _premature_reply_peer *)context;
static void
test_client_premature_reply_mail_from_cb(const struct smtp_reply *reply,
- struct _premature_reply_peer *pctx)
+ struct _premature_reply_peer *pctx)
{
if (debug) {
i_debug("MAIL FROM REPLY[%u]: %s",
static void
test_client_premature_reply_rcpt_to_cb(const struct smtp_reply *reply,
- struct _premature_reply_peer *pctx)
+ struct _premature_reply_peer *pctx)
{
if (debug) {
i_debug("RCPT TO REPLY[%u]: %s",
static void
test_client_premature_reply_rcpt_data_cb(const struct smtp_reply *reply,
- struct _premature_reply_peer *pctx)
+ struct _premature_reply_peer *pctx)
{
if (debug) {
i_debug("RCPT DATA REPLY[%u]: %s",
static void
test_client_premature_reply_data_cb(const struct smtp_reply *reply,
- struct _premature_reply_peer *pctx)
+ struct _premature_reply_peer *pctx)
{
if (debug) {
i_debug("DATA REPLY[%u]: %s",
input = i_stream_create_from_data(message, strlen(message));
i_stream_set_name(input, "message");
- smtp_client_transaction_send
- (strans, input, test_client_premature_reply_data_cb, pctx);
+ smtp_client_transaction_send(
+ strans, input, test_client_premature_reply_data_cb, pctx);
i_stream_unref(&input);
}
if (debug)
i_debug("SUBMIT2[%u]", pctx->index);
- smtp_client_transaction_add_rcpt(pctx->trans,
- &((struct smtp_address){.localpart = "rcpt",
- .domain = "example.com"}), NULL,
+ smtp_client_transaction_add_rcpt(
+ pctx->trans, &((struct smtp_address){
+ .localpart = "rcpt",
+ .domain = "example.com"}), NULL,
test_client_premature_reply_rcpt_to_cb,
test_client_premature_reply_rcpt_data_cb, pctx);
- pctx->to = timeout_add_short(500,
- test_client_premature_reply_submit3, pctx);
+ pctx->to = timeout_add_short(
+ 500, test_client_premature_reply_submit3, pctx);
}
-
static void
test_client_premature_reply_submit1(struct _premature_reply_peer *pctx)
{
if (debug)
i_debug("SUBMIT1[%u]", pctx->index);
- smtp_client_transaction_start(pctx->trans,
- test_client_premature_reply_mail_from_cb, pctx);
+ smtp_client_transaction_start(
+ pctx->trans, test_client_premature_reply_mail_from_cb, pctx);
- pctx->to = timeout_add_short(500,
- test_client_premature_reply_submit2, pctx);
+ pctx->to = timeout_add_short(
+ 500, test_client_premature_reply_submit2, pctx);
}
static void
test_client_premature_reply_submit(struct _premature_reply *ctx,
- unsigned int index)
+ unsigned int index)
{
struct _premature_reply_peer *pctx;
struct smtp_client_connection *conn;
pctx->context = ctx;
pctx->index = index;
- pctx->conn = conn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[index],
+ pctx->conn = conn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[index],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
- pctx->trans = smtp_client_transaction_create(conn,
- &((struct smtp_address){.localpart = "sender",
- .domain = "example.com"}), NULL, 0,
+ pctx->trans = smtp_client_transaction_create(
+ conn, &((struct smtp_address){
+ .localpart = "sender",
+ .domain = "example.com"}), NULL, 0,
test_client_premature_reply_finished, pctx);
- smtp_client_connection_connect(conn,
- test_client_premature_reply_login_cb, (void *)pctx);
+ smtp_client_connection_connect(
+ conn, test_client_premature_reply_login_cb, (void *)pctx);
smtp_client_connection_unref(&conn);
- pctx->to = timeout_add_short(500,
- test_client_premature_reply_submit1, pctx);
+ pctx->to = timeout_add_short(
+ 500, test_client_premature_reply_submit1, pctx);
}
static bool
-test_client_premature_reply(
- const struct smtp_client_settings *client_set)
+test_client_premature_reply(const struct smtp_client_settings *client_set)
{
struct _premature_reply *ctx;
unsigned int i;
test_begin("premature reply");
test_run_client_server(&smtp_client_set,
- test_client_premature_reply,
- test_server_premature_reply, 6, NULL);
+ test_client_premature_reply,
+ test_server_premature_reply, 6, NULL);
test_end();
}
if (debug)
i_debug("[%u] REPLIED 354", server_index);
o_stream_nsend_str(conn->conn.output,
- "354 End data with <CR><LF>.<CR><LF>\r\n");
+ "354 End data with <CR><LF>.<CR><LF>\r\n");
conn->context = (void*)1;
return 1;
}
i_debug("[%u] FINISHED TRANSACTION",
server_index);
o_stream_nsend_str(conn->conn.output,
- "250 2.0.0 Ok: queued as 73BDE342129\r\n");
+ "250 2.0.0 Ok: queued as 73BDE342129\r\n");
return 1;
}
server_index);
if (server_index == 0) {
- o_stream_nsend_str(conn->conn.output,
+ o_stream_nsend_str(
+ conn->conn.output,
"250 2.0.0 Ok: queued as 73BDE342129\r\n");
} else {
- o_stream_nsend_str(conn->conn.output,
+ o_stream_nsend_str(
+ conn->conn.output,
"452 4.3.1 Mail system full\r\n");
}
}
test_assert(smtp_reply_is_success(reply));
- pctx->to = timeout_add_short(1000,
- test_client_early_data_reply_submit1, pctx);
+ pctx->to = timeout_add_short(
+ 1000, test_client_early_data_reply_submit1, pctx);
}
static void
input = i_stream_create_fd_autoclose(&pipefd[0], 1024);
pctx->output = o_stream_create_fd_autoclose(&pipefd[1], 1024);
- pctx->conn = conn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[index],
+ pctx->conn = conn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[index],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
smtp_client_connection_connect(conn,
test_client_early_data_reply_login_cb, (void *)pctx);
- pctx->trans = smtp_client_transaction_create(conn,
- &((struct smtp_address){.localpart = "sender",
- .domain = "example.com"}), NULL, 0,
+ pctx->trans = smtp_client_transaction_create(
+ conn, &((struct smtp_address){
+ .localpart = "sender",
+ .domain = "example.com"}), NULL, 0,
test_client_early_data_reply_finished, pctx);
- smtp_client_transaction_add_rcpt(pctx->trans,
- &((struct smtp_address){.localpart = "rcpt",
- .domain = "example.com"}), NULL,
+ smtp_client_transaction_add_rcpt(
+ pctx->trans, &((struct smtp_address){
+ .localpart = "rcpt",
+ .domain = "example.com"}), NULL,
test_client_early_data_reply_rcpt_to_cb,
test_client_early_data_reply_rcpt_data_cb, pctx);
smtp_client_transaction_start(pctx->trans,
}
static bool
-test_client_early_data_reply(
- const struct smtp_client_settings *client_set)
+test_client_early_data_reply(const struct smtp_client_settings *client_set)
{
struct _early_data_reply *ctx;
unsigned int i;
test_begin("early data reply");
test_run_client_server(&smtp_client_set,
- test_client_early_data_reply,
- test_server_early_data_reply, 3, NULL);
+ test_client_early_data_reply,
+ test_server_early_data_reply, 3, NULL);
test_end();
}
if (conn->state == SERVER_CONNECTION_STATE_EHLO)
return 0;
o_stream_nsend_str(conn->conn.output,
- "666 Really bad reply\r\n");
+ "666 Really bad reply\r\n");
server_connection_deinit(&conn);
return -1;
}
smtp_client = smtp_client_init(client_set);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[0],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_bad_reply_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_bad_reply_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[0],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_bad_reply_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_bad_reply_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
test_begin("bad reply");
test_run_client_server(&smtp_client_set,
- test_client_bad_reply,
- test_server_bad_reply, 1, NULL);
+ test_client_bad_reply,
+ test_server_bad_reply, 1, NULL);
test_end();
}
/* server */
-static int
-test_bad_greeting_init(struct server_connection *conn)
+static int test_bad_greeting_init(struct server_connection *conn)
{
switch (server_index) {
case 0:
static void
test_client_bad_greeting_reply(const struct smtp_reply *reply,
- struct _bad_greeting_peer *pctx)
+ struct _bad_greeting_peer *pctx)
{
if (debug)
i_debug("REPLY: %s", smtp_reply_log(reply));
}
static void
-test_client_bad_greeting_submit(struct _bad_greeting *ctx,
- unsigned int index)
+test_client_bad_greeting_submit(struct _bad_greeting *ctx, unsigned int index)
{
struct smtp_client_connection *sconn;
struct smtp_client_command *scmd;
pctx->context = ctx;
pctx->index = index;
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[index],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[index],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_bad_greeting_reply, pctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_bad_greeting_reply, pctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
}
static bool
-test_client_bad_greeting(
- const struct smtp_client_settings *client_set)
+test_client_bad_greeting(const struct smtp_client_settings *client_set)
{
struct _bad_greeting *ctx;
test_begin("bad greeting");
test_run_client_server(&smtp_client_set,
- test_client_bad_greeting,
- test_server_bad_greeting, 3, NULL);
+ test_client_bad_greeting,
+ test_server_bad_greeting, 3, NULL);
test_end();
}
static int
test_command_timed_out_input_line(struct server_connection *conn,
- const char *line ATTR_UNUSED)
+ const char *line ATTR_UNUSED)
{
if (conn->state == SERVER_CONNECTION_STATE_EHLO)
return 0;
static void
test_client_command_timed_out_reply(const struct smtp_reply *reply,
- struct _command_timed_out *ctx)
+ struct _command_timed_out *ctx)
{
if (debug)
i_debug("REPLY: %s", smtp_reply_log(reply));
}
static bool
-test_client_command_timed_out(
- const struct smtp_client_settings *client_set)
+test_client_command_timed_out(const struct smtp_client_settings *client_set)
{
struct smtp_client_connection *sconn;
struct smtp_client_command *scmd;
smtp_client = smtp_client_init(client_set);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[0],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_command_timed_out_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_command_timed_out_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
test_begin("command timed out");
test_run_client_server(&smtp_client_set,
- test_client_command_timed_out,
- test_server_command_timed_out, 1, NULL);
+ test_client_command_timed_out,
+ test_server_command_timed_out, 1, NULL);
test_end();
}
static int
test_command_aborted_early_input_line(struct server_connection *conn,
- const char *line ATTR_UNUSED)
+ const char *line ATTR_UNUSED)
{
if (conn->state == SERVER_CONNECTION_STATE_EHLO)
return 0;
};
static void
-test_client_command_aborted_early_reply(const struct smtp_reply *reply,
+test_client_command_aborted_early_reply(
+ const struct smtp_reply *reply,
struct _command_aborted_early *ctx ATTR_UNUSED)
{
if (debug)
}
static void
-test_client_command_aborted_early_timeout(
- struct _command_aborted_early *ctx)
+test_client_command_aborted_early_timeout(struct _command_aborted_early *ctx)
{
timeout_remove(&ctx->to);
/* wait a little for server to actually respond to an
already aborted request */
- ctx->to = timeout_add_short(1000,
- test_client_command_aborted_early_timeout, ctx);
+ ctx->to = timeout_add_short(
+ 1000, test_client_command_aborted_early_timeout, ctx);
} else {
if (debug)
i_debug("FINISHED");
}
static bool
-test_client_command_aborted_early(
- const struct smtp_client_settings *client_set)
+test_client_command_aborted_early(const struct smtp_client_settings *client_set)
{
struct smtp_client_connection *sconn;
struct _command_aborted_early *ctx;
test_begin("command aborted early");
test_run_client_server(&smtp_client_set,
- test_client_command_aborted_early,
- test_server_command_aborted_early, 1, NULL);
+ test_client_command_aborted_early,
+ test_server_command_aborted_early, 1, NULL);
test_end();
}
static int
test_client_deinit_early_input_line(struct server_connection *conn,
- const char *line ATTR_UNUSED)
+ const char *line ATTR_UNUSED)
{
if (conn->state == SERVER_CONNECTION_STATE_EHLO)
return 0;
};
static void
-test_client_client_deinit_early_reply(const struct smtp_reply *reply,
+test_client_client_deinit_early_reply(
+ const struct smtp_reply *reply,
struct _client_deinit_early *ctx ATTR_UNUSED)
{
if (debug)
}
static void
-test_client_client_deinit_early_timeout(
- struct _client_deinit_early *ctx)
+test_client_client_deinit_early_timeout(struct _client_deinit_early *ctx)
{
timeout_remove(&ctx->to);
}
static bool
-test_client_client_deinit_early(
- const struct smtp_client_settings *client_set)
+test_client_client_deinit_early(const struct smtp_client_settings *client_set)
{
struct smtp_client_connection *sconn;
struct _client_deinit_early *ctx;
smtp_client = smtp_client_init(client_set);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[0],
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[0],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- ctx->cmd = smtp_client_command_new(sconn, 0,
- test_client_client_deinit_early_reply, ctx);
+ ctx->cmd = smtp_client_command_new(
+ sconn, 0, test_client_client_deinit_early_reply, ctx);
smtp_client_command_write(ctx->cmd, "FROP");
smtp_client_command_submit(ctx->cmd);
- ctx->to = timeout_add_short(500,
- test_client_client_deinit_early_timeout, ctx);
+ ctx->to = timeout_add_short(
+ 500, test_client_client_deinit_early_timeout, ctx);
return TRUE;
}
test_begin("client deinit early");
test_run_client_server(&smtp_client_set,
- test_client_client_deinit_early,
- test_server_client_deinit_early, 1, NULL);
+ test_client_client_deinit_early,
+ test_server_client_deinit_early, 1, NULL);
test_end();
}
static void
test_client_dns_service_failure_reply(const struct smtp_reply *reply,
- struct _dns_service_failure *ctx)
+ struct _dns_service_failure *ctx)
{
if (debug)
i_debug("REPLY: %s", smtp_reply_log(reply));
- test_assert(reply->status == SMTP_CLIENT_COMMAND_ERROR_HOST_LOOKUP_FAILED);
+ test_assert(reply->status ==
+ SMTP_CLIENT_COMMAND_ERROR_HOST_LOOKUP_FAILED);
if (--ctx->count == 0) {
i_free(ctx);
}
static bool
-test_client_dns_service_failure(
- const struct smtp_client_settings *client_set)
+test_client_dns_service_failure(const struct smtp_client_settings *client_set)
{
struct smtp_client_connection *sconn;
struct smtp_client_command *scmd;
smtp_client = smtp_client_init(client_set);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, "host.in-addr.arpa", 465,
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP, "host.in-addr.arpa", 465,
SMTP_CLIENT_SSL_MODE_IMMEDIATE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_dns_service_failure_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_dns_service_failure_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, "host.in-addr.arpa", 465,
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP, "host.in-addr.arpa", 465,
SMTP_CLIENT_SSL_MODE_IMMEDIATE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_dns_service_failure_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_dns_service_failure_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
test_begin("dns service failure");
test_run_client_server(&smtp_client_set,
- test_client_dns_service_failure,
- NULL, 0, NULL);
+ test_client_dns_service_failure, NULL, 0, NULL);
test_end();
}
/* dns */
-static void
-test_dns_timeout_input(struct server_connection *conn ATTR_UNUSED)
+static void test_dns_timeout_input(struct server_connection *conn ATTR_UNUSED)
{
/* hang */
sleep(100);
static void
test_client_dns_timeout_reply(const struct smtp_reply *reply,
- struct _dns_timeout *ctx)
+ struct _dns_timeout *ctx)
{
if (debug)
i_debug("REPLY: %s", smtp_reply_log(reply));
- test_assert(reply->status == SMTP_CLIENT_COMMAND_ERROR_HOST_LOOKUP_FAILED);
+ test_assert(reply->status ==
+ SMTP_CLIENT_COMMAND_ERROR_HOST_LOOKUP_FAILED);
if (--ctx->count == 0) {
i_free(ctx);
}
static bool
-test_client_dns_timeout(
- const struct smtp_client_settings *client_set)
+test_client_dns_timeout(const struct smtp_client_settings *client_set)
{
struct smtp_client_connection *sconn;
struct smtp_client_command *scmd;
smtp_client = smtp_client_init(client_set);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, "example.com", 465,
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP, "example.com", 465,
SMTP_CLIENT_SSL_MODE_IMMEDIATE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_dns_timeout_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_dns_timeout_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, "example.com", 465,
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP, "example.com", 465,
SMTP_CLIENT_SSL_MODE_IMMEDIATE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_dns_timeout_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_dns_timeout_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
test_begin("dns timeout");
test_run_client_server(&smtp_client_set,
- test_client_dns_timeout, NULL, 0,
- test_dns_dns_timeout);
+ test_client_dns_timeout, NULL, 0,
+ test_dns_dns_timeout);
test_end();
}
static void
test_dns_lookup_failure_input(struct server_connection *conn)
{
- o_stream_nsend_str(conn->conn.output,
+ o_stream_nsend_str(
+ conn->conn.output,
t_strdup_printf("VERSION\tdns\t1\t0\n%d\tFAIL\n", EAI_FAIL));
server_connection_deinit(&conn);
}
static void
test_client_dns_lookup_failure_reply(const struct smtp_reply *reply,
- struct _dns_lookup_failure *ctx)
+ struct _dns_lookup_failure *ctx)
{
if (debug)
i_debug("REPLY: %s", smtp_reply_log(reply));
- test_assert(reply->status == SMTP_CLIENT_COMMAND_ERROR_HOST_LOOKUP_FAILED);
+ test_assert(reply->status ==
+ SMTP_CLIENT_COMMAND_ERROR_HOST_LOOKUP_FAILED);
if (--ctx->count == 0) {
i_free(ctx);
}
static bool
-test_client_dns_lookup_failure(
- const struct smtp_client_settings *client_set)
+test_client_dns_lookup_failure(const struct smtp_client_settings *client_set)
{
struct smtp_client_connection *sconn;
struct smtp_client_command *scmd;
smtp_client = smtp_client_init(client_set);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, "example.com", 465,
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP, "example.com", 465,
SMTP_CLIENT_SSL_MODE_IMMEDIATE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_dns_lookup_failure_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_dns_lookup_failure_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
- sconn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, "example.com", 465,
+ sconn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP, "example.com", 465,
SMTP_CLIENT_SSL_MODE_IMMEDIATE, NULL);
smtp_client_connection_connect(sconn, NULL, NULL);
- scmd = smtp_client_command_new(sconn, 0,
- test_client_dns_lookup_failure_reply, ctx);
+ scmd = smtp_client_command_new(
+ sconn, 0, test_client_dns_lookup_failure_reply, ctx);
smtp_client_command_write(scmd, "FROP");
smtp_client_command_submit(scmd);
test_begin("dns lookup failure");
test_run_client_server(&smtp_client_set,
- test_client_dns_lookup_failure, NULL, 0,
- test_dns_dns_lookup_failure);
+ test_client_dns_lookup_failure, NULL, 0,
+ test_dns_dns_lookup_failure);
test_end();
}
static int
test_authentication_failed_input_line(struct server_connection *conn,
- const char *line ATTR_UNUSED)
+ const char *line ATTR_UNUSED)
{
switch (conn->state) {
case SERVER_CONNECTION_STATE_EHLO:
if (server_index == 1) {
- o_stream_nsend_str(conn->conn.output,
+ o_stream_nsend_str(
+ conn->conn.output,
"250-testserver\r\n"
"250-PIPELINING\r\n"
"250-ENHANCEDSTATUSCODES\r\n"
break;
case SERVER_CONNECTION_STATE_MAIL_FROM:
if (server_index == 1) {
- o_stream_nsend_str(conn->conn.output,
+ o_stream_nsend_str(
+ conn->conn.output,
"535 5.7.8 "
"Authentication credentials invalid\r\n");
sleep(10);
static void
test_client_authentication_failed_login_cb(const struct smtp_reply *reply,
- void *context)
+ void *context)
{
struct _authentication_failed_peer *pctx =
(struct _authentication_failed_peer *)context;
switch (pctx->index) {
case 0:
test_assert(reply->status ==
- SMTP_CLIENT_COMMAND_ERROR_AUTH_FAILED);
+ SMTP_CLIENT_COMMAND_ERROR_AUTH_FAILED);
break;
case 1:
test_assert(reply->status == 535);
}
static void
-test_client_authentication_failed_mail_from_cb(const struct smtp_reply *reply,
+test_client_authentication_failed_mail_from_cb(
+ const struct smtp_reply *reply,
struct _authentication_failed_peer *pctx)
{
if (debug) {
switch (pctx->index) {
case 0:
test_assert(reply->status ==
- SMTP_CLIENT_COMMAND_ERROR_AUTH_FAILED);
+ SMTP_CLIENT_COMMAND_ERROR_AUTH_FAILED);
break;
case 1:
test_assert(reply->status == 535);
}
static void
-test_client_authentication_failed_rcpt_to_cb(const struct smtp_reply *reply,
+test_client_authentication_failed_rcpt_to_cb(
+ const struct smtp_reply *reply,
struct _authentication_failed_peer *pctx)
{
if (debug) {
switch (pctx->index) {
case 0:
test_assert(reply->status ==
- SMTP_CLIENT_COMMAND_ERROR_AUTH_FAILED);
+ SMTP_CLIENT_COMMAND_ERROR_AUTH_FAILED);
break;
case 1:
test_assert(reply->status == 535);
}
static void
-test_client_authentication_failed_rcpt_data_cb(const struct smtp_reply *reply,
+test_client_authentication_failed_rcpt_data_cb(
+ const struct smtp_reply *reply,
struct _authentication_failed_peer *pctx)
{
if (debug) {
}
static void
-test_client_authentication_failed_data_cb(const struct smtp_reply *reply,
+test_client_authentication_failed_data_cb(
+ const struct smtp_reply *reply,
struct _authentication_failed_peer *pctx)
{
if (debug) {
switch (pctx->index) {
case 0:
test_assert(reply->status ==
- SMTP_CLIENT_COMMAND_ERROR_AUTH_FAILED);
+ SMTP_CLIENT_COMMAND_ERROR_AUTH_FAILED);
break;
case 1:
test_assert(reply->status == 535);
}
static void
-test_client_authentication_failed_finished(struct _authentication_failed_peer *pctx)
+test_client_authentication_failed_finished(
+ struct _authentication_failed_peer *pctx)
{
struct _authentication_failed *ctx = pctx->context;
static void
test_client_authentication_failed_submit(struct _authentication_failed *ctx,
- unsigned int index)
+ unsigned int index)
{
struct _authentication_failed_peer *pctx;
struct smtp_client_settings smtp_set;
smtp_set.username = "peter.wolfsen";
smtp_set.password = "crybaby";
- pctx->conn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[index],
+ pctx->conn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[index],
SMTP_CLIENT_SSL_MODE_NONE, &smtp_set);
- pctx->trans = smtp_client_transaction_create(pctx->conn,
- &((struct smtp_address){.localpart = "sender",
- .domain = "example.com"}), NULL, 0,
+ pctx->trans = smtp_client_transaction_create(
+ pctx->conn, &((struct smtp_address){
+ .localpart = "sender",
+ .domain = "example.com"}), NULL, 0,
test_client_authentication_failed_finished, pctx);
- smtp_client_connection_connect(pctx->conn,
- test_client_authentication_failed_login_cb, (void *)pctx);
- smtp_client_transaction_start(pctx->trans,
- test_client_authentication_failed_mail_from_cb, pctx);
+ smtp_client_connection_connect(
+ pctx->conn, test_client_authentication_failed_login_cb,
+ (void *)pctx);
+ smtp_client_transaction_start(
+ pctx->trans, test_client_authentication_failed_mail_from_cb,
+ pctx);
smtp_client_connection_unref(&pctx->conn);
- smtp_client_transaction_add_rcpt(pctx->trans,
- &((struct smtp_address){.localpart = "rcpt",
- .domain = "example.com"}), NULL,
+ smtp_client_transaction_add_rcpt(
+ pctx->trans, &((struct smtp_address){
+ .localpart = "rcpt",
+ .domain = "example.com"}), NULL,
test_client_authentication_failed_rcpt_to_cb,
test_client_authentication_failed_rcpt_data_cb, pctx);
input = i_stream_create_from_data(message, strlen(message));
i_stream_set_name(input, "message");
- smtp_client_transaction_send(pctx->trans,
- input, test_client_authentication_failed_data_cb, pctx);
+ smtp_client_transaction_send(
+ pctx->trans, input,
+ test_client_authentication_failed_data_cb, pctx);
i_stream_unref(&input);
}
static bool
-test_client_authentication_failed(
- const struct smtp_client_settings *client_set)
+test_client_authentication_failed(const struct smtp_client_settings *client_set)
{
struct _authentication_failed *ctx;
unsigned int i;
test_begin("authentication failed");
test_expect_errors(1);
test_run_client_server(&smtp_client_set,
- test_client_authentication_failed,
- test_server_authentication_failed, 2, NULL);
+ test_client_authentication_failed,
+ test_server_authentication_failed, 2, NULL);
test_end();
}
static int
test_transaction_timeout_input_line(struct server_connection *conn,
- const char *line ATTR_UNUSED)
+ const char *line ATTR_UNUSED)
{
switch (conn->state) {
case SERVER_CONNECTION_STATE_EHLO:
};
static void
-test_client_transaction_timeout_mail_from_cb(const struct smtp_reply *reply,
+test_client_transaction_timeout_mail_from_cb(
+ const struct smtp_reply *reply,
struct _transaction_timeout_peer *pctx)
{
- if (debug)
- i_debug("MAIL FROM REPLY[%u]: %s", pctx->index, smtp_reply_log(reply));
+ if (debug) {
+ i_debug("MAIL FROM REPLY[%u]: %s",
+ pctx->index, smtp_reply_log(reply));
+ }
pctx->mail_from_callback = TRUE;
}
static void
-test_client_transaction_timeout_rcpt_to_cb(const struct smtp_reply *reply,
- struct _transaction_timeout_peer *pctx)
+test_client_transaction_timeout_rcpt_to_cb(
+ const struct smtp_reply *reply, struct _transaction_timeout_peer *pctx)
{
- if (debug)
- i_debug("RCPT TO REPLY[%u]: %s", pctx->index, smtp_reply_log(reply));
+ if (debug) {
+ i_debug("RCPT TO REPLY[%u]: %s",
+ pctx->index, smtp_reply_log(reply));
+ }
pctx->rcpt_to_callback = TRUE;
}
static void
-test_client_transaction_timeout_rcpt_data_cb(const struct smtp_reply *reply,
- struct _transaction_timeout_peer *pctx)
+test_client_transaction_timeout_rcpt_data_cb(
+ const struct smtp_reply *reply, struct _transaction_timeout_peer *pctx)
{
- if (debug)
- i_debug("RCPT DATA REPLY[%u]: %s", pctx->index, smtp_reply_log(reply));
+ if (debug) {
+ i_debug("RCPT DATA REPLY[%u]: %s",
+ pctx->index, smtp_reply_log(reply));
+ }
pctx->rcpt_data_callback = TRUE;
static void
test_client_transaction_timeout_data_cb(const struct smtp_reply *reply,
- struct _transaction_timeout_peer *pctx)
+ struct _transaction_timeout_peer *pctx)
{
- if (debug)
- i_debug("DATA REPLY[%u]: %s", pctx->index, smtp_reply_log(reply));
+ if (debug) {
+ i_debug("DATA REPLY[%u]: %s",
+ pctx->index, smtp_reply_log(reply));
+ }
pctx->data_callback = TRUE;
input = i_stream_create_from_data(message, strlen(message));
i_stream_set_name(input, "message");
- smtp_client_transaction_send
- (strans, input, test_client_transaction_timeout_data_cb, pctx);
+ smtp_client_transaction_send(
+ strans, input, test_client_transaction_timeout_data_cb, pctx);
i_stream_unref(&input);
}
{
timeout_remove(&pctx->to);
- smtp_client_transaction_add_rcpt(pctx->trans,
- &((struct smtp_address){.localpart = "rcpt",
- .domain = "example.com"}), NULL,
+ smtp_client_transaction_add_rcpt(
+ pctx->trans, &((struct smtp_address){
+ .localpart = "rcpt",
+ .domain = "example.com"}), NULL,
test_client_transaction_timeout_rcpt_to_cb,
test_client_transaction_timeout_rcpt_data_cb, pctx);
- pctx->to = timeout_add_short(500,
- test_client_transaction_timeout_submit2, pctx);
+ pctx->to = timeout_add_short(
+ 500, test_client_transaction_timeout_submit2, pctx);
}
static void
test_client_transaction_timeout_submit(struct _transaction_timeout *ctx,
- unsigned int index)
+ unsigned int index)
{
struct _transaction_timeout_peer *pctx;
pctx->context = ctx;
pctx->index = index;
- pctx->conn = smtp_client_connection_create(smtp_client,
- SMTP_PROTOCOL_SMTP, net_ip2addr(&bind_ip), bind_ports[index],
+ pctx->conn = smtp_client_connection_create(
+ smtp_client, SMTP_PROTOCOL_SMTP,
+ net_ip2addr(&bind_ip), bind_ports[index],
SMTP_CLIENT_SSL_MODE_NONE, NULL);
- pctx->trans = smtp_client_transaction_create(pctx->conn,
- &((struct smtp_address){.localpart = "sender",
- .domain = "example.com"}), NULL, 0,
+ pctx->trans = smtp_client_transaction_create(
+ pctx->conn, &((struct smtp_address){
+ .localpart = "sender",
+ .domain = "example.com"}), NULL, 0,
test_client_transaction_timeout_finished, pctx);
smtp_client_transaction_set_timeout(pctx->trans, 1000);
- smtp_client_transaction_start(pctx->trans,
- test_client_transaction_timeout_mail_from_cb, pctx);
+ smtp_client_transaction_start(
+ pctx->trans, test_client_transaction_timeout_mail_from_cb,
+ pctx);
smtp_client_connection_unref(&pctx->conn);
- pctx->to = timeout_add_short(500,
- test_client_transaction_timeout_submit1, pctx);
+ pctx->to = timeout_add_short(
+ 500, test_client_transaction_timeout_submit1, pctx);
}
static bool
-test_client_transaction_timeout(
- const struct smtp_client_settings *client_set)
+test_client_transaction_timeout(const struct smtp_client_settings *client_set)
{
struct _transaction_timeout *ctx;
unsigned int i;
test_begin("transaction timeout");
test_run_client_server(&smtp_client_set,
- test_client_transaction_timeout,
- test_server_transaction_timeout, 6, NULL);
+ test_client_transaction_timeout,
+ test_server_transaction_timeout, 6, NULL);
test_end();
}
* Test client
*/
-static void
-test_client_defaults(struct smtp_client_settings *smtp_set)
+static void test_client_defaults(struct smtp_client_settings *smtp_set)
{
/* client settings */
i_zero(smtp_set);
smtp_set->debug = debug;
}
-static void
-test_client_progress_timeout(void *context ATTR_UNUSED)
+static void test_client_progress_timeout(void *context ATTR_UNUSED)
{
/* Terminate test due to lack of progress */
test_assert(FALSE);
return FALSE;
to_client_progress = timeout_add(CLIENT_PROGRESS_TIMEOUT*1000,
- test_client_progress_timeout, NULL);
+ test_client_progress_timeout, NULL);
return TRUE;
}
size_t size;
int ret;
- if (conn->dot_input == NULL)
- conn->dot_input = i_stream_create_dot(conn->conn.input, TRUE);
- while ((ret=i_stream_read_more(conn->dot_input,
- &data, &size)) > 0) {
+ if (conn->dot_input == NULL) {
+ conn->dot_input = i_stream_create_dot(
+ conn->conn.input, TRUE);
+ }
+ while ((ret = i_stream_read_more(conn->dot_input,
+ &data, &size)) > 0) {
if (test_server_input_data != NULL) {
- if (test_server_input_data(conn, data, size) < 0)
+ if (test_server_input_data(
+ conn, data, size) < 0)
return;
}
i_stream_skip(conn->dot_input, size);
return;
}
- o_stream_nsend_str(conn->conn.output,
+ o_stream_nsend_str(
+ conn->conn.output,
"250 2.0.0 Ok: queued as 73BDE342129\r\n");
conn->state = SERVER_CONNECTION_STATE_MAIL_FROM;
continue;
line = i_stream_read_next_line(conn->conn.input);
if (line == NULL) {
if (conn->conn.input->eof ||
- conn->conn.input->stream_errno != 0)
+ conn->conn.input->stream_errno != 0)
server_connection_deinit(&conn);
return;
}
if (test_server_input_line != NULL) {
- if ((ret=test_server_input_line(conn, line)) < 0)
+ if ((ret = test_server_input_line(conn, line)) < 0)
return;
if (ret > 0)
continue;
switch (conn->state) {
case SERVER_CONNECTION_STATE_EHLO:
o_stream_nsend_str(conn->conn.output,
- "250-testserver\r\n"
- "250-PIPELINING\r\n"
- "250-ENHANCEDSTATUSCODES\r\n"
- "250 DSN\r\n");
+ "250-testserver\r\n"
+ "250-PIPELINING\r\n"
+ "250-ENHANCEDSTATUSCODES\r\n"
+ "250 DSN\r\n");
conn->state = SERVER_CONNECTION_STATE_MAIL_FROM;
return;
case SERVER_CONNECTION_STATE_MAIL_FROM:
if (str_begins(line, "AUTH ")) {
- o_stream_nsend_str(conn->conn.output,
- "235 2.7.0 "
+ o_stream_nsend_str(
+ conn->conn.output, "235 2.7.0 "
"Authentication successful\r\n");
continue;
}
o_stream_nsend_str(conn->conn.output,
- "250 2.1.0 Ok\r\n");
+ "250 2.1.0 Ok\r\n");
conn->state = SERVER_CONNECTION_STATE_RCPT_TO;
continue;
case SERVER_CONNECTION_STATE_RCPT_TO:
o_stream_nsend_str(conn->conn.output,
- "250 2.1.5 Ok\r\n");
+ "250 2.1.5 Ok\r\n");
conn->state = SERVER_CONNECTION_STATE_DATA;
continue;
case SERVER_CONNECTION_STATE_DATA:
- o_stream_nsend_str(conn->conn.output,
+ o_stream_nsend_str(
+ conn->conn.output,
"354 End data with <CR><LF>.<CR><LF>\r\n");
conn->state = SERVER_CONNECTION_STATE_FINISH;
continue;
}
}
-static void
-server_connection_init(int fd)
+static void server_connection_init(int fd)
{
struct server_connection *conn;
pool_t pool;
conn = p_new(pool, struct server_connection, 1);
conn->pool = pool;
- connection_init_server
- (server_conn_list, &conn->conn, "server connection", fd, fd);
+ connection_init_server(server_conn_list, &conn->conn,
+ "server connection", fd, fd);
if (test_server_init != NULL) {
if (test_server_init(conn) != 0)
}
if (test_server_input == NULL) {
- o_stream_nsend_str(conn->conn.output,
+ o_stream_nsend_str(
+ conn->conn.output,
"220 testserver ESMTP Testfix (Debian/GNU)\r\n");
}
}
-static void
-server_connection_deinit(struct server_connection **_conn)
+static void server_connection_deinit(struct server_connection **_conn)
{
struct server_connection *conn = *_conn;
pool_unref(&conn->pool);
}
-static void
-server_connection_destroy(struct connection *_conn)
+static void server_connection_destroy(struct connection *_conn)
{
struct server_connection *conn =
(struct server_connection *)_conn;
server_connection_deinit(&conn);
}
-static void
-server_connection_accept(void *context ATTR_UNUSED)
+static void server_connection_accept(void *context ATTR_UNUSED)
{
int fd;
fd = net_accept(fd_listen, NULL, NULL);
if (fd == -1)
return;
- if (fd == -2) {
+ if (fd == -2)
i_fatal("test server: accept() failed: %m");
- }
server_connection_init(fd);
}
static struct connection_settings server_connection_set = {
.input_max_size = (size_t)-1,
.output_max_size = (size_t)-1,
- .client = FALSE
+ .client = FALSE,
};
static const struct connection_vfuncs server_connection_vfuncs = {
.destroy = server_connection_destroy,
- .input = server_connection_input
+ .input = server_connection_input,
};
static void test_server_run(unsigned int index)
server_index = index;
/* open server socket */
- io_listen = io_add(fd_listen,
- IO_READ, server_connection_accept, NULL);
+ io_listen = io_add(fd_listen, IO_READ, server_connection_accept, NULL);
- server_conn_list = connection_list_init
- (&server_connection_set, &server_connection_vfuncs);
+ server_conn_list = connection_list_init(&server_connection_set,
+ &server_connection_vfuncs);
io_loop_run(ioloop);
}
}
-static void test_run_client_server(
- const struct smtp_client_settings *client_set,
- test_client_init_t client_test,
- test_server_init_t server_test,
- unsigned int server_tests_count,
- test_dns_init_t dns_test)
+static void
+test_run_client_server(const struct smtp_client_settings *client_set,
+ test_client_init_t client_test,
+ test_server_init_t server_test,
+ unsigned int server_tests_count,
+ test_dns_init_t dns_test)
{
unsigned int i;
server_pids[i] = (pid_t)-1;
server_pids_count = 0;
hostpid_init();
- if (debug)
- i_debug("server[%d]: PID=%s", i+1, my_pid);
+ if (debug) {
+ i_debug("server[%d]: PID=%s",
+ i+1, my_pid);
+ }
/* child: server */
ioloop = io_loop_create();
server_test(i);
i_close_fd(&fd_listen);
i_free(bind_ports);
i_free(server_pids);
- /* wait for it to be killed; this way, valgrind will not
- object to this process going away inelegantly. */
+ /* wait for it to be killed; this way, valgrind
+ will not object to this process going away
+ inelegantly. */
sleep(60);
exit(1);
}
volatile sig_atomic_t terminating = 0;
-static void
-test_signal_handler(int signo)
+static void test_signal_handler(int signo)
{
if (terminating != 0)
raise(signo);