simple-module-hosting 0.0.44__tar.gz → 0.0.45__tar.gz

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 (257) hide show
  1. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/PKG-INFO +5 -5
  2. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/README.md +1 -1
  3. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/pyproject.toml +4 -4
  4. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_deferred_startup.py +2 -0
  5. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_lifespan.py +2 -0
  6. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_security_headers.py +4 -5
  7. simple_module_hosting-0.0.45/simple_module_hosting/_table_coverage.py +44 -0
  8. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/bootstrap_settings.py +2 -22
  9. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/migrations.py +37 -2
  10. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_csp_nonce.py +37 -5
  11. simple_module_hosting-0.0.45/tests/test_hosting_table_coverage.py +108 -0
  12. simple_module_hosting-0.0.45/tests/test_migration_script_cache.py +79 -0
  13. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_sqlite_path_anchor.py +9 -10
  14. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/.gitignore +0 -0
  15. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/LICENSE +0 -0
  16. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/__init__.py +0 -0
  17. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/__main__.py +0 -0
  18. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_anonymous.py +0 -0
  19. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_api_version.py +0 -0
  20. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_app_boot.py +0 -0
  21. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_body_limit.py +0 -0
  22. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_boot_checks.py +0 -0
  23. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_cors.py +0 -0
  24. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_csp_dynamic.py +0 -0
  25. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_db_health.py +0 -0
  26. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_dev_boot.py +0 -0
  27. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_error_handlers.py +0 -0
  28. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_error_negotiation.py +0 -0
  29. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_error_page.py +0 -0
  30. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_favicon.py +0 -0
  31. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_forwarded_host.py +0 -0
  32. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_host_services.py +0 -0
  33. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_host_settings_support.py +0 -0
  34. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_hydrate_step.py +0 -0
  35. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_i18n_build.py +0 -0
  36. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_i18n_json.py +0 -0
  37. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_i18n_target.py +0 -0
  38. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_inertia_setup.py +0 -0
  39. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_inertia_shared.py +0 -0
  40. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_insecure_transport.py +0 -0
  41. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_lease_redis.py +0 -0
  42. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_middleware_pipeline.py +0 -0
  43. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_module_routes.py +0 -0
  44. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_observability.py +0 -0
  45. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_openapi.py +0 -0
  46. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_phase_helpers.py +0 -0
  47. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_preapp_config.py +0 -0
  48. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_process_services.py +0 -0
  49. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_project_root.py +0 -0
  50. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_rate_limit.py +0 -0
  51. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_rate_limit_keys.py +0 -0
  52. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_rate_limit_store.py +0 -0
  53. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_registrations.py +0 -0
  54. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_request_guard_responses.py +0 -0
  55. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_route_access.py +0 -0
  56. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_route_guard.py +0 -0
  57. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_route_paths.py +0 -0
  58. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_secret_key.py +0 -0
  59. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_server_timing.py +0 -0
  60. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_settings_registration.py +0 -0
  61. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_spa_mount.py +0 -0
  62. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/_tenant.py +0 -0
  63. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/app_builder.py +0 -0
  64. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/assets.py +0 -0
  65. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/csrf.py +0 -0
  66. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/data_compatibility.py +0 -0
  67. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/db_options.py +0 -0
  68. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/errors.py +0 -0
  69. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/health.py +0 -0
  70. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/host_cli.py +0 -0
  71. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/host_settings.py +0 -0
  72. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/i18n_deps.py +0 -0
  73. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/i18n_manifest.py +0 -0
  74. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/i18n_middleware.py +0 -0
  75. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/i18n_routes.py +0 -0
  76. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/inertia_deps.py +0 -0
  77. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/inertia_utils.py +0 -0
  78. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/leases.py +0 -0
  79. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/locales/de.json +0 -0
  80. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/locales/en.json +0 -0
  81. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/locales/es.json +0 -0
  82. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/log_sinks.py +0 -0
  83. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/logging.py +0 -0
  84. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/maintenance.py +0 -0
  85. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/manifest.py +0 -0
  86. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/middleware.py +0 -0
  87. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/page_globs.py +0 -0
  88. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/pagination.py +0 -0
  89. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/path_matching.py +0 -0
  90. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/permissions.py +0 -0
  91. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/public_access.py +0 -0
  92. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/py.typed +0 -0
  93. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/rate_limit_deps.py +0 -0
  94. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/redirects.py +0 -0
  95. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/resource_deps.py +0 -0
  96. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/sentry.py +0 -0
  97. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/sentry_scrub.py +0 -0
  98. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/sentry_scrub_text.py +0 -0
  99. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/session.py +0 -0
  100. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/settings.py +0 -0
  101. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/setup_gate.py +0 -0
  102. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/setup_wizard/__init__.py +0 -0
  103. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/setup_wizard/_migration_lock.py +0 -0
  104. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/setup_wizard/components/ConnectionList.tsx +0 -0
  105. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/setup_wizard/components/StepForm.tsx +0 -0
  106. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/setup_wizard/migrate.py +0 -0
  107. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/setup_wizard/pages/Wizard.tsx +0 -0
  108. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/setup_wizard/payloads.py +0 -0
  109. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/setup_wizard/routes.py +0 -0
  110. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/shared_props.py +0 -0
  111. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/static_files.py +0 -0
  112. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/tenancy.py +0 -0
  113. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/token_guard.py +0 -0
  114. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/ui_locales/de.json +0 -0
  115. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/ui_locales/en.json +0 -0
  116. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/simple_module_hosting/ui_locales/es.json +0 -0
  117. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/_hosting_settings_db.py +0 -0
  118. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/_resacc_models.py +0 -0
  119. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/_sentry_transport.py +0 -0
  120. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/conftest.py +0 -0
  121. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_api_error_negotiation.py +0 -0
  122. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_app.py +0 -0
  123. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_auth_provider_setting.py +0 -0
  124. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_boot_config_hardening.py +0 -0
  125. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_boot_drift_check.py +0 -0
  126. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_branding_head.py +0 -0
  127. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_build_time_settings_marked.py +0 -0
  128. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_check_migrations.py +0 -0
  129. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_check_migrations_expression_note.py +0 -0
  130. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_csp_module_sources.py +0 -0
  131. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_db_health_check.py +0 -0
  132. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_design_packs_wiring.py +0 -0
  133. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_diagnostics_state.py +0 -0
  134. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_error_page_shared_props.py +0 -0
  135. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_error_status_coverage.py +0 -0
  136. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_favicon_default.py +0 -0
  137. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_forwarded_host.py +0 -0
  138. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_grant_sources.py +0 -0
  139. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_health.py +0 -0
  140. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_home_url_default.py +0 -0
  141. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_host_cli.py +0 -0
  142. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_host_settings_fields.py +0 -0
  143. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_api_version_cache.py +0 -0
  144. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_asset_version.py +0 -0
  145. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_catalog_json_cache.py +0 -0
  146. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_config_sources.py +0 -0
  147. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_cors_api.py +0 -0
  148. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_cors_unset.py +0 -0
  149. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_csp_providers.py +0 -0
  150. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_csrf.py +0 -0
  151. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_csrf_shared_prop.py +0 -0
  152. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_data_compatibility.py +0 -0
  153. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_error_handling_policy.py +0 -0
  154. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_error_json_and_session_cookie.py +0 -0
  155. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_health_bounded.py +0 -0
  156. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_inertia_body_validation.py +0 -0
  157. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_inertia_cache.py +0 -0
  158. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_inertia_validation_errors.py +0 -0
  159. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_lazy_layout_catalogs.py +0 -0
  160. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_lease_backends.py +0 -0
  161. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_lease_selection.py +0 -0
  162. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_lease_timeouts.py +0 -0
  163. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_lifespan_cleanup.py +0 -0
  164. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_log_sinks.py +0 -0
  165. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_migration_target.py +0 -0
  166. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_openapi.py +0 -0
  167. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_openapi_security.py +0 -0
  168. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_pagination_deps.py +0 -0
  169. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_permissions.py +0 -0
  170. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_platform_permissions.py +0 -0
  171. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_public_access.py +0 -0
  172. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_public_error_page.py +0 -0
  173. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_public_path_boundaries.py +0 -0
  174. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_security_static_headers.py +0 -0
  175. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_sentry.py +0 -0
  176. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_sentry_scrub.py +0 -0
  177. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_sentry_scrub_gaps.py +0 -0
  178. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_server_timing.py +0 -0
  179. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_spa_mount_nonce.py +0 -0
  180. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_hosting_ui_assets.py +0 -0
  181. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_i18n_build_overrides.py +0 -0
  182. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_i18n_manifest.py +0 -0
  183. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_i18n_manifest_published_target.py +0 -0
  184. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_i18n_routes.py +0 -0
  185. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_i18n_types_cover_installed_modules.py +0 -0
  186. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_i18n_ui_namespace.py +0 -0
  187. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_inertia_i18n_shared_props.py +0 -0
  188. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_inertia_protocol_middleware.py +0 -0
  189. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_inertia_shared_providers.py +0 -0
  190. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_insecure_transport_warning.py +0 -0
  191. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_invalidation_wiring.py +0 -0
  192. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_lifespan_deferred_startup.py +0 -0
  193. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_lifespan_order.py +0 -0
  194. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_locale_middleware.py +0 -0
  195. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_logging.py +0 -0
  196. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_maintenance_mode.py +0 -0
  197. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_manifest.py +0 -0
  198. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_menu_providers_wiring.py +0 -0
  199. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_menu_urls_are_canonical.py +0 -0
  200. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_merge_host_settings_strict.py +0 -0
  201. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_middleware_order.py +0 -0
  202. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_migration_listing.py +0 -0
  203. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_migration_multihead.py +0 -0
  204. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_native_link_prefixes_strip.py +0 -0
  205. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_preapp_config.py +0 -0
  206. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_preapp_invalid_values.py +0 -0
  207. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_preapp_read_failures.py +0 -0
  208. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_precompressed_static.py +0 -0
  209. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_principal_permissions_claim.py +0 -0
  210. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_proxy_headers.py +0 -0
  211. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_rate_limit_rules_redis.py +0 -0
  212. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_rate_limit_rules_registry.py +0 -0
  213. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_rate_limit_store_shared.py +0 -0
  214. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_redirects.py +0 -0
  215. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_request_guard_auth_parity.py +0 -0
  216. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_request_guard_body_limit.py +0 -0
  217. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_request_guard_body_limit_middleware_read.py +0 -0
  218. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_request_guard_body_limit_started.py +0 -0
  219. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_request_guard_rate_limit.py +0 -0
  220. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_resource_deps.py +0 -0
  221. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_resource_policy_owned.py +0 -0
  222. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_resource_policy_parity.py +0 -0
  223. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_resource_types_wiring.py +0 -0
  224. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_response_compression.py +0 -0
  225. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_route_guard.py +0 -0
  226. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_route_guard_fastapi_contract.py +0 -0
  227. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_route_paths.py +0 -0
  228. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_secret_key_bootstrap.py +0 -0
  229. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_server_rendered_head.py +0 -0
  230. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_session_cookie_secure.py +0 -0
  231. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_session_cookie_security.py +0 -0
  232. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_session_cookie_window.py +0 -0
  233. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_session_vary_dedupe.py +0 -0
  234. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_settings_i18n.py +0 -0
  235. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_settings_secrets.py +0 -0
  236. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_setup_gate.py +0 -0
  237. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_setup_gate_single_flight.py +0 -0
  238. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_setup_migrate_error_redaction.py +0 -0
  239. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_setup_migrate_worker_lock.py +0 -0
  240. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_setup_public_routes.py +0 -0
  241. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_setup_registry.py +0 -0
  242. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_setup_routes.py +0 -0
  243. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_spa_mounts_541.py +0 -0
  244. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_static_caching.py +0 -0
  245. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_strict_discovery_wiring.py +0 -0
  246. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_tenancy_api.py +0 -0
  247. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_tenant_middleware.py +0 -0
  248. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_tenant_resolver_diagnostic.py +0 -0
  249. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_tenant_resolver_types.py +0 -0
  250. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_tenant_scope_helpers.py +0 -0
  251. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_tenant_source.py +0 -0
  252. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_token_guard_effective_route.py +0 -0
  253. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_token_route_guard.py +0 -0
  254. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_translator_dep.py +0 -0
  255. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests/test_view_prefixes.py +0 -0
  256. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tests-js/hosting_SetupWizard.test.tsx +0 -0
  257. {simple_module_hosting-0.0.44 → simple_module_hosting-0.0.45}/tsconfig.json +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: simple_module_hosting
