@fuzdev/fuz_app 0.182.0 → 0.183.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 (191) hide show
  1. package/README.md +2 -0
  2. package/dist/actions/CLAUDE.md +4 -4
  3. package/dist/auth/CLAUDE.md +58 -34
  4. package/dist/auth/account_routes.d.ts +5 -3
  5. package/dist/auth/account_routes.d.ts.map +1 -1
  6. package/dist/auth/account_routes.js +71 -66
  7. package/dist/auth/admin_actions.d.ts.map +1 -1
  8. package/dist/auth/admin_actions.js +22 -17
  9. package/dist/auth/audit_emitter.d.ts +75 -84
  10. package/dist/auth/audit_emitter.d.ts.map +1 -1
  11. package/dist/auth/audit_emitter.js +83 -71
  12. package/dist/auth/audit_log_schema.d.ts +10 -5
  13. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  14. package/dist/auth/audit_log_schema.js +22 -6
  15. package/dist/auth/bootstrap_account.d.ts +31 -13
  16. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  17. package/dist/auth/bootstrap_account.js +34 -15
  18. package/dist/auth/bootstrap_routes.d.ts +1 -1
  19. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  20. package/dist/auth/bootstrap_routes.js +7 -14
  21. package/dist/auth/deps.d.ts +8 -5
  22. package/dist/auth/deps.d.ts.map +1 -1
  23. package/dist/auth/deps.js +3 -2
  24. package/dist/auth/resolved_auth.d.ts +7 -7
  25. package/dist/auth/resolved_auth.d.ts.map +1 -1
  26. package/dist/auth/resolved_auth.js +4 -4
  27. package/dist/auth/role_grant_offer_actions.d.ts +25 -1
  28. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  29. package/dist/auth/role_grant_offer_actions.js +40 -33
  30. package/dist/auth/role_grant_offer_queries.d.ts +60 -4
  31. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  32. package/dist/auth/role_grant_offer_queries.js +79 -5
  33. package/dist/auth/role_grant_queries.d.ts +3 -52
  34. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  35. package/dist/auth/role_grant_queries.js +5 -80
  36. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  37. package/dist/auth/self_service_role_actions.js +11 -22
  38. package/dist/auth/session_queries.d.ts +6 -3
  39. package/dist/auth/session_queries.d.ts.map +1 -1
  40. package/dist/auth/session_queries.js +20 -11
  41. package/dist/auth/signup_routes.d.ts.map +1 -1
  42. package/dist/auth/signup_routes.js +90 -38
  43. package/dist/db/sql_columns.d.ts +1 -1
  44. package/dist/db/sql_columns.js +1 -1
  45. package/dist/http/CLAUDE.md +15 -10
  46. package/dist/http/db_routes.d.ts +7 -22
  47. package/dist/http/db_routes.d.ts.map +1 -1
  48. package/dist/http/db_routes.js +72 -72
  49. package/dist/http/pending_effects.d.ts +42 -4
  50. package/dist/http/pending_effects.d.ts.map +1 -1
  51. package/dist/http/pending_effects.js +34 -4
  52. package/dist/server/app_server.d.ts +43 -2
  53. package/dist/server/app_server.d.ts.map +1 -1
  54. package/dist/server/app_server.js +57 -3
  55. package/dist/testing/CLAUDE.md +255 -786
  56. package/dist/testing/adversarial_404.d.ts +6 -1
  57. package/dist/testing/adversarial_404.d.ts.map +1 -1
  58. package/dist/testing/adversarial_404.js +38 -17
  59. package/dist/testing/app_server.d.ts +20 -140
  60. package/dist/testing/app_server.d.ts.map +1 -1
  61. package/dist/testing/app_server.js +45 -124
  62. package/dist/testing/audit_drift_guard.d.ts +11 -6
  63. package/dist/testing/audit_drift_guard.d.ts.map +1 -1
  64. package/dist/testing/audit_drift_guard.js +15 -8
  65. package/dist/testing/cross_backend/audit_cross_helpers.d.ts +12 -9
  66. package/dist/testing/cross_backend/audit_cross_helpers.d.ts.map +1 -1
  67. package/dist/testing/cross_backend/audit_cross_helpers.js +13 -14
  68. package/dist/testing/cross_backend/capabilities.d.ts +9 -6
  69. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  70. package/dist/testing/cross_backend/capabilities.js +11 -7
  71. package/dist/testing/cross_backend/capability_mounts.d.ts +103 -0
  72. package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -0
  73. package/dist/testing/cross_backend/capability_mounts.js +423 -0
  74. package/dist/testing/cross_backend/cell_moderate.js +2 -2
  75. package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
  76. package/dist/testing/cross_backend/cell_relations.js +12 -11
  77. package/dist/testing/cross_backend/conformance_principal.d.ts +54 -0
  78. package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -0
  79. package/dist/testing/cross_backend/conformance_principal.js +283 -0
  80. package/dist/testing/cross_backend/conformance_table.d.ts +2 -50
  81. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  82. package/dist/testing/cross_backend/conformance_table.js +2 -270
  83. package/dist/testing/cross_backend/credential_deadline.d.ts.map +1 -1
  84. package/dist/testing/cross_backend/credential_deadline.js +2 -0
  85. package/dist/testing/cross_backend/credential_wire.d.ts +1 -1
  86. package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -1
  87. package/dist/testing/cross_backend/db_state_diff.d.ts +72 -0
  88. package/dist/testing/cross_backend/db_state_diff.d.ts.map +1 -0
  89. package/dist/testing/cross_backend/db_state_diff.js +444 -0
  90. package/dist/testing/cross_backend/declared_skips.d.ts +68 -0
  91. package/dist/testing/cross_backend/declared_skips.d.ts.map +1 -0
  92. package/dist/testing/cross_backend/declared_skips.js +132 -0
  93. package/dist/testing/cross_backend/differential.d.ts +11 -2
  94. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  95. package/dist/testing/cross_backend/differential.js +35 -11
  96. package/dist/testing/cross_backend/differential_normalize.d.ts +12 -0
  97. package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
  98. package/dist/testing/cross_backend/differential_normalize.js +16 -0
  99. package/dist/testing/cross_backend/in_process_setup.d.ts +22 -12
  100. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  101. package/dist/testing/cross_backend/in_process_setup.js +151 -134
  102. package/dist/testing/cross_backend/login_security.d.ts +12 -0
  103. package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
  104. package/dist/testing/cross_backend/login_security.js +21 -4
  105. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +0 -2
  106. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -1
  107. package/dist/testing/cross_backend/request_target_conformance_wire.js +3 -1
  108. package/dist/testing/cross_backend/revocation_drivers.d.ts +18 -5
  109. package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
  110. package/dist/testing/cross_backend/revocation_drivers.js +18 -10
  111. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts +1 -1
  112. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts.map +1 -1
  113. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  114. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +33 -1
  115. package/dist/testing/cross_backend/role_grant_participation.js +4 -4
  116. package/dist/testing/cross_backend/rpc_adversarial.js +1 -1
  117. package/dist/testing/cross_backend/session_cap.d.ts +2 -2
  118. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  119. package/dist/testing/cross_backend/session_cap.js +22 -11
  120. package/dist/testing/cross_backend/setup.d.ts +31 -1
  121. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  122. package/dist/testing/cross_backend/setup.js +32 -1
  123. package/dist/testing/cross_backend/spine_suites.d.ts +123 -12
  124. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  125. package/dist/testing/cross_backend/spine_suites.js +454 -57
  126. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  127. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  128. package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
  129. package/dist/testing/cross_backend/sse_round_trip.d.ts +9 -1
  130. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  131. package/dist/testing/cross_backend/sse_round_trip.js +123 -27
  132. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  133. package/dist/testing/cross_backend/testing_backdoor.js +4 -2
  134. package/dist/testing/cross_backend/testing_reset_actions.d.ts +59 -27
  135. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  136. package/dist/testing/cross_backend/testing_reset_actions.js +66 -42
  137. package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
  138. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  139. package/dist/testing/cross_backend/transport_composition.js +7 -3
  140. package/dist/testing/cross_backend/ws_round_trip.d.ts +5 -0
  141. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  142. package/dist/testing/cross_backend/ws_round_trip.js +54 -8
  143. package/dist/testing/data_exposure.d.ts.map +1 -1
  144. package/dist/testing/data_exposure.js +3 -0
  145. package/dist/testing/db.d.ts +0 -32
  146. package/dist/testing/db.d.ts.map +1 -1
  147. package/dist/testing/db.js +0 -86
  148. package/dist/testing/db_entities.d.ts +14 -0
  149. package/dist/testing/db_entities.d.ts.map +1 -1
  150. package/dist/testing/db_entities.js +17 -0
  151. package/dist/testing/db_invariant_queries.d.ts +259 -0
  152. package/dist/testing/db_invariant_queries.d.ts.map +1 -0
  153. package/dist/testing/db_invariant_queries.js +400 -0
  154. package/dist/testing/db_invariants.d.ts +106 -0
  155. package/dist/testing/db_invariants.d.ts.map +1 -0
  156. package/dist/testing/db_invariants.gen.sql.d.ts +11 -0
  157. package/dist/testing/db_invariants.gen.sql.d.ts.map +1 -0
  158. package/dist/testing/db_invariants.gen.sql.js +13 -0
  159. package/dist/testing/db_invariants.js +141 -0
  160. package/dist/testing/db_invariants.sql +152 -0
  161. package/dist/testing/describe_db.d.ts +36 -0
  162. package/dist/testing/describe_db.d.ts.map +1 -0
  163. package/dist/testing/describe_db.js +71 -0
  164. package/dist/testing/integration.d.ts +6 -9
  165. package/dist/testing/integration.d.ts.map +1 -1
  166. package/dist/testing/integration.js +9 -13
  167. package/dist/testing/integration_helpers.d.ts +1 -1
  168. package/dist/testing/integration_helpers.d.ts.map +1 -1
  169. package/dist/testing/rate_limiting.d.ts +1 -1
  170. package/dist/testing/rate_limiting.d.ts.map +1 -1
  171. package/dist/testing/rate_limiting.js +3 -2
  172. package/dist/testing/role_grant_helpers.d.ts +1 -1
  173. package/dist/testing/role_grant_helpers.d.ts.map +1 -1
  174. package/dist/testing/round_trip.d.ts.map +1 -1
  175. package/dist/testing/round_trip.js +3 -0
  176. package/dist/testing/rpc_attack_surface.d.ts +8 -6
  177. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  178. package/dist/testing/rpc_attack_surface.js +69 -6
  179. package/dist/testing/rpc_round_trip.d.ts +1 -1
  180. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  181. package/dist/testing/rpc_round_trip.js +3 -0
  182. package/dist/testing/sse_round_trip.d.ts +1 -1
  183. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  184. package/dist/testing/sse_round_trip.js +13 -4
  185. package/dist/testing/stubs.d.ts +4 -2
  186. package/dist/testing/stubs.d.ts.map +1 -1
  187. package/dist/testing/stubs.js +10 -5
  188. package/dist/testing/test_app.d.ts +166 -0
  189. package/dist/testing/test_app.d.ts.map +1 -0
  190. package/dist/testing/test_app.js +124 -0
  191. package/package.json +1 -1
