/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "str.h"
#include "llist.h"
#include "array.h"
#include "path-util.h"
#include "hostpid.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "istream-base64.h"
#include "istream-crlf.h"
#include "iostream-temp.h"
#include "connection.h"
#include "test-common.h"
#include "smtp-server.h"
#include "smtp-client.h"
#include "smtp-client-connection.h"
#include "smtp-client-transaction.h"
#include <signal.h>
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
/*
* Test files
*/
{
/* open the directory */
return;
i_fatal("test files: "
"failed to open directory %s: %m", path);
}
/* read entries */
for (;;) {
const char *file;
#if 0
break;
#endif
errno = 0;
break;
continue;
} else {
}
}
}
if (errno != 0)
i_fatal("test files: "
"failed to read directory %s: %m", path);
/* Close the directory */
i_error("test files: "
"failed to close directory %s: %m", path);
}
static void test_files_init(void)
{
/* initialize file array */
/* obtain all filenames */
test_files_read_dir(".");
}
static void test_files_deinit(void)
{
}
static struct istream *
{
int fd;
if (fd < 0) {
i_fatal("test files: "
"open(%s) failed: %m", path);
}
if (debug) {
i_debug("test files: "
"open(%s) failed: %m", path);
}
return NULL;
}
return file;
}
/*
* Test server
*/
struct client {
};
struct client_transaction {
const char *path;
};
static int
{
if (debug) {
i_debug("test server: read more payload for [%s]",
}
/* read payload */
if (debug) {
i_debug("test server: "
"got data for [%s] (size=%d)",
}
/* compare with file on disk */
while ((ret=i_stream_read_more
i_fatal("test server: "
"received data does not match file [%s] "
}
}
i_fatal("test server: "
"failed to read file: %s",
}
}
if (ret == 0) {
if (debug) {
i_debug("test server: "
"need more data for [%s]",
}
/* we will be called again for this request */
return 0;
}
if (payload->stream_errno != 0) {
i_fatal("test server: "
"failed to read transaction payload: %s",
fsize = 0;
i_fatal("test server: "
"payload ended prematurely "
}
if (debug) {
i_debug("test server: "
"finished transaction for [%s]",
}
/* dereference payload stream; finishes the request */
/* finished */
return 1;
}
static void
{
if (debug) {
i_debug("test server: got transaction for: %s",
path);
}
(void)client_transaction_read_more(ctrans);
}
/* transaction */
static struct client_transaction *
struct smtp_server_cmd_ctx *data_cmd,
struct smtp_server_transaction *trans)
{
return ctrans;
}
static void
{
}
static void
struct smtp_server_transaction *trans)
{
}
static int
struct smtp_server_cmd_rcpt *data)
{
if (debug) {
i_debug("test server: RCPT TO:%s",
}
return 1;
}
static int
struct smtp_server_cmd_ctx *cmd,
struct smtp_server_transaction *trans,
struct istream *data_input)
{
if (debug) {
}
return 0;
}
static int
struct smtp_server_cmd_ctx *cmd,
struct smtp_server_transaction *trans)
{
if (debug)
i_debug("test server: DATA continue");
return client_transaction_read_more(ctrans);
}
/* client connection */
static void
{
};
{
}
{
}
static void
{
}
{
int fd;
/* accept new client */
if (fd == -1)
return;
if (fd == -2) {
i_fatal("test server: accept() failed: %m");
}
}
/* */
static void
{
/* open server socket */
}
static void test_server_deinit(void)
{
/* close server socket */
/* deinitialize */
}
/*
* Test client
*/
struct test_client_transaction {
unsigned int files_idx;
};
static struct test_client_transaction *
{
return tctrans;
}
static void
{
}
static void test_client_continue(void *dummy);
static void
{
const char **paths;
unsigned int count;
if (debug) {
i_debug("test client: "
"finished [%u]", files_idx);
}
}
static void
{
}
static void
struct test_client_transaction *tctrans)
{
const char **paths;
const char *path;
unsigned int count;
i_fatal("test client: "
"SMTP RCPT for %s failed: %s",
}
}
static void
struct test_client_transaction *tctrans)
{
const char **paths;
const char *path;
unsigned int count;
i_fatal("test client: "
"SMTP DATA for %s failed: %s",
}
}
static void
struct test_client_transaction *tctrans)
{
const char **paths;
const char *path;
unsigned int count;
if (debug) {
i_debug("test client: "
"got response for DATA [%u]",
}
if (debug) {
i_debug("test client: "
"path for [%u]: %s",
}
i_fatal("test client: "
"SMTP transaction for %s failed: %s",
}
}
{
const char **paths;
unsigned int count;
if (debug)
i_debug("test client: continue");
for (; client_files_first < client_files_last &&
if (debug) {
i_debug("test client: "
}
i_debug("test client: "
"next blocking: %s [%d]",
}
if (client_files_first >= count) {
return;
}
for (; client_files_last < count &&
client_files_last++) {
unsigned int r, rcpts;
if (debug) {
i_debug("test client: "
"skipping %s [%u]",
}
continue;
}
if (debug) {
i_debug("test client: "
"retrieving %s [%u]",
}
for (r = 1; r <= rcpts; r++) {
}
if (!test_unknown_size)
else {
}
if (debug) {
i_debug("test client: "
}
}
}
static void
const struct smtp_client_settings *client_set)
{
/* create client */
/* start querying server */
}
/* cleanup */
static void test_client_deinit(void)
{
}
/*
* Tests
*/
static void test_open_server_fd(void)
{
if (fd_listen != -1)
if (fd_listen == -1) {
i_fatal("listen(%s:%u) failed: %m",
}
}
static void test_server_kill(void)
{
}
}
static void test_run_client_server(
enum smtp_protocol protocol,
const struct smtp_client_settings *client_set,
const struct smtp_server_settings *server_set,
const struct smtp_client_settings *client_set))
{
i_fatal("fork() failed: %m");
if (server_pid == 0) {
hostpid_init();
if (debug)
i_set_failure_prefix("SERVER: ");
/* child: server */
ioloop = io_loop_create();
} else {
if (debug)
i_set_failure_prefix("CLIENT: ");
/* parent: client */
ioloop = io_loop_create();
bind_port = 0;
}
}
enum smtp_capability capabilities,
const struct smtp_client_settings *client_set))
{
/* server settings */
/* client settings */
test_max_pending = 1;
test_max_pending = 200;
test_max_pending = 200;
test_max_pending = 200;
}
static void test_smtp_normal(void)
{
test_begin("smtp payload - normal");
test_end();
}
static void test_smtp_chunking(void)
{
test_begin("smtp payload - chunking");
test_end();
}
static void test_lmtp_normal(void)
{
test_begin("lmtp payload - normal");
test_end();
}
static void test_lmtp_chunking(void)
{
test_begin("lmtp payload - chunking");
test_end();
}
static void (*const test_functions[])(void) = {
};
/*
* Main
*/
static void
{
if (terminating != 0)
terminating = 1;
/* make sure we don't leave any pesky children alive */
}
static void test_atexit(void)
{
}
{
int c;
switch (c) {
case 'D':
break;
default:
}
}
/* listen on localhost */
}