summaryrefslogtreecommitdiffstats
path: root/qa/extensions/QA
diff options
context:
space:
mode:
authorDavid Lawrence <dkl@mozilla.com>2015-06-25 05:35:16 +0200
committerDavid Lawrence <dkl@mozilla.com>2015-06-25 05:35:16 +0200
commita6238e079b4e8e62d3e23f019e0895c626133c83 (patch)
tree5c840202b0e02237a9a6b6acfdd613d78d38624a /qa/extensions/QA
parent28f425dac57db417b2a701fa99ef4ad73da0a729 (diff)
downloadbugzilla-a6238e079b4e8e62d3e23f019e0895c626133c83.tar.gz
bugzilla-a6238e079b4e8e62d3e23f019e0895c626133c83.tar.xz
Bug 1144485: Adapt upstream Selenium test suite to BMO
Diffstat (limited to 'qa/extensions/QA')
-rw-r--r--qa/extensions/QA/Config.pm20
-rw-r--r--qa/extensions/QA/Extension.pm71
-rw-r--r--qa/extensions/QA/lib/Util.pm25
-rw-r--r--qa/extensions/QA/template/en/default/pages/qa/email_in.html.tmpl7
-rw-r--r--qa/extensions/QA/template/en/default/qa/create_bug.txt.tmpl17
-rw-r--r--qa/extensions/QA/template/en/default/qa/create_bug_with_headers.txt.tmpl33
-rw-r--r--qa/extensions/QA/template/en/default/qa/results.html.tmpl28
-rw-r--r--qa/extensions/QA/template/en/default/qa/update_bug.txt.tmpl13
-rw-r--r--qa/extensions/QA/template/en/default/qa/update_bug_with_headers.txt.tmpl29
9 files changed, 243 insertions, 0 deletions
diff --git a/qa/extensions/QA/Config.pm b/qa/extensions/QA/Config.pm
new file mode 100644
index 000000000..59799ec6b
--- /dev/null
+++ b/qa/extensions/QA/Config.pm
@@ -0,0 +1,20 @@
+# 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 strict;
+
+use constant NAME => 'QA';
+
+use constant REQUIRED_MODULES => [
+];
+
+use constant OPTIONAL_MODULES => [
+];
+
+__PACKAGE__->NAME;
diff --git a/qa/extensions/QA/Extension.pm b/qa/extensions/QA/Extension.pm
new file mode 100644
index 000000000..b5f404d74
--- /dev/null
+++ b/qa/extensions/QA/Extension.pm
@@ -0,0 +1,71 @@
+# 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 strict;
+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/qa/extensions/QA/lib/Util.pm b/qa/extensions/QA/lib/Util.pm
new file mode 100644
index 000000000..9bc2d8dbb
--- /dev/null
+++ b/qa/extensions/QA/lib/Util.pm
@@ -0,0 +1,25 @@
+# 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 strict;
+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/qa/extensions/QA/template/en/default/pages/qa/email_in.html.tmpl b/qa/extensions/QA/template/en/default/pages/qa/email_in.html.tmpl
new file mode 100644
index 000000000..bcb75107d
--- /dev/null
+++ b/qa/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/qa/extensions/QA/template/en/default/qa/create_bug.txt.tmpl b/qa/extensions/QA/template/en/default/qa/create_bug.txt.tmpl
new file mode 100644
index 000000000..5a83a6c5b
--- /dev/null
+++ b/qa/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/qa/extensions/QA/template/en/default/qa/create_bug_with_headers.txt.tmpl b/qa/extensions/QA/template/en/default/qa/create_bug_with_headers.txt.tmpl
new file mode 100644
index 000000000..997378343
--- /dev/null
+++ b/qa/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/qa/extensions/QA/template/en/default/qa/results.html.tmpl b/qa/extensions/QA/template/en/default/qa/results.html.tmpl
new file mode 100644
index 000000000..a2f812697
--- /dev/null
+++ b/qa/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/qa/extensions/QA/template/en/default/qa/update_bug.txt.tmpl b/qa/extensions/QA/template/en/default/qa/update_bug.txt.tmpl
new file mode 100644
index 000000000..f37c00262
--- /dev/null
+++ b/qa/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/qa/extensions/QA/template/en/default/qa/update_bug_with_headers.txt.tmpl b/qa/extensions/QA/template/en/default/qa/update_bug_with_headers.txt.tmpl
new file mode 100644
index 000000000..fd093d3b0
--- /dev/null
+++ b/qa/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.