@fuzdev/fuz_app 0.184.0 → 0.186.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.
Files changed (174) hide show
  1. package/dist/actions/CLAUDE.md +18 -3
  2. package/dist/actions/perform_action.d.ts.map +1 -1
  3. package/dist/actions/perform_action.js +36 -5
  4. package/dist/actions/register_action_ws.d.ts +14 -7
  5. package/dist/actions/register_action_ws.d.ts.map +1 -1
  6. package/dist/actions/ws_socket_session.d.ts +17 -4
  7. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  8. package/dist/actions/ws_socket_session.js +41 -7
  9. package/dist/auth/CLAUDE.md +18 -9
  10. package/dist/auth/account_queries.d.ts +53 -40
  11. package/dist/auth/account_queries.d.ts.map +1 -1
  12. package/dist/auth/account_queries.js +57 -50
  13. package/dist/auth/account_routes.d.ts.map +1 -1
  14. package/dist/auth/account_routes.js +59 -25
  15. package/dist/auth/admin_actions.d.ts.map +1 -1
  16. package/dist/auth/admin_actions.js +26 -9
  17. package/dist/auth/audit_emitter.js +2 -2
  18. package/dist/auth/audit_log_queries.d.ts +11 -3
  19. package/dist/auth/audit_log_queries.d.ts.map +1 -1
  20. package/dist/auth/audit_log_queries.js +4 -4
  21. package/dist/auth/audit_log_routes.d.ts +1 -1
  22. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  23. package/dist/auth/audit_log_routes.js +3 -2
  24. package/dist/auth/audit_log_schema.js +1 -1
  25. package/dist/auth/auth_ddl.d.ts.map +1 -1
  26. package/dist/auth/auth_ddl.js +4 -0
  27. package/dist/auth/cleanup.d.ts +34 -3
  28. package/dist/auth/cleanup.d.ts.map +1 -1
  29. package/dist/auth/cleanup.js +12 -4
  30. package/dist/auth/migrations.d.ts.map +1 -1
  31. package/dist/auth/migrations.js +35 -0
  32. package/dist/auth/role_grant_offer_queries.d.ts +13 -13
  33. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  34. package/dist/auth/role_grant_offer_queries.js +12 -13
  35. package/dist/auth/role_grant_queries.d.ts +16 -9
  36. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  37. package/dist/auth/role_grant_queries.js +16 -9
  38. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  39. package/dist/auth/self_service_role_actions.js +15 -0
  40. package/dist/auth/session_queries.d.ts +24 -0
  41. package/dist/auth/session_queries.d.ts.map +1 -1
  42. package/dist/auth/session_queries.js +28 -0
  43. package/dist/db/CLAUDE.md +3 -3
  44. package/dist/db/cell_ddl.d.ts +8 -3
  45. package/dist/db/cell_ddl.d.ts.map +1 -1
  46. package/dist/db/cell_ddl.js +10 -5
  47. package/dist/http/CLAUDE.md +1 -1
  48. package/dist/http/body_limit.d.ts +4 -4
  49. package/dist/http/body_limit.js +4 -4
  50. package/dist/http/pending_effects.d.ts +8 -4
  51. package/dist/http/pending_effects.d.ts.map +1 -1
  52. package/dist/http/route_spec.d.ts +3 -3
  53. package/dist/http/route_spec.d.ts.map +1 -1
  54. package/dist/realtime/audit_log_sse.d.ts +1 -1
  55. package/dist/realtime/sse.d.ts +2 -2
  56. package/dist/realtime/sse.d.ts.map +1 -1
  57. package/dist/realtime/sse_constants.d.ts +1 -1
  58. package/dist/realtime/sse_constants.js +1 -1
  59. package/dist/server/app_server.d.ts +59 -71
  60. package/dist/server/app_server.d.ts.map +1 -1
  61. package/dist/server/app_server.js +52 -60
  62. package/dist/server/shutdown_drain.d.ts +69 -0
  63. package/dist/server/shutdown_drain.d.ts.map +1 -0
  64. package/dist/server/shutdown_drain.js +77 -0
  65. package/dist/testing/CLAUDE.md +197 -66
  66. package/dist/testing/admin_integration.d.ts +2 -2
  67. package/dist/testing/admin_integration.d.ts.map +1 -1
  68. package/dist/testing/admin_integration.js +36 -20
  69. package/dist/testing/app_server.d.ts +5 -7
  70. package/dist/testing/app_server.d.ts.map +1 -1
  71. package/dist/testing/app_server.js +5 -7
  72. package/dist/testing/auth_apps.d.ts +3 -1
  73. package/dist/testing/auth_apps.d.ts.map +1 -1
  74. package/dist/testing/auth_apps.js +22 -5
  75. package/dist/testing/cross_backend/backend_config.d.ts +8 -0
  76. package/dist/testing/cross_backend/backend_config.d.ts.map +1 -1
  77. package/dist/testing/cross_backend/backend_log.d.ts +71 -0
  78. package/dist/testing/cross_backend/backend_log.d.ts.map +1 -0
  79. package/dist/testing/cross_backend/backend_log.js +134 -0
  80. package/dist/testing/cross_backend/backend_swap.d.ts +41 -0
  81. package/dist/testing/cross_backend/backend_swap.d.ts.map +1 -0
  82. package/dist/testing/cross_backend/backend_swap.js +431 -0
  83. package/dist/testing/cross_backend/body_size_smuggling.js +3 -3
  84. package/dist/testing/cross_backend/bootstrap_backend.d.ts +3 -1
  85. package/dist/testing/cross_backend/bootstrap_backend.d.ts.map +1 -1
  86. package/dist/testing/cross_backend/bootstrap_backend.js +9 -5
  87. package/dist/testing/cross_backend/conformance_case.d.ts +11 -6
  88. package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
  89. package/dist/testing/cross_backend/conformance_case.js +4 -0
  90. package/dist/testing/cross_backend/conformance_principal.d.ts +2 -2
  91. package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -1
  92. package/dist/testing/cross_backend/conformance_principal.js +27 -10
  93. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +10 -1
  94. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
  95. package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +33 -7
  96. package/dist/testing/cross_backend/default_backend_configs.d.ts +38 -5
  97. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  98. package/dist/testing/cross_backend/default_backend_configs.js +50 -15
  99. package/dist/testing/cross_backend/in_process_setup.d.ts +1 -1
  100. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  101. package/dist/testing/cross_backend/in_process_setup.js +53 -31
  102. package/dist/testing/cross_backend/revocation_drivers.d.ts +14 -2
  103. package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
  104. package/dist/testing/cross_backend/revocation_drivers.js +36 -8
  105. package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
  106. package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -1
  107. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +7 -0
  108. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
  109. package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +4 -2
  110. package/dist/testing/cross_backend/setup.d.ts +44 -43
  111. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  112. package/dist/testing/cross_backend/setup.js +64 -62
  113. package/dist/testing/cross_backend/spawn_backend.d.ts +19 -1
  114. package/dist/testing/cross_backend/spawn_backend.d.ts.map +1 -1
  115. package/dist/testing/cross_backend/spawn_backend.js +138 -11
  116. package/dist/testing/cross_backend/spine_suites.d.ts +17 -14
  117. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  118. package/dist/testing/cross_backend/spine_suites.js +37 -15
  119. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  120. package/dist/testing/cross_backend/sse_round_trip.js +4 -2
  121. package/dist/testing/cross_backend/standard.d.ts +18 -82
  122. package/dist/testing/cross_backend/standard.d.ts.map +1 -1
  123. package/dist/testing/cross_backend/standard.js +6 -21
  124. package/dist/testing/cross_backend/standard_auth.d.ts +74 -0
  125. package/dist/testing/cross_backend/standard_auth.d.ts.map +1 -0
  126. package/dist/testing/cross_backend/standard_auth.js +28 -0
  127. package/dist/testing/cross_backend/standard_bundle.d.ts +48 -0
  128. package/dist/testing/cross_backend/standard_bundle.d.ts.map +1 -0
  129. package/dist/testing/cross_backend/standard_bundle.js +43 -0
  130. package/dist/testing/cross_backend/testing_reset_actions.d.ts +18 -6
  131. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  132. package/dist/testing/cross_backend/testing_reset_actions.js +23 -8
  133. package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
  134. package/dist/testing/cross_backend/testing_server_bun.js +7 -30
  135. package/dist/testing/cross_backend/testing_server_core.d.ts +16 -3
  136. package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
  137. package/dist/testing/cross_backend/testing_server_core.js +20 -4
  138. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +6 -2
  139. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  140. package/dist/testing/cross_backend/ts_spine_backend_config.js +7 -3
  141. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  142. package/dist/testing/cross_backend/ws_round_trip.js +4 -3
  143. package/dist/testing/data_exposure.d.ts +4 -1
  144. package/dist/testing/data_exposure.d.ts.map +1 -1
  145. package/dist/testing/data_exposure.js +93 -25
  146. package/dist/testing/db_invariants.d.ts +5 -5
  147. package/dist/testing/db_invariants.js +5 -5
  148. package/dist/testing/error_coverage.d.ts +5 -0
  149. package/dist/testing/error_coverage.d.ts.map +1 -1
  150. package/dist/testing/error_coverage.js +2 -1
  151. package/dist/testing/integration.d.ts +4 -20
  152. package/dist/testing/integration.d.ts.map +1 -1
  153. package/dist/testing/integration.js +49 -79
  154. package/dist/testing/integration_helpers.d.ts +16 -0
  155. package/dist/testing/integration_helpers.d.ts.map +1 -1
  156. package/dist/testing/integration_helpers.js +29 -1
  157. package/dist/testing/logged_errors.d.ts +61 -0
  158. package/dist/testing/logged_errors.d.ts.map +1 -0
  159. package/dist/testing/logged_errors.js +285 -0
  160. package/dist/testing/middleware_gate_probes.d.ts +55 -1
  161. package/dist/testing/middleware_gate_probes.d.ts.map +1 -1
  162. package/dist/testing/middleware_gate_probes.js +76 -3
  163. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  164. package/dist/testing/rpc_attack_surface.js +41 -16
  165. package/dist/testing/stubs.d.ts +5 -1
  166. package/dist/testing/stubs.d.ts.map +1 -1
  167. package/dist/testing/stubs.js +6 -3
  168. package/dist/testing/test_app.d.ts +39 -9
  169. package/dist/testing/test_app.d.ts.map +1 -1
  170. package/dist/testing/test_app.js +70 -12
  171. package/dist/testing/transports/fetch_transport.d.ts +10 -0
  172. package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
  173. package/dist/testing/transports/fetch_transport.js +13 -0
  174. package/package.json +4 -3
