Lines 41-47
subtest 'new' => sub {
Link Here
|
41 |
}; |
41 |
}; |
42 |
|
42 |
|
43 |
subtest 'clear_unless' => sub { |
43 |
subtest 'clear_unless' => sub { |
44 |
plan tests => 16; |
44 |
plan tests => 17; |
45 |
|
45 |
|
46 |
t::lib::Mocks::mock_config( Koha::CookieManager::DENY_LIST_VAR, [ 'aap', 'noot' ] ); |
46 |
t::lib::Mocks::mock_config( Koha::CookieManager::DENY_LIST_VAR, [ 'aap', 'noot' ] ); |
47 |
|
47 |
|
Lines 74-92
subtest 'clear_unless' => sub {
Link Here
|
74 |
is( $rv[1]->httponly, 0, 'cleared wim is not httponly' ); |
74 |
is( $rv[1]->httponly, 0, 'cleared wim is not httponly' ); |
75 |
is( $rv[2]->httponly, 1, 'aap httponly' ); |
75 |
is( $rv[2]->httponly, 1, 'aap httponly' ); |
76 |
|
76 |
|
77 |
# Test with _123 prefix |
77 |
# Test with numeric suffix (via regex) |
78 |
t::lib::Mocks::mock_config( Koha::CookieManager::DENY_LIST_VAR, [ 'catalogue_editor_' ] ); |
78 |
t::lib::Mocks::mock_config( Koha::CookieManager::DENY_LIST_VAR, [ 'catalogue_editor_\d+' ] ); |
79 |
$cmgr = Koha::CookieManager->new; |
79 |
$cmgr = Koha::CookieManager->new; |
80 |
$cookie1 = $q->cookie( -name => 'catalogue_editor_234', -value => '1', -expires => '+1y' ); |
80 |
$cookie1 = $q->cookie( -name => 'catalogue_editor_abc', -value => '1', -expires => '+1y' ); |
81 |
$cookie2 = $q->cookie( -name => 'catalogue_editor_345', -value => '1', -expires => '+1y' ); |
81 |
$cookie2 = $q->cookie( -name => 'catalogue_editor_345', -value => '1', -expires => '+1y' ); |
82 |
$cookie3 = $q->cookie( -name => 'catalogue_editor_', -value => '1', -expires => '+1y' ); |
82 |
$cookie3 = $q->cookie( -name => 'catalogue_editor_', -value => '1', -expires => '+1y' ); |
83 |
$cookie4 = $q->cookie( -name => 'catalogue_editor', -value => '1', -expires => '+1y' ); |
83 |
$cookie4 = $q->cookie( -name => 'catalogue_editor_123x', -value => '1', -expires => '+1y' ); |
84 |
|
84 |
|
85 |
$list = [ $cookie1, $cookie2, $cookie3, $cookie4 ]; |
85 |
$list = [ $cookie1, $cookie2, $cookie3, $cookie4 ]; |
86 |
@rv = @{$cmgr->clear_unless( @$list )}; |
86 |
@rv = @{$cmgr->clear_unless( @$list )}; |
87 |
is_deeply( [ map { $_->value ? $_->name : () } @rv ], |
87 |
is_deeply( [ map { $_->value ? $_->name : () } @rv ], |
88 |
[ 'catalogue_editor_234', 'catalogue_editor_345', 'catalogue_editor_' ], |
88 |
[ 'catalogue_editor_345' ], |
89 |
'Only cookie4 should have been cleared' ); |
89 |
'Cookie2 should be found only' ); |
|
|
90 |
|
91 |
# Test with another regex (yes, highly realistic examples :) |
92 |
t::lib::Mocks::mock_config( Koha::CookieManager::DENY_LIST_VAR, [ 'next_\w+_number\d{2}_(now|never)' ] ); |
93 |
$cmgr = Koha::CookieManager->new; |
94 |
my $cookie5; |
95 |
$cookie1 = $q->cookie( -name => 'next_mynewword_number99_never', -value => '1', -expires => '+1y' ); #fine |
96 |
$cookie2 = $q->cookie( -name => 'prefixed_next_mynewword_number99_never', -value => '1', -expires => '+1y' ); # wrong prefix |
97 |
$cookie3 = $q->cookie( -name => 'next_mynew-word_number99_never', -value => '1', -expires => '+1y' ); # wrong: hyphen in word |
98 |
$cookie4 = $q->cookie( -name => 'mynewword_number999_never', -value => '1', -expires => '+1y' ); # wrong: three digits |
99 |
$cookie5 = $q->cookie( -name => 'next_mynewword_number99_always', -value => '1', -expires => '+1y' ); # wrong: always |
100 |
@rv = @{$cmgr->clear_unless( $cookie1, $cookie2, $cookie3, $cookie4, $cookie5 )}; |
101 |
is_deeply( [ map { $_->value ? $_->name : () } @rv ], [ 'next_mynewword_number99_never' ], 'Only cookie1 matched' ); |
102 |
|
90 |
}; |
103 |
}; |
91 |
|
104 |
|
92 |
subtest 'replace_in_list' => sub { |
105 |
subtest 'replace_in_list' => sub { |
93 |
- |
|
|