dovecot-2.2-pigeonhole: testsuite: Fixed default envelope extrac...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Fri Jul 24 21:54:30 UTC 2015
details: http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/4359d879bd1d
changeset: 2082:4359d879bd1d
user: Stephan Bosch <stephan at rename-it.nl>
date: Fri Jul 24 23:54:25 2015 +0200
description:
testsuite: Fixed default envelope extraction fron test message.
diffstat:
src/testsuite/testsuite-message.c | 46 +++++++++++++++++++++++++++++++-------
1 files changed, 37 insertions(+), 9 deletions(-)
diffs (95 lines):
diff -r e97b533c0be6 -r 4359d879bd1d src/testsuite/testsuite-message.c
--- a/src/testsuite/testsuite-message.c Fri Jul 24 23:24:33 2015 +0200
+++ b/src/testsuite/testsuite-message.c Fri Jul 24 23:54:25 2015 +0200
@@ -4,6 +4,7 @@
#include "lib.h"
#include "str.h"
#include "istream.h"
+#include "message-address.h"
#include "mail-storage.h"
#include "master-service.h"
@@ -38,6 +39,23 @@
pool_t message_pool;
+static const char *
+testsuite_message_get_address(struct mail *mail, const char *header)
+{
+ struct message_address *addr;
+ const char *str;
+
+ if (mail_get_first_header(mail, header, &str) <= 0)
+ return NULL;
+ addr = message_address_parse(pool_datastack_create(),
+ (const unsigned char *)str,
+ strlen(str), 1, FALSE);
+ return (addr == NULL ||
+ addr->mailbox == NULL || *addr->mailbox == '\0' ? NULL :
+ ( addr->domain == NULL || *addr->domain == '\0' ? addr->mailbox :
+ t_strconcat(addr->mailbox, "@", addr->domain, NULL)));
+}
+
static void testsuite_message_set_data(struct mail *mail)
{
const char *recipient = NULL, *sender = NULL;
@@ -47,27 +65,36 @@
*/
/* Get recipient address */
- (void)mail_get_first_header(mail, "Envelope-To", &recipient);
+ recipient = testsuite_message_get_address(mail, "Envelope-To");
if ( recipient == NULL )
- (void)mail_get_first_header(mail, "To", &recipient);
+ recipient = testsuite_message_get_address(mail, "To");
if ( recipient == NULL )
recipient = "recipient at example.com";
/* Get sender address */
- (void)mail_get_first_header(mail, "Return-path", &sender);
+ sender = testsuite_message_get_address(mail, "Return-path");
if ( sender == NULL )
- (void)mail_get_first_header(mail, "Sender", &sender);
+ sender = testsuite_message_get_address(mail, "Sender");
if ( sender == NULL )
- (void)mail_get_first_header(mail, "From", &sender);
+ sender = testsuite_message_get_address(mail, "From");
if ( sender == NULL )
sender = "sender at example.com";
memset(&testsuite_msgdata, 0, sizeof(testsuite_msgdata));
testsuite_msgdata.mail = mail;
testsuite_msgdata.auth_user = sieve_tool_get_username(sieve_tool);
- testsuite_msgdata.return_path = sender;
- testsuite_msgdata.orig_envelope_to = recipient;
- testsuite_msgdata.final_envelope_to = recipient;
+
+ str_truncate(envelope_from, 0);
+ str_append(envelope_from, sender);
+ testsuite_msgdata.return_path = str_c(envelope_from);
+
+ str_truncate(envelope_to, 0);
+ str_append(envelope_to, recipient);
+ testsuite_msgdata.final_envelope_to = str_c(envelope_to);
+
+ str_truncate(envelope_orig_to, 0);
+ str_append(envelope_orig_to, recipient);
+ testsuite_msgdata.orig_envelope_to = str_c(envelope_orig_to);
(void)mail_get_first_header(mail, "Message-ID", &testsuite_msgdata.id);
}
@@ -80,12 +107,13 @@
str_append(default_message, _default_message_data);
testsuite_mail = sieve_tool_open_data_as_mail(sieve_tool, default_message);
- testsuite_message_set_data(testsuite_mail);
envelope_to = str_new(message_pool, 256);
envelope_orig_to = str_new(message_pool, 256);
envelope_from = str_new(message_pool, 256);
envelope_auth = str_new(message_pool, 256);
+
+ testsuite_message_set_data(testsuite_mail);
}
void testsuite_message_set_string
More information about the dovecot-cvs
mailing list