/* Copyright (c) 2017-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "hostpid.h"
#include "net.h"
#include "istream.h"
#include "ostream.h"
#include "ioloop.h"
#include "unlink-directory.h"
#include "test-common.h"
#include "imapc-client-private.h"
#include <stdio.h>
#include <unistd.h>
#include <signal.h>
typedef void test_server_init_t(void);
typedef void test_client_init_t(void);
struct test_server {
};
.host = "127.0.0.1",
.username = "testuser",
.password = "testpass",
.dns_client_socket_path = "",
.temp_path_prefix = ".test-tmp/",
.rawlog_dir = "",
.connect_timeout_msecs = 500,
.connect_retry_count = 3,
.connect_retry_interval_msecs = 10,
.max_idle_time = 10000,
};
{
if (debug)
if (fd == -1) {
i_fatal("listen(%s:%u) failed: %m",
}
return fd;
}
static void
{
if (send_banner) {
"* OK [CAPABILITY IMAP4rev1 UNSELECT QUOTA] ready\r\n");
}
}
{
}
{
}
static void test_server_kill(void)
{
}
}
static void test_run_client_server(
const struct imapc_client_settings *client_set,
{
const char *error;
if (server_test == NULL)
i_fatal("fork() failed: %m");
hostpid_init();
if (debug)
/* child: server */
ioloop = io_loop_create();
if (server_test != NULL)
server_test();
/* wait for it to be killed; this way, valgrind will not
object to this process going away inelegantly. */
sleep(60);
exit(1);
}
/* parent: client */
ioloop = io_loop_create();
client_test();
if (imapc_client != NULL)
UNLINK_DIRECTORY_FLAG_RMDIR, &error) < 0)
}
{
unsigned int count;
if (count == 0)
return IMAPC_COMMAND_STATE_INVALID;
return reply;
}
{
if (array_count(&imapc_cmd_last_replies) == 0)
return test_imapc_cmd_last_reply_pop() == state;
}
{
printf("imapc client disconnected unexpectedly: %s\n",
return FALSE;
printf("imapc client sent '%s' when expecting '%s'\n",
return FALSE;
} else {
return TRUE;
}
}
void *context ATTR_UNUSED)
{
if (debug) {
i_debug("Login reply: %s %s",
}
}
void *context ATTR_UNUSED)
{
if (debug) {
i_debug("Command reply: %s %s",
}
}
{
}
static void test_imapc_connect_failed_client(void)
{
/* connection refused & one reconnect */
}
static void test_imapc_connect_failed(void)
{
test_begin("imapc connect failed");
NULL);
test_end();
}
static void test_imapc_banner_hangs_client(void)
{
}
static void test_imapc_banner_hangs_server(void)
{
}
static void test_imapc_banner_hangs(void)
{
test_begin("imapc banner hangs");
test_end();
}
static void test_imapc_login_hangs_client(void)
{
}
static void test_imapc_login_hangs_server(void)
{
}
static void test_imapc_login_hangs(void)
{
test_begin("imapc login hangs");
test_end();
}
static void test_imapc_reconnect_client(void)
{
/* login to server */
/* disconnect */
test_expect_error_string("reconnecting");
/* we should be reconnected now. try a command. */
}
static void test_imapc_reconnect_server(void)
{
}
static void test_imapc_reconnect(void)
{
test_begin("imapc reconnect");
test_end();
}
static void test_imapc_reconnect_resend_cmds_client(void)
{
/* login to server */
/* send two commands */
/* disconnect & reconnect automatically */
test_expect_error_string("reconnecting");
/* continue reconnection */
}
static void test_imapc_reconnect_resend_cmds_server(void)
{
}
static void test_imapc_reconnect_resend_commands(void)
{
test_begin("imapc reconnect resend commands");
test_end();
}
static void test_imapc_reconnect_resend_cmds_failed_client(void)
{
/* login to server */
/* send two commands */
/* disconnect & try to reconnect automatically */
test_expect_error_string("reconnecting");
test_expect_error_string("timed out");
}
static void test_imapc_reconnect_resend_cmds_failed_server(void)
{
}
static void test_imapc_reconnect_resend_commands_failed(void)
{
test_begin("imapc reconnect resend commands failed");
test_end();
}
static void test_imapc_reconnect_mailbox_client(void)
{
/* login to server */
/* select a mailbox */
/* send a command */
/* disconnect & reconnect automatically */
test_expect_error_string("reconnecting");
/* continue reconnection */
}
static void test_imapc_reconnect_mailbox_server(void)
{
}
static void test_imapc_reconnect_mailbox(void)
{
test_begin("imapc reconnect mailbox");
test_end();
}
static void test_imapc_client_get_capabilities_client(void)
{
}
static void test_imapc_client_get_capabilities_server(void)
{
}
static void test_imapc_client_get_capabilities(void)
{
test_begin("imapc_client_get_capabilities()");
test_end();
}
static void test_imapc_client_get_capabilities_reconnected_client(void)
{
}
static void test_imapc_client_get_capabilities_reconnected_server(void)
{
}
static void test_imapc_client_get_capabilities_reconnected(void)
{
test_begin("imapc_client_get_capabilities() reconnected");
test_end();
}
static void test_imapc_client_get_capabilities_disconnected_client(void)
{
}
static void test_imapc_client_get_capabilities_disconnected_server(void)
{
}
static void test_imapc_client_get_capabilities_disconnected(void)
{
test_begin("imapc_client_get_capabilities() disconnected");
test_end();
}
{
static void (*const test_functions[])(void) = {
};
/* listen on localhost */
return test_run(test_functions);
}