@@ -32,6 +32,7 @@ import type { Context, Hono } from 'hono';
32
32
  import type { UpgradeWebSocket } from 'hono/ws';
33
33
  import { type Logger as LoggerType } from '@fuzdev/fuz_util/log.ts';
34
34
  import type { RuntimeDeps } from '../../runtime/deps.js';
35
+ import { type ShutdownDrainGivenUp } from '../../server/shutdown_drain.js';
35
36
  /**
36
37
  * Adapter-built handle to a bound HTTP server.
37
38
  *
@@ -90,7 +91,15 @@ export interface TestingServerAdapter {
90
91
  pid: number;
91
92
  /** Register SIGINT/SIGTERM listeners that invoke `handler` once each. */
92
93
  register_shutdown_signals: (handler: () => Promise<void>) => void;
93
- /** Forceful exit on graceful-shutdown completion or fatal error. */
94
+ /**
95
+ * Forceful exit on graceful-shutdown completion or fatal error: `0` for a
96
+ * shutdown that drained everything, `1` for one that gave up or threw.
97
+ *
98
+ * A give-up's exit still waits for `BuiltTestingApp.close` to return, and
99
+ * that closes the database: on `pg`, `pool.end()` waits for a client a
100
+ * wedged handler holds, so the exit can wait past teardown's SIGKILL. The
101
+ * harness's default databases (pglet, PGlite) have no pool to wait on.
102
+ */
94
103
  exit: (code: number) => never;
