diff options
author | David Lawrence <dkl@mozilla.com> | 2016-02-26 18:57:55 +0100 |
---|---|---|
committer | David Lawrence <dkl@mozilla.com> | 2016-02-26 18:57:55 +0100 |
commit | 9b6ec1f545da1cc4088ddf9cc117747954e58e65 (patch) | |
tree | 6cc3eb342a740b795052e587756f6c33438b772a /xt/extensions/QA | |
parent | 6f70920f2d2bb038a371e3cb3debff44f7001fa8 (diff) | |
download | bugzilla-9b6ec1f545da1cc4088ddf9cc117747954e58e65.tar.gz bugzilla-9b6ec1f545da1cc4088ddf9cc117747954e58e65.tar.xz |
Bug 1069799 - move the QA repository into the main repository
r=LpSolit
Diffstat (limited to 'xt/extensions/QA')
-rw-r--r-- | xt/extensions/QA/Config.pm | 22 | ||||
-rw-r--r-- | xt/extensions/QA/Extension.pm | 74 | ||||
-rw-r--r-- | xt/extensions/QA/lib/Util.pm | 28 | ||||
-rw-r--r-- | xt/extensions/QA/template/en/default/hook/README | 5 | ||||
-rw-r--r-- | xt/extensions/QA/template/en/default/pages/qa/email_in.html.tmpl | 7 | ||||
-rw-r--r-- | xt/extensions/QA/template/en/default/qa/README | 16 | ||||
-rw-r--r-- | xt/extensions/QA/template/en/default/qa/create_bug.txt.tmpl | 17 | ||||
-rw-r--r-- | xt/extensions/QA/template/en/default/qa/create_bug_with_headers.txt.tmpl | 33 | ||||
-rw-r--r-- | xt/extensions/QA/template/en/default/qa/results.html.tmpl | 28 | ||||
-rw-r--r-- | xt/extensions/QA/template/en/default/qa/update_bug.txt.tmpl | 13 | ||||
-rw-r--r-- | xt/extensions/QA/template/en/default/qa/update_bug_with_headers.txt.tmpl | 29 | ||||
-rw-r--r-- | xt/extensions/QA/web/README | 7 |
12 files changed, 279 insertions, 0 deletions
diff --git a/xt/extensions/QA/Config.pm b/xt/extensions/QA/Config.pm new file mode 100644 index 000000000..b4f6bc9a2 --- /dev/null +++ b/xt/extensions/QA/Config.pm @@ -0,0 +1,22 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +package Bugzilla::Extension::QA; + +use 5.10.1; +use strict; +use warnings; + +use constant NAME => 'QA'; + +use constant REQUIRED_MODULES => [ +]; + +use constant OPTIONAL_MODULES => [ +]; + +__PACKAGE__->NAME; diff --git a/xt/extensions/QA/Extension.pm b/xt/extensions/QA/Extension.pm new file mode 100644 index 000000000..5befe3e36 --- /dev/null +++ b/xt/extensions/QA/Extension.pm @@ -0,0 +1,74 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +package Bugzilla::Extension::QA; + +use 5.10.1; +use strict; +use warnings; + +use base qw(Bugzilla::Extension); + +use Bugzilla::Extension::QA::Util; +use Bugzilla::Constants; +use Bugzilla::Error; +use Bugzilla::Util; +use Bugzilla::Bug; +use Bugzilla::User; + +our $VERSION = '1.0'; + +sub page_before_template { + my ($self, $args) = @_; + return if $args->{page_id} ne 'qa/email_in.html'; + + my $template = Bugzilla->template; + my $cgi = Bugzilla->cgi; + print $cgi->header; + + # Needed to make sure he can access and edit bugs. + my $user = Bugzilla::User->check($cgi->param('sender')); + Bugzilla->set_user($user); + + my ($output, $tmpl_file); + my $action = $cgi->param('action') || ''; + my $vars = { sender => $user, action => $action, pid => $$ }; + + if ($action eq 'create') { + $tmpl_file = 'qa/create_bug.txt.tmpl'; + } + elsif ($action eq 'create_with_headers') { + $tmpl_file = 'qa/create_bug_with_headers.txt.tmpl'; + } + elsif ($action =~ /^update(_with_headers)?$/) { + my $f = $1 || ''; + $tmpl_file = "qa/update_bug$f.txt.tmpl"; + my $bug = Bugzilla::Bug->check($cgi->param('bug_id')); + $vars->{bug_id} = $bug->id; + } + else { + ThrowUserError('unknown_action', { action => $action }); + } + + $template->process($tmpl_file, $vars, \$output) + or ThrowTemplateError($template->error()); + + my $file = "/tmp/email_in_$$.txt"; + open(FH, '>', $file); + print FH $output; + close FH; + + $output = `email_in.pl -v < $file 2>&1`; + unlink $file; + + parse_output($output, $vars); + + $template->process('qa/results.html.tmpl', $vars) + or ThrowTemplateError($template->error()); +} + +__PACKAGE__->NAME; diff --git a/xt/extensions/QA/lib/Util.pm b/xt/extensions/QA/lib/Util.pm new file mode 100644 index 000000000..e299adcc9 --- /dev/null +++ b/xt/extensions/QA/lib/Util.pm @@ -0,0 +1,28 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +package Bugzilla::Extension::QA::Util; + +use 5.10.1; +use strict; +use warnings; + +use base qw(Exporter); + +our @EXPORT = qw( + parse_output +); + +sub parse_output { + my ($output, $vars) = @_; + + $vars->{error} = ($output =~ /software error/i) ? 1 : 0; + $vars->{output} = $output; + $vars->{bug_id} ||= ($output =~ /Created bug (\d+)/i) ? $1 : undef; +} + +1; diff --git a/xt/extensions/QA/template/en/default/hook/README b/xt/extensions/QA/template/en/default/hook/README new file mode 100644 index 000000000..3f1e487e2 --- /dev/null +++ b/xt/extensions/QA/template/en/default/hook/README @@ -0,0 +1,5 @@ +Template hooks go in this directory. Template hooks are called in normal +Bugzilla templates like [% Hook.process('some-hook') %]. +More information about them can be found in the documentation of +Bugzilla::Extension. (Do "perldoc Bugzilla::Extension" from the main +Bugzilla directory to see that documentation.) diff --git a/xt/extensions/QA/template/en/default/pages/qa/email_in.html.tmpl b/xt/extensions/QA/template/en/default/pages/qa/email_in.html.tmpl new file mode 100644 index 000000000..bcb75107d --- /dev/null +++ b/xt/extensions/QA/template/en/default/pages/qa/email_in.html.tmpl @@ -0,0 +1,7 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] diff --git a/xt/extensions/QA/template/en/default/qa/README b/xt/extensions/QA/template/en/default/qa/README new file mode 100644 index 000000000..604d00cfe --- /dev/null +++ b/xt/extensions/QA/template/en/default/qa/README @@ -0,0 +1,16 @@ +Normal templates go in this directory. You can load them in your +code like this: + +use Bugzilla::Error; +my $template = Bugzilla->template; +$template->process('qa/some-template.html.tmpl') + or ThrowTemplateError($template->error()); + +That would be how to load a file called some-template.html.tmpl that +was in this directory. + +Note that you have to be careful that the full path of your template +never conflicts with a template that exists in Bugzilla or in +another extension, or your template might override that template. That's why +we created this directory called 'qa' for you, so you +can put your templates in here to help avoid conflicts. diff --git a/xt/extensions/QA/template/en/default/qa/create_bug.txt.tmpl b/xt/extensions/QA/template/en/default/qa/create_bug.txt.tmpl new file mode 100644 index 000000000..5a83a6c5b --- /dev/null +++ b/xt/extensions/QA/template/en/default/qa/create_bug.txt.tmpl @@ -0,0 +1,17 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +From: [% sender.email %] +Subject: [% terms.Bug %] created using email_in.pl +Content-Type: text/plain; charset="UTF-8" + +@product = TestProduct +@component = TestComponent +@version = unspecified + +This [% terms.bug %] has been created using email_in.pl (PID: [% pid %]). diff --git a/xt/extensions/QA/template/en/default/qa/create_bug_with_headers.txt.tmpl b/xt/extensions/QA/template/en/default/qa/create_bug_with_headers.txt.tmpl new file mode 100644 index 000000000..997378343 --- /dev/null +++ b/xt/extensions/QA/template/en/default/qa/create_bug_with_headers.txt.tmpl @@ -0,0 +1,33 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +From - Sat Jan 1 18:38:17 2011 +X-Account-Key: account2 +X-UIDL: GmailId12d42784d83cb4a4 +X-Mozilla-Status: 0011 +X-Mozilla-Status2: 00000000 +X-Mozilla-Keys: +Return-Path: <foo@bar.com> +Received: from [192.168.0.2] (provider.com [51.162.153.14]) + by mx.google.com with ESMTPS id m10sm12712256wbc.4.2011.01.01.09.38.01 + (version=TLSv1/SSLv3 cipher=RC4-MD5); + Sat, 01 Jan 2011 09:38:01 -0800 (PST) +Message-ID: <4D1F6580.9060076@gmail.com> +Date: Sat, 01 Jan 2011 18:38:08 +0100 +User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7 +MIME-Version: 1.0 +From: [% sender.email %] +Subject: [% terms.Bug %] created using email_in.pl (with email headers) +Content-Type: text/plain; charset="UTF-8" +Content-Transfer-Encoding: 8bit + +@product = TestProduct +@component = TestComponent +@version = unspecified + +This [% terms.bug %] has been created using email_in.pl (PID: [% pid %]) with email headers. diff --git a/xt/extensions/QA/template/en/default/qa/results.html.tmpl b/xt/extensions/QA/template/en/default/qa/results.html.tmpl new file mode 100644 index 000000000..a2f812697 --- /dev/null +++ b/xt/extensions/QA/template/en/default/qa/results.html.tmpl @@ -0,0 +1,28 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +[% title = BLOCK %] + [% IF error %] + Unexpected error + [% ELSE %] + email_in.pl output + [% END %] +[% END %] + +[% PROCESS global/header.html.tmpl %] + +<h1>Action '[% action FILTER html %]' successful</h1> + +<div> +<p>PID: <span id="pid">[% pid FILTER html %]</span></p> +<p>[%+ terms.Bug %] ID: <span id="bug_id">[% bug_id FILTER html %]</span></p> + +<p>Full output:</p> +<pre id="output">[% output FILTER html_light %]</pre> + +[% PROCESS global/footer.html.tmpl %] diff --git a/xt/extensions/QA/template/en/default/qa/update_bug.txt.tmpl b/xt/extensions/QA/template/en/default/qa/update_bug.txt.tmpl new file mode 100644 index 000000000..f37c00262 --- /dev/null +++ b/xt/extensions/QA/template/en/default/qa/update_bug.txt.tmpl @@ -0,0 +1,13 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +From: [% sender.email %] +Subject: [[% terms.Bug %] [%+ bug_id %]] This subject is ignored, only the [% terms.bug %] ID matters +Content-Type: text/plain; charset="UTF-8" + +Comment added by email_in.pl (PID: [% pid %]). No other changes. diff --git a/xt/extensions/QA/template/en/default/qa/update_bug_with_headers.txt.tmpl b/xt/extensions/QA/template/en/default/qa/update_bug_with_headers.txt.tmpl new file mode 100644 index 000000000..fd093d3b0 --- /dev/null +++ b/xt/extensions/QA/template/en/default/qa/update_bug_with_headers.txt.tmpl @@ -0,0 +1,29 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +From - Sat Jan 1 18:38:17 2011 +X-Account-Key: account2 +X-UIDL: GmailId12d42784d83cb4a4 +X-Mozilla-Status: 0011 +X-Mozilla-Status2: 00000000 +X-Mozilla-Keys: +Return-Path: <foo@bar.com> +Received: from [192.168.0.2] (provider.com [51.162.153.14]) + by mx.google.com with ESMTPS id m10sm12712256wbc.4.2011.01.01.09.38.01 + (version=TLSv1/SSLv3 cipher=RC4-MD5); + Sat, 01 Jan 2011 09:38:01 -0800 (PST) +Message-ID: <4D1F6580.9060076@gmail.com> +Date: Sat, 01 Jan 2011 18:38:08 +0100 +User-Agent: Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7 +MIME-Version: 1.0 +From: [% sender.email %] +Subject: [[% terms.Bug %] [%+ bug_id %]] This subject is ignored, only the [% terms.bug %] ID matters +Content-Type: text/plain; charset="UTF-8" +Content-Transfer-Encoding: 8bit + +Comment added by email_in.pl (PID: [% pid %]) with email headers. No other changes. diff --git a/xt/extensions/QA/web/README b/xt/extensions/QA/web/README new file mode 100644 index 000000000..23456410f --- /dev/null +++ b/xt/extensions/QA/web/README @@ -0,0 +1,7 @@ +Web-accessible files, like JavaScript, CSS, and images go in this +directory. You can reference them directly in your HTML. For example, +if you have a file called "style.css" and your extension is called +"Foo", you would put it in "extensions/Foo/web/style.css", and then +you could link to it in HTML like: + +<link href="extensions/Foo/web/style.css" rel="stylesheet" type="text/css">
\ No newline at end of file |