Split src/http/app.test.ts into one file per concern, and reset the reading-cost trend #194

Merged
lilleman merged 3 commits from item-42 into main 2026-10-31 10:42:05 +01:00
6 changed files with 4 additions and 8 deletions
Showing only changes of commit c1abc67a92 - Show all commits
+1 -2
View File
@@ -1818,8 +1818,7 @@ src/ The app — strict tsc, no build step. *.test.ts sit beside
server.ts Entry point; config.ts env loader; logger.ts structured log + trace span + tracedFetch
*.test.ts Guards with no source counterpart (compose/kratos/keto/hydra/postgres/ci-gate/function-limits)
http/ Request pipeline: app.ts (createApp), builtin-routes, context, body, cookie,
static, safe-url (safeUrl + localPath), security-headers; app*.test.ts: one per concern
over shared fixtures in app-harness.ts
static, safe-url (safeUrl + localPath), security-headers
auth/ Identity + the session-JWT hot path: jwt · jwt-middleware · jwks · gen-jwks (CLI) ·
login · guards · csrf · denylist · flow-view · oauth-login · oauth-consent ·
routes · bootstrap, and the Ory REST clients (kratos-public/admin, keto, hydra,
+1 -1
View File
@@ -1,6 +1,6 @@
// Built-in OAuth2 clients admin screen: the pure view-model + Hydra-payload builders. A client
// is an Ory Hydra OAuth2 client (apps that log in *through* us); writes go only to Hydra. The
// HTTP routing/gate/CSRF + live Hydra calls (incl. the one-time secret) are exercised in app-admin.test.ts.
// HTTP routing/gate/CSRF + live Hydra calls (incl. the one-time secret) are exercised in src/http/app-admin.test.ts.
import assert from "node:assert/strict";
import { test } from "node:test";
import {
+1 -1
View File
@@ -1,5 +1,5 @@
// The pure half of permission granting: what a submitted checkbox set changes, and the picker the
// two screens render from it. The Keto writes and the HTTP round trip are covered in app-admin.test.ts.
// two screens render from it. The Keto writes and the HTTP round trip are covered in src/http/app-admin.test.ts.
import assert from "node:assert/strict";
import { test } from "node:test";
import type { PermissionDecl } from "@plainpages/plugin-api";
+1 -1
View File
@@ -1,7 +1,7 @@
// Built-in Groups admin screen: the pure view-model + Keto-tuple builders. A group is a
// Keto subject set (Group:<name>#members); membership tuples carry users (subject_id) or nested
// groups (subject_set). The HTTP routing/gate/CSRF + live Keto/Kratos calls are exercised over
// HTTP in app-admin.test.ts.
// HTTP in src/http/app-admin.test.ts.
import assert from "node:assert/strict";
import { test } from "node:test";
import {
-2
View File
@@ -1,5 +1,3 @@
// Shared fixtures for the app.*.test.ts files: a signing key for session JWTs, an app starter,
// and stub Ory clients.
import { generateKeyPairSync, sign, type JsonWebKey } from "node:crypto";
import type { AddressInfo } from "node:net";
import type { TestContext } from "node:test";
-1
View File
@@ -141,7 +141,6 @@ test("a plugin view renders the native chrome; its forms are CSRF-guarded via ct
});
// JWT middleware: a verified session cookie populates ctx.user/permissions, which the gate reads.
// The key + mintJwt + session() helper live in app-harness.ts.
test("a verified session JWT authorizes a permission-gated route; no cookie / expired token → sign in", async (t) => {
const app = createApp({ jwks: staticJwks([ecJwk]), plugins: [demoPlugin] });
await new Promise<void>((r) => app.listen(0, r));