https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42311 Pedro Amorim (ammopt) <pedro.amorim@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pedro.amorim@openfifth.co.u | |k Status|Passed QA |Failed QA --- Comment #25 from Pedro Amorim (ammopt) <pedro.amorim@openfifth.co.uk> --- Hi all, a few blockers here worth fixing before push: Setup: Inside KTD, rebuild the API bundle and restart plack: $ ktd --shell k$ yarn api:bundle k$ koha-plack --restart kohadev Blocker 1: GET /libraries/{library_id}/calendar silently truncates each list at RESTdefaultPageSize list() calls $c->objects->search for each closure type, so each list is paginated to 20 rows with no way to request more (the spec doesn't declare _per_page). The 42310 migration copies all historic special_holidays, so most upgraded libraries will be over 20 single closures from day one. 1) Add 25 single closures to CPL: k$ for d in $(seq -w 1 25); do curl -s -o /dev/null -u koha:koha -H 'Content-Type: application/json' -d "{\"date\":\"2099-01-$d\",\"description\":\"\"}" http://localhost:8081/api/v1/libraries/CPL/calendar/single_closures; done 2) Count what the calendar endpoint returns: k$ curl -s -u koha:koha http://localhost:8081/api/v1/libraries/CPL/calendar | perl -MJSON -0ne 'print scalar @{decode_json($_)->{single_closures}}, "\n"' 3) Confirm it says 20, not 25 4) Look at the pagination header: k$ curl -s -D - -o /dev/null -u koha:koha http://localhost:8081/api/v1/libraries/CPL/calendar | grep -i x-total-count 5) Confirm it's garbage: 'X-Total-Count: 0, 0, 25, 0' Blocker 2: POST with only the required fields explodes 'description' is NOT NULL with no default in all 4 tables, but optional in all 4 POST specs. 1) Add a weekly closure with just 'weekday' (the only required field in the spec): k$ curl -s -u koha:koha -H 'Content-Type: application/json' -d '{"weekday":3}' http://localhost:8081/api/v1/libraries/CPL/calendar/weekly_closures 2) Confirm it explodes with a nasty 500 error, and the log shows 'Koha::Exceptions::Object::NotNull': k$ tail -n 5 /var/log/koha/kohadev/api-error.log 3) Same thing happens for repeating_closures ('day'+'month'), single_closures and closure_exceptions ('date') Blocker 3: repeating closures accept impossible dates The spec has no bounds on 'day'/'month' and RepeatingClosure has no store validation, so invalid rows get stored and would need an atomicupdate to clean up later. 1) Add a repeating closure on day 99 of month 13: k$ curl -s -u koha:koha -H 'Content-Type: application/json' -d '{"day":99,"month":13,"description":""}' http://localhost:8081/api/v1/libraries/CPL/calendar/repeating_closures 2) Confirm it's stored and returned (201) instead of rejected with a 400 Blocker 4: copy() test starts failing on 2027-01-02 The test hardcodes a '2027-01-01' single closure, and copy_to only copies single closures dated today or later. 1) Run the tests normally, confirm they pass: k$ prove t/db_dependent/api/v1/libraries_calendar.t 2) Run them again with the clock set to 2027-01-02: k$ perl -MTest::MockTime=set_absolute_time -e 'BEGIN { set_absolute_time("2027-01-02T12:00:00Z") } do "./t/db_dependent/api/v1/libraries_calendar.t"; die $@ if $@' 2>&1 | grep -E '^(not )?ok|Failed test' 3) Confirm 'not ok 7 - copy() tests' / 'Failed test 'Single copied'' -- You are receiving this mail because: You are watching all bug changes.