Bug 5010: Fix OPACBaseURL to include protocol
[koha.git] / t / db_dependent / Auth_with_cas.t
blobb67ba1e46f990090297d6e75b7890ecf5f4ab9b4
1 #!/usr/bin/perl
3 # This file is part of Koha.
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.
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.
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>.
18 use Modern::Perl;
20 use Test::More tests => 4;
21 use CGI;
23 use C4::Context;
25 BEGIN {
26 use_ok('C4::Auth_with_cas');
27 can_ok('C4::Auth_with_cas', qw/
28 check_api_auth_cas
29 checkpw_cas
30 login_cas
31 logout_cas
32 login_cas_url
33 /);
36 my $dbh = C4::Context->dbh;
37 # Start transaction
38 $dbh->{ AutoCommit } = 0;
39 $dbh->{ RaiseError } = 1;
41 C4::Context->set_preference('OPACBaseURL','http://localhost');
42 C4::Context->set_preference('staffClientBaseURL','localhost:8080');
44 my $opac_base_url = C4::Context->preference('OpacBaseURL');
45 my $staff_base_url = C4::Context->preference('staffClientBaseURL');
46 my $query_string = 'ticket=foo&bar=baz';
48 $ENV{QUERY_STRING} = $query_string;
49 $ENV{SCRIPT_NAME} = '/cgi-bin/koha/opac-user.pl';
51 my $cgi = new CGI($query_string);
52 $cgi->delete('ticket');
54 # _url_with_get_params tests
55 is(C4::Auth_with_cas::_url_with_get_params($cgi, 'opac'),
56 "$opac_base_url/cgi-bin/koha/opac-user.pl?bar=baz",
57 "_url_with_get_params should return URL without deleted parameters (Bug 12398)");
59 # intranet url test
60 is(C4::Auth_with_cas::_url_with_get_params($cgi, 'intranet'),
61 "$staff_base_url?bar=baz",
62 "Intranet URL should be returned when using intranet login (Bug 13507)");
66 $dbh->rollback;