Lines 1-12
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
|
2 |
|
3 |
use strict; |
3 |
# This file is part of Koha. |
4 |
use warnings; |
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>. |
5 |
|
17 |
|
6 |
use Test::More tests => 6; |
18 |
use Modern::Perl; |
|
|
19 |
|
20 |
use Test::More tests => 7; |
7 |
use Test::Warn; |
21 |
use Test::Warn; |
8 |
use CGI qw ( -utf8 ); |
22 |
use CGI qw ( -utf8 ); |
9 |
|
23 |
|
|
|
24 |
use t::lib::Mocks; |
25 |
|
10 |
BEGIN { |
26 |
BEGIN { |
11 |
use_ok('C4::Output'); |
27 |
use_ok('C4::Output'); |
12 |
} |
28 |
} |
Lines 41-43
subtest 'parametrized_url' => sub {
Link Here
|
41 |
is( $res, 'https://somesite.com/search?q=_title_&author=', |
57 |
is( $res, 'https://somesite.com/search?q=_title_&author=', |
42 |
'Title replaced, author empty and SUFFIX removed' ); |
58 |
'Title replaced, author empty and SUFFIX removed' ); |
43 |
}; |
59 |
}; |
44 |
- |
60 |
|
|
|
61 |
subtest 'output_with_http_headers() tests' => sub { |
62 |
|
63 |
plan tests => 4; |
64 |
|
65 |
local *STDOUT; |
66 |
my $stdout; |
67 |
|
68 |
my $query = CGI->new(); |
69 |
my $cookie; |
70 |
my $output = 'foobarbaz'; |
71 |
|
72 |
open STDOUT, '>', \$stdout; |
73 |
t::lib::Mocks::mock_preference('AccessControlAllowOrigin',''); |
74 |
output_html_with_http_headers $query, $cookie, $output, undef; |
75 |
unlike($stdout, qr/Access-control-allow-origin/, 'No header set if no value on syspref'); |
76 |
close STDOUT; |
77 |
|
78 |
open STDOUT, '>', \$stdout; |
79 |
t::lib::Mocks::mock_preference('AccessControlAllowOrigin',undef); |
80 |
output_html_with_http_headers $query, $cookie, $output, undef; |
81 |
unlike($stdout, qr/Access-control-allow-origin/, 'No header set if no value on syspref'); |
82 |
close STDOUT; |
83 |
|
84 |
open STDOUT, '>', \$stdout; |
85 |
t::lib::Mocks::mock_preference('AccessControlAllowOrigin','*'); |
86 |
output_html_with_http_headers $query, $cookie, $output, undef; |
87 |
like($stdout, qr/Access-control-allow-origin: \*/, 'Header set to *'); |
88 |
close STDOUT; |
89 |
|
90 |
open STDOUT, '>', \$stdout; |
91 |
t::lib::Mocks::mock_preference('AccessControlAllowOrigin','https://koha-community.org'); |
92 |
output_html_with_http_headers $query, $cookie, $output, undef; |
93 |
like($stdout, qr/Access-control-allow-origin: https:\/\/koha-community\.org/, 'Header set to https://koha-community.org'); |
94 |
close STDOUT; |
95 |
}; |