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>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
- **Feature Slug**: contact-forms-module
|
||||
- **Project Type**: Brownfield
|
||||
- **Start Date**: 2026-11-09
|
||||
- **Current Stage**: PHASE 2 planning - rebased on master e671078; plans CMS-U5, U6, U7 awaiting approval by Redesign - SLS
|
||||
- **Current Stage**: PHASE 2 - CMS-U7 built and committed; next CMS-U5, then CMS-U6
|
||||
- **Branch**: feature/contact-forms-module (worktree ..SlpModularCms-contact-forms, from master d9cc539; main checkout stays on feature/identity-email-notifications — never switch it)
|
||||
|
||||
## Workspace State
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
# 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).
|
||||
@@ -51,7 +51,7 @@ All answer `404` with an empty body while the **host** switch `Contact:Enabled`
|
||||
`status`: `new|read|archived|spam|converted`; `mailStatus`: `pending|sent|failed|notApplicable`.
|
||||
|
||||
### Unchanged but relevant
|
||||
`POST /availability/admin/status` still has its `admin` segment; it becomes `PUT /availability/status` in phase 2 (CMS-U7, after the ASF merge; callers to check then: master/slave status, poll client, frontend). `GET /availability/status` stays public.
|
||||
`PUT /availability/status` (AdminOnly; body `{ newStatus, reason }`; `200` with the updated resource in the GET shape, `409` master-controlled) replaced `POST /availability/admin/status` (CMS-U7, no alias; API and admin app must be released together). `GET /availability/status` stays public; the gate exempts it for GET/HEAD only.
|
||||
|
||||
## 2. `Contact:*` and related configuration keys (Api.SlpSoftware `appsettings.json`)
|
||||
| Key | Default | Notes |
|
||||
|
||||
+7
-7
@@ -15,13 +15,13 @@ Phase 2, on the rebased branch. Decision (Bryan via SLS): no `/admin` segment in
|
||||
4. Frontend: `useUpdateAvailability` uses `PUT` and updates the cached status from the response; mocks and the two Settings tests change to `PUT`.
|
||||
|
||||
## Steps
|
||||
- [ ] **Step 1 — Controller**: `[HttpPut("status")]` replaces `admin/status`; returns the updated status object (shared builder with GET); remove the old route.
|
||||
- [ ] **Step 2 — Middleware**: method-aware bypass for `Availability/status` (small, isolated diff); comment explains why.
|
||||
- [ ] **Step 3 — Frontend**: `useAvailability.ts` mutation (PUT + cache update), `availability/mocks/handlers.ts`, `SettingsPage.test.tsx` (2 handlers); no other change.
|
||||
- [ ] **Step 4 — Docs/contract**: regenerate `openapi/slpsoftware.v1.json`; update `phase-1-handoff.md`; README mention only if it names the route (it does not).
|
||||
- [ ] **Step 5 — Tests**: controller (PUT 200 body equals GET shape, 409 master-controlled, 400 invalid status, GET unchanged and anonymous); route-table test: the only anonymous action on the controller is `GetStatus`, `UpdateStatus` is `AdminOnly`, no route contains `admin`, old route absent; middleware: `PUT /api/v1/Availability/status` without token is blocked by the gate while the CMS is off (not bypassed), `GET` still open, a verified administrator can `PUT` while the CMS is disabled (existing guarantee), expired token on PUT = `401`; pipeline on the real host: login as administrator, `PUT` Maintenance → `GET` shows it, visitors get `503` on a gated route, `PUT` back to Available; old `POST admin/status` = `404`; frontend: Settings page test uses PUT and shows the new status.
|
||||
- [ ] **Step 6 — Verification (automatic)**: build; all test projects incl. pipeline tests (temporary MariaDB, removed afterwards); `pnpm lint`, `npx tsc -b`, `pnpm test`; real output reported.
|
||||
- [ ] **Step 7 — Commit**: one commit; no push.
|
||||
- [x] **Step 1 — Controller**: `[HttpPut("status")]` replaces `admin/status`; returns the updated status object (shared builder with GET); remove the old route.
|
||||
- [x] **Step 2 — Middleware**: method-aware bypass for `Availability/status` (small, isolated diff); comment explains why.
|
||||
- [x] **Step 3 — Frontend**: `useAvailability.ts` mutation (PUT + cache update), `availability/mocks/handlers.ts`, `SettingsPage.test.tsx` (2 handlers); no other change.
|
||||
- [x] **Step 4 — Docs/contract**: regenerate `openapi/slpsoftware.v1.json`; update `phase-1-handoff.md`; README mention only if it names the route (it does not).
|
||||
- [x] **Step 5 — Tests**: controller (PUT 200 body equals GET shape, 409 master-controlled, 400 invalid status, GET unchanged and anonymous); route-table test: the only anonymous action on the controller is `GetStatus`, `UpdateStatus` is `AdminOnly`, no route contains `admin`, old route absent; middleware: `PUT /api/v1/Availability/status` without token is blocked by the gate while the CMS is off (not bypassed), `GET` still open, a verified administrator can `PUT` while the CMS is disabled (existing guarantee), expired token on PUT = `401`; pipeline on the real host: login as administrator, `PUT` Maintenance → `GET` shows it, visitors get `503` on a gated route, `PUT` back to Available; old `POST admin/status` = `404`; frontend: Settings page test uses PUT and shows the new status.
|
||||
- [x] **Step 6 — Verification (automatic)**: build; all test projects incl. pipeline tests (temporary MariaDB, removed afterwards); `pnpm lint`, `npx tsc -b`, `pnpm test`; real output reported.
|
||||
- [x] **Step 7 — Commit**: one commit; no push.
|
||||
|
||||
## Explicitly NOT touched
|
||||
Master/slave endpoints (`Master/*`, `SlaveStatus`, `CmsInstances/{id}/status`), the gate logic for any other route, `GET /Availability/status` behaviour, polling/circuit-breaker code.
|
||||
|
||||
Reference in New Issue
Block a user