summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/001compile.t5
-rw-r--r--t/004template.t29
-rw-r--r--t/008filter.t5
-rw-r--r--t/012throwables.t4
-rw-r--r--t/Support/Files.pm13
5 files changed, 46 insertions, 10 deletions
diff --git a/t/001compile.t b/t/001compile.t
index 97a339b2d..a2176babd 100644
--- a/t/001compile.t
+++ b/t/001compile.t
@@ -45,6 +45,11 @@ sub compile_file {
# Bugzilla::Install::CPAN.)
local @INC = @INC;
+ if ($file =~ /extensions/) {
+ skip "$file: extensions not tested", 1;
+ return;
+ }
+
if ($file =~ s/\.pm$//) {
$file =~ s{/}{::}g;
use_ok($file);
diff --git a/t/004template.t b/t/004template.t
index 3b858c0b3..666ce5fa4 100644
--- a/t/004template.t
+++ b/t/004template.t
@@ -38,7 +38,7 @@ use CGI qw(-no_debug);
use File::Spec;
use Template;
-use Test::More tests => ( scalar(@referenced_files) + $num_actual_files );
+use Test::More tests => ( scalar(@referenced_files) + 2 * $num_actual_files );
# Capture the TESTOUT from Test::More or Test::Builder for printing errors.
# This will handle verbosity for us automatically.
@@ -60,11 +60,16 @@ my $fh;
# fall back to English if necessary.
foreach my $file (@referenced_files) {
- my $path = File::Spec->catfile($english_default_include_path, $file);
- if (-e $path) {
- ok(1, "$path exists");
+ 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, "$path cannot be located --ERROR");
+ ok(0, "$file cannot be located --ERROR");
}
}
@@ -118,6 +123,20 @@ foreach my $include_path (@include_paths) {
ok(0, "$path has bad syntax --ERROR");
print $fh $data . "\n";
}
+
+ # Make sure no forbidden constructs are present.
+ local $/;
+ open(FILE, '<', $path) or die "Can't open $file: $!\n";
+ $data = <FILE>;
+ close (FILE);
+
+ # Forbid single quotes to delimit URLs, see bug 926085.
+ if ($data =~ /href=\\?'/) {
+ ok(0, "$path contains blacklisted constructs: href='...'");
+ }
+ else {
+ ok(1, "$path contains no blacklisted constructs");
+ }
}
}
diff --git a/t/008filter.t b/t/008filter.t
index e73d23835..d0c0311f6 100644
--- a/t/008filter.t
+++ b/t/008filter.t
@@ -175,7 +175,8 @@ sub directive_ok {
return 1 if $directive =~ /^(IF|END|UNLESS|FOREACH|PROCESS|INCLUDE|
BLOCK|USE|ELSE|NEXT|LAST|DEFAULT|FLUSH|
ELSIF|SET|SWITCH|CASE|WHILE|RETURN|STOP|
- TRY|CATCH|FINAL|THROW|CLEAR|MACRO|FILTER)/x;
+ TRY|CATCH|FINAL|THROW|CLEAR|MACRO|FILTER|
+ CALL)/x;
# ? :
if ($directive =~ /.+\?(.+):(.+)/) {
@@ -224,7 +225,7 @@ 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)\b/x;
+ txt|html_linebreak|none|json)\b/x;
return 0;
}
diff --git a/t/012throwables.t b/t/012throwables.t
index 3738ad524..590fb8aa5 100644
--- a/t/012throwables.t
+++ b/t/012throwables.t
@@ -62,7 +62,7 @@ foreach my $include_path (@include_paths) {
$file =~ s/\s.*$//; # nuke everything after the first space
$file =~ s|\\|/|g if ON_WINDOWS; # convert \ to / in path if on windows
$test_templates{$file} = ()
- if $file =~ m#global/(code|user)-error\.html\.tmpl#;
+ if $file =~ m#global/(code|user)-error(?:-errors)?\.html\.tmpl#;
}
}
@@ -75,7 +75,7 @@ plan tests => $tests;
# Collect all errors defined in templates
foreach my $file (keys %test_templates) {
- $file =~ m|template/([^/]+).*/global/([^/]+)-error\.html\.tmpl|;
+ $file =~ m|template/([^/]+).*/global/([^/]+)-error(?:-errors)?\.html\.tmpl|;
my $lang = $1;
my $errtype = $2;
diff --git a/t/Support/Files.pm b/t/Support/Files.pm
index 6c6e0ee57..2898fdd3f 100644
--- a/t/Support/Files.pm
+++ b/t/Support/Files.pm
@@ -23,14 +23,25 @@
package Support::Files;
+use Bugzilla;
+
use File::Find;
@additional_files = ();
@files = glob('*');
-find(sub { push(@files, $File::Find::name) if $_ =~ /\.pm$/;}, 'Bugzilla');
+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');
+my @extensions = glob('extensions/*');
+foreach my $extension (@extensions) {
+ # Skip disabled extensions
+ next if -e "$extension/disabled";
+
+ find(sub { push(@files, $File::Find::name) if $_ =~ /\.pm$/;}, $extension);
+}
+
sub isTestingFile {
my ($file) = @_;
my $exclude;