@@ -2,7 +2,7 @@ import './assert_dev_env.js';
2
2
  import type { SessionOptions } from '../auth/session_cookie.js';
3
3
  import type { AppServerContext } from '../server/app_server_context.js';
4
4
  import type { RouteSpec } from '../http/route_spec.js';
5
- import { type SuiteAppOptions } from './app_server.js';
5
+ import { type SuiteAppOptions } from './test_app.js';
6
6
  import { type DbFactory } from './db.js';
7
7
  import type { RpcEndpointsSuiteOption } from './rpc_helpers.js';
8
8
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"rate_limiting.d.ts","sourceRoot":"","sources":["../../src/lib/testing/rate_limiting.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA2B7B,OAAO,KAAK,EAAE,cAA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AAS,CAAC;AAGjB,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"}
@@ -25,9 +25,10 @@ import { parse_or_throw } from '@fuzdev/fuz_schema/schema.ts';
25
25
  import { RateLimiter } from '../rate_limiter.js';
26
26
  import { REST_RATE_LIMIT_EXCEEDED } from '../http/error_schemas.js';
27
27
  import { AUTH_MIGRATION_NS } from '../auth/migrations.js';
28
- import { create_test_app } from './app_server.js';
28
+ import { create_test_app } from './test_app.js';
29
29
  import { create_test_request_headers } from './test_origin.js';
