Lines 16-25
Link Here
|
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
use Data::Dumper qw( Dumper ); |
19 |
use Test::More tests => 2; |
20 |
use Test::More tests => 1; |
|
|
21 |
|
20 |
|
22 |
use Koha::AllowList; |
21 |
use Koha::AllowList; |
|
|
22 |
use Koha::DenyList; |
23 |
|
23 |
|
24 |
subtest 'AllowList' => sub { |
24 |
subtest 'AllowList' => sub { |
25 |
plan tests => 17; |
25 |
plan tests => 17; |
Lines 73-75
subtest 'AllowList' => sub {
Link Here
|
73 |
# Test keys method |
73 |
# Test keys method |
74 |
is( join(',', $allowlist->keys), 'col1,col4', 'List current entries' ); |
74 |
is( join(',', $allowlist->keys), 'col1,col4', 'List current entries' ); |
75 |
}; |
75 |
}; |
76 |
- |
76 |
|
|
|
77 |
subtest 'DenyList' => sub { |
78 |
plan tests => 6; |
79 |
|
80 |
my $defaults = [ 'col1', 'col3' ]; |
81 |
my $denylist = Koha::DenyList->new({ defaults => $defaults }); |
82 |
my $input = { col1 => 1, col2 => 2, col3 => 3, col4 => 4 }; |
83 |
my $blocked = {}; |
84 |
my $result = $denylist->apply({ input => $input, dump => $blocked }); |
85 |
is( keys %$result, 2, 'Two remain' ); |
86 |
is( $result->{col2}, 2, 'col2 was ok' ); |
87 |
is( keys %$blocked, 2, 'Two got denied' ); |
88 |
is( $blocked->{col1}, 1, 'col1 blocked' ); |
89 |
$denylist->remove('col1'); |
90 |
$denylist->add('col5'); |
91 |
is( $denylist->check({ input => $input }), q{}, 'input still fails' ); |
92 |
delete $input->{col3}; |
93 |
is( $denylist->check({ input => $input }), 1, 'input is ok now' ); |
94 |
}; |