3
- Version: 0.0.44
3
+ Version: 0.0.45
4
4
  Summary: FastAPI + Inertia.js host runtime for simple_module — app_builder, middleware stack, CLI (sm / simple-module), scaffolding
5
5
  Project-URL: Homepage, https://github.com/antosubash/simple_module_python
6
6
  Project-URL: Repository, https://github.com/antosubash/simple_module_python
@@ -26,9 +26,9 @@ Requires-Dist: fastapi<0.163,>=0.140
26
26
  Requires-Dist: httpx<0.29,>=0.27
27
27
  Requires-Dist: itsdangerous<3,>=2.0
28
28
  Requires-Dist: jinja2<4,>=3.1
29
- Requires-Dist: simple-module-core==0.0.44
30
- Requires-Dist: simple-module-db==0.0.44
31
- Requires-Dist: simple-module-inertia==0.0.44
29
+ Requires-Dist: simple-module-core==0.0.45
30
+ Requires-Dist: simple-module-db==0.0.45
31
+ Requires-Dist: simple-module-inertia==0.0.45
32
32
  Requires-Dist: starlette<2,>=0.44
33
33
  Requires-Dist: tomlkit<0.16,>=0.13
34
34
  Requires-Dist: uvicorn[standard]<0.55,>=0.34
