|
Lines 28-40
use C4::Context;
Link Here
|
| 28 |
|
28 |
|
| 29 |
BEGIN { |
29 |
BEGIN { |
| 30 |
if ( check_install( module => 'Test::DBIx::Class' ) ) { |
30 |
if ( check_install( module => 'Test::DBIx::Class' ) ) { |
| 31 |
plan tests => 11; |
31 |
plan tests => 17; |
| 32 |
} else { |
32 |
} |
| 33 |
plan skip_all => "Need Test::DBIx::Class" |
33 |
else { |
|
|
34 |
plan skip_all => "Need Test::DBIx::Class"; |
| 34 |
} |
35 |
} |
| 35 |
} |
36 |
} |
| 36 |
|
37 |
|
| 37 |
use Test::DBIx::Class; |
38 |
use Test::DBIx::Class { |
|
|
39 |
schema_class => 'Koha::Schema', |
| 40 |
connect_info => [ 'dbi:SQLite:dbname=:memory:', '', '' ] |
| 41 |
}; |
| 38 |
|
42 |
|
| 39 |
# Mock Variables |
43 |
# Mock Variables |
| 40 |
my $matchpoint = 'userid'; |
44 |
my $matchpoint = 'userid'; |
|
Lines 63-73
$context->mock( 'config', \&mockedConfig );
Link Here
|
| 63 |
|
67 |
|
| 64 |
### Mock ->preference |
68 |
### Mock ->preference |
| 65 |
my $OPACBaseURL = "testopac.com"; |
69 |
my $OPACBaseURL = "testopac.com"; |
|
|
70 |
my $staffClientBaseURL = "teststaff.com"; |
| 66 |
$context->mock( 'preference', \&mockedPref ); |
71 |
$context->mock( 'preference', \&mockedPref ); |
| 67 |
|
72 |
|
| 68 |
### Mock ->tz |
73 |
### Mock ->tz |
| 69 |
$context->mock( 'timezone', sub { return 'local'; } ); |
74 |
$context->mock( 'timezone', sub { return 'local'; } ); |
| 70 |
|
75 |
|
|
|
76 |
### Mock ->interface |
| 77 |
my $interface = 'opac'; |
| 78 |
$context->mock( 'interface', \&mockedInterface ); |
| 79 |
|
| 71 |
## Mock Database |
80 |
## Mock Database |
| 72 |
my $database = new Test::MockModule('Koha::Database'); |
81 |
my $database = new Test::MockModule('Koha::Database'); |
| 73 |
|
82 |
|
|
Lines 250-264
subtest "checkpw_shib tests" => sub {
Link Here
|
| 250 |
|
259 |
|
| 251 |
}; |
260 |
}; |
| 252 |
|
261 |
|
| 253 |
## _get_uri |
262 |
## _get_uri - opac |
| 254 |
$OPACBaseURL = "testopac.com"; |
263 |
$OPACBaseURL = "testopac.com"; |
| 255 |
is( C4::Auth_with_shibboleth::_get_uri(), |
264 |
is( C4::Auth_with_shibboleth::_get_uri(), |
| 256 |
"https://testopac.com", "https opac uri returned" ); |
265 |
"https://testopac.com", "https opac uri returned" ); |
| 257 |
|
266 |
|
| 258 |
$OPACBaseURL = "http://testopac.com"; |
267 |
$OPACBaseURL = "http://testopac.com"; |
| 259 |
my $result; |
268 |
my $result; |
| 260 |
warning_like { $result = C4::Auth_with_shibboleth::_get_uri() } |
269 |
warnings_are { $result = C4::Auth_with_shibboleth::_get_uri() }[ |
| 261 |
[qr/Shibboleth requires OPACBaseURL to use the https protocol!/], |
270 |
"shibboleth interface: $interface", |
|
|
271 |
"Shibboleth requires OPACBaseURL/staffClientBaseURL to use the https protocol!" |
| 272 |
], |
| 262 |
"improper protocol - received expected warning"; |
273 |
"improper protocol - received expected warning"; |
| 263 |
is( $result, "https://testopac.com", "https opac uri returned" ); |
274 |
is( $result, "https://testopac.com", "https opac uri returned" ); |
| 264 |
|
275 |
|
|
Lines 267-276
is( C4::Auth_with_shibboleth::_get_uri(),
Link Here
|
| 267 |
"https://testopac.com", "https opac uri returned" ); |
278 |
"https://testopac.com", "https opac uri returned" ); |
| 268 |
|
279 |
|
| 269 |
$OPACBaseURL = undef; |
280 |
$OPACBaseURL = undef; |
| 270 |
warning_like { $result = C4::Auth_with_shibboleth::_get_uri() } |
281 |
warnings_are { $result = C4::Auth_with_shibboleth::_get_uri() } |
| 271 |
[qr/OPACBaseURL not set!/], |
282 |
[ "shibboleth interface: $interface", "OPACBaseURL not set!" ], |
| 272 |
"undefined OPACBaseURL - received expected warning"; |
283 |
"undefined OPACBaseURL - received expected warning"; |
| 273 |
is( $result, "https://", "https opac uri returned" ); |
284 |
is( $result, "https://", "https $interface uri returned" ); |
|
|
285 |
|
| 286 |
## _get_uri - intranet |
| 287 |
$interface = 'intranet'; |
| 288 |
$staffClientBaseURL = "teststaff.com"; |
| 289 |
is( C4::Auth_with_shibboleth::_get_uri(), |
| 290 |
"https://teststaff.com", "https $interface uri returned" ); |
| 291 |
|
| 292 |
$staffClientBaseURL = "http://teststaff.com"; |
| 293 |
warnings_are { $result = C4::Auth_with_shibboleth::_get_uri() }[ |
| 294 |
"shibboleth interface: $interface", |
| 295 |
"Shibboleth requires OPACBaseURL/staffClientBaseURL to use the https protocol!" |
| 296 |
], |
| 297 |
"improper protocol - received expected warning"; |
| 298 |
is( $result, "https://teststaff.com", "https $interface uri returned" ); |
| 299 |
|
| 300 |
$staffClientBaseURL = "https://teststaff.com"; |
| 301 |
is( C4::Auth_with_shibboleth::_get_uri(), |
| 302 |
"https://teststaff.com", "https $interface uri returned" ); |
| 303 |
|
| 304 |
$staffClientBaseURL = undef; |
| 305 |
warnings_are { $result = C4::Auth_with_shibboleth::_get_uri() } |
| 306 |
[ "shibboleth interface: $interface", "staffClientBaseURL not set!" ], |
| 307 |
"undefined staffClientBaseURL - received expected warning"; |
| 308 |
is( $result, "https://", "https $interface uri returned" ); |
| 274 |
|
309 |
|
| 275 |
## _get_shib_config |
310 |
## _get_shib_config |
| 276 |
# Internal helper function, covered in tests above |
311 |
# Internal helper function, covered in tests above |
|
Lines 295-303
sub mockedPref {
Link Here
|
| 295 |
$return = $OPACBaseURL; |
330 |
$return = $OPACBaseURL; |
| 296 |
} |
331 |
} |
| 297 |
|
332 |
|
|
|
333 |
if ( $param eq 'staffClientBaseURL' ) { |
| 334 |
$return = $staffClientBaseURL; |
| 335 |
} |
| 336 |
|
| 298 |
return $return; |
337 |
return $return; |
| 299 |
} |
338 |
} |
| 300 |
|
339 |
|
|
|
340 |
sub mockedInterface { |
| 341 |
return $interface; |
| 342 |
} |
| 343 |
|
| 301 |
sub mockedSchema { |
344 |
sub mockedSchema { |
| 302 |
return Schema(); |
345 |
return Schema(); |
| 303 |
} |
346 |
} |
| 304 |
- |
|
|