8 # Here, we're going to shoot messages through a set of things that can
11 # First, we're going to send mesages to receive.
12 # To do so, we'll first send a message to submit,
13 # then send messages to the newly created bugnumber.
16 use File::Temp qw(tempdir);
18 use Debbugs::MIME qw(create_mime_message);
19 use File::Basename qw(dirname basename);
20 # The test functions are placed here to make things easier
22 use DebbugsTest qw(:all);
25 # HTTP::Server:::Simple defines a SIG{CHLD} handler that breaks system; undef it here.
27 my %config = create_debbugs_configuration();
30 my $sendmail_dir = $config{sendmail_dir};
31 my $spool_dir = $config{spool_dir};
32 my $config_dir = $config{config_dir};
36 # We're going to use create mime message to create these messages, and
37 # then just send them to receive.
39 send_message(to=>'submit@bugs.something',
40 headers => [To => 'submit@bugs.something',
41 From => 'foo@bugs.something',
42 Subject => 'Submiting a bug',
44 body => <<EOF) or fail('Unable to send message');
51 # now we check to see that we have a bug, and nextnumber has been incremented
52 ok(-e "$spool_dir/db-h/01/1.log",'log file created');
53 ok(-e "$spool_dir/db-h/01/1.summary",'sumary file created');
54 ok(-e "$spool_dir/db-h/01/1.status",'status file created');
55 ok(-e "$spool_dir/db-h/01/1.report",'report file created');
57 # next, we check to see that (at least) the proper messages have been
58 # sent out. 1) ack to submitter 2) mail to maintainer
60 # This keeps track of the previous size of the sendmail directory
63 num_messages_sent($SD_SIZE,2,
65 'submit messages appear to have been sent out properly',
69 # now send a message to the bug
71 send_message(to => '1@bugs.something',
72 headers => [To => '1@bugs.something',
73 From => 'foo@bugs.something',
74 Subject => 'Sending a message to a bug',
76 body => <<EOF) or fail('sending message to 1@bugs.someting failed');
84 num_messages_sent($SD_SIZE,2,
86 '1@bugs.something messages appear to have been sent out properly');
88 # just check to see that control doesn't explode
89 send_message(to => 'control@bugs.something',
90 headers => [To => 'control@bugs.something',
91 From => 'foo@bugs.something',
92 Subject => 'Munging a bug',
94 body => <<EOF) or fail 'message to control@bugs.something failed';
101 num_messages_sent($SD_SIZE,1,
103 'control@bugs.something messages appear to have been sent out properly');
104 # now we need to check to make sure the control message was processed without errors
105 ok(system('sh','-c','find '.$sendmail_dir.q( -type f | xargs grep -q "Subject: Processed: Munging a bug")) == 0,
106 'control@bugs.something message was parsed without errors');
107 # now we need to check to make sure that the control message actually did anything
108 # This is an eval because $ENV{DEBBUGS_CONFIG_FILE} isn't set at BEGIN{} time
109 eval "use Debbugs::Status qw(read_bug writebug);";
110 my $status = read_bug(bug=>1);
111 ok($status->{subject} eq 'new title','bug 1 retitled');
112 ok($status->{severity} eq 'wishlist','bug 1 wishlisted');
114 # now we're going to go through and methododically test all of the control commands.
115 my @control_commands =
117 clone => {command => 'clone',
119 status_key => 'package',
120 status_value => 'foo',
123 merge => {command => 'merge',
125 status_key => 'mergedwith',
128 unmerge => {command => 'unmerge',
130 status_key => 'mergedwith',
135 test_control_commands(\%config,
138 send_message(to => 'control@bugs.something',
139 headers => [To => 'control@bugs.something',
140 From => 'foo@bugs.something',
141 Subject => "Munging a bug with lots of stuff",
143 body => <<'EOF') or fail 'message to control@bugs.something failed';
145 clone 2 -1 -2 -3 -4 -5 -6
148 submitter 2 fleb@bleh.com
149 tag 2 unreproducible moreinfo
155 forwarded 2 http://example.com/2
165 test_control_commands(\%config,
166 forcemerge => {command => 'forcemerge',
167 value => "2 3\nseverity 2 minor",
168 status_key => 'mergedwith',
172 unmerge => {command => 'unmerge',
174 status_key => 'mergedwith',
178 forcemerge => {command => 'forcemerge',
180 status_key => 'mergedwith',
181 status_value => '2 5',
183 forcemerge => {command => 'forcemerge',
185 status_key => 'mergedwith',
186 status_value => '2 5 6',
188 merge => {command => 'merge',
190 status_key => 'mergedwith',