summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2018-06-16 00:30:47 +0200
committerDylan William Hardison <dylan@hardison.net>2018-06-28 22:41:58 +0200
commitd384888e734489a1524ca3ab1ad271343258bdea (patch)
treef154c18e1375d2bfb95c3d081f34f7b0136e6cdf
parentb3a6e0da65144921a99a369398dd390f5c65bef3 (diff)
downloadbugzilla-d384888e734489a1524ca3ab1ad271343258bdea.tar.gz
bugzilla-d384888e734489a1524ca3ab1ad271343258bdea.tar.xz
fix more tests, hopefully
-rw-r--r--Bugzilla/Quantum.pm139
-rw-r--r--Bugzilla/Quantum/CGI.pm10
-rwxr-xr-xheartbeat.cgi1
-rwxr-xr-xscripts/rewrite2mojo.pl62
4 files changed, 187 insertions, 25 deletions
diff --git a/Bugzilla/Quantum.pm b/Bugzilla/Quantum.pm
index 0c1356dd8..67d016d46 100644
--- a/Bugzilla/Quantum.pm
+++ b/Bugzilla/Quantum.pm
@@ -71,12 +71,11 @@ sub startup {
my $r = $self->routes;
Bugzilla::Quantum::CGI->load_all($r);
Bugzilla::Quantum::CGI->load_one('bzapi_cgi', 'extensions/BzAPI/bin/rest.cgi');
- $r->any('/bzapi/*PATH_INFO')->to('CGI#bzapi_cgi');
$r->any('/')->to('CGI#index_cgi');
$r->any('/rest')->to('CGI#rest_cgi');
- $r->any('/rest/*PATH_INFO')->to('CGI#rest_cgi');
-
+ $r->any('/extensions/BzAPI/bin/rest.cgi/*PATH_INFO')->to('CGI#bzapi_cgi');
+ $r->any('/rest/*PATH_INFO')->to( 'CGI#rest_cgi' => { PATH_INFO => '' });
$r->get(
'/__lbheartbeat__' => sub {
my $c = shift;
@@ -84,6 +83,140 @@ sub startup {
},
);
+ $r->any('/__heartbeat__')->to( 'CGI#heartbeat_cgi');
+ $r->any('/robots.txt')->to( 'CGI#robots_cgi' );
+
+ $r->any('/review')->to( 'CGI#page_cgi' => {'id' => 'splinter.html'});
+ $r->any('/user_profile')->to( 'CGI#page_cgi' => {'id' => 'user_profile.html'});
+ $r->any('/userprofile')->to( 'CGI#page_cgi' => {'id' => 'user_profile.html'});
+ $r->any('/request_defer')->to( 'CGI#page_cgi' => {'id' => 'request_defer.html'});
+ $r->any('/login')->to( 'CGI#index_cgi' => { 'GoAheadAndLogIn' => '1' });
+
+ $r->any('/:new_bug' => [new_bug => qr{new[-_]bug}])->to( 'CGI#new_bug_cgi');
+ $r->any('/:REWRITE_itrequest' => [REWRITE_itrequest => qr{form[\.:]itrequest}])->to(
+ 'CGI#enter_bug_cgi' => { 'product' => 'Infrastructure & Operations', 'format' => 'itrequest' }
+ );
+ $r->any('/:REWRITE_mozlist' => [REWRITE_mozlist => qr{form[\.:]mozlist}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'mozilla.org', 'format' => 'mozlist'}
+ );
+ $r->any('/:REWRITE_poweredby' => [REWRITE_poweredby => qr{form[\.:]poweredby}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'mozilla.org', 'format' => 'poweredby'}
+ );
+ $r->any('/:REWRITE_presentation' => [REWRITE_presentation => qr{form[\.:]presentation}])->to(
+ 'cgi#enter_bug_cgi' => {'product' => 'mozilla.org', 'format' => 'presentation'}
+ );
+ $r->any('/:REWRITE_trademark' => [REWRITE_trademark => qr{form[\.:]trademark}])->to(
+ 'cgi#enter_bug_cgi' => {'product' => 'mozilla.org', 'format' => 'trademark'}
+ );
+ $r->any('/:REWRITE_recoverykey' => [REWRITE_recoverykey => qr{form[\.:]recoverykey}])->to(
+ 'cgi#enter_bug_cgi' => {'product' => 'mozilla.org', 'format' => 'recoverykey'}
+ );
+ $r->any('/:REWRITE_legal' => [REWRITE_legal => qr{form[\.:]legal}])->to(
+ 'CGI#enter_bug_cgi' => { 'product' => 'Legal', 'format' => 'legal' },
+ );
+ $r->any('/:REWRITE_recruiting' => [REWRITE_recruiting => qr{form[\.:]recruiting}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Recruiting', 'format' => 'recruiting'}
+ );
+ $r->any('/:REWRITE_intern' => [REWRITE_intern => qr{form[\.:]intern}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Recruiting', 'format' => 'intern'}
+ );
+ $r->any('/:REWRITE_mozpr' => [REWRITE_mozpr => qr{form[\.:]mozpr}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Mozilla PR', 'format' => 'mozpr' },
+ );
+ $r->any('/:REWRITE_reps_mentorship' => [REWRITE_reps_mentorship => qr{form[\.:]reps[\.:]mentorship}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Mozilla Reps','format' => 'mozreps' },
+ );
+ $r->any('/:REWRITE_reps_budget' => [REWRITE_reps_budget => qr{form[\.:]reps[\.:]budget}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Mozilla Reps','format' => 'remo-budget'}
+ );
+ $r->any('/:REWRITE_reps_swag' => [REWRITE_reps_swag => qr{form[\.:]reps[\.:]swag}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Mozilla Reps','format' => 'remo-swag'}
+ );
+ $r->any('/:REWRITE_reps_it' => [REWRITE_reps_it => qr{form[\.:]reps[\.:]it}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Mozilla Reps','format' => 'remo-it'}
+ );
+ $r->any('/:REWRITE_reps_payment' => [REWRITE_reps_payment => qr{form[\.:]reps[\.:]payment}])->to(
+ 'CGI#page_cgi' => {'id' => 'remo-form-payment.html'}
+ );
+ $r->any('/:REWRITE_csa_discourse' => [REWRITE_csa_discourse => qr{form[\.:]csa[\.:]discourse}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Infrastructure & Operations', 'format' => 'csa-discourse'}
+ );
+ $r->any('/:REWRITE_employee_incident' => [REWRITE_employee_incident => qr{form[\.:]employee[\.\-:]incident}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'mozilla.org', 'format' => 'employee-incident'}
+ );
+ $r->any('/:REWRITE_brownbag' => [REWRITE_brownbag => qr{form[\.:]brownbag}])->to(
+ 'CGI#https_air_mozilla_org_requests' => {}
+ );
+ $r->any('/:REWRITE_finance' => [REWRITE_finance => qr{form[\.:]finance}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Finance','format' => 'finance'}
+ );
+ $r->any('/:REWRITE_moz_project_review' => [REWRITE_moz_project_review => qr{form[\.:]moz[\.\-:]project[\.\-:]review}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'mozilla.org','format' => 'moz-project-review'}
+ );
+ $r->any('/:REWRITE_docs' => [REWRITE_docs => qr{form[\.:]docs?}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Developer Documentation','format' => 'doc'}
+ );
+ $r->any('/:REWRITE_mdn' => [REWRITE_mdn => qr{form[\.:]mdn?}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'mdn','product' => 'developer.mozilla.org'}
+ );
+ $r->any('/:REWRITE_swag_gear' => [REWRITE_swag_gear => qr{form[\.:](swag|gear)}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'swag','product' => 'Marketing'}
+ );
+ $r->any('/:REWRITE_costume' => [REWRITE_costume => qr{form[\.:]costume}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Marketing','format' => 'costume'}
+ );
+ $r->any('/:REWRITE_ipp' => [REWRITE_ipp => qr{form[\.:]ipp}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Internet Public Policy','format' => 'ipp'}
+ );
+ $r->any('/:REWRITE_creative' => [REWRITE_creative => qr{form[\.:]creative}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'creative','product' => 'Marketing'}
+ );
+ $r->any('/:REWRITE_user_engagement' => [REWRITE_user_engagement => qr{form[\.:]user[\.\-:]engagement}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'user-engagement','product' => 'Marketing'}
+ );
+ $r->any('/:REWRITE_dev_engagement_event' => [REWRITE_dev_engagement_event => qr{form[\.:]dev[\.\-:]engagement[\.\-\:]event}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Developer Engagement','format' => 'dev-engagement-event'}
+ );
+ $r->any('/:REWRITE_mobile_compat' => [REWRITE_mobile_compat => qr{form[\.:]mobile[\.\-:]compat}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Tech Evangelism','format' => 'mobile-compat'}
+ );
+ $r->any('/:REWRITE_web_bounty' => [REWRITE_web_bounty => qr{form[\.:]web[\.:]bounty}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'web-bounty','product' => 'mozilla.org'}
+ );
+ $r->any('/:REWRITE_automative' => [REWRITE_automative => qr{form[\.:]automative}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Testing','format' => 'automative'}
+ );
+ $r->any('/:REWRITE_comm_newsletter' => [REWRITE_comm_newsletter => qr{form[\.:]comm[\.:]newsletter}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'comm-newsletter','product' => 'Marketing'}
+ );
+ $r->any('/:REWRITE_screen_share_whitelist' => [REWRITE_screen_share_whitelist => qr{form[\.:]screen[\.:]share[\.:]whitelist}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'screen-share-whitelist','product' => 'Firefox'}
+ );
+ $r->any('/:REWRITE_data_compliance' => [REWRITE_data_compliance => qr{form[\.:]data[\.\-:]compliance}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Data Compliance','format' => 'data-compliance'}
+ );
+ $r->any('/:REWRITE_fsa_budget' => [REWRITE_fsa_budget => qr{form[\.:]fsa[\.:]budget}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'FSA','format' => 'fsa-budget'}
+ );
+ $r->any('/:REWRITE_triage_request' => [REWRITE_triage_request => qr{form[\.:]triage[\.\-]request}])->to(
+ 'CGI#page_cgi' => {'id' => 'triage_request.html'}
+ );
+ $r->any('/:REWRITE_crm_CRM' => [REWRITE_crm_CRM => qr{form[\.:](crm|CRM)}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'crm','product' => 'Marketing'}
+ );
+ $r->any('/:REWRITE_nda' => [REWRITE_nda => qr{form[\.:]nda}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Legal','format' => 'nda'}
+ );
+ $r->any('/:REWRITE_name_clearance' => [REWRITE_name_clearance => qr{form[\.:]name[\.:]clearance}])->to(
+ 'CGI#enter_bug_cgi' => {'format' => 'name-clearance','product' => 'Legal'}
+ );
+ $r->any('/:REWRITE_shield_studies' => [REWRITE_shield_studies => qr{form[\.:]shield[\.:]studies}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Shield','format' => 'shield-studies'}
+ );
+ $r->any('/:REWRITE_client_bounty' => [REWRITE_client_bounty => qr{form[\.:]client[\.:]bounty}])->to(
+ 'CGI#enter_bug_cgi' => {'product' => 'Firefox','format' => 'client-bounty'}
+ );
+
}
1;
diff --git a/Bugzilla/Quantum/CGI.pm b/Bugzilla/Quantum/CGI.pm
index 353d8651e..287305ad3 100644
--- a/Bugzilla/Quantum/CGI.pm
+++ b/Bugzilla/Quantum/CGI.pm
@@ -102,7 +102,13 @@ sub _ENV {
$remote_user = $authenticate =~ /Basic\s+(.*)/ ? b64_decode $1 : '';
$remote_user = $remote_user =~ /([^:]+)/ ? $1 : '';
}
- my $path_info = $c->stash('PATH_INFO') || '';
+ my $path_info = delete $c->stash->{'mojo_captures'}{PATH_INFO};
+ my %captures = %{ $c->stash->{'mojo.captures'} // {} };
+ foreach my $key (keys %captures) {
+ delete $captures{$key} if $key =~ /^REWRITE_/;
+ }
+ my $cgi_query = Mojo::Parameters->new(%captures);
+ $cgi_query->append($req->url->query);
return (
CONTENT_LENGTH => $content_length || 0,
@@ -110,7 +116,7 @@ sub _ENV {
GATEWAY_INTERFACE => 'CGI/1.1',
HTTPS => $req->is_secure ? 'YES' : 'NO',
%env_headers,
- QUERY_STRING => $c->stash('cgi.query_string') || $req->url->query->to_string,
+ QUERY_STRING => $cgi_query->to_string,
PATH_INFO => $path_info ? "/$path_info" : '',
REMOTE_ADDR => $tx->remote_address,
REMOTE_HOST => gethostbyaddr( inet_aton( $tx->remote_address || '127.0.0.1' ), AF_INET ) || '',
diff --git a/heartbeat.cgi b/heartbeat.cgi
index 0597f1e3a..7f4f6361e 100755
--- a/heartbeat.cgi
+++ b/heartbeat.cgi
@@ -29,7 +29,6 @@ my $ok = eval {
die "database not available" unless $database_ok;
die "memcached server(s) not available" unless $memcached_ok;
- die "mod_perl not configured?" unless $ENV{MOD_PERL};
1;
};
FATAL("heartbeat error: $@") if !$ok && $@;
diff --git a/scripts/rewrite2mojo.pl b/scripts/rewrite2mojo.pl
index 66fc0d832..bae6d514b 100755
--- a/scripts/rewrite2mojo.pl
+++ b/scripts/rewrite2mojo.pl
@@ -9,6 +9,8 @@
use 5.10.1;
use strict;
use warnings;
+use Mojo::Parameters;
+use Data::Dumper;
while (<>) {
my ($cmd, @args) = split /\s+/, $_;
@@ -18,29 +20,51 @@ while (<>) {
$flags //= '';
next if $flags =~ /E=HTTP/;
next if $target eq '-';
- next if $target =~ /BzAPI/;
- next if $target =~ /rest\.cgi/;
my $action = 'rewrite_query';
if ($flags =~ /R/) {
- $action = 'redirect';
- }
- say "if (my \@match = \$path =~ m{$regex}s) {";
- say " $action(\$c, q{$target}, \@match);";
- say " return;" if $flags =~ /L/;
- say "}";
- }
- elsif (lc($cmd) eq "\LRedirect") {
- my ($type, $path, $url) = @args;
- if ($type eq 'permanent') {
- say "if (\$path =~ m{^\Q$path\E}s) {";
- say " redirect(\$c, q{$url});";
- say " return;";
- say "}";
- }
- else {
- warn "I don't understand Redirect $type\n";
+ next;
}
+ my ($script, $query) = $target =~ /^([^?]+)(?:\?(.+))?$/;
+ my $name = _file_to_method($script);
+ $regex =~ s/^\^//;
+ $regex =~ s/\$$//;
+ my $regex_name = _regex_to_name($regex);
+ my $param_hash = Mojo::Parameters->new($query)->to_hash;
+ my $param_str = Data::Dumper->new([$param_hash])->Terse(1)->Indent(0)->Dump;
+ say "\$r->any('/:$regex_name' => [$regex_name => qr{$regex}])->to(";
+ say " 'CGI#$name' => $param_str";
+ say ");";
+
}
+ # elsif (lc($cmd) eq "\LRedirect") {
+ # my ($type, $path, $url) = @args;
+ # if ($type eq 'permanent') {
+ # say "if (\$path =~ m{^\Q$path\E}s) {";
+ # say " redirect(\$c, q{$url});";
+ # say " return;";
+ # say "}";
+ # }
+ # else {
+ # warn "I don't understand Redirect $type\n";
+ # }
+ # }
+}
+
+sub _file_to_method {
+ my ($name) = @_;
+ $name =~ s/\./_/s;
+ $name =~ s/\W+/_/gs;
+ return $name;
+}
+
+sub _regex_to_name {
+ my ($name) = @_;
+ $name =~ s/\./_/s;
+ $name =~ s/\W+/_/gs;
+ $name =~ s/_+/_/g;
+ $name =~ s/^_//s;
+ $name =~ s/_$//s;
+ return $name;
}