/* Copyright (c) 2013-2018 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "str.h"
#include "array.h"
#include "test-common.h"
#include "smtp-common.h"
#include "smtp-address.h"
#include "smtp-params.h"
};
};
.data = (void*)&test_params1,
.used = sizeof(test_params1)
};
.data = (void*)&test_params2,
.used = sizeof(test_params2)
};
/* Valid mail params tests */
struct valid_mail_params_parse_test {
bool extensions;
};
static const struct valid_mail_params_parse_test
/* AUTH */
{
.input = "AUTH=<>",
.params = {
.auth = &test_address1
}
},{
.input = "AUTH=user+2Bdetail",
.params = {
.auth = &test_address2
}
},{
.input = "AUTH=e+3Dmc2@example.com",
.params = {
.auth = &test_address3
}
/* BODY */
},{
.input = "",
.params = {
.body = {
}
}
},{
.input = "BODY=7BIT",
.params = {
.body = {
}
}
},{
.input = "BODY=8BITMIME",
.params = {
.body = {
}
}
},{
.input = "BODY=BINARYMIME",
.params = {
.body = {
}
}
},{
.input = "BODY=FROP",
.extensions = TRUE,
.params = {
.body = {
.ext = "FROP"
}
}
/* ENVID */
},{
.input = "",
.params = {
}
},{
.input = "ENVID=",
.params = {
.envid = "",
}
},{
.input = "ENVID=AABBCCDD",
.params = {
.envid = "AABBCCDD",
}
},{
.input = "ENVID=AA+2BBB+3DCC+2BDD",
.params = {
.envid = "AA+BB=CC+DD",
}
/* RET */
},{
.input = "",
.params = {
}
},{
.input = "RET=HDRS",
.params = {
}
},{
.input = "RET=FULL",
.params = {
}
/* SIZE */
},{
.input = "",
.params = {
.size = 0
}
},{
.input = "SIZE=267914296",
.params = {
.size = 267914296
}
/* <extensions> */
},{
.input = "FROP=friep",
.extensions = TRUE,
.params = {
.extra_params = {
.arr = {
.element_size = sizeof(struct smtp_param)
}
}
}
},{
.input = "FROP=friep FRUP=frml",
.extensions = TRUE,
.params = {
.extra_params = {
.arr = {
.element_size = sizeof(struct smtp_param)
}
}
}
}
};
unsigned int valid_mail_params_parse_test_count =
static void
const struct smtp_params_mail *parsed)
{
} else {
}
} else {
}
}
static void
const struct smtp_params_mail *parsed)
{
type_name = "<UNSPECIFIED>";
break;
type_name = "7BIT";
break;
type_name = "8BITMIME";
break;
type_name = "BINARYMIME";
break;
break;
default:
i_unreached();
}
}
static void
const struct smtp_params_mail *parsed)
{
} else {
}
}
static void
const struct smtp_params_mail *parsed)
{
ret_name = "<UNSPECIFIED>";
break;
case SMTP_PARAM_MAIL_RET_HDRS:
ret_name = "HDRS";
break;
case SMTP_PARAM_MAIL_RET_FULL:
ret_name = "FULL";
break;
default:
i_unreached();
}
}
static void
const struct smtp_params_mail *parsed)
{
}
static void
const struct smtp_params_mail *parsed)
{
unsigned int i;
return;
}
return;
}
return;
}
"params.extra_params[%u] = [\"%s\"=\"%s\"]", i,
}
}
static void test_smtp_mail_params_parse_valid(void)
{
unsigned int i;
for (i = 0; i < valid_mail_params_parse_test_count; i++) T_BEGIN {
int ret;
&error_code, &error);
if (ret >= 0) {
/* AUTH */
/* BODY */
/* ENVID */
/* RET */
/* SIZE */
/* <extensions> */
if (test->extensions)
}
test_end();
} T_END;
}
/* Invalid mail params tests */
struct invalid_mail_params_parse_test {
const char *input;
bool extensions;
};
static const struct invalid_mail_params_parse_test
/* AUTH */
{
.input = "AUTH=<>",
},{
.input = "AUTH=++",
/* BODY */
},{
.input = "BODY=8BITMIME",
},{
.input = "BODY=BINARYMIME",
},{
.input = "BODY=BINARYMIME",
},{
.input = "BODY=FROP",
/* ENVID */
},{
.input = "ENVID=AABBCC",
},{
.input = "ENVID=++",
/* RET */
},{
.input = "RET=FULL",
},{
.input = "RET=HDR",
},{
.input = "RET=FROP",
/* SIZE */
},{
.input = "SIZE=13",
},{
.input = "SIZE=ABC",
}
};
unsigned int invalid_mail_params_parse_test_count =
static void test_smtp_mail_params_parse_invalid(void)
{
unsigned int i;
for (i = 0; i < invalid_mail_params_parse_test_count; i++) T_BEGIN {
int ret;
&error_code, &error);
test_end();
} T_END;
}
/* Valid rcpt params tests */
struct valid_rcpt_params_parse_test {
bool extensions;
};
static const struct valid_rcpt_params_parse_test
/* AUTH */
{
#if 0 // FIXME: message_address_parser() does not allow bare localpart
// addresses.
.input = "ORCPT=rfc822;user+2Bdetail",
.params = {
.orcpt = {
.addr = &test_address2
}
}
},{
#endif
.input = "ORCPT=rfc822;e+3Dmc2@example.com",
.params = {
.orcpt = {
.addr = &test_address3
}
}
/* NOTIFY */
},{
.input = "",
.params = {
}
},{
.input = "NOTIFY=SUCCESS",
.params = {
}
},{
.input = "NOTIFY=FAILURE",
.params = {
}
},{
.input = "NOTIFY=DELAY",
.params = {
}
},{
.input = "NOTIFY=NEVER",
.params = {
}
},{
.input = "NOTIFY=SUCCESS,FAILURE,DELAY",
.params = {
}
/* <extensions> */
},{
.input = "FROP=friep",
.extensions = TRUE,
.params = {
.extra_params = {
.arr = {
.element_size = sizeof(struct smtp_param)
}
}
}
},{
.input = "FROP=friep FRUP=frml",
.extensions = TRUE,
.params = {
.extra_params = {
.arr = {
.element_size = sizeof(struct smtp_param)
}
}
}
}
};
unsigned int valid_rcpt_params_parse_test_count =
static void
const struct smtp_params_rcpt *parsed)
{
test_out("params.orcpt.addr = NULL",
return;
}
} else {
}
} else {
}
}
static void
const struct smtp_params_rcpt *parsed)
{
} else {
if (str_len(notify_name) > 0)
}
if (str_len(notify_name) > 0)
}
}
}
static void
const struct smtp_params_rcpt *parsed)
{
unsigned int i;
return;
}
return;
}
return;
}
"params.extra_params[%u] = [\"%s\"=\"%s\"]", i,
}
}
static void test_smtp_rcpt_params_parse_valid(void)
{
unsigned int i;
for (i = 0; i < valid_rcpt_params_parse_test_count; i++) T_BEGIN {
int ret;
&error_code, &error);
if (ret >= 0) {
/* ORCPT */
/* NOTIFY */
/* <extensions> */
if (test->extensions)
}
test_end();
} T_END;
}
/* Invalid rcpt params tests */
struct invalid_rcpt_params_parse_test {
const char *input;
bool extensions;
};
static const struct invalid_rcpt_params_parse_test
/* DSN */
{
.input = "ORCPT=rfc822;frop@example.com",
},{
.input = "ORCPT=++",
},{
.input = "ORCPT=rfc822;++",
},{
.input = "NOTIFY=SUCCESS",
},{
.input = "NOTIFY=FROP",
},{
.input = "NOTIFY=NEVER,SUCCESS",
}
};
unsigned int invalid_rcpt_params_parse_test_count =
static void test_smtp_rcpt_params_parse_invalid(void)
{
unsigned int i;
for (i = 0; i < invalid_rcpt_params_parse_test_count; i++) T_BEGIN {
int ret;
&error_code, &error);
test_end();
} T_END;
}
int main(void)
{
static void (*test_functions[])(void) = {
};
return test_run(test_functions);
}