summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorDylan William Hardison <dylan@hardison.net>2016-07-01 05:32:40 +0200
committerDylan William Hardison <dylan@hardison.net>2016-09-12 19:03:27 +0200
commite6bf4cacb10f86077fe898349485f5c7ab9fb4b6 (patch)
tree24a4973f71f38e0cd7788a25817142ab6c05ed3e /t
parent591e2dabe136e9a9190f3a67c89349cb794ae9a9 (diff)
downloadbugzilla-e6bf4cacb10f86077fe898349485f5c7ab9fb4b6.tar.gz
bugzilla-e6bf4cacb10f86077fe898349485f5c7ab9fb4b6.tar.xz
Bug 1283930 - Add Makefile.PL & local/lib/perl5 support to bmo/master + local symlink to data/ directory
Diffstat (limited to 't')
-rw-r--r--t/001compile.t45
-rw-r--r--t/002goodperl.t89
-rw-r--r--t/003safesys.t73
-rw-r--r--t/004template.t62
-rw-r--r--t/005whitespace.t37
-rw-r--r--t/006spellcheck.t84
-rw-r--r--t/007util.t48
-rw-r--r--t/008filter.t40
-rw-r--r--t/009bugwords.t38
-rw-r--r--t/010dependencies.t29
-rw-r--r--t/011pod.t28
-rw-r--r--t/012throwables.t40
-rw-r--r--t/013remote_ip.t82
-rw-r--r--t/Support/Files.pm61
-rw-r--r--t/Support/Systemexec.pm21
-rw-r--r--t/Support/Templates.pm70
16 files changed, 292 insertions, 555 deletions
diff --git a/t/001compile.t b/t/001compile.t
index a2176babd..f8ba8d1c7 100644
--- a/t/001compile.t
+++ b/t/001compile.t
@@ -1,41 +1,31 @@
-# -*- Mode: perl; indent-tabs-mode: nil -*-
+# 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/.
#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code are the Bugzilla Tests.
-#
-# The Initial Developer of the Original Code is Zach Lipton
-# Portions created by Zach Lipton are Copyright (C) 2001 Zach Lipton.
-# All Rights Reserved.
-#
-# Contributor(s): Zach Lipton <zach@zachlipton.com>
-# Max Kanat-Alexander <mkanat@bugzilla.org>
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
#################
#Bugzilla Test 1#
###Compilation###
+use 5.10.1;
use strict;
-use 5.008001;
-use lib qw(. lib t);
+use warnings;
+
+use lib qw(. lib local/lib/perl5 t);
use Config;
use Support::Files;
-use Test::More tests => scalar(@Support::Files::testitems);
+use Test::More tests => scalar(@Support::Files::testitems)
+ + scalar(@Support::Files::test_files);
BEGIN {
use_ok('Bugzilla::Constants');
use_ok('Bugzilla::Install::Requirements');
use_ok('Bugzilla');
}
+Bugzilla->usage_mode(USAGE_MODE_TEST);
sub compile_file {
my ($file) = @_;
@@ -65,12 +55,12 @@ sub compile_file {
$T = "T";
}
- my $libs = '';
+ my $libs = '-It ';
if ($ENV{PERL5LIB}) {
- $libs = join " ", map { "-I\"$_\"" } split /$Config{path_sep}/, $ENV{PERL5LIB};
+ $libs .= join " ", map { "-I\"$_\"" } split /$Config{path_sep}/, $ENV{PERL5LIB};
}
my $perl = qq{"$^X"};
- my $output = `$perl $libs -wc$T $file 2>&1`;
+ my $output = `$perl $libs -c$T -MSupport::Systemexec $file 2>&1`;
chomp($output);
my $return_val = $?;
$output =~ s/^\Q$file\E syntax OK$//ms;
@@ -78,7 +68,7 @@ sub compile_file {
ok(!$return_val, $file) or diag('--ERROR');
}
-my @testitems = @Support::Files::testitems;
+my @testitems = (@Support::Files::testitems, @Support::Files::test_files);
my $file_features = map_files_to_features();
# Test the scripts by compiling them
@@ -102,8 +92,7 @@ foreach my $file (@testitems) {
and $file ne "Bugzilla/DB/Schema.pm")
{
my $module = lc($1);
- my $dbd = DB_MODULE->{$module}->{dbd}->{module};
- eval("use $dbd; 1") or skip "$file: $dbd not installed", 1;
+ Bugzilla->feature($module) or skip "$file: Driver for $module not installed", 1;
}
compile_file($file);
diff --git a/t/002goodperl.t b/t/002goodperl.t
index 77b014f6a..7b2e74acc 100644
--- a/t/002goodperl.t
+++ b/t/002goodperl.t
@@ -1,40 +1,28 @@
-# -*- Mode: perl; indent-tabs-mode: nil -*-
-#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code are the Bugzilla Tests.
-#
-# The Initial Developer of the Original Code is Zach Lipton
-# Portions created by Zach Lipton are
-# Copyright (C) 2001 Zach Lipton. All
-# Rights Reserved.
-#
-# Contributor(s): Zach Lipton <zach@zachlipton.com>
-# Jacob Steenhagen <jake@bugzilla.org>
-# David D. Kilzer <ddkilzer@theracingworld.com>
+# 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.
#################
#Bugzilla Test 2#
####GoodPerl#####
+use 5.10.1;
use strict;
+use warnings;
-use lib 't';
+use lib qw(. lib local/lib/perl5 t);
use Support::Files;
-use Test::More tests => (scalar(@Support::Files::testitems) * 4);
+use Test::More tests => (scalar(@Support::Files::testitems)
+ + scalar(@Support::Files::test_files)) * 6;
-my @testitems = @Support::Files::testitems; # get the files to test.
+my @testitems = (@Support::Files::test_files, @Support::Files::testitems);
+my @require_taint = qw(email_in.pl importxml.pl mod_perl.pl whine.pl);
foreach my $file (@testitems) {
$file =~ s/\s.*$//; # nuke everything after the first space (#comment)
@@ -49,28 +37,38 @@ foreach my $file (@testitems) {
my $ext = $1;
if ($file_line1 !~ m/^#\!/) {
- ok(1,"$file does not have a shebang");
+ ok(1,"$file does not have a shebang");
} else {
my $flags;
- if (!defined $ext || $ext eq "pl") {
+ if (!defined $ext || $ext eq 'pl' || $ext eq 'psgi') {
# standalone programs aren't taint checked yet
- $flags = "w";
+ if (grep { $file eq $_ } @require_taint) {
+ $flags = 'T';
+ }
+ else {
+ $flags = '';
+ }
} elsif ($ext eq "pm") {
ok(0, "$file is a module, but has a shebang");
next;
} elsif ($ext eq "cgi") {
# cgi files must be taint checked
- $flags = "wT";
+ $flags = 'T';
} else {
ok(0, "$file has shebang but unknown extension");
next;
}
- if ($file_line1 =~ m#^\#\!/usr/bin/perl\s#) {
- if ($file_line1 =~ m#\s-$flags#) {
- ok(1,"$file uses standard perl location and -$flags");
- } else {
- ok(0,"$file is MISSING -$flags --WARNING");
+ if ($file_line1 =~ m#^\#\!/usr/bin/perl(?:\s-(\w+))?$#) {
+ my $file_flags = $1 || '';
+ if ($flags eq $file_flags) {
+ ok(1, "$file uses standard perl location" . ($flags ? " and -$flags flag" : ""));
+ }
+ elsif ($flags) {
+ ok(0, "$file is MISSING -$flags flag --WARNING");
+ }
+ else {
+ ok(0, "$file has unexpected -$file_flags flag --WARNING");
}
} else {
ok(0,"$file uses non-standard perl location");
@@ -79,7 +77,10 @@ foreach my $file (@testitems) {
}
foreach my $file (@testitems) {
+ my $found_use_perl = 0;
my $found_use_strict = 0;
+ my $found_use_warnings = 0;
+
$file =~ s/\s.*$//; # nuke everything after the first space (#comment)
next if (!$file); # skip null entries
if (! open (FILE, $file)) {
@@ -87,17 +88,29 @@ foreach my $file (@testitems) {
next;
}
while (my $file_line = <FILE>) {
- if ($file_line =~ m/^\s*use strict/) {
- $found_use_strict = 1;
- last;
- }
+ $found_use_perl = 1 if $file_line =~ m/^\s*use 5.10.1/;
+ $found_use_strict = 1 if $file_line =~ m/^\s*use strict/;
+ $found_use_warnings = 1 if $file_line =~ m/^\s*use warnings/;
+ last if ($found_use_perl && $found_use_strict && $found_use_warnings);
}
close (FILE);
+ if ($found_use_perl) {
+ ok(1,"$file requires Perl 5.10.1");
+ } else {
+ ok(0,"$file DOES NOT require Perl 5.10.1 --WARNING");
+ }
+
if ($found_use_strict) {
ok(1,"$file uses strict");
} else {
ok(0,"$file DOES NOT use strict --WARNING");
}
+
+ if ($found_use_warnings) {
+ ok(1,"$file uses warnings");
+ } else {
+ ok(0,"$file DOES NOT use warnings --WARNING");
+ }
}
# Check to see that all error messages use tags (for l10n reasons.)
diff --git a/t/003safesys.t b/t/003safesys.t
deleted file mode 100644
index a69500b7a..000000000
--- a/t/003safesys.t
+++ /dev/null
@@ -1,73 +0,0 @@
-# -*- Mode: perl; indent-tabs-mode: nil -*-
-#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code are the Bugzilla Tests.
-#
-# The Initial Developer of the Original Code is Zach Lipton
-# Portions created by Zach Lipton are
-# Copyright (C) 2001 Zach Lipton. All
-# Rights Reserved.
-#
-# Contributor(s): Zach Lipton <zach@zachlipton.com>
-
-
-#################
-#Bugzilla Test 3#
-###Safesystem####
-
-use strict;
-
-use lib 't';
-
-use Support::Files;
-use File::Slurp;
-
-use Test::More tests => scalar(@Support::Files::testitems);
-
-# Capture the TESTOUT from Test::More or Test::Builder for printing errors.
-# This will handle verbosity for us automatically.
-my $fh;
-{
- local $^W = 0; # Don't complain about non-existent filehandles
- if (-e \*Test::More::TESTOUT) {
- $fh = \*Test::More::TESTOUT;
- } elsif (-e \*Test::Builder::TESTOUT) {
- $fh = \*Test::Builder::TESTOUT;
- } else {
- $fh = \*STDOUT;
- }
-}
-
-my @testitems = @Support::Files::testitems;
-my $perlapp = "\"$^X\"";
-
-foreach my $file (@testitems) {
- $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
- next if (!$file); # skip null entries
-
- my $contents = read_file($file);
- if ($contents !~ /\b(system|exec)\b/) {
- ok(1,"$file does not contain any system or exec calls");
- next;
- }
-
- my $command = "$perlapp -c -It -MSupport::Systemexec $file 2>&1";
- my $loginfo=`$command`;
- if ($loginfo =~ /arguments for Support::Systemexec::(system|exec)/im) {
- ok(0,"$file DOES NOT use proper system or exec calls");
- print $fh $loginfo;
- } else {
- ok(1,"$file uses proper system and exec calls");
- }
-}
-
-exit 0;
diff --git a/t/004template.t b/t/004template.t
index 666ce5fa4..909f1a231 100644
--- a/t/004template.t
+++ b/t/004template.t
@@ -1,35 +1,19 @@
-# -*- Mode: perl; indent-tabs-mode: nil -*-
-#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code are the Bugzilla tests.
-#
-# The Initial Developer of the Original Code is Jacob Steenhagen.
-# Portions created by Jacob Steenhagen are
-# Copyright (C) 2001 Jacob Steenhagen. All
-# Rights Reserved.
-#
-# Contributor(s): Jacob Steenhagen <jake@bugzilla.org>
-# Zach Lipton <zach@zachlipton.com>
-# David D. Kilzer <ddkilzer@kilzer.net>
-# Tobias Burnus <burnus@net-b.de>
+# 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.
#################
#Bugzilla Test 4#
####Templates####
+use 5.10.1;
use strict;
+use warnings;
-use lib 't';
+use lib qw(. lib local/lib/perl5 t);
use Support::Templates;
@@ -44,7 +28,7 @@ use Test::More tests => ( scalar(@referenced_files) + 2 * $num_actual_files );
# This will handle verbosity for us automatically.
my $fh;
{
- local $^W = 0; # Don't complain about non-existent filehandles
+ no warnings qw(unopened); # Don't complain about non-existent filehandles
if (-e \*Test::More::TESTOUT) {
$fh = \*Test::More::TESTOUT;
} elsif (-e \*Test::Builder::TESTOUT) {
@@ -55,22 +39,21 @@ my $fh;
}
# Check to make sure all templates that are referenced in Bugzilla
-# exist in the proper place in the English template directory.
+# exist in the proper place in the English template or extension directory.
# All other languages may or may not include any template as Bugzilla will
# fall back to English if necessary.
foreach my $file (@referenced_files) {
- my @path = map(File::Spec->catfile($_, $file), @include_paths);
- push(@path, File::Spec->catfile($english_default_include_path, $file));
- my $found;
- foreach my $path (@path) {
- $found = $path if -e $path;
- }
- if ($found) {
- ok(1, "$file exists");
- } else {
- ok(0, "$file cannot be located --ERROR");
+ my $found = 0;
+ foreach my $path (@english_default_include_paths) {
+ my $pathfile = File::Spec->catfile($path, $file);
+ if (-e $pathfile) {
+ $found = 1;
+ last;
+ }
}
+
+ ok($found, "$file found");
}
foreach my $include_path (@include_paths) {
@@ -83,17 +66,13 @@ foreach my $include_path (@include_paths) {
# See Template.pm for the actual codebase definitions.
# Initialize templates (f.e. by loading plugins like Hook).
- PRE_PROCESS => "global/initialize.none.tmpl",
+ PRE_PROCESS => "global/variables.none.tmpl",
FILTERS =>
{
html_linebreak => sub { return $_; },
- no_break => sub { return $_; } ,
js => sub { return $_ } ,
base64 => sub { return $_ } ,
- inactive => [ sub { return sub { return $_; } }, 1] ,
- closed => [ sub { return sub { return $_; } }, 1] ,
- obsolete => [ sub { return sub { return $_; } }, 1] ,
url_quote => sub { return $_ } ,
css_class_quote => sub { return $_ } ,
xml => sub { return $_ } ,
@@ -105,6 +84,7 @@ foreach my $include_path (@include_paths) {
wrap_comment => sub { return $_ },
none => sub { return $_ } ,
ics => [ sub { return sub { return $_; } }, 1] ,
+ markdown => sub { return $_ } ,
},
}
);
diff --git a/t/005whitespace.t b/t/005whitespace.t
index edba8b274..be13890bb 100644
--- a/t/005whitespace.t
+++ b/t/005whitespace.t
@@ -1,44 +1,29 @@
-# -*- Mode: perl; indent-tabs-mode: nil -*-
-#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code are the Bugzilla tests.
-#
-# The Initial Developer of the Original Code is Jacob Steenhagen.
-# Portions created by Jacob Steenhagen are
-# Copyright (C) 2001 Jacob Steenhagen. All
-# Rights Reserved.
-#
-# Contributor(s): Jacob Steenhagen <jake@bugzilla.org>
-# David D. Kilzer <ddkilzer@kilzer.net>
-# Colin Ogilvie <mozilla@colinogilvie.co.uk>
-# Marc Schumann <wurblzap@gmail.com>
+# 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.
#################
#Bugzilla Test 5#
#####no_tabs#####
+use 5.10.1;
use strict;
+use warnings;
-use lib 't';
+use lib qw(. lib local/lib/perl5 t);
use Support::Files;
use Support::Templates;
use File::Spec;
-use Test::More tests => ( scalar(@Support::Files::testitems)
+use Test::More tests => (scalar(@Support::Files::testitems)
+ + scalar(@Support::Files::test_files)
+ $Support::Templates::num_actual_files) * 3;
-my @testitems = @Support::Files::testitems;
+my @testitems = (@Support::Files::testitems, @Support::Files::test_files);
for my $path (@Support::Templates::include_paths) {
push(@testitems, map(File::Spec->catfile($path, $_),
Support::Templates::find_actual_files($path)));
diff --git a/t/006spellcheck.t b/t/006spellcheck.t
index e311be8ec..70181ef85 100644
--- a/t/006spellcheck.t
+++ b/t/006spellcheck.t
@@ -1,62 +1,31 @@
-# -*- Mode: perl; indent-tabs-mode: nil -*-
+# 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/.
#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code are the Bugzilla Tests.
-#
-# The Initial Developer of the Original Code is Zach Lipton
-# Portions created by Zach Lipton are
-# Copyright (C) 2002 Zach Lipton. All
-# Rights Reserved.
-#
-# Contributor(s): Zach Lipton <zach@zachlipton.com>
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
#################
#Bugzilla Test 6#
####Spelling#####
-use lib 't';
-use Support::Files;
+use 5.10.1;
+use strict;
+use warnings;
-BEGIN { # yes the indenting is off, deal with it
-#add the words to check here:
-@evilwords = qw(
-anyways
-appearence
-arbitary
-cancelled
-critera
-databasa
-dependan
-existance
-existant
-paramater
-refered
-repsentation
-retreive
-suported
-varsion
-);
-
-$testcount = scalar(@Support::Files::testitems);
-}
+use lib qw(. lib local/lib/perl5 t);
+use Support::Files;
-use Test::More tests => $testcount;
+# -1 because 006spellcheck.t must not be checked.
+use Test::More tests => scalar(@Support::Files::testitems)
+ + scalar(@Support::Files::test_files) - 1;
# Capture the TESTOUT from Test::More or Test::Builder for printing errors.
# This will handle verbosity for us automatically.
my $fh;
{
- local $^W = 0; # Don't complain about non-existent filehandles
+ no warnings qw(unopened); # Don't complain about non-existent filehandles
if (-e \*Test::More::TESTOUT) {
$fh = \*Test::More::TESTOUT;
} elsif (-e \*Test::Builder::TESTOUT) {
@@ -66,14 +35,35 @@ my $fh;
}
}
-my @testitems = @Support::Files::testitems;
+my @testitems = (@Support::Files::testitems, @Support::Files::test_files);
+
+#add the words to check here:
+my @evilwords = qw(
+ anyways
+ appearence
+ arbitary
+ cancelled
+ critera
+ databasa
+ dependan
+ existance
+ existant
+ paramater
+ refered
+ repsentation
+ retreive
+ suported
+ varsion
+);
-# at last, here we actually run the test...
my $evilwordsregexp = join('|', @evilwords);
foreach my $file (@testitems) {
$file =~ s/\s.*$//; # nuke everything after the first space (#comment)
next if (!$file); # skip null entries
+ # Do not try to validate this file as it obviously contains a list
+ # of wrongly spelled words.
+ next if ($file eq 't/006spellcheck.t');
if (open (FILE, $file)) { # open the file for reading
diff --git a/t/007util.t b/t/007util.t
index b32a1b90c..b8e9505d8 100644
--- a/t/007util.t
+++ b/t/007util.t
@@ -1,36 +1,26 @@
-# -*- Mode: perl; indent-tabs-mode: nil -*-
+# 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/.
#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code are the Bugzilla Tests.
-#
-# The Initial Developer of the Original Code is Zach Lipton
-# Portions created by Zach Lipton are Copyright (C) 2002 Zach Lipton.
-# All Rights Reserved.
-#
-# Contributor(s): Zach Lipton <zach@zachlipton.com>
-# Max Kanat-Alexander <mkanat@bugzilla.org>
-# Frédéric Buclin <LpSolit@gmail.com>
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
#################
#Bugzilla Test 7#
#####Util.pm#####
-use lib 't';
+use 5.10.1;
+use strict;
+use warnings;
+
+use lib qw(. lib local/lib/perl5 t);
use Support::Files;
-use Test::More tests => 15;
+use Test::More tests => 17;
+use DateTime;
BEGIN {
- use_ok(Bugzilla);
- use_ok(Bugzilla::Util);
+ use_ok('Bugzilla');
+ use_ok('Bugzilla::Util');
}
# We need to override user preferences so we can get an expected value when
@@ -73,6 +63,16 @@ foreach my $input (keys %email_strings) {
"email_filter('$input')");
}
+# validate_email_syntax. We need to override some parameters.
+my $params = Bugzilla->params;
+$params->{emailregexp} = '.*';
+$params->{emailsuffix} = '';
+my $ascii_email = 'admin@company.com';
+# U+0430 returns the Cyrillic "а", which looks similar to the ASCII "a".
+my $utf8_email = "\N{U+0430}dmin\@company.com";
+ok(validate_email_syntax($ascii_email), 'correctly formatted ASCII-only email address is valid');
+ok(!validate_email_syntax($utf8_email), 'correctly formatted email address with non-ASCII characters is rejected');
+
# diff_arrays():
my @old_array = qw(alpha beta alpha gamma gamma beta alpha delta epsilon gamma);
my @new_array = qw(alpha alpha beta gamma epsilon delta beta delta);
diff --git a/t/008filter.t b/t/008filter.t
index 1111c16f6..b8d05af8a 100644
--- a/t/008filter.t
+++ b/t/008filter.t
@@ -1,23 +1,9 @@
-# -*- Mode: perl; indent-tabs-mode: nil -*-
+# 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/.
#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code are the Bugzilla tests.
-#
-# The Initial Developer of the Original Code is Jacob Steenhagen.
-# Portions created by Jacob Steenhagen are
-# Copyright (C) 2001 Jacob Steenhagen. All
-# Rights Reserved.
-#
-# Contributor(s): Gervase Markham <gerv@gerv.net>
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
#################
#Bugzilla Test 8#
@@ -29,10 +15,11 @@
# Sample exploit code: '>"><script>alert('Oh dear...')</script>
+use 5.10.1;
use strict;
-use lib qw(. lib t);
+use warnings;
-use vars qw(%safe);
+use lib qw(. lib local/lib/perl5 t);
use Bugzilla::Constants;
use Support::Templates;
@@ -44,6 +31,7 @@ use Cwd;
my $oldrecsep = $/;
my $topdir = cwd;
$/ = undef;
+our %safe;
foreach my $path (@Support::Templates::include_paths) {
$path =~ s|\\|/|g if ON_WINDOWS; # convert \ to / in path if on windows
@@ -94,13 +82,13 @@ foreach my $path (@Support::Templates::include_paths) {
foreach my $file (@testitems) {
# There are some files we don't check, because there is no need to
# filter their contents due to their content-type.
- if ($file =~ /\.(pm|txt|png)\.tmpl$/) {
+ if ($file =~ /\.(pm|txt|rst|png)\.tmpl$/) {
ok(1, "($lang/$flavor) $file is filter-safe");
next;
}
-
+
# Read the entire file into a string
- open (FILE, "<$file") || die "Can't open $file: $!\n";
+ open (FILE, "<$file") || die "Can't open $file: $!\n";
my $slurp = <FILE>;
close (FILE);
@@ -225,8 +213,8 @@ sub directive_ok {
return 1 if $directive =~ /FILTER\ (html|csv|js|base64|css_class_quote|ics|
quoteUrls|time|uri|xml|lower|html_light|
obsolete|inactive|closed|unitconvert|
- txt|html_linebreak|none|json|null|id)\b/x;
-
+ txt|html_linebreak|none|json|null|id|
+ markdown)\b/x;
return 0;
}
diff --git a/t/009bugwords.t b/t/009bugwords.t
index 242ac478d..740cbf6aa 100644
--- a/t/009bugwords.t
+++ b/t/009bugwords.t
@@ -1,24 +1,9 @@
-# -*- Mode: perl; indent-tabs-mode: nil -*-
-#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code are the Bugzilla tests.
-#
-# The Initial Developer of the Original Code is Jacob Steenhagen.
-# Portions created by Jacob Steenhagen are
-# Copyright (C) 2001 Jacob Steenhagen. All
-# Rights Reserved.
-#
-# Contributor(s): Gervase Markham <gerv@gerv.net>
+# 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.
#################
#Bugzilla Test 9#
@@ -30,9 +15,11 @@
# "[% terms.bug %]". This test makes sure the relevant words aren't used
# bare.
+use 5.10.1;
use strict;
+use warnings;
-use lib 't';
+use lib qw(. lib local/lib/perl5 t);
use Support::Files;
use Support::Templates;
@@ -75,15 +62,6 @@ foreach my $file (@testitems) {
next;
}
}
-
- # "Bugzilla"
- if (grep /(?<!X\-)Bugzilla(?!_|::|-&gt|\.pm)/, $text) {
- # Exclude JS comments, hyperlinks, USE, and variable assignment.
- unless (grep /(\/\/.*|org.*>|api\/|USE |= )Bugzilla/, $text) {
- push(@errors, [$lineno, $text]);
- next;
- }
- }
}
if (scalar(@errors)) {
diff --git a/t/010dependencies.t b/t/010dependencies.t
index 3289d098e..777d42ed1 100644
--- a/t/010dependencies.t
+++ b/t/010dependencies.t
@@ -1,27 +1,20 @@
-# -*- Mode: perl; indent-tabs-mode: nil -*-
+# 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/.
#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code are the Bugzilla Tests.
-#
-# Contributor(s): David Miller <justdave@bugzilla.org>
-# Frédéric Buclin <LpSolit@gmail.com>
+# This Source Code Form is "Incompatible With Secondary Licenses", as
+# defined by the Mozilla Public License, v. 2.0.
##################
#Bugzilla Test 10#
## dependencies ##
+use 5.10.1;
use strict;
-use lib qw(. lib t);
+use warnings;
+
+use lib qw(. lib local/lib/perl5 t);
use Support::Files;
use Test::More qw(no_plan);
@@ -37,7 +30,7 @@ use constant MODULE_REGEX => qr/
['"]?
([\w:\.\\]+)
/x;
-use constant BASE_REGEX => qr/^use base qw\(([^\)]+)/;
+use constant BASE_REGEX => qr/^use (?:base|parent) (?:-norequire, )?qw\(([^\)]+)/;
# Extract all Perl modules.
foreach my $file (@Support::Files::testitems) {
@@ -69,7 +62,7 @@ foreach my $module (keys %mods) {
}
elsif ($line =~ BASE_REGEX or $line =~ MODULE_REGEX) {
my $used_string = $1;
- # "use base" can have multiple modules
+ # "use base"/"use parent" can have multiple modules
my @used_array = split(/\s+/, $used_string);
foreach my $used (@used_array) {
next if $used !~ /^Bugzilla/;
diff --git a/t/011pod.t b/t/011pod.t
index 517ca03ad..4f5fa87f7 100644
--- a/t/011pod.t
+++ b/t/011pod.t
@@ -1,27 +1,19 @@
-# -*- Mode: perl; indent-tabs-mode: nil -*-
-#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code are the Bugzilla Tests.
-#
-# Contributor(s): Frédéric Buclin <LpSolit@gmail.com>
-
+# 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.
##################
#Bugzilla Test 11#
##POD validation##
+use 5.10.1;
use strict;
+use warnings;
-use lib 't';
+use lib qw(. lib local/lib/perl5 t);
use Support::Files;
use Pod::Checker;
@@ -32,7 +24,7 @@ use Test::More tests => scalar(@Support::Files::testitems);
# This will handle verbosity for us automatically.
my $fh;
{
- local $^W = 0; # Don't complain about non-existent filehandles
+ no warnings 'unopened';
if (-e \*Test::More::TESTOUT) {
$fh = \*Test::More::TESTOUT;
} elsif (-e \*Test::Builder::TESTOUT) {
diff --git a/t/012throwables.t b/t/012throwables.t
index 590fb8aa5..4317c0e89 100644
--- a/t/012throwables.t
+++ b/t/012throwables.t
@@ -1,25 +1,9 @@
-# -*- Mode: perl; indent-tabs-mode: nil -*-
-# vim: ts=4 sw=4 et tw=80
-#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code are the Bugzilla Tests.
-#
-# The Initial Developer of the Original Code is Zach Lipton
-# Portions created by Zach Lipton are
-# Copyright (C) 2001 Zach Lipton. All
-# Rights Reserved.
-#
-# Contributor(s): Dennis Melentyev <dennis.melentyev@infopulse.com.ua>
-# Max Kanat-Alexander <mkanat@bugzilla.org>
+# 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.
@@ -27,8 +11,11 @@
#Bugzilla Test 12#
######Errors######
+use 5.10.1;
use strict;
-use lib qw(. lib t);
+use warnings;
+
+use lib qw(. lib local/lib/perl5 t);
use Bugzilla::Constants;
use Bugzilla::WebService::Constants;
@@ -63,6 +50,13 @@ foreach my $include_path (@include_paths) {
$file =~ s|\\|/|g if ON_WINDOWS; # convert \ to / in path if on windows
$test_templates{$file} = ()
if $file =~ m#global/(code|user)-error(?:-errors)?\.html\.tmpl#;
+
+ # Make sure the extension is not disabled
+ if ($file =~ m#^(extensions/[^/]+/)#) {
+ $test_templates{$file} = ()
+ if ! -e "${1}disabled"
+ && $file =~ m#global/(code|user)-error-errors\.html\.tmpl#;
+ }
}
}
diff --git a/t/013remote_ip.t b/t/013remote_ip.t
deleted file mode 100644
index 4bba7c95e..000000000
--- a/t/013remote_ip.t
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/perl
-# 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.
-
-use strict;
-use lib qw(. lib t);
-use Test::More qw(no_plan);
-use Bugzilla;
-use Bugzilla::Util qw(remote_ip);
-
-my $params = Bugzilla->params;
-local Bugzilla->localconfig->{param_override}{inbound_proxies} = undef;
-
-{
- local $params->{inbound_proxies} = '10.0.0.1,10.0.0.2';
- local $ENV{REMOTE_ADDR} = '10.0.0.2';
- local $ENV{HTTP_X_FORWARDED_FOR} = '10.42.42.42';
-
- is(remote_ip(), '10.42.42.42', "from proxy 2");
-}
-
-{
- local $params->{inbound_proxies} = '10.0.0.1,10.0.0.2';
- local $ENV{REMOTE_ADDR} = '10.0.0.1';
- local $ENV{HTTP_X_FORWARDED_FOR} = '10.42.42.42';
-
- is(remote_ip(), '10.42.42.42', "from proxy 1");
-}
-
-{
- local $params->{inbound_proxies} = '10.0.0.1,10.0.0.2';
- local $ENV{REMOTE_ADDR} = '10.0.0.3';
- local $ENV{HTTP_X_FORWARDED_FOR} = '10.42.42.42';
-
- is(remote_ip(), '10.0.0.3', "not a proxy");
-}
-
-{
- local $params->{inbound_proxies} = '*';
- local $ENV{REMOTE_ADDR} = '10.0.0.3';
- local $ENV{HTTP_X_FORWARDED_FOR} = '10.42.42.42,1.4.9.2';
-
- is(remote_ip(), '10.42.42.42', "always proxy");
-}
-
-{
- local $params->{inbound_proxies} = '';
- local $ENV{REMOTE_ADDR} = '10.9.8.7';
- local $ENV{HTTP_X_FORWARDED_FOR} = '10.42.42.42,1.4.9.2';
-
- is(remote_ip(), '10.9.8.7', "never proxy");
-}
-
-
-{
- local $params->{inbound_proxies} = '10.0.0.1,2600:cafe::cafe:ffff:bf42:4998';
- local $ENV{REMOTE_ADDR} = '2600:cafe::cafe:ffff:bf42:4998';
- local $ENV{HTTP_X_FORWARDED_FOR} = '2600:cafe::cafe:ffff:bf42:BEEF';
-
- is(remote_ip(), '2600:cafe::cafe:ffff:bf42:BEEF', "from proxy ipv6");
-}
-
-{
- local $params->{inbound_proxies} = '10.0.0.1,2600:cafe::cafe:ffff:bf42:4998';
- local $ENV{REMOTE_ADDR} = '2600:cafe::cafe:ffff:bf42:DEAD';
- local $ENV{HTTP_X_FORWARDED_FOR} = '2600:cafe::cafe:ffff:bf42:BEEF';
-
- is(remote_ip(), '2600:cafe::cafe:ffff:bf42:DEAD', "invalid proxy ipv6");
-}
-
-
-{
- local $params->{inbound_proxies} = '*';
- local $ENV{REMOTE_ADDR} = '2600:cafe::cafe:ffff:bf42:DEAD';
- local $ENV{HTTP_X_FORWARDED_FOR} = '';
-
- is(remote_ip(), '2600:cafe::cafe:ffff:bf42:DEAD', "always proxy ipv6");
-}
diff --git a/t/Support/Files.pm b/t/Support/Files.pm
index 00e0efd34..1bdf2eac7 100644
--- a/t/Support/Files.pm
+++ b/t/Support/Files.pm
@@ -1,45 +1,40 @@
-# -*- Mode: perl; indent-tabs-mode: nil -*-
-#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code are the Bugzilla Tests.
-#
-# The Initial Developer of the Original Code is Zach Lipton
-# Portions created by Zach Lipton are
-# Copyright (C) 2001 Zach Lipton. All
-# Rights Reserved.
-#
-# Contributor(s): Zach Lipton <zach@zachlipton.com>
-# Joel Peshkin <bugreport@peshkin.net>
+# 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 Support::Files;
-use Bugzilla;
+use 5.10.1;
+use strict;
+use warnings;
use File::Find;
+our @additional_files = ();
+
use constant IGNORE => qw(
Bugzilla/DuoAPI.pm
Bugzilla/DuoWeb.pm
);
-@additional_files = ();
+our @files = glob('*');
+find(sub { push(@files, $File::Find::name) if $_ =~ /\.pm$/;}, qw(Bugzilla docs));
+push(@files, 'extensions/create.pl', 'docs/makedocs.pl', 'cpanfile');
+
+our @extensions =
+ grep { $_ ne 'extensions/create.pl' && ! -e "$_/disabled" }
+ glob('extensions/*');
+
+foreach my $extension (@extensions) {
+ find(sub { push(@files, $File::Find::name) if $_ =~ /\.pm$/;}, $extension);
+}
-@files = glob('*');
-my @extension_paths = map { $_->package_dir } @{ Bugzilla->extensions };
-find(sub { push(@files, $File::Find::name) if $_ =~ /\.pm$/;}, 'Bugzilla', @extension_paths);
-push(@files, 'extensions/create.pl');
+our @test_files = glob('t/*.t xt/*/*.t');
-my @extensions = glob('extensions/*');
foreach my $extension (@extensions) {
# Skip disabled extensions
next if -e "$extension/disabled";
@@ -55,7 +50,7 @@ sub isTestingFile {
return undef if $ignore eq $file;
}
- if ($file =~ /\.cgi$|\.pl$|\.pm$/) {
+ if ($file =~ /\.psgi$|\.cgi$|\.pl$|\.pm$/) {
return 1;
}
my $additional;
@@ -65,11 +60,13 @@ sub isTestingFile {
return undef;
}
-foreach $currentfile (@files) {
+our (@testitems, @module_files);
+
+foreach my $currentfile (@files) {
if (isTestingFile($currentfile)) {
- push(@testitems,$currentfile);
+ push(@testitems, $currentfile);
}
+ push(@module_files, $currentfile) if $currentfile =~ /\.pm$/;
}
-
1;
diff --git a/t/Support/Systemexec.pm b/t/Support/Systemexec.pm
index 676ee02a4..e73763f8f 100644
--- a/t/Support/Systemexec.pm
+++ b/t/Support/Systemexec.pm
@@ -1,14 +1,25 @@
-# -*- Mode: perl; indent-tabs-mode: nil -*-
+# 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 Support::Systemexec;
-require Exporter;
-@ISA = qw(Exporter);
-@EXPORT = qw(system exec);
-@EXPORT_OK = qw();
+
+use 5.10.1;
+use strict;
+use warnings;
+
+use parent qw(Exporter);
+@Support::Systemexec::EXPORT = qw(system exec);
+
sub system($$@) {
1;
}
+
sub exec($$@) {
1;
}
+
1;
diff --git a/t/Support/Templates.pm b/t/Support/Templates.pm
index 81dc8cc3f..5071d67ae 100644
--- a/t/Support/Templates.pm
+++ b/t/Support/Templates.pm
@@ -1,38 +1,21 @@
-# -*- Mode: perl; indent-tabs-mode: nil -*-
-#
-# The contents of this file are subject to the Mozilla Public
-# License Version 1.1 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS
-# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
-# implied. See the License for the specific language governing
-# rights and limitations under the License.
-#
-# The Original Code are the Bugzilla tests.
-#
-# The Initial Developer of the Original Code is Jacob Steenhagen.
-# Portions created by Jacob Steenhagen are
-# Copyright (C) 2001 Jacob Steenhagen. All
-# Rights Reserved.
-#
-# Contributor(s): Jacob Steenhagen <jake@bugzilla.org>
-# David D. Kilzer <ddkilzer@kilzer.net>
-# Tobias Burnus <burnus@net-b.de>
+# 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 Support::Templates;
+use 5.10.1;
use strict;
+use warnings;
use lib 't';
use base qw(Exporter);
-@Support::Templates::EXPORT =
- qw(@languages @include_paths $english_default_include_path
- %include_path @referenced_files %actual_files $num_actual_files);
-use vars qw(@languages @include_paths $english_default_include_path
- %include_path @referenced_files %actual_files $num_actual_files);
+@Support::Templates::EXPORT =
+ qw(@languages @include_paths @english_default_include_paths
+ %include_path @referenced_files %actual_files $num_actual_files);
use Bugzilla;
use Bugzilla::Constants;
@@ -42,33 +25,32 @@ use Support::Files;
use File::Find;
use File::Spec;
-# The available template languages
-@languages = ();
+# English default include paths
+our @english_default_include_paths =
+ (File::Spec->catdir(bz_locations()->{'templatedir'}, 'en', 'default'));
-# The colon separated includepath per language
-%include_path = ();
-
-# All include paths
-@include_paths = ();
-
-# English default include path
-$english_default_include_path =
- File::Spec->catdir(bz_locations()->{'templatedir'}, 'en', 'default');
+# And the extensions too
+foreach my $extension (@Support::Files::extensions) {
+ my $dir = File::Spec->catdir($extension, 'template', 'en', 'default');
+ if (-e $dir) {
+ push @english_default_include_paths, $dir;
+ }
+}
# Files which are referenced in the cgi files
-@referenced_files = ();
+our @referenced_files = ();
# All files sorted by include_path
-%actual_files = ();
+our %actual_files = ();
# total number of actual_files
-$num_actual_files = 0;
+our $num_actual_files = 0;
# Set the template available languages and include paths
-@languages = @{ Bugzilla->languages };
-@include_paths = @{ template_include_path({ language => Bugzilla->languages }) };
+our @languages = @{ Bugzilla->languages };
+our @include_paths = @{ template_include_path({ language => Bugzilla->languages }) };
-my @files;
+our @files;
# Local subroutine used with File::Find
sub find_templates {