95
104
  }
96
105
  /** What the core hands a `StartTestingServerOptions.build_app` seam. */
@@ -115,8 +124,10 @@ export interface BuiltTestingApp {
115
124
  * Tear down backend(s) + DB + any rotation on graceful shutdown. Called
116
125
  * after the listener stops accepting connections and before its drain is
117
126
  * awaited, so it must end live WebSockets (`AppServer.close` does).
127
+ * Resolves what the shutdown gave up on — `AppServer.close`'s report — and
128
+ * a report that gave up on anything exits the process `1`.
118
129
  */
119
- close: () => Promise<void>;
130
+ close: () => Promise<ShutdownDrainGivenUp>;
120
131
  }
121
132
  /** Options for `start_testing_server`. */
122
133
  export interface StartTestingServerOptions {
@@ -159,7 +170,9 @@ export declare const is_loopback_bind_host: (host: string) => boolean;
159
170
  * Boot a test-mode server using the supplied runtime adapter.
160
171
  *
161
172
  * Mirrors a production `start_server` at the surface level — stale-daemon
162
- * check, daemon-info write, bind, graceful shutdown — but the app is the
173
+ * check, daemon-info write, bind, graceful shutdown, exiting `1` when the
174
+ * shutdown gave up on work still running or threw, without waiting for the
175
+ * listener's drain behind a request it gave up on — but the app is the
163
176
  * caller's no-domain (or domain) `StartTestingServerOptions.build_app`
164
177
  * and the runtime boundary is the `TestingServerAdapter`. Refuses any
165
178
  * non-loopback bind host (the test binary must stay on loopback — see
@@ -1 +1 @@
1
- {"version":3,"file":"testing_server_core.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_server_core.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAU,KAAK,MAAM,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC3B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,4DAA4D;AAC5D,MAAM,WAAW,uBAAuB;IACvC;;;;;;;;;;;;;;OAcG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACpC,4EAA4E;IAC5E,aAAa,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,OAAO,EAAE,WAAW,CAAC;IACrB,6DAA6D;IAC7D,iBAAiB,EAAE,CAAC,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E;IAC1E,GAAG,CAAC,EAAE,UAAU,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,GAAI,MAAM,MAAM,KAAG,OAGpD,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,GAAU,SAAS,yBAAyB,KAAG,OAAO,CAAC,IAAI,CA2D3F,CAAC"}
1
+ {"version":3,"file":"testing_server_core.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_server_core.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAU,KAAK,MAAM,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAG5E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAoB,KAAK,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AAE7F;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC3B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,4DAA4D;AAC5D,MAAM,WAAW,uBAAuB;IACvC;;;;;;;;;;;;;;OAcG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACpC,4EAA4E;IAC5E,aAAa,EAAE,MAAM,CAAC;IACtB,kEAAkE;IAClE,OAAO,EAAE,WAAW,CAAC;IACrB,6DAA6D;IAC7D,iBAAiB,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,CAAC;IACtD;;;;OAIG;IACH,iBAAiB,EAAE,CAAC,OAAO,CAAC,EAAE,uBAAuB,KAAK,gBAAg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pD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oBAAoB,GAAU,SAAS,yBAAyB,KAAG,OAAO,CAAC,IAAI,CAuE3F,CAAC"}
@@ -1,6 +1,7 @@
1
1
  import '../assert_dev_env.js';
2
2
  import { Logger } from '@fuzdev/fuz_util/log.ts';
3
3
  import { write_daemon_info, read_daemon_info, is_daemon_running } from '../daemon_info.js';
4
+ import { shutdown_gave_up } from '../../server/shutdown_drain.js';
4
5
  /**
5
6
  * Loopback bind hosts — the only ones the test binary may serve on. It ships
6
7
  * deterministic dev secrets (fixed cookie keys + bootstrap token in
@@ -18,7 +19,9 @@ export const is_loopback_bind_host = (host) => {
18
19
  * Boot a test-mode server using the supplied runtime adapter.
19
20
  *
20
21
  * Mirrors a production `start_server` at the surface level — stale-daemon
21
- * check, daemon-info write, bind, graceful shutdown — but the app is the
22
+ * check, daemon-info write, bind, graceful shutdown, exiting `1` when the
23
+ * shutdown gave up on work still running or threw, without waiting for the
24
+ * listener's drain behind a request it gave up on — but the app is the
22
25
  * caller's no-domain (or domain) `StartTestingServerOptions.build_app`
23
26
  * and the runtime boundary is the `TestingServerAdapter`. Refuses any
24
27
  * non-loopback bind host (the test binary must stay on loopback — see
@@ -60,6 +63,7 @@ export const start_testing_server = async (options) => {
60
63
  adapter.exit(1);
61
64
  shutting_down = true;
62
65
  log.info('shutting down...');
66
+ let failed = false;
63
67
  try {
64
68
  // Stop accepting first so no new request reaches a closed DB, but
65
69
  // don't await the drain yet: live WebSockets hold it open until
@@ -68,13 +72,25 @@ export const start_testing_server = async (options) => {
68
72
  // in flight when the signal lands is waited for by `AppServer.close`
69
73
  // (behind `built.close()`), within its drain bound.
70
74
  const drained = server.shutdown();
71
- await built.close();
72
- await drained;
75
+ // awaited only on a clean close, below — never left unhandled
76
+ drained.catch(() => { });
77
+ const given_up = await built.close();
78
+ // `AppServer.close` has logged what it gave up on
79
+ failed = shutdown_gave_up(given_up);
80
+ // a request the drain gave up on still holds its connection, which
81
+ // the listener's close would wait on past teardown's SIGKILL — as
82
+ // the Rust spine's one bound covers its listener drain too
83
+ if (!failed)
84
+ await drained;
73
85
  }
74
86
  catch (error) {
75
87
  log.error('shutdown error:', error);
88
+ failed = true;
76
89
  }
77
- adapter.exit(0);
90
+ // a shutdown that went wrong is a failed exit, which the cross-backend
91
+ // teardown reports — twin of the Rust spine's
92
+ // `StartupError::ShutdownGivenUp`, which exits 1
93
+ adapter.exit(failed ? 1 : 0);
78
94
  };
79
95
  adapter.register_shutdown_signals(shutdown);
80
96
  };
@@ -92,8 +92,12 @@ export interface TsSpineBackendConfigOptions {
92
92
  readonly db_audit_checkout_timeout_ms?: number;
93
93
  }
94
94
  /**
95
- * `BackendConfig` for the Node TS spine binary — spawned via `gro run`
96
- * (Gro's TS loader resolves the entry's relative imports).
95
+ * `BackendConfig` for the Node TS spine binary — spawned on plain Node (type
96
+ * stripping, with the `development` condition the testing modules assert),
97
+ * not under `gro run`: gro's CLI passes a SIGTERM on to the task's process
98
+ * but then dies by the signal itself, without waiting for the server's exit
99
+ * code, so teardown — which holds the spawned process to exit `0` — would see
100
+ * a signal exit whatever the shutdown exited with.
97
101
  */
98
102
  export declare const ts_spine_node_backend_config: (options?: TsSpineBackendConfigOptions) => BackendConfig;
99
103
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ts_spine_backend_config.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/ts_spine_backend_config.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AA4EzD,6FAA6F;AAC7F,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,gDAAgD;AAChD,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAE9C,yDAAyD;AACzD,eAAO,MAAM,mBAAmB,wDAAwD,CAAC;AAEzF,wDAAwD;AACxD,eAAO,MAAM,kBA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AyD;AACzD,eAAO,MAAM,mBAAmB,wDAAwD,CAAC;AAEzF,wDAAwD;AACxD,eAAO,MAAM,kBAAkB,uDAAuD,CAAC;AAEvF,MAAM,WAAW,2BAA2B;IAC3C,sEAAsE;IACtE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,6DAA6D;IAC7D,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;;OASG;IACH,QAAQ,CAAC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAC3C;;;;;;OAMG;IACH,QAAQ,CAAC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAC5C;;;;;OAKG;IACH,QAAQ,CAAC,8BAA8B,CAAC,EAAE,MAAM,CAAC;IACjD;;;;;OAKG;IACH,QAAQ,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IAC1C;;;;OAIG;IACH,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IACxC;;;;OAIG;IACH,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,4BAA4B,CAAC,EAAE,MAAM,CAAC;CAC/C;AAWD;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,GACxC,UAAS,2BAAgC,KACvC,aAyBF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,GACvC,UAAS,2BAAgC,KACvC,aAyBF,CAAC"}
@@ -76,8 +76,12 @@ export const TS_SPINE_BUN_ENTRY = 'src/test/cross_backend/testing_spine_server_b
76
76
  */
77
77
  const login_rate_limit_env = (enable) => enable ? { [LOGIN_RATE_LIMIT_ENABLED_ENV]: 'true' } : {};
78
78
  /**
79
- * `BackendConfig` for the Node TS spine binary — spawned via `gro run`
80
- * (Gro's TS loader resolves the entry's relative imports).
79
+ * `BackendConfig` for the Node TS spine binary — spawned on plain Node (type
80
+ * stripping, with the `development` condition the testing modules assert),
81
+ * not under `gro run`: gro's CLI passes a SIGTERM on to the task's process
82
+ * but then dies by the signal itself, without waiting for the server's exit
83
+ * code, so teardown — which holds the spawned process to exit `0` — would see
84
+ * a signal exit whatever the shutdown exited with.
81
85
  */
82
86
  export const ts_spine_node_backend_config = (options = {}) => {
83
87
  const { port = TS_SPINE_NODE_DEFAULT_PORT, database_url, enable_login_rate_limit, name = 'ts_spine_node' } = options;
@@ -86,7 +90,7 @@ export const ts_spine_node_backend_config = (options = {}) => {
86
90
  ...make_default_ts_backend_config({
87
91
  name,
88
92
  port,
89
- start_command: ['gro', 'run', TS_SPINE_NODE_ENTRY],
93
+ start_command: ['node', '--conditions=development', TS_SPINE_NODE_ENTRY],
90
94
  database_url,
91
95
  paths,
92
96
  daemon_token_dir_env: TS_SPINE_DIR_ENV,
@@ -1 +1 @@
1
- {"version":3,"file":"ws_round_trip.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/ws_round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA2H9B,OAAO,EAAE,KAAK,mBAAmB,EAAW,MAAM,mBAAmB,CAAC;AAItE,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AAOzD,OAAO,EAGN,KAAK,gBAAgB,EACrB,MAAM,kBAAkB,CAAC;AAK1B,2DAA2D;AAC3D,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IAClE;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,uEAAuE;IACvE,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC3C;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,wFAAwF;IACxF,QAAQ,CAAC,WAAW,CAAC,EAAE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AQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;;;;;OAMG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAClD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,+BAA+B,GAAI,SAAS,yBAAyB,KAAG,IAmiBpF,CAAC"}
@@ -56,7 +56,8 @@ import '../assert_dev_env.js';
56
56
  * a socket on the account's other token open; `admin_token_revoke_all`,
57
57
  * `POST /password`, and `account_purge` (also gated on
58
58
  * `capabilities.account_lifecycle`) close the account's bearer and session
59
- * sockets, and `POST /logout` closes only the socket of the session it ends,
59
+ * sockets, and `POST /logout` and `account_session_revoke` of the caller's own
60
+ * session close only the socket of the session they end,
60
61
  * the account's bearer socket and a second session's socket each answering a
61
62
  * request after it — the rows `create_account_revocations` shares with the SSE
62
63
  * suite;
@@ -383,8 +384,8 @@ export const describe_cross_process_ws_tests = (options) => {
383
384
  });
384
385
  // The revocations of `revocation_drivers.ts`, shared with the SSE suite.
385
386
  // An account-wide one closes the account's connections — its bearer
386
- // socket, and its session socket too. A session-scoped one (logout)
387
- // closes the socket of the session it was sent on, and leaves the
387
+ // socket, and its session socket too. A session-scoped one (logout, a
388
+ // revoke of the current session) closes the socket of the session it was sent on, and leaves the
388
389
  // account's bearer socket and another session's socket open, each proven
389
390
  // by a reply after the close.
390
391
  // Without `rpc_path` the rows still register, as skipped cases, and never
@@ -78,7 +78,10 @@ export interface DataExposureTestOptions {
78
78
  * 1. Schema-level — walk route, RPC, and WebSocket output schemas (both sides
79
79
  * of a transform), pushed WebSocket params, and route error schemas for
80
80
  * sensitive field names, and non-admin route outputs for admin-only ones
81
- * 2. Runtime — fire real requests and check response bodies against blocklists
81
+ * 2. Runtime — fire real requests and check response bodies against blocklists,
82
+ * a public route both anonymously and as an authenticated account; fails
83
+ * when no 2xx JSON answer carried data, since a sweep that saw none checked
84
+ * nothing
82
85
  * 3. Cross-privilege — admin routes return 403 for non-admin, error responses
83
86
  * contain no sensitive fields
84
87
  */
@@ -1 +1 @@
1
- {"version":3,"file":"data_exposure.d.ts","sourceRoot":"","sources":["../../src/lib/testing/data_exposure.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA2B7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAKzD,OAAO,EAIN,KAAK,gBAAgB,EACrB,MAAM,wBAAwB,CAAC;AAehC,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,0BAA0B,CAAC;AAIvE;;;;;;;;GAQG;AACH,eAAO,MAAM,kCAAkC,GAAI,QAAQ,OAAO,KAAG,GAAG,CAAC,MAAM,CAmC9E,CAAC;AA0HF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,yCAAyC,GACrD,gBAAgB,cAAc,EAC9B,mBAAkB,aAAa,CAAC,MAAM,CAA6B,EACnE,cAAc,aAAa,CAAC,MAAM,CAAC,KACjC,IAOF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wCAAwC,GACpD,gBAAgB,cAAc,EAC9B,oBAAmB,aAAa,CAAC,MAAM,CAA8B,EACrE,cAAc,aAAa,CAAC,MAAM,CAAC,KACjC,IAYF,CAAC;AAIF,kDAAkD;AAClD,MAAM,WAAW,uBAAuB;IACvC,kEAAkE;IAClE,UAAU,EAAE,SAAS,CAAC;IACtB;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,2FAA2F;IAC3F,gBAAgB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,iGAAiG;IACjG,iBAAiB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C;;;;OAIG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B;;;;OAIG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,4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A4B,GAAI,SAAS,uBAAuB,KAAG,IAuQ/E,CAAC"}
@@ -7,7 +7,9 @@ import './assert_dev_env.js';
7
7
  * output (both sides of a transform), the params the server pushes over
8
8
  * WebSocket, and every route error schema for sensitive property names,
9
9
  * and non-admin route outputs for admin-only ones
10
- * - Runtime: fires real requests and checks response bodies against field blocklists
10
+ * - Runtime: fires real requests and checks response bodies against field
11
+ * blocklists — a public route as anonymous and as an authenticated account —
12
+ * failing when no 2xx answer carried data to check
11
13
  * - Cross-privilege: verifies admin routes return 403 for non-admin users,
12
14
  * and non-admin responses exclude admin-only fields
13
15
  *
@@ -26,7 +28,7 @@ import { create_test_request_headers } from './test_origin.js';
26
28
  import { resolve_valid_path, generate_valid_body, to_route_content_type } from './schema_generators.js';
27
29
  import { is_null_schema, is_strict_object_schema, schema_to_surface } from '../http/schema_helpers.js';
28
30
  import { is_keeper_auth, is_public_auth } from '../http/auth_shape.js';
29
- import { sensitive_field_blocklist, admin_only_field_blocklist, assert_no_sensitive_fields_in_json, pick_auth_headers, pick_auth_principal, to_principal_transport } from './integration_helpers.js';
31
+ import { sensitive_field_blocklist, admin_only_field_blocklist, assert_no_sensitive_fields_in_json, collect_json_keys_recursive, is_unauthenticated_refusal, pick_auth_headers, pick_auth_principal, round_trip_uses_fresh_account, to_principal_transport } from './integration_helpers.js';
30
32
  // --- Schema introspection ---
31
33
  /**
32
34
  * Recursively collect all property names from a JSON Schema.
@@ -81,6 +83,13 @@ export const collect_json_schema_property_names = (schema) => {
81
83
  // any-of roles gate only admins and the keeper when every role is one of them
82
84
  const is_elevated_roles = (roles) => !!roles?.length && roles.every((r) => r === ROLE_ADMIN || r === ROLE_KEEPER);
83
85
  const is_elevated_auth = (auth) => auth !== null && (is_keeper_auth(auth) || is_elevated_roles(auth.roles));
86
+ /**
87
+ * Whether a 2xx JSON body carries data the blocklists can check: a key besides
88
+ * `ok` at any depth (`collect_json_keys_recursive`, what the blocklists walk).
89
+ * An `{ok: true}` acknowledgment, a scalar, and an array of scalars or empty
90
+ * objects carry no field that could leak.
91
+ */
92
+ const is_data_bearing_body = (body) => [...collect_json_keys_recursive(body)].some((key) => key !== 'ok');
84
93
  // every schema a caller can receive: route outputs, RPC method outputs, and
85
94
  // over WS the method outputs plus the params the server pushes — a
86
95
  // `remote_notification`'s payload, and the request of a `request_response`
@@ -207,7 +216,10 @@ export const assert_non_admin_schemas_no_admin_fields = (surface_source, admin_o
207
216
  * 1. Schema-level — walk route, RPC, and WebSocket output schemas (both sides
208
217
  * of a transform), pushed WebSocket params, and route error schemas for
209
218
  * sensitive field names, and non-admin route outputs for admin-only ones
210
- * 2. Runtime — fire real requests and check response bodies against blocklists
219
+ * 2. Runtime — fire real requests and check response bodies against blocklists,
220
+ * a public route both anonymously and as an authenticated account; fails
221
+ * when no 2xx JSON answer carried data, since a sweep that saw none checked
222
+ * nothing
211
223
  * 3. Cross-privilege — admin routes return 403 for non-admin, error responses
212
224
  * contain no sensitive fields
213
225
  */
@@ -322,42 +334,98 @@ export const describe_data_exposure_tests = (options) => {
322
334
  return 1;
323
335
  return 0;
324
336
  });
325
- for (const spec of sorted_specs) {
326
- const route_key = format_route_key(spec);
327
- if (skip_set.has(route_key))
328
- continue;
329
- // keeper auth (daemon token) is strictly more privileged than admin
330
- const is_elevated = is_elevated_auth(spec.auth);
331
- const url = resolve_valid_path(spec.path, spec.params, options.param_values?.[route_key]);
332
- const body = generate_valid_body(spec.input);
333
- const headers = pick_auth_headers(spec, fixture, authed_account, admin_account);
334
- const request_init = {
335
- method: spec.method,
336
- headers: { ...headers, 'content-type': to_route_content_type(spec) },
337
- ...(body ? { body: JSON.stringify(body) } : {})
338
- };
339
- const res = await to_principal_transport(pick_auth_principal(spec.auth), fixture)(url, request_init);
337
+ // the 2xx answers whose body carried data, which the sweep must see one of
338
+ let data_bearing_count = 0;
339
+ const check_response = async (res, spec, label) => {
340
340
  if (res.headers.get('Content-Type')?.includes('text/event-stream')) {
341
341
  await res.body?.cancel();
342
- continue;
342
+ return;
343
343
  }
344
344
  if (!res.ok)
345
- continue;
345
+ return;
346
346
  let response_body;
347
347
  try {
348
348
  response_body = await res.clone().json();
349
349
  }
350
350
  catch {
351
- continue;
351
+ return;
352
352
  }
353
- assert_no_sensitive_fields_in_json(response_body, sensitive_fields, `${route_key} (${res.status})`);
354
- // Admin-only field check applies to non-elevated routes with strict
353
+ if (is_data_bearing_body(response_body))
354
+ data_bearing_count++;
355
+ assert_no_sensitive_fields_in_json(response_body, sensitive_fields, label);
356
+ // Admin-only field check applies to non-elevated routes (keeper auth,
357
+ // the daemon token, is strictly more privileged than admin) with strict
355
358
  // output schemas. Loose schemas (e.g. surface route returning JSON
356
359
  // Schema representations) may contain admin field names as metadata.
357
- if (!is_elevated && !is_null_schema(spec.output) && is_strict_object_schema(spec.output)) {
358
- assert_no_sensitive_fields_in_json(response_body, admin_only_fields, `non-admin ${route_key} (${res.status})`);
360
+ if (!is_elevated_auth(spec.auth) &&
361
+ !is_null_schema(spec.output) &&
362
+ is_strict_object_schema(spec.output)) {
363
+ assert_no_sensitive_fields_in_json(response_body, admin_only_fields, `non-admin ${label}`);
364
+ }
365
+ };
366
+ // a credential the sweep sent to a route that requires one must
367
+ // authenticate: a request refused as unauthenticated
368
+ // (`is_unauthenticated_refusal`) checked nothing of the route it was sent to
369
+ const assert_credential_authenticated = async (res, label) => {
370
+ if (res.status !== 401)
371
+ return;
372
+ const refusal = (await res
373
+ .clone()
374
+ .json()
375
+ .catch(() => undefined));
376
+ assert.ok(!is_unauthenticated_refusal(res.status, refusal?.error), `${label}: the credential did not authenticate, so the route went unchecked ` +
377
+ `(${JSON.stringify(refusal)})`);
378
+ };
379
+ for (const spec of sorted_specs) {
380
+ const route_key = format_route_key(spec);
381
+ if (skip_set.has(route_key))
382
+ continue;
383
+ const url = resolve_valid_path(spec.path, spec.params, options.param_values?.[route_key]);
384
+ const body = generate_valid_body(spec.input);
385
+ const content_type = to_route_content_type(spec);
386
+ const body_init = body ? { body: JSON.stringify(body) } : {};
387
+ const principal = pick_auth_principal(spec.auth);
388
+ // a mutation as the authed principal runs on a fresh account, so one
389
+ // that ends its session (logout) leaves the shared account's alone —
390
+ // the round trip's rule
391
+ const account = round_trip_uses_fresh_account(principal, spec.method !== 'GET')
392
+ ? await fixture.create_account({ roles: [] })
393
+ : authed_account;
394
+ const headers = pick_auth_headers(spec, fixture, account, admin_account);
395
+ const res = await to_principal_transport(principal, fixture)(url, {
396
+ method: spec.method,
397
+ headers: { ...headers, 'content-type': content_type },
398
+ ...body_init
399
+ });
400
+ // only a route that requires a credential: a public one may answer a
401
+ // 401 of its own, which reads like an unauthenticated refusal
402
+ if (principal !== 'public') {
403
+ await assert_credential_authenticated(res, `${route_key} as ${principal}`);
359
404
  }
405
+ await check_response(res, spec, `${route_key} (${res.status})`);
406
+ // a public route answers an authenticated caller too, often with more
407
+ // (the status route names the account), so it is swept as the authed
408
+ // account as well — on a fresh transport, so a cookie it clears leaves
409
+ // the fixture's jar alone, and for a mutation on a fresh account, so
410
+ // one that ends its session leaves the shared account's alone
411
+ if (!is_public_auth(spec.auth))
412
+ continue;
413
+ const caller = round_trip_uses_fresh_account('authed', spec.method !== 'GET')
414
+ ? await fixture.create_account({ roles: [] })
415
+ : authed_account;
416
+ const authed_res = await fixture.fresh_transport()(url, {
417
+ method: spec.method,
418
+ headers: { ...caller.create_session_headers(), 'content-type': content_type },
419
+ ...body_init
420
+ });
421
+ // no liveness check on this pass: a public route reads no credential
422
+ // of the spine's, so a 401 is its own answer (a git route asking for
423
+ // HTTP Basic, say), not a dead session
424
+ await check_response(authed_res, spec, `authed ${route_key} (${authed_res.status})`);
360
425
  }
426
+ assert.ok(data_bearing_count > 0, 'the 2xx sweep saw no 2xx JSON response carrying data, so it checked nothing — ' +
427
+ 'every route refused, answered no JSON, or answered `{ok}` alone ' +
428
+ '(check the credentials and `param_values`, or `skip_routes`)');
361
429
  });
362
430
  });
363
431
  };
@@ -42,11 +42,11 @@ export declare const assert_db_invariant_rows: (rows: ReadonlyArray<DbInvariantR
42
42
  */
43
43
  export declare const assert_db_invariants: (deps: QueryDeps, label: string, exclude?: DbInvariantExclusions) => Promise<void>;
44
44
  /**
45
- * Run `check` when the current test finishes — the per-test hook
46
- * `create_test_app` registers when it builds an app (in-process, and so every
47
- * `default_in_process_setup` fixture) and the cross-process setup registers
48
- * from `setup_test()`, with `check` the app's or fixture's
49
- * `assert_db_invariants`.
45
+ * Run `check` when the current test finishes — the per-test hook the
46
+ * cross-process setup registers from `setup_test()`, with `check` the
47
+ * fixture's `assert_db_invariants`. `create_test_app` runs the same check in a
48
+ * hook of its own, which closes the app after it (and so every
49
+ * `default_in_process_setup` fixture).
50
50
  *
51
51
  * Runs after the test body and its `afterEach` hooks, before the next test's
52
52
  * setup resets the database. A test that already failed is left as it
@@ -61,11 +61,11 @@ export const assert_db_invariants = async (deps, label, exclude) => {
61
61
  throw new Error(format_db_invariant_violations(violations, label));
62
62
  };
63
63
  /**
64
- * Run `check` when the current test finishes — the per-test hook
65
- * `create_test_app` registers when it builds an app (in-process, and so every
66
- * `default_in_process_setup` fixture) and the cross-process setup registers
67
- * from `setup_test()`, with `check` the app's or fixture's
68
- * `assert_db_invariants`.
64
+ * Run `check` when the current test finishes — the per-test hook the
65
+ * cross-process setup registers from `setup_test()`, with `check` the
66
+ * fixture's `assert_db_invariants`. `create_test_app` runs the same check in a
67
+ * hook of its own, which closes the app after it (and so every
68
+ * `default_in_process_setup` fixture).
69
69
  *
70
70
  * Runs after the test body and its `afterEach` hooks, before the next test's
71
71
  * setup resets the database. A test that already failed is left as it
@@ -15,6 +15,11 @@ export interface CoverageFilterOptions {
15
15
  ignore_routes?: Array<string>;
16
16
  /** HTTP status codes to skip. */
17
17
  ignore_statuses?: Array<number>;
18
+ /**
19
+ * Error codes to skip at any status — the codes another suite owns. A code
20
+ * names one status (`assert_error_code_status_consistency`).
21
+ */
22
+ ignore_codes?: ReadonlyArray<string>;
18
23
  }
19
24
  /**
20
25
  * Tracks which route × status (and route × status × code) combinations have
@@ -1 +1 @@
1
- {"version":3,"file":"error_coverage.d.ts","sourceRoot":"","sources":["../../src/lib/testing/error_coverage.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAmB7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGlF,gFAAgF;AAChF,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;CACb;AAED,6EAA6E;AAC7E,MAAM,WAAW,qBAAqB;IACrC,kDAAkD;IAClD,aAAa,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,iCAAiC;IACjC,eAAe,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CAChC;AAgDD;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,sBAAsB;IAClC;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,IAAI,CAAC;IAErE;;OAEG;gBACS,gBAAgB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,IAAI;IAIxE;;;;OAIG;IACH,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAa;IAE3C;;;;;;;;;;;;;OAaG;IACH,MAAM,CACL,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,EAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,GAAG,IAAI,GACjB,IAAI;IASP;;;;;;;;;;;;;;;OAeG;IACG,iBAAiB,CACtB,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,EAC7B,MAAM,EAAE,MA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
@@ -31,6 +31,7 @@ import { find_route_spec, assert_response_matches_spec } from './integration_hel
31
31
  const walk_coverage = (collector, route_specs, options) => {
32
32
  const ignore_routes = new Set(options?.ignore_routes);
33
33
  const ignore_statuses = new Set(options?.ignore_statuses);
34
+ const ignore_codes = new Set(options?.ignore_codes);
34
35
  const entries = [];
35
36
  for (const spec of route_specs) {
36
37
  const route_key = format_route_key(spec);
@@ -39,7 +40,7 @@ const walk_coverage = (collector, route_specs, options) => {
39
40
  // a code with two shapes at one status is one path
40
41
  const seen = new Set();
41
42
  for (const { status, code } of get_route_error_map(collector.route_error_maps, spec).defs) {
42
- if (ignore_statuses.has(status))
43
+ if (ignore_statuses.has(status) || ignore_codes.has(code))
43
44
  continue;
44
45
  const status_key = `${spec.method} ${spec.path}:${status}`;
45
46
  const code_key = `${status_key}:${code}`;
@@ -55,24 +55,6 @@ export interface StandardIntegrationTestOptions {
55
55
  * denial-path drivers.
56
56
  */
57
57
  error_coverage_min?: number;
58
- /**
59
- * Base URL the backend is reachable at, or `null` in-process. The
60
- * middleware-gate probes write their heads to the socket when there is one
61
- * (`fetch` replaces a caller's `Host` and `Content-Length`), and go through
62
- * the fixture's transport when there isn't.
63
- */
64
- base_url: string | null;
65
- /**
66
- * The backend's request-body cap on every counted route but the RPC
67
- * endpoint, in bytes — the body-limit probe declares one byte more.
68
- * Default `SPINE_BODY_LIMIT_DEFAULT_BYTES`, the spines' default.
69
- */
70
- max_body_bytes?: number;
71
- /**
72
- * The backend's request-body cap on the RPC endpoint, in bytes, when it
73
- * isn't `max_body_bytes`.
74
- */
75
- rpc_max_body_bytes?: number;
76
58
  /**
77
59
  * Called once the suite's tests have run, with the declared error paths of
78
60
  * the counted routes it never observed, before the coverage floor is
@@ -88,8 +70,10 @@ export interface StandardIntegrationTestOptions {
88
70
  * revocation, password change (incl. API token revocation), origin
89
71
  * verification, bearer auth (incl. browser context discard on mutations),
90
72
  * token revocation, cross-account isolation, expired credential rejection,
91
- * signup invite edge cases, response body validation, and the middleware
92
- * gates each counted route's error map declares (`middleware_gate_probes.ts`).
73
+ * signup invite edge cases, and response body validation. The middleware
74
+ * gates each counted route's error map declares are
75
+ * `describe_middleware_gate_tests`' (`middleware_gate_probes.ts`), a suite of
76
+ * their own since over a socket they write raw request heads.
93
77
  *
94
78
  * Each test group asserts that required routes exist, failing with a descriptive
95
79
  * message if the consumer's route specs are misconfigured.
@@ -1 +1 @@
1
- {"version":3,"file":"integration.d.ts","sourceRoot":"","sources":["../../src/lib/testing/integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA4B7B,OAAO,EAKN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAIN,KAAK,cAAc,EACnB,MAAM,qBAAqB,CAAC;AAa7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAW,KAAK,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAKpF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAY1D;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC9C;;;;OAIG;IACH,UAAU,EAAE,SAAS,CAAC;IACtB;;;;;;;;;OASG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,kEAAkE;IAClE,YAAY,EAAE,mBAAmB,CAAC;IAClC;;;;OAIG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;;;;;;;;OAWG;IACH,aAAa,EAAE,uBAAuB,CAAC;IACvC;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,CA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