View | Details | Raw Unified | Return to bug 24879
Collapse All | Expand All

(-)a/xt/find-missing-auth_checks.t (-1 / +72 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
use Test::More;
20
21
use File::Spec;
22
use File::Find;
23
24
my @files;
25
sub wanted {
26
    my $name = $File::Find::name;
27
    push @files, $name
28
      if $name =~ m{^\./(
29
           acqui
30
          |admin
31
          |authorities
32
          |basket
33
          |catalogue
34
          |cataloguing
35
          |circ
36
          |clubs
37
          |course_reserves
38
          |installer
39
          |labels
40
          |members
41
          |patroncards
42
          |pos
43
          |reports
44
          |reserve
45
          |reviews
46
          |rotating_collections
47
          |serials
48
          |services
49
          |suggestion
50
          |svc
51
          |tags
52
          |tools
53
          |virtualshelves
54
        )}xms
55
      && $name =~ m{\.(pl)$}
56
      && -f $name;
57
}
58
59
find({ wanted => \&wanted, no_chdir => 1 }, File::Spec->curdir());
60
61
my @missing_auth_check;
62
FILE: foreach my $name (@files) {
63
    open( FILE, $name ) || die "cannot open file $name $!";
64
    while ( my $line = <FILE> ) {
65
        for my $routine ( qw( get_template_and_user check_cookie_auth checkauth check_api_auth ) ) {
66
            next FILE if $line =~ m|^[^#]*$routine|;
67
        }
68
    }
69
    push @missing_auth_check, $name;
70
}
71
is( scalar @missing_auth_check, 0 ) or diag "No auth check in the following files:\n" . join "\n", @missing_auth_check;
72
done_testing;

Return to bug 24879