30
- import { create_default_db_factory, create_describe_db, auth_integration_truncate_tables } from './db.js';
30
+ import { create_default_db_factory, auth_integration_truncate_tables } from './db.js';
31
+ import { create_describe_db } from './describe_db.js';
31
32
  import { find_auth_route, assert_rate_limit_retry_after_header } from './integration_helpers.js';
32
33
  import { run_migrations } from '../db/migrate.js';
33
34
  /**
@@ -1,6 +1,6 @@
1
1
  import './assert_dev_env.js';
2
2
  import type { Uuid } from '../primitive_schemas.js';
3
- import type { TestAccount, TestApp } from './app_server.js';
3
+ import type { TestAccount, TestApp } from './test_app.js';
4
4
  import type { TestFixture } from './cross_backend/setup.js';
5
5
  import { type RpcCallArgs } from './rpc_helpers.js';
6
6
  export interface RoleGrantOfferAndAcceptArgs {
@@ -1 +1 @@
1
- {"version":3,"file":"role_grant_helpers.d.ts","sourceRoot":"","sources":["../../src/lib/testing/role_grant_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAiB7B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAMpD,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEvE,MAAM,WAAW,2BAA2B;IAC3C,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,OAAO,EAAE,OAAO,GAAG,WAAW,GAAG,WAAW,CAAC;IAC7C,SAAS,EAAE,WAAW,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,2BAA2B,GACvC,MAAM,2BAA2B,KAC/B,OAAO,CAAC;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,aAAa,EAAE,IAAI,CAAA;CAAE,CAyBjD,CAAC"}
1
+ {"version":3,"file":"role_grant_helpers.d.ts","sourceRoot":"","sources":["../../src/lib/testing/role_grant_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAiB7B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAMpD,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AA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,GAAG,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,CAAC,CACnF,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,0BAA0B,GACtC,WAAW,MAAM,EACjB,QAAQ,MAAM,EACd,MAAM,OAAO,EACb,WAAW,aAAa,KACtB,IAiBF,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,8BAA8B,GAAI,SAAS,oBAAoB,KAAG,IAqK9E,CAAC"}
@@ -21,6 +21,7 @@ import './assert_dev_env.js';
21
21
  * @module
22
22
  */
23
23
  import { describe, test, beforeAll, assert } from 'vitest';
24
+ import { check_db_invariants_after_all } from './db_invariants.js';
24
25
  import { ROLE_ADMIN } from '../auth/role_schema.js';
25
26
  import { format_route_key } from '../http/surface_query.js';
26
27
  import { ERROR_CREDENTIAL_TYPE_REQUIRED } from '../http/error_schemas.js';
