Bug 34999 - REST API: Public routes should respect OPACMaintenance
Summary: REST API: Public routes should respect OPACMaintenance
Status: Pushed to oldstable
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor (vote)
Assignee: Marcel de Rooy
QA Contact: Kyle M Hall
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-10-06 06:48 UTC by Marcel de Rooy
Modified: 2024-02-02 16:23 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This report ensures that if OPACMaintenance is set, public API calls are blocked with an UnderMaintenance exception.
Version(s) released in:
24.05.00,23.11.02,23.05.09


Attachments
Bug 34999: Throw exception for public routes if OPACMaintenance is enabled (2.09 KB, patch)
2023-11-24 10:57 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 34999: Throw exception for public routes if OPACMaintenance is enabled (1.64 KB, patch)
2023-11-24 10:59 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 34999: Throw exception for public routes if OPACMaintenance is enabled (1.59 KB, patch)
2024-01-11 10:43 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 34999: Add unit test (1.48 KB, patch)
2024-01-11 10:43 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 34999: Throw exception for public routes if OPACMaintenance is enabled (1.61 KB, patch)
2024-01-11 11:40 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 34999: Add unit test (1.50 KB, patch)
2024-01-11 11:40 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 34999: Throw exception for public routes if OPACMaintenance is enabled (1.67 KB, patch)
2024-01-12 14:54 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 34999: Add unit test (1.56 KB, patch)
2024-01-12 14:54 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2023-10-06 06:48:15 UTC

    
Comment 1 Marcel de Rooy 2023-11-24 10:43:32 UTC Comment hidden (obsolete)
Comment 2 Marcel de Rooy 2023-11-24 10:47:45 UTC Comment hidden (obsolete)
Comment 3 Marcel de Rooy 2023-11-24 10:56:43 UTC
New title, new contents.
The public endpoints now still return output while Maintenance is enabled.
Comment 4 Marcel de Rooy 2023-11-24 10:57:12 UTC
Created attachment 159234 [details] [review]
Bug 34999: Throw exception for public routes if OPACMaintenance is enabled

Test plan:
[1] Try public endpoint like /api/v1/public/biblios/X/items.
    * Replace X by an existing biblionumber.
    You should receive a 200.
[2] Enable OPACMaintenance. Set to Show.
[3] Try same endpoint. You should get a 503 with a json error.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 5 Marcel de Rooy 2023-11-24 10:57:31 UTC
Still needs a unit test.
Comment 6 Marcel de Rooy 2023-11-24 10:58:58 UTC
TODO 

-            return $c->render(status => 503, json => { error => $_->error });
+            return $c->render(status => 503, json => { error => $_->message });

This is not needed.
Comment 7 Marcel de Rooy 2023-11-24 10:59:47 UTC
Created attachment 159235 [details] [review]
Bug 34999: Throw exception for public routes if OPACMaintenance is enabled

Test plan:
[1] Try public endpoint like /api/v1/public/biblios/X/items.
    * Replace X by an existing biblionumber.
    You should receive a 200.
[2] Enable OPACMaintenance. Set to Show.
[3] Try same endpoint. You should get a 503 with a json error.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 8 Marcel de Rooy 2024-01-11 10:43:33 UTC
Created attachment 160828 [details] [review]
Bug 34999: Throw exception for public routes if OPACMaintenance is enabled

Test plan:
[1] Try public endpoint like /api/v1/public/biblios/X/items.
    * Replace X by an existing biblionumber.
    You should receive a 200.
[2] Enable OPACMaintenance. Set to Show.
[3] Try same endpoint. You should get a 503 with a json error.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 9 Marcel de Rooy 2024-01-11 10:43:35 UTC
Created attachment 160829 [details] [review]
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 <m.de.rooy@rijksmuseum.nl>
Comment 10 Marcel de Rooy 2024-01-11 10:44:43 UTC
Test Summary Report
-------------------
t/db_dependent/api/v1/erm_counter_registries.t       (Wstat: 256 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
t/db_dependent/api/v1/erm_sushi_services.t           (Wstat: 256 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
t/db_dependent/api/v1/two_factor_auth.t              (Wstat: 512 Tests: 1 Failed: 1)
  Failed test:  1
  Non-zero exit status: 2
  Parse errors: Bad plan.  You planned 2 tests but ran 1.
Files=67, Tests=380, 812 wallclock secs ( 0.75 usr  0.18 sys + 748.36 cusr 48.36 csys = 797.65 CPU)
Result: FAIL

So 3 tests failed. No problem however:
Bug 35757 - Sushi service and counter registry tests are failing RESOLVES the first two failing tests.
Adding an encryption key to koha_conf resolved the two_factor_auth.t failures.
Comment 11 Martin Renvoize 2024-01-11 11:40:48 UTC
Created attachment 160840 [details] [review]
Bug 34999: Throw exception for public routes if OPACMaintenance is enabled

Test plan:
[1] Try public endpoint like /api/v1/public/biblios/X/items.
    * Replace X by an existing biblionumber.
    You should receive a 200.
[2] Enable OPACMaintenance. Set to Show.
[3] Try same endpoint. You should get a 503 with a json error.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 12 Martin Renvoize 2024-01-11 11:40:51 UTC
Created attachment 160841 [details] [review]
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 <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 13 Kyle M Hall 2024-01-12 14:54:17 UTC
Created attachment 160973 [details] [review]
Bug 34999: Throw exception for public routes if OPACMaintenance is enabled

Test plan:
[1] Try public endpoint like /api/v1/public/biblios/X/items.
    * Replace X by an existing biblionumber.
    You should receive a 200.
[2] Enable OPACMaintenance. Set to Show.
[3] Try same endpoint. You should get a 503 with a json error.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 14 Kyle M Hall 2024-01-12 14:54:45 UTC
Created attachment 160974 [details] [review]
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 <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 15 Katrin Fischer 2024-01-16 11:09:05 UTC
Pushed for 24.05!

Well done everyone, thank you!
Comment 16 Fridolin Somers 2024-01-17 09:19:19 UTC
Pushed to 23.11.x for 23.11.02
Comment 17 Fridolin Somers 2024-01-17 09:20:06 UTC
Needs some release notes
Comment 18 Marcel de Rooy 2024-01-19 08:44:34 UTC
(In reply to Fridolin Somers from comment #17)
> Needs some release notes

Hmm. The title of this report tells mostly what it does. But I can add a few words that tell it again :)
Comment 19 Lucas Gass 2024-02-02 16:23:39 UTC
Backported to 23.05.x for upcoming 23.05.09