@@ -51,7 +51,7 @@ pip install simple_module_hosting
51
51
  For a new project, most users run the generator instead (shipped by the standalone `simple_module_cli` distribution):
52
52
 
53
53
  ```bash
54
- uvx --from simple_module_cli smpy new my-app
54
+ uvx --from simple_module_cli@latest smpy new my-app
55
55
  ```
56
56
 
57
57
  ## What it provides
@@ -11,7 +11,7 @@ pip install simple_module_hosting
11
11
  For a new project, most users run the generator instead (shipped by the standalone `simple_module_cli` distribution):
12
12
 
13
13
  ```bash
14
- uvx --from simple_module_cli smpy new my-app
14
+ uvx --from simple_module_cli@latest smpy new my-app
15
15
  ```
16
16
 
17
17
  ## What it provides
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "simple_module_hosting"
3
- version = "0.0.44"
3
+ version = "0.0.45"
4
4
  description = "FastAPI + Inertia.js host runtime for simple_module — app_builder, middleware stack, CLI (sm / simple-module), scaffolding"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -29,9 +29,9 @@ dependencies = [
29
29
  # it directly — out-of-tree hosts have nothing else pulling it in.
30
30
  "itsdangerous>=2.0,<3",
31
31
  "jinja2>=3.1,<4",
32
- "simple_module_core==0.0.44",
33
- "simple_module_db==0.0.44",
34
- "simple_module_inertia==0.0.44",
32
+ "simple_module_core==0.0.45",
33
+ "simple_module_db==0.0.45",
34
+ "simple_module_inertia==0.0.45",
35
35
  "starlette>=0.44,<2",
36
36
  "tomlkit>=0.13,<0.16",
37
37
  "uvicorn[standard]>=0.34,<0.55",
@@ -11,6 +11,7 @@ from simple_module_core.module_settings import get_module_settings_registry
11
11
  from simple_module_db.stored_settings import SessionOverrideSource, settings_table_exists
12
12
 
13
13
  from simple_module_hosting._hydrate_step import hydrate_all
14
+ from simple_module_hosting._table_coverage import add_table_coverage
14
15
  from simple_module_hosting.data_compatibility import check_data_compatibility
15
16
 
16
17
  logger = logging.getLogger(__name__)
@@ -52,6 +53,7 @@ async def run_deferred_startup(app: FastAPI) -> None:
52
53
  pending_checks = getattr(app.state, "deferred_data_compatibility", None)
53
54
  if pending_checks:
54
55
  await check_data_compatibility(app, pending_checks)
56
+ await add_table_coverage(app, pending_checks)
55
57
  app.state.deferred_data_compatibility = []
56
58
  deferred = get_deferred_startup(app)
57
59
  if not deferred:
@@ -22,6 +22,7 @@ from simple_module_core.app_state import get_migration_status
22
22
 
23
23
  from simple_module_hosting._deferred_startup import hydrate_settings_from_db
24
24
  from simple_module_hosting._route_guard import guard_included_routers
25
+ from simple_module_hosting._table_coverage import add_table_coverage
25
26
  from simple_module_hosting.data_compatibility import check_data_compatibility
26
27
  from simple_module_hosting.migrations import migration_status
27
28
  from simple_module_hosting.setup_gate import STEP_MIGRATIONS
@@ -89,6 +90,7 @@ def build_lifespan(modules: Sequence) -> Callable:
89
90
  migration = app.state.migration
90
91
  if migration["is_current"] and migration.get("current_revision") is not None:
91
92
  await check_data_compatibility(app, modules)
93
+ await add_table_coverage(app, modules)
92
94
  else:
93
95
  app.state.deferred_data_compatibility = list(modules)
94
96
 
@@ -132,14 +132,13 @@ class SecurityHeadersMiddleware:
132
132
  # A 304 refreshes the cached response's headers: a new nonce there
133
133
  # would no longer match the cached body, so keep the cached CSP.
134
134
  if self.csp and message.get("status") != _HTTP_NOT_MODIFIED:
135
- # Separate policies intersect: sandbox responses cannot replace
136
- # the app's default-src, frame-ancestors or other protections.
137
- own = (headers.get(_HEADER_CSP) or "").lower()
138
- keeps_own = any(d.split()[:1] == ["sandbox"] for d in own.split(";"))
135
+ # Separate policies intersect, so a response's own policy is
136
+ # kept beside the app policy: it can tighten a page (#870) but
137
+ # never relax default-src or frame-ancestors.
139
138
  dyn = self._dynamic
140
139
  policy = dyn.policy_for(scope.get("app")) if dyn else self.csp
141
140
  policy = policy.replace("'strict-dynamic'", f"'nonce-{nonce}' 'strict-dynamic'")
142
- if keeps_own:
141
+ if _HEADER_CSP in headers:
143
142
  headers.append(_HEADER_CSP, policy)
144
143
  else:
145
144
  headers[_HEADER_CSP] = policy
@@ -0,0 +1,44 @@
1
+ """SM011 at a development boot, once the database is open and at head (#895)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+ from collections.abc import Sequence
7
+
8
+ from fastapi import FastAPI
9
+ from simple_module_core.diagnostics import Diagnostic, print_diagnostics
10
+ from simple_module_core.diagnostics._migration import MigrationDiagnostics, module_table_names
11
+ from simple_module_core.module import ModuleBase
12
+ from sqlalchemy import inspect
13
+
14
+ logger = logging.getLogger(__name__)
15
+
16
+
17
+ async def add_table_coverage(app: FastAPI, modules: Sequence[ModuleBase]) -> None:
18
+ """Report module tables the migrated database lacks, and keep them for the Doctor screen.
19
+
20
+ The boot diagnostics run while the app is built, before the database is
21
+ open, so this half runs from the lifespan. Only development keeps a runner;
22
+ wrapping it lets the Doctor screen's ``rerun()`` show the findings again.
23
+ Call it only for a database at every head: behind head, a missing table may
24
+ simply be in a pending revision.
25
+ """
26
+ state = getattr(app.state.sm, "diagnostics", None)
27
+ runner = state.runner if state is not None else None
28
+ if state is None or runner is None:
29
+ return
30
+ try:
31
+ async with app.state.sm.db.engine.connect() as conn:
32
+ tables = set(await conn.run_sync(lambda sync: inspect(sync).get_table_names()))
33
+ except Exception:
34
+ # A diagnostics-only read must never fail the boot or the wizard's migrations action.
35
+ logger.warning("SM011 table coverage could not be read; skipped", exc_info=True)
36
+ return
37
+ found: list[Diagnostic] = MigrationDiagnostics().check_table_coverage(
38
+ module_table_names(modules), tables
39
+ )
40
+ if not found:
41
+ return
42
+ print_diagnostics(found)
43
+ state.runner = lambda: [*runner(), *found]
44
+ state.results = [*state.results, *found]
@@ -22,32 +22,12 @@ from typing import Any
22
22
 
23
23
  from pydantic import model_validator
24
24
  from pydantic_settings import BaseSettings, SettingsConfigDict
25
- from simple_module_core.dotenv import find_env_file
25
+ from simple_module_core.dotenv import absolutize_sqlite_url, find_env_file
26
26
  from simple_module_core.environments import NON_PROD_ENVIRONMENTS
27
27
 
28
28
  PLACEHOLDER_SECRET_KEY = "change-me-in-production"
29
29
 
30
30
 
31
- def _absolutize_sqlite_url(url: str, *, anchor: Path) -> str:
32
- """Rewrite a relative sqlite path to an absolute one under ``anchor``.
33
-
34
- ``sqlite+aiosqlite:///./host/app.db`` means "relative to the project
35
- root" by convention, but SQLAlchemy resolves it against the process cwd
36
- — correct in the web process (which chdirs) and silently wrong in every
37
- CLI run from a subdirectory. Absolute paths (``:////...``), ``:memory:``,
38
- SQLite URI-mode paths (``file:...?uri=true``), and non-sqlite URLs pass
39
- through untouched.
40
- """
41
- if not url.startswith("sqlite"):
42
- return url
43
- scheme, sep, rest = url.partition(":///")
44
- if not sep or not rest or rest.startswith(("/", ":memory:", "file:")):
45
- return url
46
- path_part, query_sep, query = rest.partition("?")
47
- resolved = (anchor / path_part).resolve()
48
- return f"{scheme}:///{resolved}{query_sep}{query}"
49
-
50
-
51
31
  class BootstrapSettings(BaseSettings):
52
32
  """Pre-DB bootstrap environment knobs."""
53
33
 
@@ -77,7 +57,7 @@ class BootstrapSettings(BaseSettings):
77
57
  anchor = (
78
58
  Path(env_file).parent if isinstance(env_file, (str, Path)) else find_env_file().parent
79
59
  )
80
- self.database_url = _absolutize_sqlite_url(self.database_url, anchor=anchor)
60
+ self.database_url = absolutize_sqlite_url(self.database_url, anchor=anchor)
81
61
 
82
62
  database_url: str = "sqlite+aiosqlite:///./app.db"
83
63
 
@@ -5,6 +5,10 @@ from __future__ import annotations
5
5
  import logging
6
6
  import os
7
7
  from pathlib import Path
8
+ from typing import TYPE_CHECKING
9
+
10
+ if TYPE_CHECKING:
11
+ from alembic.script import ScriptDirectory
8
12
 
9
13
  logger = logging.getLogger(__name__)
10
14
 
@@ -29,17 +33,48 @@ def default_alembic_ini() -> str:
29
33
  return str(Path(root) / _ALEMBIC_INI_RELATIVE) if root else _ALEMBIC_INI_RELATIVE
30
34
 
31
35
 
32
- def script_directory(alembic_ini_path: str | None = None):
36
+ # ini path -> (revision files and their mtimes, ScriptDirectory with its revision map loaded).
37
+ _SCRIPTS: dict[str, tuple[tuple, ScriptDirectory]] = {}
38
+
39
+
40
+ def _revision_files(script: ScriptDirectory) -> tuple:
41
+ # ``_version_locations`` is alembic's resolved list of version directories (there
42
+ # is no public accessor for more than one location).
43
+ files = []
44
+ for location in script._version_locations:
45
+ for path in Path(location).rglob("*.py"):
46
+ try:
47
+ stat = path.stat()
48
+ except FileNotFoundError: # removed while scanning: the next call sees the new set
49
+ continue
50
+ files.append((str(path), stat.st_mtime_ns, stat.st_size))
51
+ return tuple(sorted(files))
52
+
53
+
54
+ def script_directory(alembic_ini_path: str | None = None) -> ScriptDirectory:
33
55
  """Build the ``ScriptDirectory`` for ``alembic_ini_path``.
34
56
 
35
57
  Shared by every caller that needs to walk or query alembic revisions
36
58
  (boot-time head check, the in-app Doctor screen) so the config/ini-path
37
59
  construction has exactly one source of truth.
60
+
61
+ Reused while the revision files are unchanged: loading the revision map
62
+ imports every migration file, which every app build paid for twice. A file
63
+ added, removed or edited (``smpy migrations prepare``, a new revision in
64
+ development) builds a fresh one.
38
65
  """
39
66
  from alembic.config import Config as AlembicConfig
40
67
  from alembic.script import ScriptDirectory
41
68
 
42
- return ScriptDirectory.from_config(AlembicConfig(alembic_ini_path or default_alembic_ini()))
69
+ ini_path = alembic_ini_path or default_alembic_ini()
70
+ script = ScriptDirectory.from_config(AlembicConfig(ini_path))
71
+ files = _revision_files(script)
72
+ key = str(Path(ini_path).resolve())
73
+ cached = _SCRIPTS.get(key)
74
+ if cached is not None and cached[0] == files:
75
+ return cached[1]
76
+ _SCRIPTS[key] = (files, script)
77
+ return script
43
78
 
44
79
 
45
80
  def resolve_head_revisions(alembic_ini_path: str | None = None) -> tuple[str, ...]:
@@ -1,4 +1,4 @@
1
- """Nonce-bearing scripts and intersecting response policies (#785)."""
1
+ """Nonce-bearing scripts and intersecting response policies (#785, #870)."""
2
2
 
3
3
  from html.parser import HTMLParser
4
4
  from pathlib import Path
@@ -98,17 +98,24 @@ async def test_scripts_share_the_request_nonce(template_dir, environment):
98
98
  assert any(s.get("src", "").endswith("/@vite/client") for s in scripts)
99
99
 
100
100
 
101
- @pytest.mark.parametrize("own", ["sandbox allow-scripts; script-src *", "SANDBOX\tallow-scripts"])
102
- async def test_sandbox_response_keeps_both_policies(own):
101
+ async def _policies_for(*own: str) -> list[str]:
103
102
  async def page(request):
104
- return PlainTextResponse("ok", headers={_CSP: own})
103
+ response = PlainTextResponse("ok")
104
+ for policy in own:
105
+ response.headers.append(_CSP, policy)
106
+ return response
105
107
 
106
108
  app = SecurityHeadersMiddleware(Starlette(routes=[Route("/", page)]))
107
109
  async with httpx.AsyncClient(
108
110
  transport=httpx.ASGITransport(app=app), base_url="http://test"
109
111
  ) as client:
110
112
  response = await client.get("/")
111
- policies = response.headers.get_list(_CSP)
113
+ return response.headers.get_list(_CSP)
114
+
115
+
116
+ @pytest.mark.parametrize("own", ["sandbox allow-scripts; script-src *", "SANDBOX\tallow-scripts"])
117
+ async def test_sandbox_response_keeps_both_policies(own):
118
+ policies = await _policies_for(own)
112
119
  assert len(policies) == 2
113
120
  assert own in policies
114
121
  app_policy = next(policy for policy in policies if policy != own)
@@ -121,6 +128,31 @@ async def test_sandbox_response_keeps_both_policies(own):
121
128
  assert directive in app_policy
122
129
 
123
130
 
131
+ async def test_stricter_response_policy_is_kept_beside_the_app_policy():
132
+ """A page can tighten the app policy; the two intersect (#870)."""
133
+ own = "default-src 'self'; frame-ancestors 'none'"
134
+ policies = await _policies_for(own)
135
+ assert len(policies) == 2
136
+ assert policies[0] == own
137
+ assert "frame-ancestors 'self'" in policies[1]
138
+ assert "'nonce-" in policies[1]
139
+ assert "'nonce-" not in policies[0]
140
+
141
+
142
+ async def test_every_response_policy_is_kept():
143
+ first, second = "frame-ancestors 'none'", "img-src 'self'"
144
+ policies = await _policies_for(first, second)
145
+ assert policies[:2] == [first, second]
146
+ assert len(policies) == 3
147
+ assert "default-src 'self'" in policies[2]
148
+
149
+
150
+ async def test_without_a_response_policy_only_the_app_policy_is_sent():
151
+ policies = await _policies_for()
152
+ assert len(policies) == 1
153
+ assert "default-src 'self'" in policies[0]
154
+
155
+
124
156
  async def test_not_modified_keeps_the_cached_policy():
125
157
  """A 304 must not carry a fresh nonce the cached body does not have."""
126
158
  from starlette.responses import Response
@@ -0,0 +1,108 @@
1
+ """A development boot reports SM011 once the database is open (#895)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from types import SimpleNamespace
6
+
7
+ import pytest
8
+ import sqlalchemy as sa
9
+ from simple_module_core.diagnostics import Diagnostic, DiagnosticLevel
10
+ from simple_module_core.services import DiagnosticsState
11
+ from simple_module_hosting import _table_coverage
12
+ from simple_module_hosting._table_coverage import add_table_coverage
13
+ from sqlalchemy.ext.asyncio import create_async_engine
14
+
15
+ _BOOT = Diagnostic(
16
+ level=DiagnosticLevel.WARNING, code="SM019", message="boot finding", module_name="Demo"
17
+ )
18
+
19
+
20
+ @pytest.fixture
21
+ async def engine():
22
+ engine = create_async_engine("sqlite+aiosqlite://")
23
+ async with engine.begin() as conn:
24
+ await conn.execute(sa.text("CREATE TABLE orders_order (id INTEGER)"))
25
+ yield engine
26
+ await engine.dispose()
27
+
28
+
29
+ def _app(engine, state: DiagnosticsState) -> SimpleNamespace:
30
+ return SimpleNamespace(
31
+ state=SimpleNamespace(
32
+ sm=SimpleNamespace(diagnostics=state, db=SimpleNamespace(engine=engine))
33
+ )
34
+ )
35
+
36
+
37
+ @pytest.fixture(autouse=True)
38
+ def _module_tables(monkeypatch):
39
+ monkeypatch.setattr(
40
+ _table_coverage, "module_table_names", lambda modules: {"orders_order", "orders_line"}
41
+ )
42
+
43
+
44
+ async def test_hosting_table_coverage_survives_rerun(engine, capsys):
45
+ state = DiagnosticsState(runner=lambda: [_BOOT])
46
+ state.rerun()
47
+
48
+ await add_table_coverage(_app(engine, state), [])
49
+
50
+ assert [d.code for d in state.results] == ["SM019", "SM011"]
51
+ assert "orders_line" in state.results[1].message
52
+ assert "SM011" in capsys.readouterr().err
53
+ assert [d.code for d in state.rerun()] == ["SM019", "SM011"]
54
+
55
+
56
+ async def test_hosting_table_coverage_is_quiet_when_covered(engine, monkeypatch):
57
+ monkeypatch.setattr(_table_coverage, "module_table_names", lambda modules: {"orders_order"})
58
+ state = DiagnosticsState(runner=lambda: [_BOOT])
59
+ state.rerun()
60
+
61
+ await add_table_coverage(_app(engine, state), [])
62
+
63
+ assert [d.code for d in state.rerun()] == ["SM019"]
64
+
65
+
66
+ async def test_hosting_table_coverage_skips_when_the_database_cannot_be_read(caplog):
67
+ # A diagnostics-only read must not fail the boot or the wizard's migrations action.
68
+ class _BrokenEngine:
69
+ def connect(self):
70
+ raise RuntimeError("database is gone")
71
+
72
+ state = DiagnosticsState(runner=lambda: [_BOOT])
73
+ state.rerun()
74
+
75
+ await add_table_coverage(_app(_BrokenEngine(), state), [])
76
+
77
+ assert [d.code for d in state.rerun()] == ["SM019"]
78
+ assert "SM011 table coverage could not be read" in caplog.text
79
+
80
+
81
+ async def test_hosting_table_coverage_skips_without_a_runner(engine):
82
+ # Outside development no diagnostics run, so the database is not inspected.
83
+ state = DiagnosticsState()
84
+
85
+ await add_table_coverage(_app(engine, state), [])
86
+
87
+ assert state.results == []
88
+ assert state.supported is False
89
+
90
+
91
+ async def test_hosting_table_coverage_runs_after_the_wizard_migrates(engine, monkeypatch):
92
+ # A first run defers the check; replaying deferred startup reports it once at head.
93
+ from simple_module_hosting import _deferred_startup
94
+
95
+ async def no_compat_issues(app, modules):
96
+ return None
97
+
98
+ monkeypatch.setattr(_deferred_startup, "check_data_compatibility", no_compat_issues)
99
+ state = DiagnosticsState(runner=lambda: [_BOOT])
100
+ state.rerun()
101
+ app = _app(engine, state)
102
+ app.state.deferred_data_compatibility = ["module"]
103
+ app.state.deferred_startup = []
104
+
105
+ await _deferred_startup.run_deferred_startup(app)
106
+
107
+ assert [d.code for d in state.rerun()] == ["SM019", "SM011"]
108
+ assert app.state.deferred_data_compatibility == []
@@ -0,0 +1,79 @@
1
+ """``script_directory`` reuses the loaded revision map until a revision file changes."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import os
6
+ from pathlib import Path
7
+
8
+ import pytest
9
+ from simple_module_hosting import migrations
10
+ from simple_module_hosting.migrations import resolve_head_revisions, script_directory
11
+
12
+ _INI = """\
13
+ [alembic]
14
+ script_location = %(here)s/migrations
15
+ """
16
+
17
+ _REVISION = """\
18
+ revision = "{rev}"
19
+ down_revision = {down}
20
+ branch_labels = None
21
+ depends_on = None
22
+
23
+
24
+ def upgrade() -> None:
25
+ pass
26
+
27
+
28
+ def downgrade() -> None:
29
+ pass
30
+ """
31
+
32
+
33
+ @pytest.fixture
34
+ def project(tmp_path: Path, monkeypatch) -> Path:
35
+ monkeypatch.setattr(migrations, "_SCRIPTS", {})
36
+ (tmp_path / "migrations" / "versions").mkdir(parents=True)
37
+ (tmp_path / "alembic.ini").write_text(_INI)
38
+ _write(tmp_path, "a1", None)
39
+ return tmp_path
40
+
41
+
42
+ def _write(project: Path, rev: str, down: str | None) -> Path:
43
+ path = project / "migrations" / "versions" / f"{rev}_rev.py"
44
+ path.write_text(_REVISION.format(rev=rev, down=repr(down)))
45
+ return path
46
+
47
+
48
+ def test_an_unchanged_history_reuses_the_loaded_script(project: Path) -> None:
49
+ ini = str(project / "alembic.ini")
50
+ assert script_directory(ini) is script_directory(ini)
51
+
52
+
53
+ def test_a_new_revision_is_seen(project: Path) -> None:
54
+ ini = str(project / "alembic.ini")
55
+ assert resolve_head_revisions(ini) == ("a1",)
56
+
57
+ _write(project, "b2", "a1")
58
+
59
+ assert resolve_head_revisions(ini) == ("b2",)
60
+
61
+
62
+ def test_an_edited_revision_is_seen(project: Path) -> None:
63
+ ini = str(project / "alembic.ini")
64
+ first = script_directory(ini)
65
+ path = _write(project, "a1", None)
66
+ stat = path.stat()
67
+ os.utime(path, ns=(stat.st_atime_ns, stat.st_mtime_ns + 1_000_000))
68
+
69
+ assert script_directory(ini) is not first
70
+
71
+
72
+ def test_a_removed_revision_is_seen(project: Path) -> None:
73
+ ini = str(project / "alembic.ini")
74
+ second = _write(project, "b2", "a1")
75
+ assert resolve_head_revisions(ini) == ("b2",)
76
+
77
+ second.unlink()
78
+
79
+ assert resolve_head_revisions(ini) == ("a1",)
@@ -19,42 +19,41 @@ from __future__ import annotations
19
19
  from pathlib import Path
20
20
 
21
21
  import pytest
22
- from simple_module_core.dotenv import find_env_file
23
- from simple_module_hosting.bootstrap_settings import _absolutize_sqlite_url
22
+ from simple_module_core.dotenv import absolutize_sqlite_url, find_env_file
24
23
 
25
24
 
26
25
  class TestAbsolutize:
27
26
  def test_relative_path_resolves_against_anchor(self, tmp_path: Path) -> None:
28
- url = _absolutize_sqlite_url("sqlite+aiosqlite:///./host/app.db", anchor=tmp_path)
27
+ url = absolutize_sqlite_url("sqlite+aiosqlite:///./host/app.db", anchor=tmp_path)
29
28
  assert url == f"sqlite+aiosqlite:///{tmp_path / 'host' / 'app.db'}"
30
29
 
31
30
  def test_bare_relative_path_resolves(self, tmp_path: Path) -> None:
32
- url = _absolutize_sqlite_url("sqlite+aiosqlite:///app.db", anchor=tmp_path)
31
+ url = absolutize_sqlite_url("sqlite+aiosqlite:///app.db", anchor=tmp_path)
33
32
  assert url == f"sqlite+aiosqlite:///{tmp_path / 'app.db'}"
34
33
 
35
34
  def test_absolute_path_untouched(self, tmp_path: Path) -> None:
36
35
  url = "sqlite+aiosqlite:////var/data/app.db"
37
- assert _absolutize_sqlite_url(url, anchor=tmp_path) == url
36
+ assert absolutize_sqlite_url(url, anchor=tmp_path) == url
38
37
 
39
38
  def test_memory_untouched(self, tmp_path: Path) -> None:
40
39
  url = "sqlite+aiosqlite:///:memory:"
41
- assert _absolutize_sqlite_url(url, anchor=tmp_path) == url
40
+ assert absolutize_sqlite_url(url, anchor=tmp_path) == url
42
41
 
43
42
  def test_uri_mode_untouched(self, tmp_path: Path) -> None:
44
43
  """SQLite URI-mode paths (shared in-memory DBs) are not file paths."""
45
44
  url = "sqlite+aiosqlite:///file:shared?mode=memory&cache=shared&uri=true"
46
- assert _absolutize_sqlite_url(url, anchor=tmp_path) == url
45
+ assert absolutize_sqlite_url(url, anchor=tmp_path) == url
47
46
 
48
47
  def test_bare_scheme_untouched(self, tmp_path: Path) -> None:
49
48
  url = "sqlite+aiosqlite://"
50
- assert _absolutize_sqlite_url(url, anchor=tmp_path) == url
49
+ assert absolutize_sqlite_url(url, anchor=tmp_path) == url
51
50
 
52
51
  def test_postgres_untouched(self, tmp_path: Path) -> None:
53
52
  url = "postgresql+asyncpg://u:p@localhost/db"
54
- assert _absolutize_sqlite_url(url, anchor=tmp_path) == url
53
+ assert absolutize_sqlite_url(url, anchor=tmp_path) == url
55
54
 
56
55
  def test_query_string_survives(self, tmp_path: Path) -> None:
57
- url = _absolutize_sqlite_url("sqlite+aiosqlite:///app.db?mode=ro", anchor=tmp_path)
56
+ url = absolutize_sqlite_url("sqlite+aiosqlite:///app.db?mode=ro", anchor=tmp_path)
58
57
  assert url == f"sqlite+aiosqlite:///{tmp_path / 'app.db'}?mode=ro"
59
58
 
60
59