@@ -79,6 +80,8 @@ export const describe_round_trip_validation = (options) => {
79
80
  const skip_set = new Set(options.skip_routes);
80
81
  describe('round-trip validation', () => {
81
82
  let fixture;
83
+ // `fixture` is unassigned until `beforeAll` runs, which the check allows for
84
+ check_db_invariants_after_all(() => fixture);
82
85
  let authed_account;
83
86
  let admin_account;
84
87
  beforeAll(async () => {
@@ -7,12 +7,14 @@ export interface RpcAttackSurfaceOptions {
7
7
  /** All roles in the app (e.g. `['admin', 'keeper']`). */
8
8
  roles: Array<string>;
9
9
  /**
10
- * Valid params per method (method name → params) to build its adversarial
11
- * params cases from, in place of the generated base — for an input whose
12
- * valid shape the generator can't reach. Each must pass the method's input
13
- * schema; one that doesn't throws at collection, naming the method. The
14
- * cases are sent as a single-actor principal, so an override omits
15
- * `acting`. The cross-process twin is
10
+ * Valid params per method (method name → params), in place of the
11
+ * generated base — for an input whose valid shape the generator can't
12
+ * reach. They seed the adversarial params cases and the "correct auth
13
+ * passes" request. Each must pass the method's input schema: in the params
14
+ * group one that doesn't throws at collection, naming the method; in
15
+ * "correct auth passes" its 400 fails the method's test, the handler
16
+ * unreached. The params cases are sent as a single-actor principal, so an
17
+ * override omits `acting`. The cross-process twin is
16
18
  * `RpcAdversarialCrossTestOptions.input_overrides`.
17
19
  */
18
20
  input_overrides?: ReadonlyMap<string, Record<string, unknown>>;
@@ -1 +1 @@
1
- {"version":3,"file":"rpc_attack_surface.d.ts","sourceRoot":"","sources":["../../src/lib/testing/rpc_attack_surface.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAkB7B,OAAO,KAAK,EAGX,cAAc,EACd,MAAM,oBAAoB,CAAC;AA+B5B,uDAAuD;AACvD,MAAM,WAAW,uBAAuB;IACvC,+FAA+F;IAC/F,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5B,yDAAyD;IACzD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC/D;AA2VD;;;;;;;;;GASG;AACH,eAAO,MAAM,iCAAiC,GAAI,SAAS,uBAAuB,KAAG,IAOpF,CAAC"}
1
+ {"version":3,"file":"rpc_attack_surface.d.ts","sourceRoot":"","sources":["../../src/lib/testing/rpc_attack_surface.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAmB7B,OAAO,KAAK,EAGX,cAAc,EACd,MAAM,oBAAoB,CAAC;AAmC5B,uDAAuD;AACvD,MAAM,WAAW,uBAAuB;IACvC,+FAA+F;IAC/F,KAAK,EAAE,MAAM,cAAc,CAAC;IAC5B,yDAAyD;IACzD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB;;;;;;;;;;OAUG;IACH,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC/D;AAuaD;;;;;;;;;GASG;AACH,eAAO,MAAM,iCAAiC,GAAI,SAAS,uBAAuB,KAAG,IAOpF,CAAC"}
@@ -13,10 +13,14 @@ import './assert_dev_env.js';
13
13
  * @module
14
14
  */
15
15
  import { test, assert, describe } from 'vitest';
16
+ import { Logger } from '@fuzdev/fuz_util/log.ts';
16
17
  import { is_keeper_auth, is_public_auth, is_role_auth } from '../http/auth_shape.js';
17
18
  import { JSONRPC_ERROR_CODES } from '../http/jsonrpc_errors.js';
18
19
  import { create_auth_test_apps, create_test_app_from_specs, create_test_request_context, select_auth_app } from './auth_apps.js';
19
20
  import { generate_valid_body } from './schema_generators.js';
21
+ import { create_rpc_endpoint } from '../actions/action_rpc.js';
22
+ import { format_route_key } from '../http/surface_query.js';
23
+ import { noop_notification_sender } from '../actions/notification_sender.js';
20
24
  import { create_rpc_post_init, create_rpc_get_url, assert_jsonrpc_error_response } from './rpc_helpers.js';
21
25
  import { assert_rpc_envelope_refusal, create_rpc_envelope_cases, generate_rpc_params_test_cases, to_rpc_envelope_request } from './rpc_envelope_cases.js';
22
26
  import { expected_invalid_reason } from './adversarial_input_cases.js';
@@ -35,6 +39,57 @@ const find_rpc_action = (rpc_endpoint_specs, endpoint_path, method_name) => {
35
39
  const ep = rpc_endpoint_specs.find((e) => e.path === endpoint_path);
36
40
  return ep?.actions.find((a) => a.spec.method === method_name);
37
41
  };
42
+ /** The key a recording stub notes its call under: the endpoint path and method. */
43
+ const to_reached_key = (endpoint_path, method_name) => `${endpoint_path} ${method_name}`;
44
+ /**
45
+ * The route specs with every RPC endpoint's routes rebuilt over its actions,
46
+ * each handler swapped for a stub that records its call in `reached` and
47
+ * answers `null`, so a test that the handler is reached never depends on
48
+ * what the handler would do over stub deps (a live re-read's 401). Each
49
+ * endpoint's routes take the place of its first route in the list, matched
50
+ * on method and path, so another route at the endpoint's path stays; the
51
+ * rest of the list is kept in order. The endpoints mount with no rate limiters,
52
+ * a silent logger (a stub's `null` fails a non-null output schema, which DEV
53
+ * validation only logs), and the no-op notification sender.
54
+ *
55
+ * @param route_specs - the app's route specs, the endpoints' routes among them
56
+ * @param rpc_endpoint_specs - the endpoints whose handlers are stubbed
57
+ * @param reached - where each stub records its call (`to_reached_key`)
58
+ * @returns the route specs with the endpoints rebuilt
59
+ */
60
+ const stub_rpc_endpoint_handlers = (route_specs, rpc_endpoint_specs, reached) => {
61
+ const log = new Logger('test:rpc_attack_surface', { level: 'off' });
62
+ // each endpoint's rebuilt routes, keyed by every `METHOD path` they serve
63
+ const rebuilt_by_key = new Map();
64
+ for (const endpoint of rpc_endpoint_specs) {
65
+ const rebuilt = create_rpc_endpoint({
66
+ path: endpoint.path,
67
+ actions: endpoint.actions.map((action) => ({
68
+ spec: action.spec,
69
+ handler: () => {
70
+ reached.add(to_reached_key(endpoint.path, action.spec.method));
71
+ return null;
72
+ }
73
+ })),
74
+ log,
75
+ action_ip_rate_limiter: null,
76
+ action_account_rate_limiter: null,
77
+ notification_sender: noop_notification_sender
78
+ });
79
+ for (const spec of rebuilt)
80
+ rebuilt_by_key.set(format_route_key(spec), rebuilt);
81
+ }
82
+ const mounted = new Set();
83
+ return route_specs.flatMap((spec) => {
84
+ const rebuilt = rebuilt_by_key.get(format_route_key(spec));
85
+ if (!rebuilt)
86
+ return [spec];
87
+ if (mounted.has(rebuilt))
88
+ return [];
89
+ mounted.add(rebuilt);
90
+ return rebuilt;
91
+ });
92
+ };
38
93
  // --- Auth enforcement ---
39
94
  /**
40
95
  * Generate adversarial auth enforcement tests for RPC endpoints.
@@ -48,7 +103,9 @@ const find_rpc_action = (rpc_endpoint_specs, endpoint_path, method_name) => {
48
103
  * - wrong role → error code -32002 — every role method with non-matching roles
49
104
  * - authenticated without role → -32002 — every role method, no-role context
50
105
  * - keeper rejects non-daemon credentials → -32002 — session and api_token rejected
51
- * - correct auth passes — every protected method, assert not 401/403
106
+ * - correct auth passes — every protected method, sent valid params by the
107
+ * app its auth admits, reaches its handler, a recording stub
108
+ * (`stub_rpc_endpoint_handlers`), at 200
52
109
  */
53
110
  const describe_rpc_auth = (options) => {
54
111
  const { build, roles } = options;
@@ -56,6 +113,8 @@ const describe_rpc_auth = (options) => {
56
113
  if (surface.rpc_endpoints.length === 0)
57
114
  return;
58
115
  const apps = create_auth_test_apps(route_specs, roles);
116
+ const reached = new Set();
117
+ const stubbed_apps = create_auth_test_apps(stub_rpc_endpoint_handlers(route_specs, rpc_endpoint_specs, reached), roles);
59
118
  describe('RPC auth enforcement', () => {
60
119
  for (const endpoint of surface.rpc_endpoints) {
61
120
  const protected_methods = filter_protected_rpc_methods(endpoint);
@@ -138,11 +197,15 @@ const describe_rpc_auth = (options) => {
138
197
  describe('correct auth passes', () => {
139
198
  for (const method of protected_methods) {
140
199
  test(method.name, async () => {
141
- const app = select_auth_app(apps, method.auth);
142
- const res = await app.request(endpoint.path, create_rpc_post_init(method.name));
143
- // handler may error (500, 404 from stub deps) — that's fine
144
- assert.notStrictEqual(res.status, 401, 'should not be 401');
145
- assert.notStrictEqual(res.status, 403, 'should not be 403');
200
+ const action = find_rpc_action(rpc_endpoint_specs, endpoint.path, method.name);
201
+ assert.ok(action, `surface has method '${method.name}' but no matching RpcAction in rpc_endpoints`);
202
+ const params = options.input_overrides?.get(method.name) ?? generate_valid_body(action.spec.input);
203
+ const key = to_reached_key(endpoint.path, method.name);
204
+ reached.delete(key);
205
+ const app = select_auth_app(stubbed_apps, method.auth);
206
+ const res = await app.request(endpoint.path, create_rpc_post_init(method.name, params));
207
+ assert.ok(reached.has(key), `${method.name} should reach its handler, got ${res.status}: ${await res.text()}`);
208
+ assert.strictEqual(res.status, 200, `${method.name} should answer 200`);
146
209
  });
147
210
  }
148
211
  });
@@ -1,5 +1,5 @@
1
1
  import './assert_dev_env.js';
2
- import type { TestAccount } from './app_server.js';
2
+ import type { TestAccount } from './test_app.js';
3
3
  import type { AppSurfaceSpec, AppSurfaceRpcMethod } from '../http/surface.js';
4
4
  import { type RpcEndpointsSuiteOption } from './rpc_helpers.js';
5
5
  import { type AuthPrincipal, type KeeperHeaderProvider } from './integration_helpers.js';
@@ -1 +1 @@
1
- {"version":3,"file":"rpc_round_trip.d.ts","sourceRoot":"","sources":["../../src/lib/testing/rpc_round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAwC7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EAQN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAON,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhE,mDAAmD;AACnD,MAAM,WAAW,uBAAuB;IACvC,kEAAkE;IAClE,UAAU,EAAE,SAAS,CAAC;IACtB;;;;OAIG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B;;;;;OAKG;IACH,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC;;;;;OAKG;IACH,aAAa,EAAE,uBAAuB,CAAC;IACvC,qDAAqD;IACrD,YAAY,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC7B,6EAA6E;IAC7E,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACvD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,gBAAgB,CAAC,EAAE,kBAAkB,CAAC;CACtC;AAED,oFAAoF;AACpF,MAAM,WAAW,qBAAqB;IACrC,4CAA4C;IAC5C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC;;;;;;OAMG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,oBAAoB,EAC5B,gBAAgB,WAAW,EAC3B,eAAe,WAAW,KACxB,gBAMF,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,wBAAwB,GACpC,QAAQ,MAAM,EACd,QAAQ,MAAM,EACd,MAAM,OAAO,EACb,WAAW,aAAa,KACtB,IAwBF,CAAC;AA8GF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,6BAA6B,GAAI,SAAS,uBAAuB,KAAG,IAuKhF,CAAC"}
@@ -26,6 +26,7 @@ import './assert_dev_env.js';
26
26
  * @module
27
27
  */
28
28
  import { describe, test, beforeAll, assert } from 'vitest';
29
+ import { check_db_invariants_after_all } from './db_invariants.js';
29
30
  import { is, parse } from '@fuzdev/fuz_schema/schema.ts';
30
31
  import { ROLE_ADMIN } from '../auth/role_schema.js';
31
32
  import { JSONRPC_INTERNAL_ERROR, JSONRPC_METHOD_NOT_FOUND, JsonrpcErrorResponse } from '../http/jsonrpc.js';
@@ -213,6 +214,8 @@ export const describe_rpc_round_trip_tests = (options) => {
213
214
  const surface_rpc_endpoints = options.surface_source.surface.rpc_endpoints;
214
215
  describe('RPC round-trip validation', () => {
215
216
  let fixture;
217
+ // `fixture` is unassigned until `beforeAll` runs, which the check allows for
218
+ check_db_invariants_after_all(() => fixture);
216
219
  let authed_account;
217
220
  let admin_account;
218
221
  beforeAll(async () => {
@@ -4,7 +4,7 @@ import type { AppServerContext } from '../server/app_server_context.js';
4
4
  import type { SessionOptions } from '../auth/session_cookie.js';
5
5
  import type { EventSpec } from '../realtime/sse.js';
6
6
  import type { AuditLogEvent } from '../auth/audit_log_schema.js';
7
- import { type SuiteAppOptions, type TestApp, type TestAccount } from './app_server.js';
7
+ import { type SuiteAppOptions, type TestApp, type TestAccount } from './test_app.js';
8
8
  import { type DbFactory } from './db.js';
9
9
  import { type RpcEndpointsSuiteOption } from './rpc_helpers.js';
10
10
  /** Config for a single SSE route under test. */
@@ -1 +1 @@
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IAC7E;;;OAGG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC/B;;;;;OAKG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,8CAA8C;AAC9C,MAAM,WAAW,mBAAmB;IACnC,4CAA4C;IAC5C,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC,qDAAqD;IACrD,kBAAkB,EAAE,CAAC,GAAG,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAChE,iDAAiD;IACjD,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,gHAAgH;IAChH,YAAY,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAChC;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAChD;;;;;;;;;;;;OAYG;IACH,aAAa,EAAE,uBAAuB,CAAC;IACvC,8BAA8B;IAC9B,MAAM,EAAE,KAAK,CAAC,gBAAgB,CAAC,CAAC;CAChC;AAmDD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,wBAAwB,GAAI,SAAS,mBAAmB,KAAG,IAyIvE,CAAC"}
@@ -18,7 +18,8 @@ import { parse } from '@fuzdev/fuz_schema/schema.ts';
18
18
  import { SSE_CONNECTED_COMMENT } from '../realtime/sse_constants.js';
19
19
  import { ROLE_ADMIN } from '../auth/role_schema.js';
20
20
  import { create_audit_emitter } from '../auth/audit_emitter.js';
21
- import { create_test_app } from './app_server.js';
21
+ import { create_test_app } from './test_app.js';
22
+ import { check_db_invariants_after_suite } from './db_invariants.js';
22
23
  import { create_default_db_factory } from './db.js';
23
24
  import { find_route_spec, pick_auth_headers } from './integration_helpers.js';
24
25
  import { rpc_call, require_rpc_endpoint_path, resolve_rpc_endpoints_for_setup } from './rpc_helpers.js';
@@ -112,9 +113,17 @@ export const describe_sse_route_tests = (options) => {
112
113
  roles: [ROLE_ADMIN]
113
114
  });
114
115
  });
115
- afterAll(async () => {
116
- await test_app.cleanup();
117
- await factory.close(db);
116
+ // the app is built in `beforeAll`, outside any test, so it is checked
117
+ // once the describe's tests are done, ahead of the cleanup
118
+ // eslint-disable-next-line no-empty-pattern
119
+ afterAll(async ({}, suite) => {
120
+ try {
121
+ await check_db_invariants_after_suite(suite, test_app);
122
+ }
123
+ finally {
124
+ await test_app.cleanup();
125
+ await factory.close(db);
126
+ }
118
127
  });
119
128
  test('opens, emits payload, closes on revoke', async () => {
120
129
  const spec = find_route_spec(test_app.route_specs, 'GET', route_config.path);
@@ -50,7 +50,9 @@ export declare const stub: any;
50
50
  * Returns a real `Db` instance with:
51
51
  * - `query` returns empty rows (safety net for unmocked query functions)
52
52
  * - `query_one` returns undefined
53
- * - `transaction(fn)` calls `fn(db)` synchronously (no real transaction)
53
+ * - `transaction(fn)` calls `fn(tx)` with a stub transaction `Db` (no real
54
+ * transaction): it reads as one (`in_transaction`) and refuses a nested
55
+ * transaction, as a production transaction `Db` does
54
56
  */
55
57
  export declare const create_stub_db: () => Db;
56
58
  /** Stub handler that answers a 200 `stub` text response, as a raw result. */
@@ -75,7 +77,7 @@ export declare const stub_mw: (_c: any, next: any) => Promise<void>;
75
77
  * wires a listener fails loudly instead of silently never firing
76
78
  * (`create_recording_audit_emitter` accepts listeners); `listener_count`
77
79
  * returns 0; `drain_inflight` resolves immediately, since nothing is ever
78
- * written, and `is_tracking_inflight` answers `false`. Tests asserting on
80
+ * written, and `inflight_count` returns 0. Tests asserting on
79
81
  * real audit-row persistence (or on listener fan-out) build a real emitter
80
82
  * via `create_audit_emitter` against a stub or real DB — `create_test_app`
81
83
  * already does this on the test backend.
@@ -1 +1 @@
1
- {"version":3,"file":"stubs.d.ts","sourceRoot":"","sources":["../../src/lib/testing/stubs.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAa7B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,KAAK,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leware_shape } from '../http/host.js';
14
14
  import { create_realtime_closer } from '../actions/connection_closer.js';
15
15
  import { create_realtime_notification_sender } from '../actions/notification_sender.js';
16
- import { Db } from '../db/db.js';
16
+ import { Db, no_nested_transaction } from '../db/db.js';
17
17
  import { attach_route_handler, prefix_route_specs } from '../http/route_spec.js';
18
18
  import { route_raw } from '../http/route_result.js';
19
19
  import { bootstrap_route_shape } from '../auth/bootstrap_route_schema.js';
@@ -87,11 +87,16 @@ export const stub = create_throwing_stub('stub');
87
87
  * Returns a real `Db` instance with:
88
88
  * - `query` returns empty rows (safety net for unmocked query functions)
89
89
  * - `query_one` returns undefined
90
- * - `transaction(fn)` calls `fn(db)` synchronously (no real transaction)
90
+ * - `transaction(fn)` calls `fn(tx)` with a stub transaction `Db` (no real
91
+ * transaction): it reads as one (`in_transaction`) and refuses a nested
92
+ * transaction, as a production transaction `Db` does
91
93
  */
92
94
  export const create_stub_db = () => new Db({
93
95
  client: { query: async () => ({ rows: [] }) },
94
- transaction: async (fn) => fn(create_stub_db())
96
+ transaction: async (fn) => fn(new Db({
97
+ client: { query: async () => ({ rows: [] }) },
98
+ transaction: no_nested_transaction
99
+ }))
95
100
  });
96
101
  /** Stub handler that answers a 200 `stub` text response, as a raw result. */
97
102
  export const stub_handler = () => route_raw({ status: 200, headers: { 'Content-Type': 'text/plain;charset=UTF-8' }, body: 'stub' });
@@ -120,7 +125,7 @@ const stub_db = create_noop_stub('stub_db');
120
125
  * wires a listener fails loudly instead of silently never firing
121
126
  * (`create_recording_audit_emitter` accepts listeners); `listener_count`
122
127
  * returns 0; `drain_inflight` resolves immediately, since nothing is ever
123
- * written, and `is_tracking_inflight` answers `false`. Tests asserting on
128
+ * written, and `inflight_count` returns 0. Tests asserting on
124
129
  * real audit-row persistence (or on listener fan-out) build a real emitter
125
130
  * via `create_audit_emitter` against a stub or real DB — `create_test_app`
126
131
  * already does this on the test backend.
@@ -135,7 +140,7 @@ export const create_test_audit_emitter = () => ({
135
140
  },
136
141
  listener_count: () => 0,
137
142
  drain_inflight: async () => { },
138
- is_tracking_inflight: () => false
143
+ inflight_count: () => 0
139
144
  });
140
145
  /**
141
146
  * Build a no-op `AuditLogSse` for tests that wire `audit_sse` into the
@@ -0,0 +1,166 @@
1
+ import './assert_dev_env.js';
2
+ /**
3
+ * Fully assembled Hono test app for integration tests.
4
+ *
5
+ * `create_test_app` combines `create_test_app_server` (`testing/app_server.ts`,
6
+ * the vitest-free backend primitives) with `create_app_server`, and hands back
7
+ * the app, the backend, the surface, and request header builders. Built inside
8
+ * a test, the app's database is held to the auth-schema invariants when the
9
+ * test finishes (`register_db_invariants_check`).
10
+ *
11
+ * @module
12
+ */
13
+ import type { Hono } from 'hono';
14
+ import type { Uuid } from '../primitive_schemas.js';
15
+ import { type AppServer, type AppServerOptions, type BootstrapServerOptions } from '../server/app_server.js';
16
+ import type { AppServerContext } from '../server/app_server_context.js';
17
+ import type { AppSurface, AppSurfaceSpec } from '../http/surface.js';
18
+ import type { RouteSpec } from '../http/route_spec.js';
19
+ import type { RpcEndpointsSuiteOption } from './rpc_helpers.js';
20
+ import { type TestAppServer, type TestAppServerOptions } from './app_server.js';
21
+ import type { DbInvariantExclusions } from './db_invariant_queries.js';
22
+ /**
23
+ * Configuration for `create_test_app`.
24
+ */
25
+ export interface CreateTestAppOptions extends TestAppServerOptions {
26
+ /** Route spec factory — called with the assembled `AppServerContext`. */
27
+ create_route_specs: (context: AppServerContext) => Array<RouteSpec>;
28
+ /**
29
+ * RPC endpoints mounted by `create_app_server` — eager array or
30
+ * `(ctx: AppServerContext) => Array<RpcEndpointSpec>` factory. Single
31
+ * source of truth; the equivalent slot under `app_options` is `Omit`'d
32
+ * so setup-time path lookup and runtime dispatch read from one place.
33
+ * Symmetric with the suite-level `rpc_endpoints` option on
34
+ * `describe_standard_admin_integration_tests` etc.
35
+ */
36
+ rpc_endpoints?: RpcEndpointsSuiteOption;
37
+ /**
38
+ * Bootstrap config — symmetric with `AppServerOptions.bootstrap`. Same
39
+ * single-source-of-truth precedent as `rpc_endpoints`: setup-time surface
40
+ * generation and runtime dispatch both read this slot, so the equivalent
41
+ * field under `app_options` is `Omit`'d. Discriminated union over
42
+ * `{mode: 'disabled' | 'surface_only' | 'live'}`. Omit (or pass
43
+ * `{mode: 'disabled'}`) for the default — no bootstrap route mounted.
44
+ */
45
+ bootstrap?: BootstrapServerOptions;
46
+ /**
47
+ * Optional overrides for `AppServerOptions`. Excludes fields
48
+ * `create_test_app` manages directly: `backend`, `session_options`,
49
+ * `create_route_specs`, `rpc_endpoints`, `bootstrap` (top-level slots
50
+ * above).
51
+ */
52
+ app_options?: SuiteAppOptions;
53
+ /**
54
+ * Database invariants left unchecked on this app's database, each with the
55
+ * reason the test's state is deliberate — rows written by hand without the
56
+ * cascade production runs. Every other invariant is checked when the test
57
+ * that built the app finishes, and by `TestApp.assert_db_invariants`.
58
+ * Never exclude a state a production path produces: that is a bug.
59
+ * Validated on every call; logged once per distinct set.
60
+ */
61
+ exclude_db_invariants?: DbInvariantExclusions;
62
+ }
63
+ /**
64
+ * `app_options` shape accepted by `create_test_app` and the DB-backed suite
65
+ * helpers. Excludes fields the helpers manage directly — `backend` /
66
+ * `session_options` / `create_route_specs` are constructed by the helper
67
+ * itself; `rpc_endpoints` and `bootstrap` live on top-level options so
68
+ * setup-time surface lookup and runtime dispatch read from one source of
69
+ * truth.
70
+ */
71
+ export type SuiteAppOptions = Partial<Omit<AppServerOptions, 'backend' | 'session_options' | 'create_route_specs' | 'rpc_endpoints' | 'bootstrap'>>;
72
+ /**
73
+ * A bootstrapped test account with credentials.
74
+ */
75
+ export interface TestAccount {
76
+ account: {
77
+ id: Uuid;
78
+ username: string;
79
+ };
80
+ actor: {
81
+ id: Uuid;
82
+ };
83
+ /** Signed session cookie value. */
84
+ session_cookie: string;
85
+ /** Raw API token for Bearer auth. */
86
+ api_token: string;
87
+ /** Build request headers with this account's session cookie. */
88
+ create_session_headers: (extra?: Record<string, string>) => Record<string, string>;
89
+ /** Build request headers with this account's Bearer token. */
90
+ create_bearer_headers: (extra?: Record<string, string>) => Record<string, string>;
91
+ }
92
+ /**
93
+ * Args for `TestApp.create_account` — mint an additional account alongside the
94
+ * keeper. Mirrors the cross-process `CreateTestAccountOptions` (the two
95
+ * `create_account` paths share a shape so fixture call sites read identically),
96
+ * kept local to avoid a cross-module cycle with `cross_backend/setup.ts`.
97
+ */
98
+ export interface CreateTestAppAccountArgs {
99
+ username?: string;
100
+ password_value?: string;
101
+ roles?: Array<string>;
102
+ /** Optional email stored on the account row — exercises the username-or-email login lookup. */
103
+ email?: string;
104
+ }
105
+ /**
106
+ * A fully assembled test app — Hono app + backend + helpers.
107
+ */
108
+ export interface TestApp {
109
+ app: Hono;
110
+ backend: TestAppServer;
111
+ /**
112
+ * The assembled `AppServer` — reach for what `create_app_server` built
113
+ * beyond the fields lifted onto `TestApp`: `audit_sse` (with
114
+ * `audit_log_sse` in `app_options`), the `ws_endpoints` transports,
115
+ * `bootstrap_status`, `migration_results`.
116
+ */
117
+ server: AppServer;
118
+ surface_spec: AppSurfaceSpec;
119
+ surface: AppSurface;
120
+ route_specs: Array<RouteSpec>;
121
+ /** Build request headers with the bootstrapped session cookie. */
122
+ create_session_headers: (extra?: Record<string, string>) => Record<string, string>;
123
+ /** Build request headers with the bootstrapped Bearer token. */
124
+ create_bearer_headers: (extra?: Record<string, string>) => Record<string, string>;
125
+ /** Build request headers with the daemon token (keeper auth). */
126
+ create_daemon_token_headers: (extra?: Record<string, string>) => Record<string, string>;
127
+ /** Create an additional account with credentials. */
128
+ create_account: (options?: CreateTestAppAccountArgs) => Promise<TestAccount>;
129
+ /**
130
+ * Check the app's database against the auth-schema invariants now, less
131
+ * `exclude_db_invariants` — what runs when the test that built the app
132
+ * finishes, and what `check_db_invariants_after_all` and
133
+ * `check_db_invariants_after_suite` call for an app built in `beforeAll`.
134
+ *
135
+ * @throws Error listing every broken invariant and its rows
136
+ */
137
+ assert_db_invariants: () => Promise<void>;
138
+ /** Cleanup resources — `AppServer.close`: stops an opted-in auth cleanup schedule, closes live connections, disposes the limiters the server built and removes the audit listeners and closer members it added, then the backend's `close`. Idempotent. */
139
+ cleanup: () => Promise<void>;
140
+ }
141
+ /**
142
+ * Create a fully assembled test app with a Hono server, middleware, and routes.
143
+ *
144
+ * Combines `create_test_app_server` + `create_app_server` into a single call.
145
+ * Disables every rate limiter (`rate_limiters: 'disabled_for_testing'`) and
146
+ * logging by default (test-friendly). A limiter passed through `app_options`
147
+ * wins over the mode, so a rate-limit test enables just the one it pins.
148
+ *
149
+ * A fresh Hono app is created each call — middleware closures bind to the
150
+ * server's deps (db, keyring), so reuse across servers is unsafe.
151
+ * The expensive resource (the WASM database) is cached separately in `testing/db.ts`.
152
+ *
153
+ * Built inside a running test, it registers the database invariant check
154
+ * (`register_db_invariants_check`) to run when the test finishes; built in
155
+ * `beforeAll`, nothing is registered, and the suite calls
156
+ * `check_db_invariants_after_all(() => test_app)`, or, when the describe
157
+ * closes the app in its own `afterAll`, `check_db_invariants_after_suite(suite,
158
+ * test_app)` inside that hook ahead of the close.
159
+ *
160
+ * @param options - test app configuration
161
+ * @returns a `TestApp` ready for HTTP testing
162
+ * @throws Error on an `exclude_db_invariants` entry naming no invariant or
163
+ * carrying no reason
164
+ */
165
+ export declare const create_test_app: (options: CreateTestAppOptions) => Promise<TestApp>;
166
+ //# sourceMappingURL=test_app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test_app.d.ts","sourceRoot":"","sources":["../../src/lib/testing/test_app.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAEN,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,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