Files
SluijsensandClaude Sonnet 5.5 728fc08db8 PUT /availability/status vervangt POST /availability/admin/status; de poort sluit alleen het lezen van de status vrij
De status is één resource: de publieke GET en de PUT van de beheerder delen het pad; de PUT geeft de bijgewerkte resource terug. De vrijstelling van de poort geldt nu alleen voor GET en HEAD, zodat de PUT als beheerroute gewoon achter de poort blijft. De oude route verdwijnt zonder alias, dus API en admin-app moeten als één release uit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-10 13:39:40 +01:00

3.8 KiB

CMS-U7 availability-restful-status: code summary

RELEASE NOTE: this unit must go out as ONE release together with the admin app

POST /api/v1/Availability/admin/status is removed (no alias) and replaced by PUT /api/v1/Availability/status. The API and the admin app (frontend/) change together. Deploying only one half breaks the status change in Settings: a new API with an old admin bundle gets a non-JSON fallback page on the old route; a new bundle on an old API gets 405/404. During a deploy window a still-open old browser tab fails until its next page load.

Result

  • PUT /api/v1/Availability/status (AdminOnly), body unchanged { "newStatus": "Available"|"Maintenance"|"NotAvailable", "reason": string|null }. 200 with the updated resource, same JSON as GET /api/v1/Availability/status ({ status, checkedAt, message, isMasterControlled }); 409 problem+json when the status is master-controlled (unchanged); 400 for an invalid status or a service that cannot persist; 401/403 like every admin route.
  • GET /api/v1/Availability/status is unchanged (public, open for everyone, also while the CMS is off).
  • Old route removed; openapi/slpsoftware.v1.json regenerated.
  • Gate (AvailabilityMiddleware, small isolated diff): the exemption for /api/v1/Availability/status now applies to GET/HEAD only. PUT (and any other method) follows the normal gate: a verified Owner/Administrator passes, an expired token gets 401, everyone else 503. Before, the prefix exemption let any method through.
  • Frontend: useUpdateAvailability uses PUT and writes the answer into the status cache; msw default handler and the two failure handlers in SettingsPage.test.tsx moved to PUT; a new test asserts method, path (no admin) and body.

Callers of the old route (checked repository-wide: code, docs, CI, configs)

Only the admin frontend: features/availability/services/useAvailability.ts, features/availability/mocks/handlers.ts, two handlers in features/settings/pages/SettingsPage.test.tsx. No server-side caller: the master pushes with POST /Master/status, slaves read GET /SlaveStatus; no proxy, deploy script or workflow mentions it; the README names only the GET. Historic aidlc-docs mentions are history and unchanged.

Changes to existing tests (for the record)

Three existing tests built a request without an HTTP method (the default is empty) and relied on the old method-less prefix exemption. They now set GET like a real request does: TestContexts.Api() and AvailabilityGateScopeTests.RunAsync (shared helpers) and PublicSiteEndpointGateTests.TheAvailabilityStatusEndpoint_StaysOpen.... AvailabilityControllerTests.UpdateStatus_ReturnsOk... now asserts the body (OkObjectResult, same four fields as the GET) instead of OkResult. No assertion about gate behaviour was weakened.

Verification (real output)

Build 0 errors. Availability.Tests 165 passed (11 new in AvailabilityStatusRouteTests: GET/HEAD stay open; PUT/POST/DELETE/PATCH are gated; a verified administrator passes while the CMS is disabled; an expired token on PUT = 401; case-insensitive path; route table = exactly GET status + PUT status, PUT is AdminOnly and not public-marked, no admin in any route). Contact.Tests 228 passed (3 new pipeline tests on the real host: anonymous PUT 401, user 403, administrator PUT Maintenance -> body is the updated resource -> anonymous GET shows it -> visitor gets 503 on a gated route and on the PUT itself -> administrator switches it back; invalid status 400 and unchanged state; the old route behaves like a route that never existed and changes nothing). Api.AndreaSlopFotografie 11, Api 4, Core 625, Identity 145, Master 61, Offerings 86. Frontend: pnpm lint clean, npx tsc -b clean, vitest 57 files / 432 tests passed (1 new).