View | Details | Raw Unified | Return to bug 12027
Collapse All | Expand All

(-)a/C4/Auth_with_shibboleth.pm (-1 lines)
Lines 134-140 sub _get_uri { Link Here
134
    my $interface = C4::Context->interface;
134
    my $interface = C4::Context->interface;
135
    $debug and warn "shibboleth interface: " . $interface;
135
    $debug and warn "shibboleth interface: " . $interface;
136
136
137
    my $return;
138
    my $uri;
137
    my $uri;
139
    if ( $interface eq 'intranet' ) {
138
    if ( $interface eq 'intranet' ) {
140
139
(-)a/t/Auth_with_shibboleth.t (-11 / +52 lines)
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 { schema_class => 'Koha::Schema', connect_info => ['dbi:SQLite:dbname=:memory:','',''] };
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-70 $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
73
my $interface = 'opac';
74
$context->mock( 'interface', \&mockedInterface );
75
68
## Mock Database
76
## Mock Database
69
my $database = new Test::MockModule('Koha::Database');
77
my $database = new Test::MockModule('Koha::Database');
70
78
Lines 247-261 subtest "checkpw_shib tests" => sub { Link Here
247
255
248
};
256
};
249
257
250
## _get_uri
258
## _get_uri - opac
251
$OPACBaseURL = "testopac.com";
259
$OPACBaseURL = "testopac.com";
252
is( C4::Auth_with_shibboleth::_get_uri(),
260
is( C4::Auth_with_shibboleth::_get_uri(),
253
    "https://testopac.com", "https opac uri returned" );
261
    "https://testopac.com", "https opac uri returned" );
254
262
255
$OPACBaseURL = "http://testopac.com";
263
$OPACBaseURL = "http://testopac.com";
256
my $result;
264
my $result;
257
warning_like { $result = C4::Auth_with_shibboleth::_get_uri() }
265
warnings_are { $result = C4::Auth_with_shibboleth::_get_uri() }[
258
[qr/Shibboleth requires OPACBaseURL to use the https protocol!/],
266
    "shibboleth interface: $interface",
267
"Shibboleth requires OPACBaseURL/staffClientBaseURL to use the https protocol!"
268
],
259
  "improper protocol - received expected warning";
269
  "improper protocol - received expected warning";
260
is( $result, "https://testopac.com", "https opac uri returned" );
270
is( $result, "https://testopac.com", "https opac uri returned" );
261
271
Lines 264-273 is( C4::Auth_with_shibboleth::_get_uri(), Link Here
264
    "https://testopac.com", "https opac uri returned" );
274
    "https://testopac.com", "https opac uri returned" );
265
275
266
$OPACBaseURL = undef;
276
$OPACBaseURL = undef;
267
warning_like { $result = C4::Auth_with_shibboleth::_get_uri() }
277
warnings_are { $result = C4::Auth_with_shibboleth::_get_uri() }
268
[qr/OPACBaseURL not set!/],
278
[ "shibboleth interface: $interface", "OPACBaseURL not set!" ],
269
  "undefined OPACBaseURL - received expected warning";
279
  "undefined OPACBaseURL - received expected warning";
270
is( $result, "https://", "https opac uri returned" );
280
is( $result, "https://", "https $interface uri returned" );
281
282
## _get_uri - intranet
283
$interface = 'intranet';
284
$staffClientBaseURL = "teststaff.com";
285
is( C4::Auth_with_shibboleth::_get_uri(),
286
    "https://teststaff.com", "https $interface uri returned" );
287
288
$staffClientBaseURL = "http://teststaff.com";
289
warnings_are { $result = C4::Auth_with_shibboleth::_get_uri() }[
290
    "shibboleth interface: $interface",
291
"Shibboleth requires OPACBaseURL/staffClientBaseURL to use the https protocol!"
292
],
293
  "improper protocol - received expected warning";
294
is( $result, "https://teststaff.com", "https $interface uri returned" );
295
296
$staffClientBaseURL = "https://teststaff.com";
297
is( C4::Auth_with_shibboleth::_get_uri(),
298
    "https://teststaff.com", "https $interface uri returned" );
299
300
$staffClientBaseURL = undef;
301
warnings_are { $result = C4::Auth_with_shibboleth::_get_uri() }
302
[ "shibboleth interface: $interface", "staffClientBaseURL not set!" ],
303
  "undefined staffClientBaseURL - received expected warning";
304
is( $result, "https://", "https $interface uri returned" );
271
305
272
## _get_shib_config
306
## _get_shib_config
273
# Internal helper function, covered in tests above
307
# Internal helper function, covered in tests above
Lines 292-300 sub mockedPref { Link Here
292
        $return = $OPACBaseURL;
326
        $return = $OPACBaseURL;
293
    }
327
    }
294
328
329
    if ( $param eq 'staffClientBaseURL' ) {
330
        $return = $staffClientBaseURL;
331
    }
332
295
    return $return;
333
    return $return;
296
}
334
}
297
335
336
sub mockedInterface {
337
    return $interface;
338
}
339
298
sub mockedSchema {
340
sub mockedSchema {
299
    return Schema();
341
    return Schema();
300
}
342
}
301
- 

Return to bug 12027