3 use Test::More tests => 9;
10 # Here, we're going to shoot messages through a set of things that can
13 # First, we're going to send mesages to receive.
14 # To do so, we'll first send a message to submit,
15 # then send messages to the newly created bugnumber.
18 use File::Temp qw(tempdir);
20 use Debbugs::MIME qw(create_mime_message);
21 use File::Basename qw(dirname basename);
22 # The test functions are placed here to make things easier
24 use DebbugsTest qw(:all);
26 use Encode qw(decode encode decode_utf8 encode_utf8);
28 # HTTP::Server:::Simple defines a SIG{CHLD} handler that breaks system; undef it here.
32 %config = create_debbugs_configuration();
38 my $sendmail_dir = $config{sendmail_dir};
39 my $spool_dir = $config{spool_dir};
40 my $config_dir = $config{config_dir};
44 # We're going to use create mime message to create these messages, and
45 # then just send them to receive.
47 send_message(to=>'submit@bugs.something',
48 headers => [To => 'submit@bugs.something',
49 From => 'föoff@bugs.something',
50 Subject => 'Submiting a bug',
52 body => <<EOF,attachments => [{Type=>"text/plain",Charset=>"utf-8",Data=>encode_utf8(<<EOF2)}]) or fail('Unable to send message');
58 This is the silly bug's test ütff8 attachment.
63 # now we check to see that we have a bug, and nextnumber has been incremented
64 ok(-e "$spool_dir/db-h/01/1.log",'log file created');
65 ok(-e "$spool_dir/db-h/01/1.summary",'sumary file created');
66 ok(-e "$spool_dir/db-h/01/1.status",'status file created');
67 ok(-e "$spool_dir/db-h/01/1.report",'report file created');
68 ok(system('sh','-c','[ $(grep "attachment." '.$spool_dir.'/db-h/01/1.log|grep -v "ütff8"|wc -l) -eq 0 ]') == 0,
69 'Everything attachment is escaped properly');
71 # next, we check to see that (at least) the proper messages have been
72 # sent out. 1) ack to submitter 2) mail to maintainer
74 # This keeps track of the previous size of the sendmail directory
77 num_messages_sent($SD_SIZE,2,
79 'submit messages appear to have been sent out properly',
83 # now send a message to the bug
85 send_message(to => '1@bugs.something',
86 headers => [To => '1@bugs.something',
87 From => 'föoff@bugs.something',
88 Subject => 'Sending a message to a bug',
90 body => <<EOF) or fail('sending message to 1@bugs.someting failed');
98 num_messages_sent($SD_SIZE,2,
100 '1@bugs.something messages appear to have been sent out properly');
102 # just check to see that control doesn't explode
103 send_message(to => 'control@bugs.something',
104 headers => [To => 'control@bugs.something',
105 From => 'föoff@bugs.something',
106 Subject => 'Munging a bug',
108 body => <<EOF) or fail 'message to control@bugs.something failed';
110 retitle 1 ütff8 title encoding test
115 num_messages_sent($SD_SIZE,1,
117 'control@bugs.something messages appear to have been sent out properly');
118 # now we need to check to make sure the control message was processed without errors
119 # now we need to check to make sure that the control message actually did anything
120 # This is an eval because $ENV{DEBBUGS_CONFIG_FILE} isn't set at BEGIN{} time
121 eval "use Debbugs::Status qw(read_bug writebug);";
122 ok(system('bin/debbugs-rebuild-index.db')==0,'debbugs-rebuild-index seems to work');