From b8d9cce6645b913c57410a855986b76c84d2346b Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Thu, 11 Jan 2024 10:09:57 +0000 Subject: [PATCH] Bug 34999: Add unit test Test plan: Run t/db_dependent/api/v1/auth.t [Bonus] Run prove t/db_dependent/api/v1 Signed-off-by: Marcel de Rooy Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Katrin Fischer --- t/db_dependent/api/v1/auth.t | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/api/v1/auth.t b/t/db_dependent/api/v1/auth.t index cdb171925c..5d4f827f58 100755 --- a/t/db_dependent/api/v1/auth.t +++ b/t/db_dependent/api/v1/auth.t @@ -40,7 +40,7 @@ my $tx; subtest 'under() tests' => sub { - plan tests => 20; + plan tests => 23; $schema->storage->txn_begin; @@ -104,6 +104,15 @@ subtest 'under() tests' => sub { ->status_is(503) ->json_is('/error', 'System is under maintenance.'); + # 503 (public while maintenance syspref activated) + t::lib::Mocks::mock_preference( 'OPACMaintenance', 1 ); + t::lib::Mocks::mock_preference( 'RESTPublicAPI', 1 ); + $tx = $t->ua->build_tx( GET => "/api/v1/public/libraries" ); + $tx->req->env( { REMOTE_ADDR => $remote_address } ); + $t->request_ok($tx)->status_is(503)->json_is( '/error', 'Under maintenance' ); + t::lib::Mocks::mock_preference( 'OPACMaintenance', 0 ); + t::lib::Mocks::mock_preference( 'RESTPublicAPI', 0 ); + $schema->storage->txn_rollback; }; -- 2.20.1