@fuzdev/fuz_app 0.162.0 → 0.164.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/actions/action_event_data.d.ts +1 -1
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +4 -0
- package/dist/actions/action_spec.d.ts +3 -3
- package/dist/actions/action_spec.d.ts.map +1 -1
- package/dist/auth/CLAUDE.md +39 -36
- package/dist/auth/account_action_specs.d.ts +441 -115
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_action_specs.js +47 -46
- package/dist/auth/account_route_schema.d.ts +98 -62
- package/dist/auth/account_route_schema.d.ts.map +1 -1
- package/dist/auth/account_route_schema.js +45 -45
- package/dist/auth/account_routes.js +1 -1
- package/dist/auth/account_schema.d.ts +54 -27
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +16 -18
- package/dist/auth/admin_action_specs.d.ts +76 -76
- package/dist/auth/admin_action_specs.js +2 -4
- package/dist/auth/admin_actions.d.ts +4 -4
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +3 -3
- package/dist/auth/all_cell_actions.d.ts +3 -3
- package/dist/auth/all_cell_actions.d.ts.map +1 -1
- package/dist/auth/all_cell_actions.js +1 -1
- package/dist/auth/api_token.d.ts +4 -4
- package/dist/auth/api_token.d.ts.map +1 -1
- package/dist/auth/api_token.js +3 -3
- package/dist/auth/audit_log_route_schema.d.ts +1 -1
- package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_route_schema.js +4 -5
- package/dist/auth/audit_log_schema.d.ts +46 -66
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +34 -30
- package/dist/auth/bootstrap_route_schema.d.ts +146 -52
- package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
- package/dist/auth/bootstrap_route_schema.js +33 -19
- package/dist/auth/cell_grant_action_specs.d.ts +1 -1
- package/dist/auth/cell_grant_action_specs.js +1 -1
- package/dist/auth/cell_grant_actions.d.ts +4 -4
- package/dist/auth/cell_grant_actions.d.ts.map +1 -1
- package/dist/auth/cell_grant_actions.js +1 -1
- package/dist/auth/credential_type_schema.d.ts +16 -29
- package/dist/auth/credential_type_schema.d.ts.map +1 -1
- package/dist/auth/credential_type_schema.js +14 -18
- package/dist/auth/daemon_token.d.ts +4 -4
- package/dist/auth/daemon_token.d.ts.map +1 -1
- package/dist/auth/daemon_token.js +3 -3
- package/dist/auth/daemon_token_middleware.d.ts +1 -1
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +5 -5
- package/dist/auth/grant_path_schema.d.ts +15 -29
- package/dist/auth/grant_path_schema.d.ts.map +1 -1
- package/dist/auth/grant_path_schema.js +13 -17
- package/dist/auth/middleware.js +4 -4
- package/dist/auth/migrations.js +1 -1
- package/dist/auth/name_schema.d.ts +7 -6
- package/dist/auth/name_schema.d.ts.map +1 -1
- package/dist/auth/name_schema.js +8 -9
- package/dist/auth/password.d.ts +15 -7
- package/dist/auth/password.d.ts.map +1 -1
- package/dist/auth/password.js +16 -9
- package/dist/auth/role_grant_offer_action_specs.d.ts +2 -2
- package/dist/auth/role_grant_offer_action_specs.js +2 -2
- package/dist/auth/role_grant_offer_actions.d.ts +4 -4
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +3 -3
- package/dist/auth/role_grant_offer_notifications.js +2 -2
- package/dist/auth/role_grant_offer_schema.d.ts +2 -2
- package/dist/auth/role_grant_offer_schema.js +2 -2
- package/dist/auth/role_schema.d.ts +47 -55
- package/dist/auth/role_schema.d.ts.map +1 -1
- package/dist/auth/role_schema.js +29 -35
- package/dist/auth/scope_kind_schema.d.ts +22 -26
- package/dist/auth/scope_kind_schema.d.ts.map +1 -1
- package/dist/auth/scope_kind_schema.js +19 -19
- package/dist/auth/self_service_role_action_specs.js +1 -1
- package/dist/auth/self_service_role_actions.d.ts +6 -6
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +7 -6
- package/dist/auth/signup_route_schema.d.ts +71 -21
- package/dist/auth/signup_route_schema.d.ts.map +1 -1
- package/dist/auth/signup_route_schema.js +17 -19
- package/dist/auth/standard_rpc_actions.d.ts +1 -1
- package/dist/auth/standard_rpc_actions.js +1 -1
- package/dist/auth/token_lifetime.d.ts +33 -9
- package/dist/auth/token_lifetime.d.ts.map +1 -1
- package/dist/auth/token_lifetime.js +8 -7
- package/dist/auth/token_scope.d.ts +99 -25
- package/dist/auth/token_scope.d.ts.map +1 -1
- package/dist/auth/token_scope.js +57 -35
- package/dist/db/CLAUDE.md +2 -1
- package/dist/db/file_fact_url.d.ts +11 -6
- package/dist/db/file_fact_url.d.ts.map +1 -1
- package/dist/db/file_fact_url.js +5 -5
- package/dist/db/schema_ready.d.ts +0 -5
- package/dist/db/schema_ready.d.ts.map +1 -1
- package/dist/db/schema_ready.js +0 -5
- package/dist/http/CLAUDE.md +104 -71
- package/dist/http/auth_shape.d.ts +48 -29
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +12 -85
- package/dist/http/body_limit.d.ts +12 -0
- package/dist/http/body_limit.d.ts.map +1 -1
- package/dist/http/body_limit.js +15 -0
- package/dist/http/body_limit_schema.d.ts +20 -0
- package/dist/http/body_limit_schema.d.ts.map +1 -0
- package/dist/http/body_limit_schema.js +20 -0
- package/dist/http/common_routes.d.ts +1 -1
- package/dist/http/common_routes.d.ts.map +1 -1
- package/dist/http/common_routes.js +11 -14
- package/dist/http/db_routes.d.ts.map +1 -1
- package/dist/http/db_routes.js +59 -69
- package/dist/http/dev_route_error_check.d.ts +70 -0
- package/dist/http/dev_route_error_check.d.ts.map +1 -0
- package/dist/http/dev_route_error_check.js +119 -0
- package/dist/http/error_schemas.d.ts +365 -189
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +256 -149
- package/dist/http/health_schema.d.ts +10 -6
- package/dist/http/health_schema.d.ts.map +1 -1
- package/dist/http/health_schema.js +3 -3
- package/dist/http/middleware_spec.d.ts +8 -3
- package/dist/http/middleware_spec.d.ts.map +1 -1
- package/dist/http/origin.d.ts +12 -43
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +10 -6
- package/dist/http/route_error_check.d.ts +158 -0
- package/dist/http/route_error_check.d.ts.map +1 -0
- package/dist/http/route_error_check.js +247 -0
- package/dist/http/route_errors.d.ts +80 -0
- package/dist/http/route_errors.d.ts.map +1 -0
- package/dist/http/route_errors.js +83 -0
- package/dist/http/route_spec.d.ts +33 -17
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +48 -62
- package/dist/http/schema_helpers.d.ts +0 -33
- package/dist/http/schema_helpers.d.ts.map +1 -1
- package/dist/http/schema_helpers.js +0 -45
- package/dist/http/surface.d.ts +19 -12
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface.js +25 -38
- package/dist/http/surface_query.d.ts +11 -2
- package/dist/http/surface_query.d.ts.map +1 -1
- package/dist/http/surface_query.js +7 -1
- package/dist/primitive_schemas.d.ts +2 -19
- package/dist/primitive_schemas.d.ts.map +1 -1
- package/dist/primitive_schemas.js +2 -20
- package/dist/primitive_schemas_fuz.d.ts +39 -5
- package/dist/primitive_schemas_fuz.d.ts.map +1 -1
- package/dist/primitive_schemas_fuz.js +36 -7
- package/dist/rate_limiter.d.ts +13 -0
- package/dist/rate_limiter.d.ts.map +1 -1
- package/dist/rate_limiter.js +20 -2
- package/dist/schema_issues.d.ts +29 -11
- package/dist/schema_issues.d.ts.map +1 -1
- package/dist/schema_issues.js +11 -10
- package/dist/schema_meta.d.ts +8 -1
- package/dist/schema_meta.d.ts.map +1 -1
- package/dist/schema_meta.js +2 -1
- package/dist/server/app_server.d.ts +3 -1
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +24 -10
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +8 -31
- package/dist/server/surface_route.d.ts.map +1 -1
- package/dist/server/surface_route.js +5 -6
- package/dist/server/x_accel.d.ts +12 -7
- package/dist/server/x_accel.d.ts.map +1 -1
- package/dist/server/x_accel.js +7 -9
- package/dist/testing/CLAUDE.md +55 -44
- package/dist/testing/admin_integration.d.ts +3 -3
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +2 -2
- package/dist/testing/adversarial_404.d.ts +4 -18
- package/dist/testing/adversarial_404.d.ts.map +1 -1
- package/dist/testing/adversarial_404.js +19 -51
- package/dist/testing/adversarial_headers.d.ts +3 -4
- package/dist/testing/adversarial_headers.d.ts.map +1 -1
- package/dist/testing/adversarial_headers.js +8 -6
- package/dist/testing/adversarial_input.d.ts.map +1 -1
- package/dist/testing/adversarial_input.js +18 -17
- package/dist/testing/assertions.d.ts +33 -11
- package/dist/testing/assertions.d.ts.map +1 -1
- package/dist/testing/assertions.js +52 -12
- package/dist/testing/attack_surface.d.ts +5 -35
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/attack_surface.js +29 -91
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +2 -1
- package/dist/testing/cross_backend/action_manifest.d.ts +126 -56
- package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest.js +11 -11
- package/dist/testing/cross_backend/action_manifest_parity.d.ts +1 -1
- package/dist/testing/cross_backend/action_manifest_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_crud.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_crud.js +2 -1
- package/dist/testing/cross_backend/conformance_table.js +1 -1
- package/dist/testing/cross_backend/default_spine_surface.d.ts +2 -2
- package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_spine_surface.js +2 -2
- package/dist/testing/cross_backend/fact_serving.js +3 -3
- package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/identity_parity.js +39 -6
- package/dist/testing/cross_backend/origin_conformance.d.ts +278 -102
- package/dist/testing/cross_backend/origin_conformance.d.ts.map +1 -1
- package/dist/testing/cross_backend/origin_conformance.js +21 -21
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +3 -3
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.js +7 -1
- package/dist/testing/cross_backend/setup.d.ts +14 -1
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +68 -48
- package/dist/testing/cross_backend/spine_suites.d.ts +3 -3
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/standard.d.ts +4 -4
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_origin_check.d.ts +147 -71
- package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_origin_check.js +16 -13
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +70 -27
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.js +34 -1
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +5 -4
- package/dist/testing/error_coverage.d.ts +24 -34
- package/dist/testing/error_coverage.d.ts.map +1 -1
- package/dist/testing/error_coverage.js +46 -89
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +6 -14
- package/dist/testing/integration_helpers.d.ts +37 -9
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +86 -40
- package/dist/testing/middleware.d.ts +3 -5
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +5 -4
- package/dist/testing/rate_limiting.d.ts +1 -1
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +5 -4
- package/dist/testing/round_trip.d.ts.map +1 -1
- package/dist/testing/round_trip.js +5 -3
- package/dist/testing/schema_generators.d.ts +10 -3
- package/dist/testing/schema_generators.d.ts.map +1 -1
- package/dist/testing/schema_generators.js +23 -11
- package/dist/testing/stubs.d.ts +10 -1
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +15 -5
- package/dist/testing/surface_invariants.d.ts +36 -115
- package/dist/testing/surface_invariants.d.ts.map +1 -1
- package/dist/testing/surface_invariants.js +106 -269
- package/dist/testing/token_scope_fixtures.d.ts +24 -0
- package/dist/testing/token_scope_fixtures.d.ts.map +1 -0
- package/dist/testing/token_scope_fixtures.js +49 -0
- package/dist/testing/transports/bootstrap.d.ts +1 -1
- package/dist/testing/transports/bootstrap.d.ts.map +1 -1
- package/dist/testing/transports/bootstrap.js +13 -12
- package/dist/ui/BootstrapForm.svelte +4 -2
- package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -1
- package/dist/ui/CLAUDE.md +4 -2
- package/dist/ui/SignupForm.svelte +4 -2
- package/dist/ui/SignupForm.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.d.ts.map +1 -1
- package/dist/ui/auth_state.svelte.js +2 -8
- package/dist/ui/backend_probe.svelte.js +3 -3
- package/dist/ui/table_state.svelte.d.ts.map +1 -1
- package/dist/ui/table_state.svelte.js +1 -8
- package/dist/ui/ui_fetch.d.ts +12 -2
- package/dist/ui/ui_fetch.d.ts.map +1 -1
- package/dist/ui/ui_fetch.js +22 -4
- package/package.json +1 -1
- package/dist/auth/audit_log_schema_fuz.d.ts +0 -53
- package/dist/auth/audit_log_schema_fuz.d.ts.map +0 -1
- package/dist/auth/audit_log_schema_fuz.js +0 -50
- package/dist/auth/role_schema_fuz.d.ts +0 -30
- package/dist/auth/role_schema_fuz.d.ts.map +0 -1
- package/dist/auth/role_schema_fuz.js +0 -30
- package/dist/auth/scope_kind_schema_fuz.d.ts +0 -31
- package/dist/auth/scope_kind_schema_fuz.d.ts.map +0 -1
- package/dist/auth/scope_kind_schema_fuz.js +0 -31
|
@@ -5,34 +5,64 @@ import './assert_dev_env.js';
|
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
7
|
import { assert } from 'vitest';
|
|
8
|
-
import { is_null_schema
|
|
8
|
+
import { is_null_schema } from '../http/schema_helpers.js';
|
|
9
|
+
import { get_route_error_map } from '../http/route_errors.js';
|
|
9
10
|
import { is_public_auth } from '../http/auth_shape.js';
|
|
10
11
|
import { ERROR_AUTHENTICATION_REQUIRED } from '../http/error_schemas.js';
|
|
11
12
|
import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
12
13
|
import { create_test_request_headers } from './test_origin.js';
|
|
13
14
|
import { parse_any } from '../schema_issues.js';
|
|
15
|
+
import { find_mounted_route, is_json_response, to_mounted_routes } from '../http/route_error_check.js';
|
|
16
|
+
import { assert_error_response_declared } from './assertions.js';
|
|
17
|
+
/** Each spec list's compiled routes, so a list is compiled once. */
|
|
18
|
+
const mounted_routes_cache = new WeakMap();
|
|
14
19
|
/**
|
|
15
|
-
*
|
|
20
|
+
* A request path as Hono reads it: the URL's pathname (a query string
|
|
21
|
+
* dropped, `.` and `..` segments resolved), percent-decoded by `decodeURI`
|
|
22
|
+
* with `%25` kept, or the raw path when decoding fails.
|
|
23
|
+
*/
|
|
24
|
+
const to_hono_path = (path) => {
|
|
25
|
+
let pathname = new URL(path, 'http://localhost').pathname;
|
|
26
|
+
if (pathname.includes('%')) {
|
|
27
|
+
try {
|
|
28
|
+
pathname = decodeURI(pathname.replaceAll('%25', '%2525'));
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// a malformed escape: Hono matches the raw path
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return pathname;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Find the route spec a request reaches: the first in list (mount) order
|
|
38
|
+
* whose method and path template match it, `HEAD` read as `GET` — the order
|
|
39
|
+
* Hono dispatches by, which the DEV error check reads through Hono's own
|
|
40
|
+
* router (`create_route_lookup`). This lookup is hono-free
|
|
41
|
+
* (`find_mounted_route`), pinned against Hono by the route-lookup tests. The
|
|
42
|
+
* path is read as Hono reads it: its pathname, percent-decoded.
|
|
16
43
|
*
|
|
17
|
-
*
|
|
44
|
+
* A path template passed as the path (`/api/things/:id`, a segment that is
|
|
45
|
+
* `*` or starts with `:`) finds its own spec first, outranking mount order.
|
|
18
46
|
*
|
|
19
|
-
* @param
|
|
47
|
+
* @param specs - the route specs, in mount order
|
|
48
|
+
* @param method - the request method
|
|
49
|
+
* @param path - request path, concrete or a route's own template
|
|
20
50
|
*/
|
|
21
51
|
export const find_route_spec = (specs, method, path) => {
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
52
|
+
// a template names its own spec; only a whole param or wildcard segment
|
|
53
|
+
// makes one, as a concrete path can hold a `:` mid-segment
|
|
54
|
+
if (path.split('/').some((segment) => segment === '*' || segment.startsWith(':'))) {
|
|
55
|
+
const read_method = method === 'HEAD' ? 'GET' : method;
|
|
56
|
+
const own = specs.find((s) => s.method === read_method && s.path === path);
|
|
57
|
+
if (own)
|
|
58
|
+
return own;
|
|
59
|
+
}
|
|
60
|
+
let routes = mounted_routes_cache.get(specs);
|
|
61
|
+
if (!routes) {
|
|
62
|
+
routes = to_mounted_routes(specs, (spec) => spec);
|
|
63
|
+
mounted_routes_cache.set(specs, routes);
|
|
64
|
+
}
|
|
65
|
+
return find_mounted_route(routes, method, to_hono_path(path));
|
|
36
66
|
};
|
|
37
67
|
/**
|
|
38
68
|
* REST auth route suffixes on the account/bootstrap surface — the only
|
|
@@ -68,24 +98,50 @@ export const find_auth_route = (specs, suffix, method) => {
|
|
|
68
98
|
/**
|
|
69
99
|
* Validate a response body against the route spec's declared schemas.
|
|
70
100
|
*
|
|
71
|
-
* For 2xx responses, validates against `spec.output`.
|
|
72
|
-
*
|
|
101
|
+
* For 2xx responses, validates against `spec.output`. For an error response
|
|
102
|
+
* (400 and up), checks it against the route's error map
|
|
103
|
+
* (`resolve_route_error_map`) — the one in `route_error_maps`, an
|
|
104
|
+
* `AppSurfaceSpec`'s, built with the app's middleware, or without one the
|
|
105
|
+
* route's own — through `assert_error_response_declared`, by the rule the DEV
|
|
106
|
+
* error check runs (`check_route_error`): the status must be
|
|
107
|
+
* declared and the body must parse against it. A 500 `internal_error` and a
|
|
108
|
+
* 503 `service_unavailable` are always accepted, and on a `jsonrpc` route (the
|
|
109
|
+
* RPC endpoint's) a JSON-RPC error envelope is not a REST error body; on any
|
|
110
|
+
* other route it is checked like any error body.
|
|
111
|
+
*
|
|
112
|
+
* The route is the one `find_route_spec` finds, the request's as Hono
|
|
113
|
+
* dispatches it. A failure reads as the DEV check logs it
|
|
114
|
+
* (`format_route_error_check`), then `: ` and the issues or the body as JSON.
|
|
73
115
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
116
|
+
* Only a JSON response, by its `Content-Type` (`is_json_response`, the DEV
|
|
117
|
+
* check's gate), has a body to check. A non-JSON response passes only where
|
|
118
|
+
* no schema applies: a 2xx on a route with a null output, or an error status
|
|
119
|
+
* the map doesn't declare.
|
|
120
|
+
*
|
|
121
|
+
* @param route_error_maps - each route's error map, keyed `METHOD path` (`AppSurfaceSpec.route_error_maps`)
|
|
122
|
+
* @throws Error if no route spec matches `method` + `path`, if the body fails
|
|
123
|
+
* its output schema, if a JSON error is at a status the route's map lacks or
|
|
124
|
+
* off its schema, or if the response is non-JSON despite a declared schema
|
|
125
|
+
* for its status.
|
|
77
126
|
*/
|
|
78
|
-
export const assert_response_matches_spec = async (route_specs, method, path, response) => {
|
|
127
|
+
export const assert_response_matches_spec = async (route_specs, method, path, response, route_error_maps) => {
|
|
79
128
|
const spec = find_route_spec(route_specs, method, path);
|
|
80
129
|
if (!spec) {
|
|
81
130
|
throw new Error(`No route spec found for ${method} ${path}`);
|
|
82
131
|
}
|
|
83
|
-
|
|
132
|
+
// the DEV error check's gate: only a JSON response has a body to check
|
|
84
133
|
let body;
|
|
85
|
-
|
|
86
|
-
|
|
134
|
+
let parsed = false;
|
|
135
|
+
if (is_json_response(response)) {
|
|
136
|
+
try {
|
|
137
|
+
body = await response.clone().json();
|
|
138
|
+
parsed = true;
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
// a body claiming JSON that isn't — read as non-JSON below
|
|
142
|
+
}
|
|
87
143
|
}
|
|
88
|
-
|
|
144
|
+
if (!parsed) {
|
|
89
145
|
// Non-JSON response — only acceptable when no schema applies.
|
|
90
146
|
// If the spec declares an output or error schema for this status,
|
|
91
147
|
// getting non-JSON is a real bug.
|
|
@@ -93,8 +149,7 @@ export const assert_response_matches_spec = async (route_specs, method, path, re
|
|
|
93
149
|
throw new Error(`${method} ${path} (${response.status}) returned non-JSON but has output schema`);
|
|
94
150
|
}
|
|
95
151
|
if (!response.ok) {
|
|
96
|
-
|
|
97
|
-
if (merged?.[response.status]) {
|
|
152
|
+
if (get_route_error_map(route_error_maps, spec).schemas[response.status]) {
|
|
98
153
|
throw new Error(`${method} ${path} (${response.status}) returned non-JSON but has error schema for status ${response.status}`);
|
|
99
154
|
}
|
|
100
155
|
}
|
|
@@ -107,16 +162,7 @@ export const assert_response_matches_spec = async (route_specs, method, path, re
|
|
|
107
162
|
}
|
|
108
163
|
}
|
|
109
164
|
else {
|
|
110
|
-
|
|
111
|
-
if (merged) {
|
|
112
|
-
const status_schema = merged[response.status];
|
|
113
|
-
if (status_schema) {
|
|
114
|
-
const result = parse_any(status_schema, body);
|
|
115
|
-
if (!result.ok) {
|
|
116
|
-
throw new Error(`Error schema mismatch for ${method} ${path} (${response.status}): ${JSON.stringify(result.issues)}`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
165
|
+
await assert_error_response_declared(get_route_error_map(route_error_maps, spec), spec.jsonrpc ?? false, response, `${method} ${path}`);
|
|
120
166
|
}
|
|
121
167
|
};
|
|
122
168
|
/** Fields in error responses that indicate information leakage. */
|
|
@@ -15,9 +15,9 @@ import './assert_dev_env.js';
|
|
|
15
15
|
*/
|
|
16
16
|
import { vi } from 'vitest';
|
|
17
17
|
import { Hono } from 'hono';
|
|
18
|
-
import type { z } from 'zod';
|
|
19
18
|
import { type RequestContext } from '../auth/request_context.js';
|
|
20
19
|
import type { TokenScope } from '../auth/token_scope.js';
|
|
20
|
+
import type { RestErrorDef } from '../http/error_schemas.js';
|
|
21
21
|
/** Mock configuration for bearer auth middleware test setup. */
|
|
22
22
|
export interface BearerAuthTestOptions {
|
|
23
23
|
/** Test description. */
|
|
@@ -36,10 +36,8 @@ export interface BearerAuthTestOptions {
|
|
|
36
36
|
mock_role_grants_result?: unknown;
|
|
37
37
|
/** Expected HTTP status, or `'next'` if the middleware should call `next()`. */
|
|
38
38
|
expected_status: number | 'next';
|
|
39
|
-
/**
|
|
40
|
-
expected_error?:
|
|
41
|
-
/** Zod schema to validate error response body against. Defaults to `ApiError` when `expected_error` is set. */
|
|
42
|
-
expected_error_schema?: z.ZodType;
|
|
39
|
+
/** The error definition the JSON body must be — its code, and a body its schema accepts. */
|
|
40
|
+
expected_error?: RestErrorDef;
|
|
43
41
|
}
|
|
44
42
|
/** A full test case for the table-driven bearer auth runner. */
|
|
45
43
|
export interface BearerAuthTestCase extends BearerAuthTestOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middleware.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;;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AEhD,sDAAsD;AACtD,MAAM,WAAW,0BAA0B;IAC1C,iDAAiD;IACjD,eAAe,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,oFAAoF;IACpF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC;CACpD;AAED,yDAAyD;AACzD,MAAM,WAAW,sBAAsB;IACtC,GAAG,EAAE,IAAI,CAAC;IACV,aAAa,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IACxC,eAAe,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1C,qBAAqB,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IAChD,2BAA2B,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IACtD,0BAA0B,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;CACrD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gCAAgC,GAC5C,UAAU,0BAA0B,KAClC,sBA4DF,CAAC"}
|
|
@@ -28,7 +28,7 @@ import { REQUEST_CONTEXT_KEY } from '../auth/request_context.js';
|
|
|
28
28
|
import { RESOLVED_AUTH_KEY, TEST_CONTEXT_PRESET, TEST_CONTEXT_PRESET_KEY } from '../hono_context.js';
|
|
29
29
|
import { get_resolved_auth } from '../auth/resolved_auth.js';
|
|
30
30
|
import { create_test_resolved_auth } from './resolved_auth.js';
|
|
31
|
-
import {
|
|
31
|
+
import { parse_any } from '../schema_issues.js';
|
|
32
32
|
// Mock the query modules so test cases can control return values.
|
|
33
33
|
// vi.mock() is hoisted by vitest, so these run before any imports resolve.
|
|
34
34
|
vi.mock('../auth/api_token_queries.js', () => ({
|
|
@@ -175,9 +175,10 @@ export const describe_bearer_auth_cases = (suite_name, cases) => {
|
|
|
175
175
|
else {
|
|
176
176
|
assert.strictEqual(res.status, tc.expected_status);
|
|
177
177
|
if (tc.expected_error) {
|
|
178
|
-
assert.strictEqual(body.error, tc.expected_error);
|
|
179
|
-
|
|
180
|
-
|
|
178
|
+
assert.strictEqual(body.error, tc.expected_error.code);
|
|
179
|
+
assert.strictEqual(res.status, tc.expected_error.status);
|
|
180
|
+
const parsed = parse_any(tc.expected_error.schema, body);
|
|
181
|
+
assert.ok(parsed.ok, `error body fails its schema: ${JSON.stringify(body)}`);
|
|
181
182
|
}
|
|
182
183
|
}
|
|
183
184
|
if (tc.validate_expectation === 'not_called') {
|
|
@@ -41,7 +41,7 @@ export interface RateLimitingTestOptions {
|
|
|
41
41
|
*
|
|
42
42
|
* Creates 2 test groups:
|
|
43
43
|
* 1. IP rate limiting on login — fires `max_attempts + 1` login requests,
|
|
44
|
-
* verifies the last returns 429 with a valid `
|
|
44
|
+
* verifies the last returns 429 with a valid `REST_RATE_LIMIT_EXCEEDED` body.
|
|
45
45
|
* 2. Per-account rate limiting on login — fires `max_attempts + 1` login
|
|
46
46
|
* requests with the same username, verifies the last returns 429.
|
|
47
47
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate_limiting.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/rate_limiting.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"rate_limiting.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/rate_limiting.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA2B7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIvD,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAExE,OAAO,EAIN,KAAK,SAAS,EACd,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAIhE;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC,4CAA4C;IAC5C,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,wDAAwD;IACxD,kBAAkB,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAChE,iDAAiD;IACjD,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B;;;OAGG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAChC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACxC;AAED;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,4BAA4B,GAAI,SAAS,uBAAuB,KAAG,IA2J/E,CAAC"}
|
|
@@ -21,8 +21,9 @@ import './assert_dev_env.js';
|
|
|
21
21
|
* @module
|
|
22
22
|
*/
|
|
23
23
|
import { describe, test, assert } from 'vitest';
|
|
24
|
+
import { parse_or_throw } from '@fuzdev/fuz_schema/schema.ts';
|
|
24
25
|
import { RateLimiter } from '../rate_limiter.js';
|
|
25
|
-
import {
|
|
26
|
+
import { REST_RATE_LIMIT_EXCEEDED } from '../http/error_schemas.js';
|
|
26
27
|
import { AUTH_MIGRATION_NS } from '../auth/migrations.js';
|
|
27
28
|
import { create_test_app } from './app_server.js';
|
|
28
29
|
import { create_test_request_headers } from './test_origin.js';
|
|
@@ -34,7 +35,7 @@ import { run_migrations } from '../db/migrate.js';
|
|
|
34
35
|
*
|
|
35
36
|
* Creates 2 test groups:
|
|
36
37
|
* 1. IP rate limiting on login — fires `max_attempts + 1` login requests,
|
|
37
|
-
* verifies the last returns 429 with a valid `
|
|
38
|
+
* verifies the last returns 429 with a valid `REST_RATE_LIMIT_EXCEEDED` body.
|
|
38
39
|
* 2. Per-account rate limiting on login — fires `max_attempts + 1` login
|
|
39
40
|
* requests with the same username, verifies the last returns 429.
|
|
40
41
|
*
|
|
@@ -94,7 +95,7 @@ export const describe_rate_limiting_tests = (options) => {
|
|
|
94
95
|
});
|
|
95
96
|
assert.strictEqual(blocked_res.status, 429);
|
|
96
97
|
const body = await blocked_res.json();
|
|
97
|
-
|
|
98
|
+
parse_or_throw(REST_RATE_LIMIT_EXCEEDED.schema, body);
|
|
98
99
|
assert.ok(typeof body.retry_after === 'number' && body.retry_after > 0, 'Expected positive retry_after');
|
|
99
100
|
assert_rate_limit_retry_after_header(blocked_res, body);
|
|
100
101
|
}
|
|
@@ -143,7 +144,7 @@ export const describe_rate_limiting_tests = (options) => {
|
|
|
143
144
|
});
|
|
144
145
|
assert.strictEqual(blocked_res.status, 429);
|
|
145
146
|
const body = await blocked_res.json();
|
|
146
|
-
|
|
147
|
+
parse_or_throw(REST_RATE_LIMIT_EXCEEDED.schema, body);
|
|
147
148
|
assert.ok(typeof body.retry_after === 'number' && body.retry_after > 0, 'Expected positive retry_after');
|
|
148
149
|
assert_rate_limit_retry_after_header(blocked_res, body);
|
|
149
150
|
// A different username should NOT be rate limited
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"round_trip.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"round_trip.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA8B7B,OAAO,EAON,KAAK,aAAa,EAClB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,oDAAoD;AACpD,MAAM,WAAW,oBAAoB;IACpC;;;;;OAKG;IACH,UAAU,EAAE,SAAS,CAAC;IACtB;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,kDAAkD;IAClD,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,+EAA+E;IAC/E,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD;;;;;;;;;;;;;OAaG;IACH,gBAAgB,CAAC,EAAE,GAAG,CACrB,MAAM,EACN,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC;QAAE,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CACnF,CAAC;CACF;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,0BAA0B,GACtC,WAAW,MAAM,EACjB,QAAQ,MAAM,EACd,MAAM,OAAO,EACb,WAAW,aAAa,KACtB,IAUF,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,8BAA8B,GAAI,SAAS,oBAAoB,KAAG,IAgK9E,CAAC"}
|
|
@@ -22,6 +22,7 @@ import './assert_dev_env.js';
|
|
|
22
22
|
*/
|
|
23
23
|
import { describe, test, beforeAll, assert } from 'vitest';
|
|
24
24
|
import { ROLE_ADMIN } from '../auth/role_schema.js';
|
|
25
|
+
import { format_route_key } from '../http/surface_query.js';
|
|
25
26
|
import { needs_actor, input_schema_declares_acting } from '../http/auth_shape.js';
|
|
26
27
|
import { assert_response_matches_spec, is_unauthenticated_refusal, pick_auth_headers, pick_auth_principal, round_trip_uses_fresh_account, to_principal_headers } from './integration_helpers.js';
|
|
27
28
|
import { resolve_valid_path, generate_valid_body, to_route_content_type } from './schema_generators.js';
|
|
@@ -64,6 +65,7 @@ export const assert_route_authenticated = (route_key, status, body, principal) =
|
|
|
64
65
|
*/
|
|
65
66
|
export const describe_round_trip_validation = (options) => {
|
|
66
67
|
const describe_time_specs = options.surface_source.route_specs;
|
|
68
|
+
const route_error_maps = options.surface_source.route_error_maps;
|
|
67
69
|
const skip_set = new Set(options.skip_routes);
|
|
68
70
|
describe('round-trip validation', () => {
|
|
69
71
|
let fixture;
|
|
@@ -99,7 +101,7 @@ export const describe_round_trip_validation = (options) => {
|
|
|
99
101
|
}
|
|
100
102
|
};
|
|
101
103
|
test.each(describe_time_specs)('$method $path produces schema-valid response', async (spec) => {
|
|
102
|
-
const route_key =
|
|
104
|
+
const route_key = format_route_key(spec);
|
|
103
105
|
if (skip_set.has(route_key))
|
|
104
106
|
return;
|
|
105
107
|
// Raw-byte / streaming routes (git smart-HTTP, binary upload/download)
|
|
@@ -150,7 +152,7 @@ export const describe_round_trip_validation = (options) => {
|
|
|
150
152
|
.catch(() => undefined);
|
|
151
153
|
assert_route_authenticated(route_key, res.status, body, principal);
|
|
152
154
|
}
|
|
153
|
-
await assert_response_matches_spec(describe_time_specs, spec.method, url, res);
|
|
155
|
+
await assert_response_matches_spec(describe_time_specs, spec.method, url, res, route_error_maps);
|
|
154
156
|
}
|
|
155
157
|
catch (e) {
|
|
156
158
|
throw new Error(`Round-trip validation failed for ${route_key} (status ${res.status}): ${e.message}`);
|
|
@@ -180,7 +182,7 @@ export const describe_round_trip_validation = (options) => {
|
|
|
180
182
|
.clone()
|
|
181
183
|
.text()
|
|
182
184
|
.catch(() => '<unreadable>')}`);
|
|
183
|
-
await assert_response_matches_spec(describe_time_specs, spec.method, url, res);
|
|
185
|
+
await assert_response_matches_spec(describe_time_specs, spec.method, url, res, route_error_maps);
|
|
184
186
|
}
|
|
185
187
|
catch (e) {
|
|
186
188
|
throw new Error(`Round-trip success-fixture failed for ${route_key} (status ${res.status}): ${e.message}`);
|
|
@@ -171,8 +171,14 @@ export declare const to_route_content_type: (route: {
|
|
|
171
171
|
* Resolve a route path with valid-ish param values so params validation passes.
|
|
172
172
|
* Used when testing input on routes that also have params.
|
|
173
173
|
*
|
|
174
|
+
* The template is read as Hono reads it (`split_route_template`,
|
|
175
|
+
* `parse_route_param`): only a whole param segment — `:name` or `:name{re}`,
|
|
176
|
+
* optional or not — is filled, so a `:` inside a literal segment
|
|
177
|
+
* (`/v1/files:upload`) stays, and a `{re}` goes with its param. An optional
|
|
178
|
+
* param is filled too.
|
|
179
|
+
*
|
|
174
180
|
* Without a params schema (or for a param the schema doesn't name) each
|
|
175
|
-
*
|
|
181
|
+
* param becomes `test_<name>` — fine for an unconstrained segment. With
|
|
176
182
|
* one, `test_<name>` is still preferred wherever the field schema accepts
|
|
177
183
|
* it, because the param name in the URL is what makes a failure message
|
|
178
184
|
* readable. Only a segment that refuses it falls through: a `uuid` param
|
|
@@ -180,13 +186,14 @@ export declare const to_route_content_type: (route: {
|
|
|
180
186
|
* anything else is synthesized by `generate_valid_string`, so a
|
|
181
187
|
* format-constrained segment (a `blake3:…` fact hash, a `tok_…` id)
|
|
182
188
|
* resolves to a value its schema accepts instead of a `test_<name>` that
|
|
183
|
-
* 400s before the route's real gates run.
|
|
189
|
+
* 400s before the route's real gates run. A `{re}` is not read: the value
|
|
190
|
+
* comes from the schema alone.
|
|
184
191
|
*
|
|
185
192
|
* The synthesized value is percent-encoded, and a value containing `/` is
|
|
186
193
|
* refused (it would silently add a path segment and route elsewhere) —
|
|
187
194
|
* both fall back to `test_<name>`.
|
|
188
195
|
*
|
|
189
|
-
* @param path - the route path
|
|
196
|
+
* @param path - the route's path template
|
|
190
197
|
* @param params_schema - the route's params schema, a Zod or `@fuzdev/fuz_schema` object schema
|
|
191
198
|
* @throws Error when `params_schema` is no object schema, or of neither library
|
|
192
199
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema_generators.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/schema_generators.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAsB7B,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AO,CAAC,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,qBAAqB,GACjC,eAAe,gBAAgB,EAC/B,QAAQ,gBAAgB,KACtB,eAID,CAAC;AAqDH;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,gCAAgC,GAC5C,eAAe,gBAAgB,EAC/B,QAAQ,gBAAgB,EACxB,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,eAAe,KACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IA8B5B,CAAC;AAIF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,2BAA2B,GACvC,OAAO,eAAe,EACtB,cAAc,gBAAgB,KAC5B,MAAM,GAAG,IA2BX,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,GACzB,cAAc,gBAAgB,EAC9B,OAAO,MAAM,KACX,gBAAgB,GAAG,IAgBrB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAAI,OAAO;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,KAAG,MACL,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,EAAE,gBAAgB,gBAAgB,KAAG,MAqBnF,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,mBAAmB,GAC/B,cAAc,gBAAgB,KAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAW5B,CAAC"}
|
|
@@ -16,6 +16,7 @@ import { get_schema_entries, get_schema_fields, unwrap_schema } from '@fuzdev/fu
|
|
|
16
16
|
import { to_json_schema } from '@fuzdev/fuz_schema/json_schema.ts';
|
|
17
17
|
import { zod_unwrap_def, zod_get_base_type, zod_unwrap_to_object, zod_extract_fields } from '../zod.js';
|
|
18
18
|
import { is_null_schema, is_void_schema } from '../http/schema_helpers.js';
|
|
19
|
+
import { parse_route_param, split_route_template } from '../http/route_error_check.js';
|
|
19
20
|
import { assert_zod_schema, format_issues, parse_any } from '../schema_issues.js';
|
|
20
21
|
/**
|
|
21
22
|
* The JSON Schema of a field's input side — where its format, pattern and
|
|
@@ -663,8 +664,14 @@ export const to_route_content_type = (route) => route.raw_body ? 'application/oc
|
|
|
663
664
|
* Resolve a route path with valid-ish param values so params validation passes.
|
|
664
665
|
* Used when testing input on routes that also have params.
|
|
665
666
|
*
|
|
667
|
+
* The template is read as Hono reads it (`split_route_template`,
|
|
668
|
+
* `parse_route_param`): only a whole param segment — `:name` or `:name{re}`,
|
|
669
|
+
* optional or not — is filled, so a `:` inside a literal segment
|
|
670
|
+
* (`/v1/files:upload`) stays, and a `{re}` goes with its param. An optional
|
|
671
|
+
* param is filled too.
|
|
672
|
+
*
|
|
666
673
|
* Without a params schema (or for a param the schema doesn't name) each
|
|
667
|
-
*
|
|
674
|
+
* param becomes `test_<name>` — fine for an unconstrained segment. With
|
|
668
675
|
* one, `test_<name>` is still preferred wherever the field schema accepts
|
|
669
676
|
* it, because the param name in the URL is what makes a failure message
|
|
670
677
|
* readable. Only a segment that refuses it falls through: a `uuid` param
|
|
@@ -672,27 +679,27 @@ export const to_route_content_type = (route) => route.raw_body ? 'application/oc
|
|
|
672
679
|
* anything else is synthesized by `generate_valid_string`, so a
|
|
673
680
|
* format-constrained segment (a `blake3:…` fact hash, a `tok_…` id)
|
|
674
681
|
* resolves to a value its schema accepts instead of a `test_<name>` that
|
|
675
|
-
* 400s before the route's real gates run.
|
|
682
|
+
* 400s before the route's real gates run. A `{re}` is not read: the value
|
|
683
|
+
* comes from the schema alone.
|
|
676
684
|
*
|
|
677
685
|
* The synthesized value is percent-encoded, and a value containing `/` is
|
|
678
686
|
* refused (it would silently add a path segment and route elsewhere) —
|
|
679
687
|
* both fall back to `test_<name>`.
|
|
680
688
|
*
|
|
681
|
-
* @param path - the route path
|
|
689
|
+
* @param path - the route's path template
|
|
682
690
|
* @param params_schema - the route's params schema, a Zod or `@fuzdev/fuz_schema` object schema
|
|
683
691
|
* @throws Error when `params_schema` is no object schema, or of neither library
|
|
684
692
|
*/
|
|
685
693
|
export const resolve_valid_path = (path, params_schema) => {
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
const
|
|
690
|
-
|
|
691
|
-
const
|
|
692
|
-
const field_schema = view.field_schema(name);
|
|
694
|
+
const view = params_schema
|
|
695
|
+
? to_object_schema_view(params_schema, `resolve_valid_path(${path}): the params schema`)
|
|
696
|
+
: null;
|
|
697
|
+
const fill = (name) => {
|
|
698
|
+
const fallback = encodeURIComponent(`test_${name}`);
|
|
699
|
+
const field_schema = view?.field_schema(name);
|
|
693
700
|
if (!field_schema)
|
|
694
701
|
return fallback;
|
|
695
|
-
if (accepts(field_schema,
|
|
702
|
+
if (accepts(field_schema, `test_${name}`))
|
|
696
703
|
return fallback;
|
|
697
704
|
if (to_base_type(field_schema) === 'uuid')
|
|
698
705
|
return NIL_UUID;
|
|
@@ -703,7 +710,12 @@ export const resolve_valid_path = (path, params_schema) => {
|
|
|
703
710
|
if (generated.includes('/'))
|
|
704
711
|
return fallback;
|
|
705
712
|
return encodeURIComponent(generated);
|
|
713
|
+
};
|
|
714
|
+
const segments = split_route_template(path).map((segment) => {
|
|
715
|
+
const param = parse_route_param(segment);
|
|
716
|
+
return param ? fill(param.name) : segment;
|
|
706
717
|
});
|
|
718
|
+
return (path.startsWith('/') ? '/' : '') + segments.join('/');
|
|
707
719
|
};
|
|
708
720
|
/**
|
|
709
721
|
* Generate a valid request body for a route's or action's input schema.
|
package/dist/testing/stubs.d.ts
CHANGED
|
@@ -207,6 +207,13 @@ export interface CreateTestAppSurfaceSpecOptions {
|
|
|
207
207
|
* @default false
|
|
208
208
|
*/
|
|
209
209
|
daemon_token?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Symmetric with `AppServerOptions.max_body_size` — `null` leaves out the
|
|
212
|
+
* body limit's spec, which `create_app_server` mounts ahead of the other
|
|
213
|
+
* middleware unless the limit is disabled. Only whether it is `null` is
|
|
214
|
+
* read: the spec's handler here is a stub.
|
|
215
|
+
*/
|
|
216
|
+
max_body_size?: number | null;
|
|
210
217
|
}
|
|
211
218
|
/**
|
|
212
219
|
* Create an `AppSurfaceSpec` for the standard testing suites.
|
|
@@ -231,7 +238,9 @@ export interface CreateTestAppSurfaceSpecOptions {
|
|
|
231
238
|
* one: a stub `trusted_proxy` spec at `'*'`, then the stub auth stack (with
|
|
232
239
|
* `daemon_token` when `options.daemon_token` is set). If
|
|
233
240
|
* `create_app_server` changes how it wires routes, update this helper
|
|
234
|
-
* to stay in sync (single source of truth for all consumers).
|
|
241
|
+
* to stay in sync (single source of truth for all consumers). The body
|
|
242
|
+
* limit's spec heads the list unless `max_body_size` is `null`, as it does on
|
|
243
|
+
* the live server.
|
|
235
244
|
*
|
|
236
245
|
* @param options - surface spec options
|
|
237
246
|
* @returns the surface spec for the standard suites
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stubs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/stubs.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAa7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"stubs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/stubs.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAa7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,E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AK,CAAC,eAAe,CAAC,CAAC,CAAC;IAC7F;;;;;;;;OAQG;IACH,YAAY,CAAC,EACZ,aAAa,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,gBAAgB,KAAK,aAAa,CAAC,cAAc,CAAC,CAAC,CAAC;IAC5F;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACxC;;;;;;;;OAQG;IACH,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,KAAK,KAAK,CAAC,cAAc,CAAC,CAAC;IAC/E;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC9C;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,sBAAsB,CAAC;IACnC;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAmBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,4BAA4B,GACxC,SAAS,+BAA+B,KACtC,cA+GF,CAAC"}
|
package/dist/testing/stubs.js
CHANGED
|
@@ -8,7 +8,8 @@ import './assert_dev_env.js';
|
|
|
8
8
|
* @module
|
|
9
9
|
*/
|
|
10
10
|
import { Logger } from '@fuzdev/fuz_util/log.ts';
|
|
11
|
-
import {
|
|
11
|
+
import { REST_FORBIDDEN_ORIGIN } from '../http/error_schemas.js';
|
|
12
|
+
import { body_limit_middleware_shape } from '../http/body_limit_schema.js';
|
|
12
13
|
import { create_realtime_closer } from '../actions/connection_closer.js';
|
|
13
14
|
import { Db } from '../db/db.js';
|
|
14
15
|
import { prefix_route_specs } from '../http/route_spec.js';
|
|
@@ -188,7 +189,7 @@ export const create_stub_api_middleware = (options) => {
|
|
|
188
189
|
name: 'origin',
|
|
189
190
|
path: ORIGIN_MIDDLEWARE_PATH,
|
|
190
191
|
handler: create_stub_mw(),
|
|
191
|
-
errors:
|
|
192
|
+
errors: [REST_FORBIDDEN_ORIGIN],
|
|
192
193
|
...(origin_carve_outs.length > 0 && { carve_outs: origin_carve_outs })
|
|
193
194
|
},
|
|
194
195
|
...(options?.include_daemon_token
|
|
@@ -197,7 +198,7 @@ export const create_stub_api_middleware = (options) => {
|
|
|
197
198
|
name: 'daemon_token',
|
|
198
199
|
path: AUTH_MIDDLEWARE_PATH,
|
|
199
200
|
handler: create_stub_mw(),
|
|
200
|
-
errors:
|
|
201
|
+
errors: []
|
|
201
202
|
}
|
|
202
203
|
]
|
|
203
204
|
: []),
|
|
@@ -207,7 +208,7 @@ export const create_stub_api_middleware = (options) => {
|
|
|
207
208
|
name: 'bearer_auth',
|
|
208
209
|
path: AUTH_MIDDLEWARE_PATH,
|
|
209
210
|
handler: create_stub_mw(),
|
|
210
|
-
errors:
|
|
211
|
+
errors: []
|
|
211
212
|
}
|
|
212
213
|
];
|
|
213
214
|
return specs;
|
|
@@ -274,7 +275,9 @@ const assert_self_resolved_ws_origins = (endpoint) => {
|
|
|
274
275
|
* one: a stub `trusted_proxy` spec at `'*'`, then the stub auth stack (with
|
|
275
276
|
* `daemon_token` when `options.daemon_token` is set). If
|
|
276
277
|
* `create_app_server` changes how it wires routes, update this helper
|
|
277
|
-
* to stay in sync (single source of truth for all consumers).
|
|
278
|
+
* to stay in sync (single source of truth for all consumers). The body
|
|
279
|
+
* limit's spec heads the list unless `max_body_size` is `null`, as it does on
|
|
280
|
+
* the live server.
|
|
278
281
|
*
|
|
279
282
|
* @param options - surface spec options
|
|
280
283
|
* @returns the surface spec for the standard suites
|
|
@@ -369,6 +372,13 @@ export const create_test_app_surface_spec = (options) => {
|
|
|
369
372
|
middleware_specs = options.transform_middleware(stack_specs.map((spec) => ({ ...spec })));
|
|
370
373
|
assert_middleware_stack_mounted(stack_specs, middleware_specs);
|
|
371
374
|
}
|
|
375
|
+
// mirrors `create_app_server`'s body limit spec, ahead of the transformed stack
|
|
376
|
+
if (options.max_body_size !== null) {
|
|
377
|
+
middleware_specs = [
|
|
378
|
+
{ ...body_limit_middleware_shape, handler: create_stub_mw() },
|
|
379
|
+
...middleware_specs
|
|
380
|
+
];
|
|
381
|
+
}
|
|
372
382
|
const surface_spec = create_app_surface_spec({
|
|
373
383
|
middleware_specs,
|
|
374
384
|
route_specs,
|