2 # test_bts tests a running BTS by sending mail to it, and is released
3 # under the terms of the GPL version 2, or any later version, at your
4 # option. See the file README and COPYING for more information.
5 # Copyright 2006 by Don Armstrong <don@debian.org>.
18 test_bts - Test a running bts install
25 --bug, -b bug number to mail
26 --host, -h host to send mail to
27 --control, -c whether to send control messages (off by default)
28 --process, -p whether to send process messages (on by default)
29 --submit, -s whether a new bug is created (off by default)
30 --quiet, -q disable output (off by default)
31 --debug, -d debugging level (Default 0)
32 --help, -h display this help
33 --man, -m display manual
45 The host running the bts
47 =item B<--control, -c>
49 Whether control messages are sent; defaults to false.
51 =item B<--process, -p>
53 Whether messages are sent to process (bugnum@host)
57 Whether a new bug is created by a message to submit; not enabled by default.
65 Debug verbosity. (Default 0)
69 Display brief useage information.
79 test_bts --bug 7 --host donbugs.donarmstrong.com
85 use Debbugs::Mail qw(send_mail_message);
86 use Debbugs::MIME qw(create_mime_message);
89 use vars qw($DEBUG $VERBOSE);
91 # XXX parse config file
93 my %options = (debug => 0,
105 GetOptions(\%options,'host|H=s','bug|b=s','control|c!','submit|s!',
106 'process|p!','from|f=s','quiet|q+',
107 'debug|d+','help|h|?','man|m');
111 $ERRORS .= "--from must be set\n" if not defined $options{from};
112 $ERRORS .= "--host must be set\n" if not defined $options{host};
113 $ERRORS .= "--bug must be set\n" if not defined $options{bug};
114 pod2usage($ERRORS) if length $ERRORS;
116 pod2usage() if $options{help};
117 pod2usage({verbose=>2}) if $options{man};
120 $DEBUG = $options{debug};
122 $VERBOSE = 1 - $options{quiet};
124 if ($options{process}) {
125 my @standard_headers = ([],
126 ['X-Debbugs-No-Ack:','yes no ack'],
129 my %process_messages = ('-maintonly' => \@standard_headers,
130 '-quiet' => \@standard_headers,
131 '-forwarded' => \@standard_headers,
132 '-done' => \@standard_headers,
133 '-submitter' => \@standard_headers,
134 '' => \@standard_headers,
136 my $message_count = 0;
137 for my $addr (keys %process_messages) {
138 for my $header (@{$process_messages{$addr}}) {
141 create_mime_message([To => "$options{bug}$addr\@$options{host}",
142 From => $options{from},
143 Subject => "message $message_count to $addr from test_bts",
146 This is a testing message from test_bts
147 This message was sent:
148 To: $options{bug}$addr\@$options{host}
150 Subject: message $message_count to $options{bug}$addr\@$options{host} from test_bts
152 with additional headers:
155 If you are seeing this, and have no idea what this means, please
156 ignore this message. If you are sure that this message has been sent
157 in error please send mail to $options{from} so they can stop sending
158 stupid messages to you.
160 If you are reading this message in a BTS, it's only a testing message.
161 Please ignore it... it shouldn't have been sent to a public one, but
165 send_mail_message(message => $message,
166 recipients => "$options{bug}$addr\@$options{host}",
171 if ($options{control}) {
172 die "Not implemented";
174 if ($options{submit}) {
175 die "Not implemented";