.params = {
.auth = &test_address1
}
- },{
+ },
+ {
.input = "AUTH=user+2Bdetail",
.caps = SMTP_CAPABILITY_AUTH,
.params = {
.auth = &test_address2
}
- },{
+ },
+ {
.input = "AUTH=e+3Dmc2@example.com",
.caps = SMTP_CAPABILITY_AUTH,
.params = {
.auth = &test_address3
}
+ },
/* BODY */
- },{
+ {
.input = "",
.caps = SMTP_CAPABILITY_8BITMIME,
.params = {
.type = SMTP_PARAM_MAIL_BODY_TYPE_UNSPECIFIED,
}
}
- },{
+ },
+ {
.input = "BODY=7BIT",
.caps = SMTP_CAPABILITY_8BITMIME,
.params = {
.type = SMTP_PARAM_MAIL_BODY_TYPE_7BIT,
}
}
- },{
+ },
+ {
.input = "BODY=8BITMIME",
.caps = SMTP_CAPABILITY_8BITMIME,
.params = {
.type = SMTP_PARAM_MAIL_BODY_TYPE_8BITMIME,
}
}
- },{
+ },
+ {
.input = "BODY=BINARYMIME",
.caps = SMTP_CAPABILITY_8BITMIME |
SMTP_CAPABILITY_BINARYMIME |
.type = SMTP_PARAM_MAIL_BODY_TYPE_BINARYMIME,
}
}
- },{
+ },
+ {
.input = "BODY=FROP",
.caps = SMTP_CAPABILITY_8BITMIME |
SMTP_CAPABILITY_BINARYMIME |
.ext = "FROP"
}
}
+ },
/* ENVID */
- },{
+ {
.input = "",
.caps = SMTP_CAPABILITY_DSN,
.params = {
.envid = NULL,
}
- },{
+ },
+ {
.input = "ENVID=",
.caps = SMTP_CAPABILITY_DSN,
.params = {
.envid = "",
}
- },{
+ },
+ {
.input = "ENVID=AABBCCDD",
.caps = SMTP_CAPABILITY_DSN,
.params = {
.envid = "AABBCCDD",
}
- },{
+ },
+ {
.input = "ENVID=AA+2BBB+3DCC+2BDD",
.caps = SMTP_CAPABILITY_DSN,
.params = {
.envid = "AA+BB=CC+DD",
}
+ },
/* RET */
- },{
+ {
.input = "",
.caps = SMTP_CAPABILITY_DSN,
.params = {
.ret = SMTP_PARAM_MAIL_RET_UNSPECIFIED,
}
- },{
+ },
+ {
.input = "RET=HDRS",
.caps = SMTP_CAPABILITY_DSN,
.params = {
.ret = SMTP_PARAM_MAIL_RET_HDRS,
}
- },{
+ },
+ {
.input = "RET=FULL",
.caps = SMTP_CAPABILITY_DSN,
.params = {
.ret = SMTP_PARAM_MAIL_RET_FULL,
}
+ },
/* SIZE */
- },{
+ {
.input = "",
.caps = SMTP_CAPABILITY_SIZE,
.params = {
.size = 0
}
- },{
+ },
+ {
.input = "SIZE=267914296",
.caps = SMTP_CAPABILITY_SIZE,
.params = {
.size = 267914296
}
+ },
/* <extensions> */
- },{
+ {
.input = "FROP=friep",
.caps = SMTP_CAPABILITY_SIZE,
.extensions = test_extensions,
}
}
}
- },{
+ },
+ {
.input = "FROP=friep FRUP=frml",
.extensions = test_extensions,
.params = {
static void
test_smtp_mail_params_auth(const struct smtp_params_mail *test,
- const struct smtp_params_mail *parsed)
+ const struct smtp_params_mail *parsed)
{
if (parsed->auth->localpart == NULL ||
- test->auth->localpart == NULL) {
+ test->auth->localpart == NULL) {
test_out(t_strdup_printf("params.auth->localpart = %s",
parsed->auth->localpart),
(parsed->auth->localpart == test->auth->localpart));
test->auth->localpart) == 0);
}
if (parsed->auth->domain == NULL ||
- test->auth->domain == NULL) {
+ test->auth->domain == NULL) {
test_out(t_strdup_printf("params.auth->domain = %s",
parsed->auth->domain),
(parsed->auth->domain == test->auth->domain));
static void
test_smtp_mail_params_body(const struct smtp_params_mail *test,
- const struct smtp_params_mail *parsed)
+ const struct smtp_params_mail *parsed)
{
const char *type_name = NULL;
}
test_out(t_strdup_printf("params.body.type = %s", type_name),
- (parsed->body.type == test->body.type &&
- (parsed->body.type != SMTP_PARAM_MAIL_BODY_TYPE_EXTENSION ||
- (parsed->body.ext != NULL &&
- strcmp(parsed->body.ext, test->body.ext) == 0))));
+ (parsed->body.type == test->body.type &&
+ (parsed->body.type != SMTP_PARAM_MAIL_BODY_TYPE_EXTENSION ||
+ (parsed->body.ext != NULL &&
+ strcmp(parsed->body.ext, test->body.ext) == 0))));
}
static void
test_smtp_mail_params_envid(const struct smtp_params_mail *test,
- const struct smtp_params_mail *parsed)
+ const struct smtp_params_mail *parsed)
{
- if (parsed->envid == NULL ||
- test->envid == NULL) {
+ if (parsed->envid == NULL || test->envid == NULL) {
test_out(t_strdup_printf("params.auth->localpart = %s",
parsed->envid),
(parsed->envid == test->envid));
static void
test_smtp_mail_params_ret(const struct smtp_params_mail *test,
- const struct smtp_params_mail *parsed)
+ const struct smtp_params_mail *parsed)
{
const char *ret_name = NULL;
static void
test_smtp_mail_params_size(const struct smtp_params_mail *test,
- const struct smtp_params_mail *parsed)
+ const struct smtp_params_mail *parsed)
{
test_out(t_strdup_printf("params.size = %"PRIuUOFF_T, parsed->size),
parsed->size == test->size);
static void
test_smtp_mail_params_extensions(const struct smtp_params_mail *test,
- const struct smtp_params_mail *parsed)
+ const struct smtp_params_mail *parsed)
{
const struct smtp_param *tparam, *pparam;
unsigned int i;
if (!array_is_created(&test->extra_params) ||
- array_count(&test->extra_params) == 0) {
+ array_count(&test->extra_params) == 0) {
test_out(t_strdup_printf("params.extra_params.count = %u",
- (!array_is_created(&parsed->extra_params) ? 0 :
- array_count(&parsed->extra_params))),
+ (!array_is_created(&parsed->extra_params) ?
+ 0 : array_count(&parsed->extra_params))),
(!array_is_created(&parsed->extra_params) ||
- array_count(&parsed->extra_params) == 0));
+ array_count(&parsed->extra_params) == 0));
return;
}
if (!array_is_created(&parsed->extra_params) ||
- array_count(&parsed->extra_params) == 0) {
+ array_count(&parsed->extra_params) == 0) {
test_out("params.extra_params.count = 0", FALSE);
return;
}
if (array_count(&test->extra_params) !=
- array_count(&parsed->extra_params)) {
+ array_count(&parsed->extra_params)) {
test_out(t_strdup_printf("params.extra_params.count = %u",
- (!array_is_created(&parsed->extra_params) ? 0 :
- array_count(&parsed->extra_params))), FALSE);
+ (!array_is_created(&parsed->extra_params) ?
+ 0 : array_count(&parsed->extra_params))), FALSE);
return;
}
tparam = array_idx(&test->extra_params, i);
pparam = array_idx(&parsed->extra_params, i);
- test_out(t_strdup_printf(
- "params.extra_params[%u] = [\"%s\"=\"%s\"]", i,
- pparam->keyword, pparam->value),
- strcmp(pparam->keyword, tparam->keyword) == 0 &&
+ test_out(t_strdup_printf("params.extra_params[%u] = [\"%s\"=\"%s\"]",
+ i, pparam->keyword, pparam->value),
+ strcmp(pparam->keyword, tparam->keyword) == 0 &&
((pparam->value == NULL && tparam->value == NULL) ||
(pparam->value != NULL && tparam->value != NULL &&
- strcmp(pparam->value, tparam->value) == 0)));
+ strcmp(pparam->value, tparam->value) == 0)));
}
}
test->body_extensions, ¶ms, &error_code, &error);
test_begin(t_strdup_printf("smtp mail params valid [%d]", i));
- test_out_reason(t_strdup_printf("parse(\"%s\")",
- test->input), ret >= 0, error);
+ test_out_reason(t_strdup_printf("parse(\"%s\")", test->input),
+ ret >= 0, error);
if (ret >= 0) {
string_t *encoded;
smtp_params_mail_write(encoded, test->caps, ¶ms);
output = (test->output == NULL ? test->input : test->output);
- test_out(t_strdup_printf
- ("encode() = \"%s\"", str_c(encoded)),
- strcmp(str_c(encoded), output) == 0);
+ test_out(t_strdup_printf("encode() = \"%s\"",
+ str_c(encoded)),
+ strcmp(str_c(encoded), output) == 0);
}
test_end();
} T_END;
/* AUTH */
{
.input = "AUTH=<>",
- },{
+ },
+ {
.input = "AUTH=++",
.caps = SMTP_CAPABILITY_AUTH
+ },
/* BODY */
- },{
+ {
.input = "BODY=8BITMIME",
- },{
+ },
+ {
.input = "BODY=BINARYMIME",
- },{
+ },
+ {
.input = "BODY=BINARYMIME",
.caps = SMTP_CAPABILITY_BINARYMIME
- },{
+ },
+ {
.input = "BODY=FROP",
.caps = SMTP_CAPABILITY_8BITMIME
+ },
/* ENVID */
- },{
+ {
.input = "ENVID=AABBCC",
- },{
+ },
+ {
.input = "ENVID=++",
.caps = SMTP_CAPABILITY_DSN
+ },
/* RET */
- },{
+ {
.input = "RET=FULL",
- },{
+ },
+ {
.input = "RET=HDR",
- },{
+ },
+ {
.input = "RET=FROP",
.caps = SMTP_CAPABILITY_DSN
+ },
/* SIZE */
- },{
+ {
.input = "SIZE=13",
- },{
+ },
+ {
.input = "SIZE=ABC",
.caps = SMTP_CAPABILITY_SIZE
}
test = &invalid_mail_params_parse_tests[i];
ret = smtp_params_mail_parse(pool_datastack_create(),
- test->input, test->caps, test->extensions, NULL,
- ¶ms, &error_code, &error);
+ test->input, test->caps,
+ test->extensions, NULL,
+ ¶ms, &error_code, &error);
test_begin(t_strdup_printf("smtp mail params invalid [%d]", i));
- test_out_reason(t_strdup_printf("parse(\"%s\")",
- test->input), ret < 0, error);
+ test_out_reason(t_strdup_printf("parse(\"%s\")", test->input),
+ ret < 0, error);
test_end();
} T_END;
}
static const struct valid_rcpt_params_parse_test
valid_rcpt_params_parse_tests[] = {
- /* AUTH */
- {
+ /* ORCPT */
#if 0 // FIXME: message_address_parser() does not allow bare localpart
// addresses.
+ {
+
.input = "ORCPT=rfc822;user+2Bdetail",
.caps = SMTP_CAPABILITY_DSN,
.params = {
.addr = &test_address2
}
}
- },{
+ },
#endif
+ {
.input = "ORCPT=rfc822;e+3Dmc2@example.com",
.caps = SMTP_CAPABILITY_DSN,
.params = {
.addr = &test_address3
}
}
+ },
/* NOTIFY */
- },{
+ {
.input = "",
.caps = SMTP_CAPABILITY_DSN,
.params = {
.notify = SMTP_PARAM_RCPT_NOTIFY_UNSPECIFIED,
}
- },{
+ },
+ {
.input = "NOTIFY=SUCCESS",
.caps = SMTP_CAPABILITY_DSN,
.params = {
.notify = SMTP_PARAM_RCPT_NOTIFY_SUCCESS,
}
- },{
+ },
+ {
.input = "NOTIFY=FAILURE",
.caps = SMTP_CAPABILITY_DSN,
.params = {
.notify = SMTP_PARAM_RCPT_NOTIFY_FAILURE,
}
- },{
+ },
+ {
.input = "NOTIFY=DELAY",
.caps = SMTP_CAPABILITY_DSN,
.params = {
.notify = SMTP_PARAM_RCPT_NOTIFY_DELAY,
}
- },{
+ },
+ {
.input = "NOTIFY=NEVER",
.caps = SMTP_CAPABILITY_DSN,
.params = {
.notify = SMTP_PARAM_RCPT_NOTIFY_NEVER,
}
- },{
+ },
+ {
.input = "NOTIFY=SUCCESS,FAILURE,DELAY",
.caps = SMTP_CAPABILITY_DSN,
.params = {
SMTP_PARAM_RCPT_NOTIFY_FAILURE |
SMTP_PARAM_RCPT_NOTIFY_DELAY,
}
+ },
/* <extensions> */
- },{
+ {
.input = "FROP=friep",
.caps = SMTP_CAPABILITY_SIZE,
.extensions = test_extensions,
}
}
}
- },{
+ },
+ {
.input = "FROP=friep FRUP=frml",
.extensions = test_extensions,
.params = {
static void
test_smtp_rcpt_params_orcpt(const struct smtp_params_rcpt *test,
- const struct smtp_params_rcpt *parsed)
+ const struct smtp_params_rcpt *parsed)
{
if (parsed->orcpt.addr == NULL) {
test_out("params.orcpt.addr = NULL",
}
if (parsed->orcpt.addr->localpart == NULL ||
- test->orcpt.addr->localpart == NULL) {
+ test->orcpt.addr->localpart == NULL) {
test_out(t_strdup_printf("params.orcpt.addr->localpart = %s",
parsed->orcpt.addr->localpart),
(parsed->orcpt.addr->localpart ==
- test->orcpt.addr->localpart));
+ test->orcpt.addr->localpart));
} else {
test_out(t_strdup_printf("params.orcpt.addr->localpart = \"%s\"",
parsed->orcpt.addr->localpart),
test->orcpt.addr->localpart) == 0);
}
if (parsed->orcpt.addr->domain == NULL ||
- test->orcpt.addr->domain == NULL) {
+ test->orcpt.addr->domain == NULL) {
test_out(t_strdup_printf("params.orcpt.addr->domain = %s",
parsed->orcpt.addr->domain),
(parsed->orcpt.addr->domain ==
- test->orcpt.addr->domain));
+ test->orcpt.addr->domain));
} else {
test_out(t_strdup_printf("params.orcpt.addr->domain = \"%s\"",
parsed->orcpt.addr->domain),
static void
test_smtp_rcpt_params_notify(const struct smtp_params_rcpt *test,
- const struct smtp_params_rcpt *parsed)
+ const struct smtp_params_rcpt *parsed)
{
string_t *notify_name;
static void
test_smtp_rcpt_params_extensions(const struct smtp_params_rcpt *test,
- const struct smtp_params_rcpt *parsed)
+ const struct smtp_params_rcpt *parsed)
{
const struct smtp_param *tparam, *pparam;
unsigned int i;
if (!array_is_created(&test->extra_params) ||
- array_count(&test->extra_params) == 0) {
+ array_count(&test->extra_params) == 0) {
test_out(t_strdup_printf("params.extra_params.count = %u",
- (!array_is_created(&parsed->extra_params) ? 0 :
- array_count(&parsed->extra_params))),
+ (!array_is_created(&parsed->extra_params) ?
+ 0 : array_count(&parsed->extra_params))),
(!array_is_created(&parsed->extra_params) ||
- array_count(&parsed->extra_params) == 0));
+ array_count(&parsed->extra_params) == 0));
return;
}
if (!array_is_created(&parsed->extra_params) ||
- array_count(&parsed->extra_params) == 0) {
+ array_count(&parsed->extra_params) == 0) {
test_out("params.extra_params.count = 0", FALSE);
return;
}
if (array_count(&test->extra_params) !=
- array_count(&parsed->extra_params)) {
+ array_count(&parsed->extra_params)) {
test_out(t_strdup_printf("params.extra_params.count = %u",
(!array_is_created(&parsed->extra_params) ? 0 :
array_count(&parsed->extra_params))), FALSE);
tparam = array_idx(&test->extra_params, i);
pparam = array_idx(&parsed->extra_params, i);
- test_out(t_strdup_printf(
- "params.extra_params[%u] = [\"%s\"=\"%s\"]", i,
- pparam->keyword, pparam->value),
+ test_out(t_strdup_printf("params.extra_params[%u] = [\"%s\"=\"%s\"]",
+ i, pparam->keyword, pparam->value),
strcmp(pparam->keyword, tparam->keyword) == 0 &&
((pparam->value == NULL && tparam->value == NULL) ||
(pparam->value != NULL && tparam->value != NULL &&
- strcmp(pparam->value, tparam->value) == 0)));
+ strcmp(pparam->value, tparam->value) == 0)));
}
}
test = &valid_rcpt_params_parse_tests[i];
ret = smtp_params_rcpt_parse(pool_datastack_create(),
- test->input, test->caps, test->extensions,
- ¶ms, &error_code, &error);
+ test->input, test->caps,
+ test->extensions,
+ ¶ms, &error_code, &error);
test_begin(t_strdup_printf("smtp rcpt params valid [%d]", i));
test_out_reason(t_strdup_printf("parse(\"%s\")",
/* DSN */
{
.input = "ORCPT=rfc822;frop@example.com",
- },{
+ },
+ {
.input = "ORCPT=++",
.caps = SMTP_CAPABILITY_DSN
- },{
+ },
+ {
.input = "ORCPT=rfc822;++",
.caps = SMTP_CAPABILITY_DSN
- },{
+ },
+ {
.input = "NOTIFY=SUCCESS",
- },{
+ },
+ {
.input = "NOTIFY=FROP",
.caps = SMTP_CAPABILITY_DSN
- },{
+ },
+ {
.input = "NOTIFY=NEVER,SUCCESS",
.caps = SMTP_CAPABILITY_DSN
}
test = &invalid_rcpt_params_parse_tests[i];
ret = smtp_params_rcpt_parse(pool_datastack_create(),
- test->input, test->caps, test->extensions,
- ¶ms, &error_code, &error);
+ test->input, test->caps,
+ test->extensions,
+ ¶ms, &error_code, &error);
test_begin(t_strdup_printf("smtp rcpt params invalid [%d]", i));
- test_out_reason(t_strdup_printf("parse(\"%s\")",
- test->input), ret < 0, error);
+ test_out_reason(t_strdup_printf("parse(\"%s\")", test->input),
+ ret < 0, error);
test_end();
} T_END;
}