diff --git a/aidlc-docs/features/andreaslop-site-hosting/aidlc-state.md b/aidlc-docs/features/andreaslop-site-hosting/aidlc-state.md index 0ed575b..1b22b4c 100644 --- a/aidlc-docs/features/andreaslop-site-hosting/aidlc-state.md +++ b/aidlc-docs/features/andreaslop-site-hosting/aidlc-state.md @@ -5,7 +5,7 @@ - **Feature Slug**: andreaslop-site-hosting - **Project Type**: Brownfield - **Start Date**: 2026-11-06T00:06:13Z -- **Current Stage**: CONSTRUCTION - U2 Code Generation (code complete, awaiting approval) +- **Current Stage**: CONSTRUCTION - Build and Test (awaiting approval) - **Branch**: feature/andreaslop-site-hosting - **Request Type**: Feature (two units: U1 core-site-hosting, U2 andreaslop-client) diff --git a/aidlc-docs/features/andreaslop-site-hosting/audit.md b/aidlc-docs/features/andreaslop-site-hosting/audit.md index ba26351..8b416c7 100644 --- a/aidlc-docs/features/andreaslop-site-hosting/audit.md +++ b/aidlc-docs/features/andreaslop-site-hosting/audit.md @@ -405,3 +405,8 @@ ## U2 Code Generation - complete **Timestamp**: 2026-11-07 **AI Response**: Parts A-F implemented (see construction/andreaslop-client/code/code-summary.md). Core 351, Identity 57, Availability 82, Master 57, Offerings 57, ASF host config 5, frontend 293 tests green; ESLint/tsc clean; Api.Tests and ASF host pipeline tests need MariaDB (not available locally, run in CI). U1 defect found by the property test (unencoded 301 Location) fixed with regression tests. No push, no deploy. Awaiting approval. + +## U2 Code approval, hand-back and Build and Test +**Timestamp**: 2026-11-07 +**User Input**: "Ga verder" (approved U2 code) +**AI Response**: handback-u2.md written (incl. U1 Location-encoding correction, below-AA pairs as information, dependency advisory finding). Build and Test documents generated under construction/build-and-test/. Finding: pre-existing vulnerable packages will fail the CI vulnerability-scan gate; decision requested. Awaiting approval. diff --git a/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/build-and-test-summary.md b/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/build-and-test-summary.md new file mode 100644 index 0000000..cba5105 --- /dev/null +++ b/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/build-and-test-summary.md @@ -0,0 +1,20 @@ +# Build and Test Summary - andreaslop-site-hosting (U1 + U2) + +## Build Status +- **Backend**: `dotnet build SlpModularCms.sln` succeeded (0 errors). **Frontend**: default and `VITE_THEME=asf` builds succeeded; `VITE_THEME=nope` fails as intended. +- **Artifacts**: none published here (CI publishes `app-asf-test`). + +## Test Execution Summary (local, 2026-11-07) +### Unit tests +- Core 351, Modules.Identity 57, Availability 82, Master 57, Offerings 57, ASF host configuration 5, frontend 293: **all passed**, 0 failed. ESLint and `tsc -b` clean. +### Integration tests +- In-memory integration (website routing, headers, proxy awareness, setup token controller): passed (inside Core/Identity counts). +- **Not run locally**: `Api.Tests` and `Api.AndreaSlopFotografie.Tests/HostPipelineTests` (10 tests) need MariaDB, which is not available on this machine. They run in CI `backend-test`; result to be reported after the first push and CI run. +### Performance +- Local 0.72 ms/request (in-memory). Pi measurement pending the first test deploy. +### Additional +- **Security / dependency scan: FAIL (pre-existing).** `dotnet list package --vulnerable` reports `System.Security.Cryptography.Xml 10.0.10` and transitive `Pkcs 10.0.10` (high; patched in 10.0.12+, 10.0.14 available) in `Core` and four test projects; `pnpm audit --prod` reports 6 findings (seroval, zod; patched versions exist). Not caused by this feature, but the CI `vulnerability-scan` gate will fail and block publishing. Decision needed. +- Contract/E2E: the curl checks in manual-steps 14-18 act as the E2E check on the test host after the first deploy. + +## Overall Status +- **Build**: Success. **All locally runnable tests**: Pass. **Ready for Operations**: Yes for the code; CI is blocked by the dependency advisories until resolved or overridden, and the database-backed tests are unproven until CI runs. diff --git a/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/build-instructions.md b/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/build-instructions.md new file mode 100644 index 0000000..50404f5 --- /dev/null +++ b/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/build-instructions.md @@ -0,0 +1,16 @@ +# Build Instructions + +## Prerequisites +- **Build tools**: .NET SDK 10 (`10.0.x`), Node 20+ with pnpm (CI uses Node 20, pnpm 9; local pnpm 12 works, lockfile format unchanged). +- **Dependencies**: NuGet and npm registries reachable. New frontend packages: `@fontsource/jost@5.3.0`, `@fontsource/marcellus@5.3.0` (only bundled when `VITE_THEME=asf`). +- **Environment variables** (admin build only, all optional): `VITE_THEME` (`asf`), `VITE_DEFAULT_LANGUAGE` (`nl`|`en`), `VITE_APP_TITLE`, `VITE_APP_ENV`, `VITE_SENTRY_DSN`. + +## Build steps +1. Backend, all projects: `dotnet build SlpModularCms.sln` (from the repo root). Expected: 0 errors; warnings NU1903/NU1902/NU1510 about packages are known (see summary). +2. Admin, default look: `cd frontend && pnpm install --frozen-lockfile && pnpm build`. +3. Admin, ASF look: `VITE_THEME=asf VITE_DEFAULT_LANGUAGE=nl VITE_APP_TITLE="Andrea Slop Fotografie" pnpm build`. Expect `dist/favicon-theme.png`, four `*.woff2` files and `index.html` linking `/admin/favicon-theme.png`. An unknown `VITE_THEME` must fail the build. +4. Publish as CI does: copy `frontend/dist/.` to `src/SlpModularCms.Api.AndreaSlopFotografie/wwwroot/admin/`, then `dotnet publish -c Release -r linux-arm64 --self-contained false` in that project. + +## Troubleshooting +- `Unknown VITE_THEME "x"`: the name must be a folder under `frontend/themes/` containing `theme.css` (available: `asf`). +- Lockfile mismatch in CI: run `pnpm install` locally with the same major lockfile format and commit `pnpm-lock.yaml`. diff --git a/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/integration-test-instructions.md b/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/integration-test-instructions.md new file mode 100644 index 0000000..0636f33 --- /dev/null +++ b/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/integration-test-instructions.md @@ -0,0 +1,12 @@ +# Integration Test Instructions + +## Scenarios +1. **Real host with database** (`Api.Tests`, `Api.AndreaSlopFotografie.Tests/HostPipelineTests`): `WebApplicationFactory` boots the composed pipeline in `Development`; checks `/health`, `/api/v1/System/capabilities` (Identity and Availability present; Offerings and Master absent), `Setup/status` (`tokenRequired:false` without token), the unknown website path (404 with `StrictSite` CSP and `X-Robots-Tag: noindex, nofollow`), and `/robots.txt` (`Disallow: /`). The startup migration needs a reachable MariaDB. +2. **Proxy awareness** (`Core.Tests/Hosting/Proxy`, in-memory, no database): untrusted peers cannot spoof `X-Forwarded-For`; a trusted proxy yields the real address/scheme and separate limiter buckets; no configuration keeps the old shared bucket. +3. **Prerendered website** (`Core.Tests/Hosting/Website`, in-memory): routing parity, headers on every response, 404 page, 301 including the percent-encoded `Location`. + +## Environment for scenario 1 +Local MariaDB matching `appsettings.Development.json`, or override `ConnectionStrings__DefaultConnection`. CI (`backend-test`) starts `mariadb:11` on port 3307 and runs `dotnet test SlpModularCms.sln -c Release`. + +## Run +`dotnet test SlpModularCms.sln -c Release` (with the database available). Cleanup: stop the container. diff --git a/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/performance-test-instructions.md b/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/performance-test-instructions.md new file mode 100644 index 0000000..77f5476 --- /dev/null +++ b/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/performance-test-instructions.md @@ -0,0 +1,5 @@ +# Performance Test Instructions + +Requirement (NFR-PF): website responses must not add noticeable latency; per-request file lookup, no cache. +- **Local (done)**: 500 `GET /over-mij` on an in-memory server = 0.72 ms per request (U1). +- **On the Pi (after the first test deploy, optional, cheap)**: `for i in $(seq 1 200); do curl -s -o /dev/null -w "%{time_total}\n" http://127.0.0.1:5200/over-mij; done | sort -n | awk '{a[NR]=$1} END{print "median",a[int(NR/2)],"p95",a[int(NR*0.95)]}'`; repeat with the website folder on `/mnt/storage1`. Report the numbers in the hand-back; no load test is planned (single small site). diff --git a/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/security-test-instructions.md b/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/security-test-instructions.md new file mode 100644 index 0000000..878e1da --- /dev/null +++ b/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/security-test-instructions.md @@ -0,0 +1,6 @@ +# Security Test Instructions + +- **Dependency scan**: `dotnet list SlpModularCms.sln package --vulnerable --include-transitive` (CI gate `vulnerability-scan` fails when it prints "has the following vulnerable packages") and `cd frontend && pnpm audit --prod`. +- **Setup token**: unit tests cover only-exact-token-passes (PBT), uniform 401, no token in logs, whitespace-only token rejected at startup, limiter on both endpoints (configuration). Manual after the first deploy (manual-steps 16-17): wrong token gives the Dutch error and a `setup_token_rejected` log line, right token creates the owner, then remove the token from `shared/env`. +- **Forwarded headers**: tests prove an untrusted peer cannot spoof; wildcard/unparsable proxy entries fail at startup. Manual: after the first deploy the visitor address (not 192.168.1.102) should be what the limiter/logs see. +- **Headers**: CSP byte-identical to nginx (asserted); verify with `curl -I https://test.andreaslop.nl/` (manual-steps 14). diff --git a/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/unit-test-instructions.md b/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/unit-test-instructions.md new file mode 100644 index 0000000..138d387 --- /dev/null +++ b/aidlc-docs/features/andreaslop-site-hosting/construction/build-and-test/unit-test-instructions.md @@ -0,0 +1,12 @@ +# Unit Test Execution + +## Run +- Backend, suites that need no database (run each from the repo root): + `dotnet test src/SlpModularCms.Core.Tests`, `...Modules.Identity.Tests`, `...Modules.Availability.Tests`, `...Modules.Master.Tests`, `...Modules.Offerings.Tests`, and `dotnet test src/SlpModularCms.Api.AndreaSlopFotografie.Tests --filter "FullyQualifiedName~HostConfigurationTests"`. +- Frontend: `cd frontend && pnpm test` (Vitest, includes `themes/*.test.ts`), plus `pnpm lint` and `npx tsc -b`. + +## Expected (2026-11-07, local) +Core 351, Identity 57, Availability 82, Master 57, Offerings 57, ASF host configuration 5, frontend 293; 0 failures. Property-based tests (FsCheck, random seed per run) are part of Core and Identity; on failure the replay seed is printed in the message; pin the shrunk counterexample as an example test. + +## If a test fails +Read the failure and seed, reproduce, fix the code (not the test) unless the test is wrong, rerun several times for property tests (a failure may appear in only 1 of ~15 runs: this is how the U1 `Location` encoding defect was found). diff --git a/aidlc-docs/features/andreaslop-site-hosting/handback-u2.md b/aidlc-docs/features/andreaslop-site-hosting/handback-u2.md new file mode 100644 index 0000000..649c197 --- /dev/null +++ b/aidlc-docs/features/andreaslop-site-hosting/handback-u2.md @@ -0,0 +1,33 @@ +# Hand-back U2 - andreaslop-client + +Branch `feature/andreaslop-site-hosting` (3 U2 commits on top of the U1 ones, **not pushed**, nothing deployed). Code summary: `construction/andreaslop-client/code/code-summary.md`. Test deploy status: **not done**, it needs Bryan's explicit go in this session and the Pi steps (`construction/andreaslop-client/infrastructure-design/manual-steps-for-bryan.md`, final). + +## 1. What was built +- New client `SlpModularCms.Api.AndreaSlopFotografie` (Identity + Availability; no Master, no Offerings), `WebsiteMode.PrerenderedPages`, port 5200, `StrictSite` default policy with the website's Umami/Sentry origins, `Website:NoIndex=true` committed, tests project. +- Optional first-admin setup token (`Identity:Setup:Token`, `X-Setup-Token`, 401 identical for missing/wrong, `tokenRequired` in `GET Setup/status`, both setup endpoints under the `login` limiter, security event `setup_token_rejected` 5007). +- Shared Core change (option B): opt-in `ForwardedHeaders:KnownProxies` and per-client-address rate-limit partitions for `login`, `refresh`, sentry-tunnel, `offerings-public`. Without configuration the old behaviour applies to `Api`, `Api.SlpSoftware`, `Api.Slave`. +- Admin theme `asf` (`VITE_THEME=asf`, website palette exactly, Marcellus/Jost self-hosted, the website's real `favicon.png`), `VITE_DEFAULT_LANGUAGE=nl` (stored choice still wins), token field on the setup page. +- CI: `config-asf`, `publish-asf-test`, `deploy-asf-test` behind Gitea variable `ASF_TEST_DEPLOY_ENABLED == 'true'`, manual box "Deploy ASF test"; existing jobs, env block and `deploy-scp.yaml` unchanged (diff = additions only). + +## 2. Names (for U3 and Pi-Main) +Gitea variables `ASF_TEST_DEPLOY_ENABLED`, `DEPLOY_PATH_ASF_TEST`, `SERVICE_NAME_ASF_TEST` (same form as `SERVICE_NAME_TEST`), `HEALTH_CHECK_URL_ASF_TEST`, `VITE_SENTRY_DSN_ASF` (DSN of the ASF **website** Sentry project); jobs `publish-asf-test`/`deploy-asf-test`; theme `frontend/themes/asf`; unit `andreaslopfotografie-test`; folder `apps/andreaslopfotografie/test`; DB `AndreaSlopFotografieTest` / user `AndreaSlopFotografie`; port 5200; shared/env variables listed in `infrastructure-design.md`. + +## 3. U1 correction found during U2 +The 301 `Location` was built from the decoded path without re-encoding: `/a%3Fb/` redirected to `/a?b` (another resource), `#` would start a fragment, non-ASCII ended up raw in a header value. Found by the existing property test (flaky about 1 in 15 runs), fixed with `PathString.ToUriComponent` plus regression tests. Normal paths are unchanged. The host is never worse than before for such paths; whether nginx encodes identically is for the web verify (one encoded path), I cannot run nginx here. + +## 4. Test results +- Green locally: Core 351, Identity 57, Availability 82, Master 57, Offerings 57, ASF host configuration 5, frontend 293 (Vitest), ESLint and `tsc -b` clean, frontend builds for default and `asf` verified. +- **Not run here (no MariaDB on this machine): `Api.Tests` and `Api.AndreaSlopFotografie.Tests/HostPipelineTests`.** The CI job `backend-test` starts MariaDB and runs them; the result will be reported after the first push and CI run. +- Not yet observed, only possible on the first test deploy: forwarded headers and HTTP/1.0 behind the proxy Pi, `vars` in a job-level `if:` on this Gitea, per-request file lookup timing on the Pi. + +## 5. Information, no action needed +- Contrast pairs below WCAG AA (decision Q5 = B, colours exactly as the website): border on background 1.30:1 (decorative line colour) and ink-3 `#8a827a` on paper 3.54:1 (not used as a text colour by the theme). All text and button pairs pass AA, in light mode with the website palette. Dark mode is derived (the website has none; button accent lightened to `#8a9681` for 5.16:1). +- Radius `0.25rem` is a choice; the website defines no radius token. +- `logo.png` is not used: the admin has no logo element and the scope is tokens + favicon. +- The admin favicon is `themes/asf/favicon.png` (copied read-only from the website; the website repo was not touched). + +## 6. Open items and risks +1. **Vulnerability-scan gate will fail in CI** (pre-existing, not caused by U2): `System.Security.Cryptography.Xml 10.0.10` and transitive `System.Security.Cryptography.Pkcs 10.0.10` now have high advisories (patched at 10.0.12+; 10.0.14 exists), pinned in `Core` and four test projects; plus `pnpm audit` reports 6 findings (seroval, zod). This blocks publish for SlpSoftware and ASF alike. Needs a decision (small dependency bump, separate from this feature, or accept and override). +2. Setup token must be removed from `shared/env` after the first administrator exists (step 17). +3. The proxy block change is only the `proxy_pass` target (port 5200); the website repo generator is updated in U3. +4. Production for ASF is out of scope.