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

(-)a/t/Auth_with_shibboleth.t (-45 / +44 lines)
Lines 270-326 subtest "checkpw_shib tests" => sub { Link Here
270
};
270
};
271
271
272
subtest 'get_uri' => sub {
272
subtest 'get_uri' => sub {
273
plan tests => 13;
273
    plan tests => 13;
274
# Tests for OPAC
274
    # Tests for OPAC
275
t::lib::Mocks::mock_preference('OPACBaseURL', 'testopac.com' );
275
    t::lib::Mocks::mock_preference('OPACBaseURL', 'testopac.com' );
276
is( C4::Auth_with_shibboleth::_get_uri(),
276
    is( C4::Auth_with_shibboleth::_get_uri(),
277
    "https://testopac.com", "https opac uri returned" );
277
        "https://testopac.com", "https opac uri returned" );
278
279
    $logger->clear;
280
281
    t::lib::Mocks::mock_preference('OPACBaseURL', 'http://testopac.com' );
282
    my $result = C4::Auth_with_shibboleth::_get_uri();
283
    is( $result, "https://testopac.com", "https opac uri returned" );
284
    $logger->warn_is("Shibboleth requires OPACBaseURL/staffClientBaseURL to use the https protocol!", "Improper protocol logged to warn")
285
           ->clear();
278
286
279
$logger->clear;
287
    t::lib::Mocks::mock_preference('OPACBaseURL', 'https://testopac.com' );
288
    is( C4::Auth_with_shibboleth::_get_uri(),
289
        "https://testopac.com", "https opac uri returned" );
280
290
281
t::lib::Mocks::mock_preference('OPACBaseURL', 'http://testopac.com' );
291
    $logger->clear();
282
my $result = C4::Auth_with_shibboleth::_get_uri();
283
is( $result, "https://testopac.com", "https opac uri returned" );
284
$logger->warn_is("Shibboleth requires OPACBaseURL/staffClientBaseURL to use the https protocol!", "Improper protocol logged to warn")
285
       ->clear();
286
292
287
t::lib::Mocks::mock_preference('OPACBaseURL', 'https://testopac.com' );
293
    t::lib::Mocks::mock_preference('OPACBaseURL', undef );
288
is( C4::Auth_with_shibboleth::_get_uri(),
294
    $result = C4::Auth_with_shibboleth::_get_uri();
289
    "https://testopac.com", "https opac uri returned" );
295
    is( $result, "https://", "https $interface uri returned" );
290
296
291
$logger->clear();
297
    $logger->warn_is("Syspref staffClientBaseURL or OPACBaseURL not set!", "undefined OPACBaseURL - received expected warning")
298
           ->clear();
292
299
293
t::lib::Mocks::mock_preference('OPACBaseURL', undef );
300
    # Tests for staff client
294
$result = C4::Auth_with_shibboleth::_get_uri();
301
    $interface = 'intranet';
295
is( $result, "https://", "https $interface uri returned" );
302
    t::lib::Mocks::mock_preference('StaffClientBaseURL', 'teststaff.com' );
303
    is( C4::Auth_with_shibboleth::_get_uri(),
304
        "https://teststaff.com", "https $interface uri returned" );
296
305
297
$logger->warn_is("Syspref staffClientBaseURL or OPACBaseURL not set!", "undefined OPACBaseURL - received expected warning")
306
    $logger->clear;
298
       ->clear();
299
307
300
# Tests for staff client
308
    t::lib::Mocks::mock_preference('StaffClientBaseURL', 'http://teststaff.com' );
301
$interface = 'intranet';
309
    $result = C4::Auth_with_shibboleth::_get_uri();
302
t::lib::Mocks::mock_preference('StaffClientBaseURL', 'teststaff.com' );
310
    is( $result, "https://teststaff.com", "https $interface uri returned" );
303
is( C4::Auth_with_shibboleth::_get_uri(),
311
    $logger->warn_is("Shibboleth requires OPACBaseURL/staffClientBaseURL to use the https protocol!", 'check protocol warn')
304
    "https://teststaff.com", "https $interface uri returned" );
312
           ->clear;
305
313
306
$logger->clear;
314
    t::lib::Mocks::mock_preference('StaffClientBaseURL', 'https://teststaff.com' );
307
315
    is( C4::Auth_with_shibboleth::_get_uri(),
308
t::lib::Mocks::mock_preference('StaffClientBaseURL', 'http://teststaff.com' );
316
        "https://teststaff.com", "https $interface uri returned" );
309
$result = C4::Auth_with_shibboleth::_get_uri();
317
    is( $logger->count(), 0, 'No logging' );
310
is( $result, "https://teststaff.com", "https $interface uri returned" );
318
311
$logger->warn_is("Shibboleth requires OPACBaseURL/staffClientBaseURL to use the https protocol!", 'check protocol warn')
319
    t::lib::Mocks::mock_preference('StaffClientBaseURL', undef );
312
       ->clear;
320
    $result = C4::Auth_with_shibboleth::_get_uri();
313
321
    is( $result, "https://", "https $interface uri returned" );
314
t::lib::Mocks::mock_preference('StaffClientBaseURL', 'https://teststaff.com' );
322
    $logger->warn_is("Syspref staffClientBaseURL or OPACBaseURL not set!", "undefined staffClientBaseURL - received expected warning")
315
is( C4::Auth_with_shibboleth::_get_uri(),
323
           ->clear;
316
    "https://teststaff.com", "https $interface uri returned" );
317
is( $logger->count(), 0, 'No logging' );
318
319
t::lib::Mocks::mock_preference('StaffClientBaseURL', undef );
320
$result = C4::Auth_with_shibboleth::_get_uri();
321
is( $result, "https://", "https $interface uri returned" );
322
$logger->warn_is("Syspref staffClientBaseURL or OPACBaseURL not set!", "undefined staffClientBaseURL - received expected warning")
323
       ->clear;
324
};
324
};
325
$schema->storage->txn_rollback;
325
$schema->storage->txn_rollback;
326
326
327
- 

Return to bug 33778