Bug 15839: Koha::Reviews - Add Koha::Review[s] classes
[koha.git] / t / db_dependent / Auth_with_cas.t
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
20 use Test::More tests => 4;
21 use CGI;
22
23 use t::lib::Mocks;
24 use C4::Context;
25
26 BEGIN {
27     use_ok('C4::Auth_with_cas');
28     can_ok('C4::Auth_with_cas', qw/
29             check_api_auth_cas
30             checkpw_cas
31             login_cas
32             logout_cas
33             login_cas_url
34             /);
35 }
36
37 my $dbh = C4::Context->dbh;
38 # Start transaction
39 $dbh->{ AutoCommit } = 0;
40 $dbh->{ RaiseError } = 1;
41
42 C4::Context->disable_syspref_cache();
43 t::lib::Mocks::mock_preference('OPACBaseURL','http://localhost');
44 t::lib::Mocks::mock_preference('staffClientBaseURL','localhost:8080');
45
46 my $opac_base_url = C4::Context->preference('OpacBaseURL');
47 my $staff_base_url = C4::Context->preference('staffClientBaseURL');
48 my $query_string = 'ticket=foo&bar=baz';
49
50 $ENV{QUERY_STRING} = $query_string;
51 $ENV{SCRIPT_NAME} = '/cgi-bin/koha/opac-user.pl';
52
53 my $cgi = new CGI($query_string);
54 $cgi->delete('ticket');
55
56 # _url_with_get_params tests
57 is(C4::Auth_with_cas::_url_with_get_params($cgi, 'opac'),
58     "$opac_base_url/cgi-bin/koha/opac-user.pl?bar=baz",
59    "_url_with_get_params should return URL without deleted parameters (Bug 12398)");
60
61 # intranet url test
62 is(C4::Auth_with_cas::_url_with_get_params($cgi, 'intranet'),
63     "$staff_base_url?bar=baz",
64    "Intranet URL should be returned when using intranet login (Bug 13507)");
65
66
67
68 $dbh->rollback;
69
70 1;