Finishes the master-cms-module feature (Units 1-4): runs Build and Test across master-backend, slave-availability-extension and frontend-cms-page, fixes a missing Availability EF migration for MasterRegistration and a TanStack Query v5 mutation-callback type break, adds the missing MasterModule appsettings section, and documents the module in README.md. Also seeds a tech-debt-backlog feature to track dead config and pre-existing/introduced frontend lint findings for later cleanup.
5.3 KiB
5.3 KiB
Integration Test Instructions
Purpose
Verify that the three units of the Master CMS Module work together: the Master module (Unit 1), the slave-side Availability extension (Unit 2), and the /cms frontend page (Unit 3).
Test Scenarios
Scenario 1: Owner Adds a Slave — Master Pushes Registration (Unit 1 → Unit 2)
- Description: The Owner registers a slave CMS from the Master
/cmspage; the Master generates an API key and pushes registration to the slave. - Setup: Run two instances of the API — one configured as Master (
SlpModularCms.Modules.Masterenabled), one as Slave (SlpModularCms.Modules.Availabilityrunning, reachable at a known URL). - Test Steps:
- On the Master, call
POST /api/v1/CmsInstanceswith the slave's URL. CmsInstanceServicegenerates an API key, stores it (Data-Protection-encrypted) inCmsInstance, and callsISlaveApiClient.RegisterMasterAsyncwhichPOSTs to the slave's/api/v1/master/registerwith theX-Master-Api-Keyheader.- Query the Master's
GET /api/v1/CmsInstanceslist endpoint. - Query the slave's
GET /api/v1/master/registered-url(with the same header) to confirm it stored the registration.
- On the Master, call
- Expected Results: The new instance appears in the Master's
CmsInstancelist (API key never included in the DTO); the slave'sMasterRegistrationtable stores the Master's URL and the Data-Protection-encrypted API key. - Cleanup: Stop both instances; clear both DBs if reused.
Scenario 2: Master Sets Slave to Inactive → Slave Enforces via Two-Phase Middleware (Unit 1 → Unit 2)
- Description: Owner disables a slave from the Master
/cmspage; the Master pushes the new status to the slave, whoseAvailabilityMiddlewareblocks CMS requests. - Setup: Both instances running and registered (per Scenario 1).
- Test Steps:
- On the Master, call
PUT /api/v1/CmsInstances/{id}/statuswithInactive. - Confirm the Master's
SlaveApiClientpushes the status to the slave synchronously as part of the same request (SlaveContactSuccessin the response). - Send a request to the slave's CMS route.
- On the Master, call
- Expected Results: Slave's static
_masterIsAvailableflag flips immediately on push; slave responds with503and the extended response body signaling master-controlled unavailability; frontend on the slave redirects to the disable message. - Cleanup: Set status back to
Activeon the Master.
Scenario 3: Fail-Open on Master Unreachable or Slave Restart (Unit 1 & Unit 2)
- Description: The slave gate must never hard-fail when it cannot reach the Master.
- Setup A (push failure): Registered slave; stop the Slave instance, then call the status-update endpoint on the Master.
- Test Steps A:
- Stop the Slave process.
- On the Master, call
PUT /api/v1/CmsInstances/{id}/statuswithInactive. - Inspect the Master's response body and
CmsInstance.LastIntegrityCheckFailedAt.
- Expected Results A: The DB status change is NOT rolled back; response reports
SlaveContactSuccess = false;IntegrityCheckBackgroundServicewill retry and updateLastIntegrityCheckFailedAton its next interval (IntegrityCheckIntervalMinutes, default 60). - Setup B (slave restart): Restart the Slave process while the Master is unreachable.
- Test Steps B:
- Stop both Master and Slave.
- Start only the Slave.
- Send a request to the slave's CMS route immediately after startup.
- Expected Results B:
_masterIsAvailabledefaults totrueon process start (fail-open), so the slave is reachable even before the Master pushes a fresh status.
Scenario 4: Frontend CMS Page End-to-End (Unit 3 → Unit 1)
- Description: Owner manages slave CMS instances through the
/cmspage. - Setup: Master API running; frontend dev server pointed at it (
npm run dev); logged in as Administrator. - Test Steps:
- Navigate to
/cms. - Add a new CMS instance via
AddCmsInstanceDialog. - Confirm it appears in
CmsInstanceList. - Open
SetStatusDialogand toggle its status.
- Navigate to
- Expected Results: List refreshes via TanStack Query invalidation after each mutation; API key is never shown in the list response (per NFR).
Setup Integration Test Environment
1. Start Required Services
# Terminal 1 — Master instance
dotnet run --project src/SlpModularCms.Api --urls http://localhost:5001
# Terminal 2 — Slave instance (separate DB, MasterUrl pointing at Terminal 1)
dotnet run --project src/SlpModularCms.Api --urls http://localhost:5002
2. Configure Frontend
cd frontend
npm run dev # defaults to Master instance per vite proxy config
Run Integration Tests
These scenarios are currently manual (no automated cross-process integration test harness exists in this codebase). Automated coverage for the underlying units (registration logic, middleware two-phase check, cache/fallback, frontend mutations) is provided by the unit test suites listed in unit-test-instructions.md.
Verify Service Interactions
- Check Master logs for registration and status-update requests
- Check Slave logs for
MasterAvailabilityServicepull attempts and cache hits/misses - Check browser dev tools network tab for
/api/v1/CmsInstancescalls from the frontend
Cleanup
# Stop both dotnet run processes (Ctrl+C)