jishushell 0.6.18 → 0.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/anythingllm-container.yaml +1 -0
- package/apps/browserless-chromium-container.yaml +1 -0
- package/apps/filebrowser-container.yaml +1 -0
- package/apps/hermes-container.yaml +1 -7
- package/apps/immich-container-lite.yaml +337 -0
- package/apps/immich-container.yaml +371 -0
- package/apps/jishu-kb-container.yaml +26 -21
- package/apps/ollama-binary.yaml +1 -0
- package/apps/ollama-cpu-container.yaml +1 -0
- package/apps/ollama-with-hollama-binary.yaml +2 -0
- package/apps/openclaw-binary.yaml +4 -8
- package/apps/openclaw-container.yaml +1 -7
- package/apps/openclaw-with-ollama-container.yaml +1 -0
- package/apps/openclaw-with-searxng-container.yaml +20 -0
- package/apps/searxng-container.yaml +20 -0
- package/apps/weknora-container.yaml +5 -0
- package/dependencies/jishushell-panel-0.7.3.tgz +0 -0
- package/dist/cli/core.js +1 -1
- package/dist/cli/core.js.map +1 -1
- package/dist/cli/doctor.js +96 -0
- package/dist/cli/doctor.js.map +1 -1
- package/dist/config.d.ts +9 -1
- package/dist/config.js +72 -2
- package/dist/config.js.map +1 -1
- package/dist/install.js +60 -19
- package/dist/install.js.map +1 -1
- package/dist/routes/admin.d.ts +2 -0
- package/dist/routes/admin.js +72 -0
- package/dist/routes/admin.js.map +1 -0
- package/dist/routes/docker.d.ts +2 -0
- package/dist/routes/docker.js +58 -0
- package/dist/routes/docker.js.map +1 -0
- package/dist/routes/file-mounts.js +5 -8
- package/dist/routes/file-mounts.js.map +1 -1
- package/dist/routes/instances.d.ts +0 -14
- package/dist/routes/instances.js +44 -1184
- package/dist/routes/instances.js.map +1 -1
- package/dist/server.d.ts +6 -0
- package/dist/server.js +53 -20
- package/dist/server.js.map +1 -1
- package/dist/services/app-common/catalog-service.js +15 -5
- package/dist/services/app-common/catalog-service.js.map +1 -1
- package/dist/services/app-common/delete-service.js +5 -0
- package/dist/services/app-common/delete-service.js.map +1 -1
- package/dist/services/app-common/instance-store.js +3 -0
- package/dist/services/app-common/instance-store.js.map +1 -1
- package/dist/services/app-common/lifecycle-service.js +12 -4
- package/dist/services/app-common/lifecycle-service.js.map +1 -1
- package/dist/services/app-common/ownership.d.ts +3 -0
- package/dist/services/app-common/ownership.js +11 -0
- package/dist/services/app-common/ownership.js.map +1 -0
- package/dist/services/app-common/runtime-facts.js +2 -0
- package/dist/services/app-common/runtime-facts.js.map +1 -1
- package/dist/services/app-common/spec-materializer.d.ts +0 -1
- package/dist/services/app-common/spec-materializer.js +21 -87
- package/dist/services/app-common/spec-materializer.js.map +1 -1
- package/dist/services/app-common/status-refresh.js +25 -13
- package/dist/services/app-common/status-refresh.js.map +1 -1
- package/dist/services/app-modules/browserless/routes.js +5 -3
- package/dist/services/app-modules/browserless/routes.js.map +1 -1
- package/dist/services/capabilities/contract.d.ts +1 -2
- package/dist/services/capabilities/contract.js +0 -10
- package/dist/services/capabilities/contract.js.map +1 -1
- package/dist/services/capabilities/endpoint-validator.js +0 -1
- package/dist/services/capabilities/endpoint-validator.js.map +1 -1
- package/dist/services/capabilities/health.js +1 -1
- package/dist/services/capabilities/health.js.map +1 -1
- package/dist/services/capability-proxy/http.d.ts +7 -0
- package/dist/services/capability-proxy/http.js +555 -0
- package/dist/services/capability-proxy/http.js.map +1 -0
- package/dist/services/capability-proxy/terminal.d.ts +4 -0
- package/dist/services/capability-proxy/terminal.js +179 -0
- package/dist/services/capability-proxy/terminal.js.map +1 -0
- package/dist/services/connections/admin.js +19 -9
- package/dist/services/connections/admin.js.map +1 -1
- package/dist/services/connections/apply.d.ts +3 -9
- package/dist/services/connections/apply.js +0 -29
- package/dist/services/connections/apply.js.map +1 -1
- package/dist/services/connections/transactor.js +2 -2
- package/dist/services/connections/transactor.js.map +1 -1
- package/dist/services/files/bootstrap.d.ts +7 -0
- package/dist/services/files/bootstrap.js +16 -0
- package/dist/services/files/bootstrap.js.map +1 -0
- package/dist/services/files/photos/upload-page.d.ts +2 -0
- package/dist/services/files/photos/upload-page.js +248 -0
- package/dist/services/files/photos/upload-page.js.map +1 -0
- package/dist/services/files/photos/upload-store.d.ts +74 -0
- package/dist/services/files/photos/upload-store.js +432 -0
- package/dist/services/files/photos/upload-store.js.map +1 -0
- package/dist/services/http/proxy-utils.d.ts +7 -0
- package/dist/services/http/proxy-utils.js +29 -0
- package/dist/services/http/proxy-utils.js.map +1 -0
- package/dist/services/http/request-utils.d.ts +3 -0
- package/dist/services/http/request-utils.js +23 -0
- package/dist/services/http/request-utils.js.map +1 -0
- package/dist/services/instances/manager.d.ts +6 -5
- package/dist/services/instances/manager.js +45 -51
- package/dist/services/instances/manager.js.map +1 -1
- package/dist/services/instances/pairing.d.ts +17 -0
- package/dist/services/instances/pairing.js +53 -0
- package/dist/services/instances/pairing.js.map +1 -0
- package/dist/services/instances/status.d.ts +2 -0
- package/dist/services/instances/status.js +11 -0
- package/dist/services/instances/status.js.map +1 -0
- package/dist/services/integrations/hermes/integration.d.ts +1 -1
- package/dist/services/integrations/hermes/integration.js +7 -8
- package/dist/services/integrations/hermes/integration.js.map +1 -1
- package/dist/services/integrations/immich/client.d.ts +93 -0
- package/dist/services/integrations/immich/client.js +458 -0
- package/dist/services/integrations/immich/client.js.map +1 -0
- package/dist/services/integrations/immich/config.d.ts +15 -0
- package/dist/services/integrations/immich/config.js +178 -0
- package/dist/services/integrations/immich/config.js.map +1 -0
- package/dist/services/integrations/immich/discovery.d.ts +9 -0
- package/dist/services/integrations/immich/discovery.js +101 -0
- package/dist/services/integrations/immich/discovery.js.map +1 -0
- package/dist/services/integrations/immich/gallery-renderer.d.ts +5 -0
- package/dist/services/integrations/immich/gallery-renderer.js +150 -0
- package/dist/services/integrations/immich/gallery-renderer.js.map +1 -0
- package/dist/services/integrations/immich/immich-shim.d.ts +11 -0
- package/dist/services/integrations/immich/immich-shim.js +439 -0
- package/dist/services/integrations/immich/immich-shim.js.map +1 -0
- package/dist/services/integrations/immich/integration.d.ts +18 -0
- package/dist/services/integrations/immich/integration.js +64 -0
- package/dist/services/integrations/immich/integration.js.map +1 -0
- package/dist/services/integrations/immich/photo-library.d.ts +4 -0
- package/dist/services/integrations/immich/photo-library.js +63 -0
- package/dist/services/integrations/immich/photo-library.js.map +1 -0
- package/dist/services/integrations/immich/review-executor.d.ts +3 -0
- package/dist/services/integrations/immich/review-executor.js +41 -0
- package/dist/services/integrations/immich/review-executor.js.map +1 -0
- package/dist/services/integrations/immich/review-session-service.d.ts +27 -0
- package/dist/services/integrations/immich/review-session-service.js +206 -0
- package/dist/services/integrations/immich/review-session-service.js.map +1 -0
- package/dist/services/integrations/immich/review-store.d.ts +47 -0
- package/dist/services/integrations/immich/review-store.js +347 -0
- package/dist/services/integrations/immich/review-store.js.map +1 -0
- package/dist/services/integrations/immich/routes.d.ts +7 -0
- package/dist/services/integrations/immich/routes.js +363 -0
- package/dist/services/integrations/immich/routes.js.map +1 -0
- package/dist/services/integrations/immich/types.d.ts +186 -0
- package/dist/services/integrations/immich/types.js +2 -0
- package/dist/services/integrations/immich/types.js.map +1 -0
- package/dist/services/integrations/index.d.ts +1 -0
- package/dist/services/integrations/index.js +1 -0
- package/dist/services/integrations/index.js.map +1 -1
- package/dist/services/integrations/installable/installers/integration.js +113 -7
- package/dist/services/integrations/installable/installers/integration.js.map +1 -1
- package/dist/services/integrations/jishukb/integration.d.ts +3 -1
- package/dist/services/integrations/jishukb/integration.js +121 -10
- package/dist/services/integrations/jishukb/integration.js.map +1 -1
- package/dist/services/integrations/openclaw/integration.d.ts +21 -7
- package/dist/services/integrations/openclaw/integration.js +385 -158
- package/dist/services/integrations/openclaw/integration.js.map +1 -1
- package/dist/services/integrations/openclaw/jishukb-native-mcp.d.ts +58 -0
- package/dist/services/integrations/openclaw/jishukb-native-mcp.js +373 -0
- package/dist/services/integrations/openclaw/jishukb-native-mcp.js.map +1 -0
- package/dist/services/integrations/openclaw/jishukb-shim.d.ts +8 -4
- package/dist/services/integrations/openclaw/jishukb-shim.js +624 -17
- package/dist/services/integrations/openclaw/jishukb-shim.js.map +1 -1
- package/dist/services/integrations/openclaw/mcporter.d.ts +13 -0
- package/dist/services/integrations/openclaw/mcporter.js +31 -0
- package/dist/services/integrations/openclaw/mcporter.js.map +1 -1
- package/dist/services/integrations/openclaw/native-mcp.d.ts +48 -0
- package/dist/services/integrations/openclaw/native-mcp.js +125 -0
- package/dist/services/integrations/openclaw/native-mcp.js.map +1 -0
- package/dist/services/integrations/openclaw/routes.js +4 -1
- package/dist/services/integrations/openclaw/routes.js.map +1 -1
- package/dist/services/integrations/types.d.ts +5 -17
- package/dist/services/repair/runtime-repair.js +68 -1
- package/dist/services/repair/runtime-repair.js.map +1 -1
- package/dist/services/runtime/docker-network.d.ts +8 -0
- package/dist/services/runtime/docker-network.js +123 -0
- package/dist/services/runtime/docker-network.js.map +1 -0
- package/dist/services/runtime/driver-registry.d.ts +4 -0
- package/dist/services/runtime/driver-registry.js.map +1 -1
- package/dist/services/runtime/drivers/nomad.d.ts +1 -0
- package/dist/services/runtime/drivers/nomad.js +35 -5
- package/dist/services/runtime/drivers/nomad.js.map +1 -1
- package/dist/services/runtime/service-manager.d.ts +2 -0
- package/dist/services/runtime/service-manager.js +18 -0
- package/dist/services/runtime/service-manager.js.map +1 -0
- package/dist/services/runtime/types.d.ts +1 -0
- package/dist/services/runtime/workload-compiler.js +29 -4
- package/dist/services/runtime/workload-compiler.js.map +1 -1
- package/dist/services/setup/setup-manager.js +29 -73
- package/dist/services/setup/setup-manager.js.map +1 -1
- package/dist/services/system/runtime-ownership.d.ts +36 -0
- package/dist/services/system/runtime-ownership.js +250 -0
- package/dist/services/system/runtime-ownership.js.map +1 -0
- package/dist/services/system/system-reconciler.js +53 -0
- package/dist/services/system/system-reconciler.js.map +1 -1
- package/dist/types.d.ts +19 -3
- package/dist/utils/path-safety.js +1 -1
- package/dist/utils/service-user.d.ts +13 -0
- package/dist/utils/service-user.js +129 -0
- package/dist/utils/service-user.js.map +1 -0
- package/install/jishu-install.sh +0 -1
- package/node_modules/brace-expansion/dist/commonjs/index.js +24 -14
- package/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -1
- package/node_modules/brace-expansion/dist/esm/index.js +24 -14
- package/node_modules/brace-expansion/dist/esm/index.js.map +1 -1
- package/node_modules/brace-expansion/package.json +2 -2
- package/node_modules/fast-uri/index.js +1 -1
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/fast-uri/test/security.test.js +28 -0
- package/node_modules/fastify/SECURITY.md +1 -1
- package/node_modules/fastify/SPONSORS.md +6 -4
- package/node_modules/fastify/docs/Guides/Database.md +0 -28
- package/node_modules/fastify/docs/Guides/Ecosystem.md +13 -2
- package/node_modules/fastify/docs/Guides/Serverless.md +2 -2
- package/node_modules/fastify/docs/Guides/Write-Plugin.md +1 -1
- package/node_modules/fastify/docs/Reference/Encapsulation.md +27 -26
- package/node_modules/fastify/docs/Reference/Errors.md +10 -4
- package/node_modules/fastify/docs/Reference/HTTP2.md +10 -10
- package/node_modules/fastify/docs/Reference/Hooks.md +4 -4
- package/node_modules/fastify/docs/Reference/Index.md +14 -16
- package/node_modules/fastify/docs/Reference/LTS.md +12 -13
- package/node_modules/fastify/docs/Reference/Lifecycle.md +9 -8
- package/node_modules/fastify/docs/Reference/Logging.md +44 -39
- package/node_modules/fastify/docs/Reference/Middleware.md +21 -25
- package/node_modules/fastify/docs/Reference/Principles.md +2 -2
- package/node_modules/fastify/docs/Reference/Reply.md +6 -1
- package/node_modules/fastify/docs/Reference/Request.md +27 -16
- package/node_modules/fastify/docs/Reference/Routes.md +5 -2
- package/node_modules/fastify/docs/Reference/Server.md +31 -3
- package/node_modules/fastify/docs/Reference/Type-Providers.md +29 -5
- package/node_modules/fastify/docs/Reference/Validation-and-Serialization.md +15 -2
- package/node_modules/fastify/docs/Reference/Warnings.md +7 -6
- package/node_modules/fastify/eslint.config.js +7 -2
- package/node_modules/fastify/fastify.d.ts +8 -3
- package/node_modules/fastify/fastify.js +43 -14
- package/node_modules/fastify/lib/content-type-parser.js +13 -1
- package/node_modules/fastify/lib/decorate.js +11 -3
- package/node_modules/fastify/lib/error-handler.js +4 -3
- package/node_modules/fastify/lib/error-serializer.js +59 -59
- package/node_modules/fastify/lib/errors.js +16 -1
- package/node_modules/fastify/lib/four-oh-four.js +14 -9
- package/node_modules/fastify/lib/handle-request.js +11 -5
- package/node_modules/fastify/lib/plugin-override.js +2 -1
- package/node_modules/fastify/lib/plugin-utils.js +5 -5
- package/node_modules/fastify/lib/reply.js +63 -8
- package/node_modules/fastify/lib/request.js +14 -4
- package/node_modules/fastify/lib/route.js +20 -6
- package/node_modules/fastify/lib/schema-controller.js +1 -1
- package/node_modules/fastify/lib/schemas.js +37 -30
- package/node_modules/fastify/lib/symbols.js +3 -1
- package/node_modules/fastify/lib/validation.js +1 -13
- package/node_modules/fastify/lib/warnings.js +3 -3
- package/node_modules/fastify/package.json +13 -15
- package/node_modules/fastify/scripts/validate-ecosystem-links.js +1 -0
- package/node_modules/fastify/test/bundler/esbuild/package.json +1 -1
- package/node_modules/fastify/test/close-pipelining.test.js +1 -2
- package/node_modules/fastify/test/custom-http-server.test.js +38 -0
- package/node_modules/fastify/test/decorator-instance-properties.test.js +63 -0
- package/node_modules/fastify/test/diagnostics-channel/async-error-handler.test.js +74 -0
- package/node_modules/fastify/test/hooks.test.js +23 -0
- package/node_modules/fastify/test/http-methods/get.test.js +1 -1
- package/node_modules/fastify/test/http2/plain.test.js +135 -0
- package/node_modules/fastify/test/http2/secure-with-fallback.test.js +1 -1
- package/node_modules/fastify/test/https/https.test.js +1 -2
- package/node_modules/fastify/test/internals/errors.test.js +31 -1
- package/node_modules/fastify/test/internals/plugin.test.js +3 -1
- package/node_modules/fastify/test/internals/request.test.js +27 -3
- package/node_modules/fastify/test/internals/schema-controller-perf.test.js +33 -0
- package/node_modules/fastify/test/logger/logging.test.js +18 -1
- package/node_modules/fastify/test/logger/options.test.js +38 -1
- package/node_modules/fastify/test/reply-error.test.js +1 -1
- package/node_modules/fastify/test/reply-trailers.test.js +70 -0
- package/node_modules/fastify/test/request-media-type.test.js +105 -0
- package/node_modules/fastify/test/route-prefix.test.js +34 -0
- package/node_modules/fastify/test/router-options.test.js +222 -11
- package/node_modules/fastify/test/schema-serialization.test.js +108 -0
- package/node_modules/fastify/test/schema-validation.test.js +24 -0
- package/node_modules/fastify/test/scripts/validate-ecosystem-links.test.js +40 -57
- package/node_modules/fastify/test/throw.test.js +14 -0
- package/node_modules/fastify/test/trust-proxy.test.js +21 -0
- package/node_modules/fastify/test/types/content-type-parser.tst.ts +70 -0
- package/node_modules/fastify/test/types/{decorate-request-reply.test-d.ts → decorate-request-reply.tst.ts} +4 -4
- package/node_modules/fastify/test/types/{dummy-plugin.ts → dummy-plugin.mts} +1 -1
- package/node_modules/fastify/test/types/errors.tst.ts +91 -0
- package/node_modules/fastify/test/types/fastify.tst.ts +351 -0
- package/node_modules/fastify/test/types/hooks.tst.ts +578 -0
- package/node_modules/fastify/test/types/instance.tst.ts +597 -0
- package/node_modules/fastify/test/types/{logger.test-d.ts → logger.tst.ts} +61 -62
- package/node_modules/fastify/test/types/plugin.tst.ts +96 -0
- package/node_modules/fastify/test/types/register.tst.ts +245 -0
- package/node_modules/fastify/test/types/reply.tst.ts +297 -0
- package/node_modules/fastify/test/types/request.tst.ts +199 -0
- package/node_modules/fastify/test/types/route.tst.ts +576 -0
- package/node_modules/fastify/test/types/{schema.test-d.ts → schema.tst.ts} +22 -22
- package/node_modules/fastify/test/types/{serverFactory.test-d.ts → serverFactory.tst.ts} +4 -4
- package/node_modules/fastify/test/types/tsconfig.json +9 -0
- package/node_modules/fastify/test/types/{type-provider.test-d.ts → type-provider.tst.ts} +256 -250
- package/node_modules/fastify/test/types/using.tst.ts +14 -0
- package/node_modules/fastify/types/errors.d.ts +3 -0
- package/node_modules/fastify/types/request.d.ts +23 -2
- package/node_modules/jishushell-panel/output/public/assets/{ApiKeyField-NKcbHjNz.js → ApiKeyField-Ce5d1xna.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/{Dashboard-Da1fL38t.js → Dashboard-BXame3yg.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/{HermesChatPanel-DZvmYsoh.js → HermesChatPanel-BHZtPCJd.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/{HermesConfigForm-BLUWlKwm.js → HermesConfigForm-CB3GbNX9.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/{InitPassword-BAKsshzk.js → InitPassword-Boab9F6g.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/InstanceDetail-DrIWCqo-.js +14 -0
- package/node_modules/jishushell-panel/output/public/assets/{Login-DHeOmwI8.js → Login-CzpOkNau.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/NewInstance-CANXyCcL.js +1 -0
- package/node_modules/jishushell-panel/output/public/assets/{ProviderRecommendations-H0ByEYF0.js → ProviderRecommendations-BABo9VOC.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/Settings-CKp5XxFh.js +1 -0
- package/node_modules/jishushell-panel/output/public/assets/Setup-C7xVDPow.js +1 -0
- package/node_modules/jishushell-panel/output/public/assets/{WeixinLoginPanel-D-T6BxkQ.js → WeixinLoginPanel-B765Xz4C.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/{index-ERt6_ngA.js → index-Bs6DSbiR.js} +6 -6
- package/node_modules/jishushell-panel/output/public/assets/{registry-DF93EzIb.js → registry-sWIZsIEF.js} +2 -2
- package/node_modules/jishushell-panel/output/public/assets/{usePolling-DeoThIQn.js → usePolling-D4IDOQd_.js} +1 -1
- package/node_modules/jishushell-panel/output/public/assets/vendor-i18n-Df8aUdv8.js +1 -0
- package/node_modules/jishushell-panel/output/public/assets/{vendor-react-Cc84NArf.js → vendor-react-0L0rjmYG.js} +3 -3
- package/node_modules/jishushell-panel/output/public/index.html +3 -3
- package/node_modules/jishushell-panel/package.json +1 -1
- package/node_modules/semver/classes/range.js +6 -2
- package/node_modules/semver/package.json +1 -1
- package/package.json +4 -4
- package/scripts/check-app-spec.mjs +4 -12
- package/scripts/check-architecture-boundaries.mjs +178 -0
- package/scripts/pack-gui-and-send-pi.sh +5 -3
- package/dependencies/jishushell-panel-0.6.18.tgz +0 -0
- package/dist/services/connections/suggestions.d.ts +0 -27
- package/dist/services/connections/suggestions.js +0 -124
- package/dist/services/connections/suggestions.js.map +0 -1
- package/node_modules/fastify/test/types/content-type-parser.test-d.ts +0 -72
- package/node_modules/fastify/test/types/errors.test-d.ts +0 -90
- package/node_modules/fastify/test/types/fastify.test-d.ts +0 -352
- package/node_modules/fastify/test/types/hooks.test-d.ts +0 -550
- package/node_modules/fastify/test/types/import.ts +0 -2
- package/node_modules/fastify/test/types/instance.test-d.ts +0 -588
- package/node_modules/fastify/test/types/plugin.test-d.ts +0 -97
- package/node_modules/fastify/test/types/register.test-d.ts +0 -237
- package/node_modules/fastify/test/types/reply.test-d.ts +0 -254
- package/node_modules/fastify/test/types/request.test-d.ts +0 -188
- package/node_modules/fastify/test/types/route.test-d.ts +0 -553
- package/node_modules/fastify/test/types/using.test-d.ts +0 -17
- package/node_modules/jishushell-panel/output/public/assets/InstanceDetail-Dgyc_TX5.js +0 -14
- package/node_modules/jishushell-panel/output/public/assets/NewInstance-CIy0cYtp.js +0 -1
- package/node_modules/jishushell-panel/output/public/assets/Settings-DAT-UMfP.js +0 -1
- package/node_modules/jishushell-panel/output/public/assets/Setup-g3uckFYR.js +0 -1
- package/node_modules/jishushell-panel/output/public/assets/vendor-i18n-CS8DFbkQ.js +0 -1
|
@@ -6,6 +6,7 @@ const querystring = require('node:querystring')
|
|
|
6
6
|
const Fastify = require('../')
|
|
7
7
|
const {
|
|
8
8
|
FST_ERR_BAD_URL,
|
|
9
|
+
FST_ERR_MAX_PARAM_LENGTH,
|
|
9
10
|
FST_ERR_ASYNC_CONSTRAINT
|
|
10
11
|
} = require('../lib/errors')
|
|
11
12
|
|
|
@@ -84,7 +85,7 @@ test('Should honor maxParamLength option', async (t) => {
|
|
|
84
85
|
method: 'GET',
|
|
85
86
|
url: '/test/123456789abcd'
|
|
86
87
|
})
|
|
87
|
-
t.assert.strictEqual(resError.statusCode,
|
|
88
|
+
t.assert.strictEqual(resError.statusCode, 414)
|
|
88
89
|
})
|
|
89
90
|
|
|
90
91
|
test('Should expose router options via getters on request and reply', (t, done) => {
|
|
@@ -262,6 +263,130 @@ test('Should honor disableRequestLogging option in frameworkErrors wrapper - FST
|
|
|
262
263
|
)
|
|
263
264
|
})
|
|
264
265
|
|
|
266
|
+
test('Should honor frameworkErrors option - FST_ERR_MAX_PARAM_LENGTH', (t, done) => {
|
|
267
|
+
t.plan(3)
|
|
268
|
+
const fastify = Fastify({
|
|
269
|
+
maxParamLength: 1,
|
|
270
|
+
frameworkErrors: function (err, req, res) {
|
|
271
|
+
if (err instanceof FST_ERR_MAX_PARAM_LENGTH) {
|
|
272
|
+
t.assert.ok(true)
|
|
273
|
+
} else {
|
|
274
|
+
t.assert.fail()
|
|
275
|
+
}
|
|
276
|
+
res.send(`${err.message} - ${err.code}`)
|
|
277
|
+
}
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
fastify.get('/test/:id', (req, res) => {
|
|
281
|
+
res.send('{ hello: \'world\' }')
|
|
282
|
+
})
|
|
283
|
+
|
|
284
|
+
fastify.inject(
|
|
285
|
+
{
|
|
286
|
+
method: 'GET',
|
|
287
|
+
url: '/test/123'
|
|
288
|
+
},
|
|
289
|
+
(err, res) => {
|
|
290
|
+
t.assert.ifError(err)
|
|
291
|
+
t.assert.strictEqual(res.body, '\'/test/123\' is exceeding the max param length - FST_ERR_MAX_PARAM_LENGTH')
|
|
292
|
+
done()
|
|
293
|
+
}
|
|
294
|
+
)
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
test('Should supply Fastify request to the logger in frameworkErrors wrapper - FST_ERR_MAX_PARAM_LENGTH', (t, done) => {
|
|
298
|
+
t.plan(8)
|
|
299
|
+
|
|
300
|
+
const REQ_ID = 'REQ-1234'
|
|
301
|
+
const logStream = split(JSON.parse)
|
|
302
|
+
|
|
303
|
+
const fastify = Fastify({
|
|
304
|
+
maxParamLength: 1,
|
|
305
|
+
frameworkErrors: function (err, req, res) {
|
|
306
|
+
t.assert.deepStrictEqual(req.id, REQ_ID)
|
|
307
|
+
t.assert.deepStrictEqual(req.raw.httpVersion, '1.1')
|
|
308
|
+
res.send(`${err.message} - ${err.code}`)
|
|
309
|
+
},
|
|
310
|
+
logger: {
|
|
311
|
+
stream: logStream,
|
|
312
|
+
serializers: {
|
|
313
|
+
req (request) {
|
|
314
|
+
t.assert.deepStrictEqual(request.id, REQ_ID)
|
|
315
|
+
return { httpVersion: request.raw.httpVersion }
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
genReqId: () => REQ_ID
|
|
320
|
+
})
|
|
321
|
+
|
|
322
|
+
fastify.get('/test/:id', (req, res) => {
|
|
323
|
+
res.send('{ hello: \'world\' }')
|
|
324
|
+
})
|
|
325
|
+
|
|
326
|
+
logStream.on('data', (json) => {
|
|
327
|
+
t.assert.deepStrictEqual(json.msg, 'incoming request')
|
|
328
|
+
t.assert.deepStrictEqual(json.reqId, REQ_ID)
|
|
329
|
+
t.assert.deepStrictEqual(json.req.httpVersion, '1.1')
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
fastify.inject(
|
|
333
|
+
{
|
|
334
|
+
method: 'GET',
|
|
335
|
+
url: '/test/123'
|
|
336
|
+
},
|
|
337
|
+
(err, res) => {
|
|
338
|
+
t.assert.ifError(err)
|
|
339
|
+
t.assert.strictEqual(res.body, '\'/test/123\' is exceeding the max param length - FST_ERR_MAX_PARAM_LENGTH')
|
|
340
|
+
done()
|
|
341
|
+
}
|
|
342
|
+
)
|
|
343
|
+
})
|
|
344
|
+
|
|
345
|
+
test('Should honor disableRequestLogging option in frameworkErrors wrapper - FST_ERR_MAX_PARAM_LENGTH', (t, done) => {
|
|
346
|
+
t.plan(2)
|
|
347
|
+
|
|
348
|
+
const logStream = split(JSON.parse)
|
|
349
|
+
|
|
350
|
+
const fastify = Fastify({
|
|
351
|
+
disableRequestLogging: true,
|
|
352
|
+
maxParamLength: 1,
|
|
353
|
+
frameworkErrors: function (err, req, res) {
|
|
354
|
+
res.send(`${err.message} - ${err.code}`)
|
|
355
|
+
},
|
|
356
|
+
logger: {
|
|
357
|
+
stream: logStream,
|
|
358
|
+
serializers: {
|
|
359
|
+
req () {
|
|
360
|
+
t.assert.fail('should not be called')
|
|
361
|
+
},
|
|
362
|
+
res () {
|
|
363
|
+
t.assert.fail('should not be called')
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
})
|
|
368
|
+
|
|
369
|
+
fastify.get('/test/:id', (req, res) => {
|
|
370
|
+
res.send('{ hello: \'world\' }')
|
|
371
|
+
})
|
|
372
|
+
|
|
373
|
+
logStream.on('data', (json) => {
|
|
374
|
+
t.assert.fail('should not be called')
|
|
375
|
+
})
|
|
376
|
+
|
|
377
|
+
fastify.inject(
|
|
378
|
+
{
|
|
379
|
+
method: 'GET',
|
|
380
|
+
url: '/test/123'
|
|
381
|
+
},
|
|
382
|
+
(err, res) => {
|
|
383
|
+
t.assert.ifError(err)
|
|
384
|
+
t.assert.strictEqual(res.body, '\'/test/123\' is exceeding the max param length - FST_ERR_MAX_PARAM_LENGTH')
|
|
385
|
+
done()
|
|
386
|
+
}
|
|
387
|
+
)
|
|
388
|
+
})
|
|
389
|
+
|
|
265
390
|
test('Should honor frameworkErrors option - FST_ERR_ASYNC_CONSTRAINT', (t, done) => {
|
|
266
391
|
t.plan(3)
|
|
267
392
|
|
|
@@ -507,6 +632,67 @@ test('Should honor disableRequestLogging function in frameworkErrors wrapper - F
|
|
|
507
632
|
)
|
|
508
633
|
})
|
|
509
634
|
|
|
635
|
+
test('Should honor disableRequestLogging function in frameworkErrors wrapper - FST_ERR_MAX_PARAM_LENGTH', (t, done) => {
|
|
636
|
+
t.plan(4)
|
|
637
|
+
|
|
638
|
+
let logCallCount = 0
|
|
639
|
+
const logStream = split(JSON.parse)
|
|
640
|
+
|
|
641
|
+
const fastify = Fastify({
|
|
642
|
+
maxParamLength: 1,
|
|
643
|
+
disableRequestLogging: (req) => {
|
|
644
|
+
// Disable logging for URLs containing 'silent'
|
|
645
|
+
return req.url.includes('silent')
|
|
646
|
+
},
|
|
647
|
+
frameworkErrors: function (err, req, res) {
|
|
648
|
+
res.send(`${err.message} - ${err.code}`)
|
|
649
|
+
},
|
|
650
|
+
logger: {
|
|
651
|
+
stream: logStream,
|
|
652
|
+
level: 'info'
|
|
653
|
+
}
|
|
654
|
+
})
|
|
655
|
+
|
|
656
|
+
fastify.get('/test/:id', (req, res) => {
|
|
657
|
+
res.send('{ hello: \'world\' }')
|
|
658
|
+
})
|
|
659
|
+
|
|
660
|
+
logStream.on('data', (json) => {
|
|
661
|
+
if (json.msg === 'incoming request') {
|
|
662
|
+
logCallCount++
|
|
663
|
+
}
|
|
664
|
+
})
|
|
665
|
+
|
|
666
|
+
// First request: URL does not contain 'silent', so logging should happen
|
|
667
|
+
fastify.inject(
|
|
668
|
+
{
|
|
669
|
+
method: 'GET',
|
|
670
|
+
url: '/test/123'
|
|
671
|
+
},
|
|
672
|
+
(err, res) => {
|
|
673
|
+
t.assert.ifError(err)
|
|
674
|
+
t.assert.strictEqual(res.body, '\'/test/123\' is exceeding the max param length - FST_ERR_MAX_PARAM_LENGTH')
|
|
675
|
+
|
|
676
|
+
// Second request: URL contains 'silent', so logging should be disabled
|
|
677
|
+
fastify.inject(
|
|
678
|
+
{
|
|
679
|
+
method: 'GET',
|
|
680
|
+
url: '/silent/123'
|
|
681
|
+
},
|
|
682
|
+
(err2, res2) => {
|
|
683
|
+
t.assert.ifError(err2)
|
|
684
|
+
// Give time for any potential log events
|
|
685
|
+
setImmediate(() => {
|
|
686
|
+
// Only the first request should have logged
|
|
687
|
+
t.assert.strictEqual(logCallCount, 1)
|
|
688
|
+
done()
|
|
689
|
+
})
|
|
690
|
+
}
|
|
691
|
+
)
|
|
692
|
+
}
|
|
693
|
+
)
|
|
694
|
+
})
|
|
695
|
+
|
|
510
696
|
test('Should honor disableRequestLogging function in frameworkErrors wrapper - FST_ERR_ASYNC_CONSTRAINT', (t, done) => {
|
|
511
697
|
t.plan(4)
|
|
512
698
|
|
|
@@ -615,7 +801,7 @@ test('Should honor routerOptions.defaultRoute', async t => {
|
|
|
615
801
|
t.assert.strictEqual(res.payload, 'default route')
|
|
616
802
|
})
|
|
617
803
|
|
|
618
|
-
test('Should honor routerOptions.
|
|
804
|
+
test('Should honor routerOptions.onBadUrl', async t => {
|
|
619
805
|
t.plan(3)
|
|
620
806
|
const fastify = Fastify({
|
|
621
807
|
routerOptions: {
|
|
@@ -625,7 +811,7 @@ test('Should honor routerOptions.badUrl', async t => {
|
|
|
625
811
|
onBadUrl: function (path, _, res) {
|
|
626
812
|
t.assert.ok('bad url called')
|
|
627
813
|
res.statusCode = 400
|
|
628
|
-
res.end(`
|
|
814
|
+
res.end(`Bad URL: ${path}`)
|
|
629
815
|
}
|
|
630
816
|
}
|
|
631
817
|
})
|
|
@@ -636,7 +822,32 @@ test('Should honor routerOptions.badUrl', async t => {
|
|
|
636
822
|
|
|
637
823
|
const res = await fastify.inject('/hello/%world')
|
|
638
824
|
t.assert.strictEqual(res.statusCode, 400)
|
|
639
|
-
t.assert.strictEqual(res.payload, '
|
|
825
|
+
t.assert.strictEqual(res.payload, 'Bad URL: /hello/%world')
|
|
826
|
+
})
|
|
827
|
+
|
|
828
|
+
test('Should honor routerOptions.onMaxParamLength', async t => {
|
|
829
|
+
t.plan(3)
|
|
830
|
+
const fastify = Fastify({
|
|
831
|
+
routerOptions: {
|
|
832
|
+
defaultRoute: function (_, res) {
|
|
833
|
+
t.asset.fail('default route should not be called')
|
|
834
|
+
},
|
|
835
|
+
maxParamLength: 10,
|
|
836
|
+
onMaxParamLength: function (path, _, res) {
|
|
837
|
+
t.assert.ok('max param length called')
|
|
838
|
+
res.statusCode = 414
|
|
839
|
+
res.end(`URL: ${path}`)
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
})
|
|
843
|
+
|
|
844
|
+
fastify.get('/hello/:id', (req, res) => {
|
|
845
|
+
res.send({ hello: 'world' })
|
|
846
|
+
})
|
|
847
|
+
|
|
848
|
+
const res = await fastify.inject('/hello/12345678901')
|
|
849
|
+
t.assert.strictEqual(res.statusCode, 414)
|
|
850
|
+
t.assert.strictEqual(res.payload, 'URL: /hello/12345678901')
|
|
640
851
|
})
|
|
641
852
|
|
|
642
853
|
test('Should honor routerOptions.ignoreTrailingSlash', async t => {
|
|
@@ -727,7 +938,7 @@ test('Should honor routerOptions.maxParamLength', async (t) => {
|
|
|
727
938
|
method: 'GET',
|
|
728
939
|
url: '/test/123456789abcd'
|
|
729
940
|
})
|
|
730
|
-
t.assert.strictEqual(resError.statusCode,
|
|
941
|
+
t.assert.strictEqual(resError.statusCode, 414)
|
|
731
942
|
})
|
|
732
943
|
|
|
733
944
|
test('Should honor routerOptions.allowUnsafeRegex', async (t) => {
|
|
@@ -854,11 +1065,11 @@ test('Should honor routerOptions.buildPrettyMeta', async (t) => {
|
|
|
854
1065
|
}
|
|
855
1066
|
})
|
|
856
1067
|
|
|
857
|
-
fastify.get('/test', () => {})
|
|
858
|
-
fastify.get('/test/hello', () => {})
|
|
859
|
-
fastify.get('/testing', () => {})
|
|
860
|
-
fastify.get('/testing/:param', () => {})
|
|
861
|
-
fastify.put('/update', () => {})
|
|
1068
|
+
fastify.get('/test', () => { })
|
|
1069
|
+
fastify.get('/test/hello', () => { })
|
|
1070
|
+
fastify.get('/testing', () => { })
|
|
1071
|
+
fastify.get('/testing/:param', () => { })
|
|
1072
|
+
fastify.put('/update', () => { })
|
|
862
1073
|
|
|
863
1074
|
await fastify.ready()
|
|
864
1075
|
|
|
@@ -928,7 +1139,7 @@ test('Should honor routerOptions.maxParamLength over maxParamLength option', asy
|
|
|
928
1139
|
method: 'GET',
|
|
929
1140
|
url: '/test/123456789abcd'
|
|
930
1141
|
})
|
|
931
|
-
t.assert.strictEqual(resError.statusCode,
|
|
1142
|
+
t.assert.strictEqual(resError.statusCode, 414)
|
|
932
1143
|
})
|
|
933
1144
|
|
|
934
1145
|
test('Should honor routerOptions.allowUnsafeRegex over allowUnsafeRegex option', async (t) => {
|
|
@@ -1169,3 +1169,111 @@ test('allow default as status code and used as last fallback', (t, testDone) =>
|
|
|
1169
1169
|
testDone()
|
|
1170
1170
|
})
|
|
1171
1171
|
})
|
|
1172
|
+
|
|
1173
|
+
test('response schema is applied when Content-Type has whitespace before parameters', (t, testDone) => {
|
|
1174
|
+
t.plan(3)
|
|
1175
|
+
|
|
1176
|
+
const fastify = Fastify()
|
|
1177
|
+
fastify.get('/', {
|
|
1178
|
+
schema: {
|
|
1179
|
+
response: {
|
|
1180
|
+
200: {
|
|
1181
|
+
content: {
|
|
1182
|
+
'application/json': {
|
|
1183
|
+
schema: {
|
|
1184
|
+
type: 'object',
|
|
1185
|
+
required: ['public'],
|
|
1186
|
+
additionalProperties: false,
|
|
1187
|
+
properties: {
|
|
1188
|
+
public: { type: 'string' }
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
}, function (req, reply) {
|
|
1197
|
+
reply.header('Content-Type', 'application/json ; charset=utf-8')
|
|
1198
|
+
reply.send({ public: 'ok', secret: 'SHOULD_BE_STRIPPED' })
|
|
1199
|
+
})
|
|
1200
|
+
|
|
1201
|
+
fastify.inject('/', (err, res) => {
|
|
1202
|
+
t.assert.ifError(err)
|
|
1203
|
+
t.assert.strictEqual(res.statusCode, 200)
|
|
1204
|
+
t.assert.deepStrictEqual(res.json(), { public: 'ok' })
|
|
1205
|
+
testDone()
|
|
1206
|
+
})
|
|
1207
|
+
})
|
|
1208
|
+
|
|
1209
|
+
test('response schema is applied when Content-Type has tab before semicolon', (t, testDone) => {
|
|
1210
|
+
t.plan(3)
|
|
1211
|
+
|
|
1212
|
+
const fastify = Fastify()
|
|
1213
|
+
fastify.get('/', {
|
|
1214
|
+
schema: {
|
|
1215
|
+
response: {
|
|
1216
|
+
200: {
|
|
1217
|
+
content: {
|
|
1218
|
+
'application/json': {
|
|
1219
|
+
schema: {
|
|
1220
|
+
type: 'object',
|
|
1221
|
+
required: ['public'],
|
|
1222
|
+
additionalProperties: false,
|
|
1223
|
+
properties: {
|
|
1224
|
+
public: { type: 'string' }
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
}, function (req, reply) {
|
|
1233
|
+
reply.header('Content-Type', 'application/json\t; charset=utf-8')
|
|
1234
|
+
reply.send({ public: 'ok', secret: 'SHOULD_BE_STRIPPED' })
|
|
1235
|
+
})
|
|
1236
|
+
|
|
1237
|
+
fastify.inject('/', (err, res) => {
|
|
1238
|
+
t.assert.ifError(err)
|
|
1239
|
+
t.assert.strictEqual(res.statusCode, 200)
|
|
1240
|
+
t.assert.deepStrictEqual(res.json(), { public: 'ok' })
|
|
1241
|
+
testDone()
|
|
1242
|
+
})
|
|
1243
|
+
})
|
|
1244
|
+
|
|
1245
|
+
test('response schema is applied when Content-Type has trailing semicolon only', (t, testDone) => {
|
|
1246
|
+
t.plan(3)
|
|
1247
|
+
|
|
1248
|
+
const fastify = Fastify()
|
|
1249
|
+
fastify.get('/', {
|
|
1250
|
+
schema: {
|
|
1251
|
+
response: {
|
|
1252
|
+
200: {
|
|
1253
|
+
content: {
|
|
1254
|
+
'application/json': {
|
|
1255
|
+
schema: {
|
|
1256
|
+
type: 'object',
|
|
1257
|
+
required: ['public'],
|
|
1258
|
+
additionalProperties: false,
|
|
1259
|
+
properties: {
|
|
1260
|
+
public: { type: 'string' }
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
}, function (req, reply) {
|
|
1269
|
+
reply.header('Content-Type', 'application/json ;')
|
|
1270
|
+
reply.send({ public: 'ok', secret: 'SHOULD_BE_STRIPPED' })
|
|
1271
|
+
})
|
|
1272
|
+
|
|
1273
|
+
fastify.inject('/', (err, res) => {
|
|
1274
|
+
t.assert.ifError(err)
|
|
1275
|
+
t.assert.strictEqual(res.statusCode, 200)
|
|
1276
|
+
t.assert.deepStrictEqual(res.json(), { public: 'ok' })
|
|
1277
|
+
testDone()
|
|
1278
|
+
})
|
|
1279
|
+
})
|
|
@@ -6,6 +6,7 @@ const Fastify = require('..')
|
|
|
6
6
|
const AJV = require('ajv')
|
|
7
7
|
const Schema = require('fluent-json-schema')
|
|
8
8
|
const { waitForCb } = require('./toolkit')
|
|
9
|
+
const { kRequestContentType } = require('../lib/symbols')
|
|
9
10
|
|
|
10
11
|
const customSchemaCompilers = {
|
|
11
12
|
body: new AJV({
|
|
@@ -1374,6 +1375,7 @@ test('Schema validation when no content type is provided', async t => {
|
|
|
1374
1375
|
},
|
|
1375
1376
|
preValidation: async (request) => {
|
|
1376
1377
|
request.headers['content-type'] = undefined
|
|
1378
|
+
request[kRequestContentType] = undefined
|
|
1377
1379
|
}
|
|
1378
1380
|
}, async () => 'ok')
|
|
1379
1381
|
|
|
@@ -1591,3 +1593,25 @@ test('Schema validation will not be bypass by different content type', async t =
|
|
|
1591
1593
|
t.assert.strictEqual(found.status, 415)
|
|
1592
1594
|
t.assert.strictEqual((await found.json()).code, 'FST_ERR_CTP_INVALID_MEDIA_TYPE')
|
|
1593
1595
|
})
|
|
1596
|
+
test('coercion of empty string to null with nullable types', async t => {
|
|
1597
|
+
const assert = require('node:assert')
|
|
1598
|
+
const fastify = Fastify()
|
|
1599
|
+
fastify.get('/', {
|
|
1600
|
+
schema: {
|
|
1601
|
+
querystring: {
|
|
1602
|
+
type: 'object',
|
|
1603
|
+
properties: {
|
|
1604
|
+
param: { type: ['integer', 'null'] }
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
}, async (req, reply) => {
|
|
1609
|
+
return { param: req.query.param }
|
|
1610
|
+
})
|
|
1611
|
+
|
|
1612
|
+
const res = await fastify.inject({
|
|
1613
|
+
method: 'GET',
|
|
1614
|
+
url: '/?param='
|
|
1615
|
+
})
|
|
1616
|
+
assert.strictEqual(JSON.parse(res.payload).param, null)
|
|
1617
|
+
})
|
|
@@ -127,7 +127,6 @@ Some description [inline link](https://github.com/a/b).
|
|
|
127
127
|
describe('checkGitHubRepo', () => {
|
|
128
128
|
let originalDispatcher
|
|
129
129
|
let mockAgent
|
|
130
|
-
let originalFetch
|
|
131
130
|
let originalSetTimeout
|
|
132
131
|
|
|
133
132
|
beforeEach(() => {
|
|
@@ -136,12 +135,10 @@ describe('checkGitHubRepo', () => {
|
|
|
136
135
|
mockAgent = new MockAgent()
|
|
137
136
|
mockAgent.disableNetConnect()
|
|
138
137
|
setGlobalDispatcher(mockAgent)
|
|
139
|
-
originalFetch = global.fetch
|
|
140
138
|
originalSetTimeout = global.setTimeout
|
|
141
139
|
})
|
|
142
140
|
|
|
143
141
|
afterEach(async () => {
|
|
144
|
-
global.fetch = originalFetch
|
|
145
142
|
global.setTimeout = originalSetTimeout
|
|
146
143
|
setGlobalDispatcher(originalDispatcher)
|
|
147
144
|
await mockAgent.close()
|
|
@@ -180,16 +177,9 @@ describe('checkGitHubRepo', () => {
|
|
|
180
177
|
|
|
181
178
|
it('returns invalid status for malformed owner or repository names', async () => {
|
|
182
179
|
const { checkGitHubRepo } = loadValidateEcosystemLinksModule()
|
|
183
|
-
let called = false
|
|
184
|
-
|
|
185
|
-
global.fetch = async () => {
|
|
186
|
-
called = true
|
|
187
|
-
return { status: 200 }
|
|
188
|
-
}
|
|
189
180
|
|
|
190
181
|
const result = await checkGitHubRepo('owner/evil', 'repo', 1)
|
|
191
182
|
|
|
192
|
-
assert.strictEqual(called, false)
|
|
193
183
|
assert.strictEqual(result.exists, false)
|
|
194
184
|
assert.strictEqual(result.status, 'invalid')
|
|
195
185
|
assert.strictEqual(result.error, 'Invalid GitHub repository identifier')
|
|
@@ -199,17 +189,17 @@ describe('checkGitHubRepo', () => {
|
|
|
199
189
|
const { checkGitHubRepo } = loadValidateEcosystemLinksModule()
|
|
200
190
|
let attempts = 0
|
|
201
191
|
|
|
202
|
-
global.setTimeout = (fn) => {
|
|
203
|
-
fn()
|
|
204
|
-
return 0
|
|
205
|
-
}
|
|
192
|
+
global.setTimeout = (fn) => { fn(); return 0 }
|
|
206
193
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
194
|
+
const mockPool = mockAgent.get('https://api.github.com')
|
|
195
|
+
mockPool.intercept({
|
|
196
|
+
path: '/repos/owner/repo',
|
|
197
|
+
method: 'HEAD'
|
|
198
|
+
}).reply(() => { attempts++; return { statusCode: 403 } })
|
|
199
|
+
mockPool.intercept({
|
|
200
|
+
path: '/repos/owner/repo',
|
|
201
|
+
method: 'HEAD'
|
|
202
|
+
}).reply(() => { attempts++; return { statusCode: 200 } })
|
|
213
203
|
|
|
214
204
|
const result = await checkGitHubRepo('owner', 'repo', 1)
|
|
215
205
|
|
|
@@ -221,23 +211,25 @@ describe('checkGitHubRepo', () => {
|
|
|
221
211
|
it('adds authorization header when GITHUB_TOKEN is set', async () => {
|
|
222
212
|
process.env.GITHUB_TOKEN = 'my-token'
|
|
223
213
|
const { checkGitHubRepo } = loadValidateEcosystemLinksModule()
|
|
224
|
-
let authorization
|
|
225
214
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
215
|
+
const mockPool = mockAgent.get('https://api.github.com')
|
|
216
|
+
mockPool.intercept({
|
|
217
|
+
path: '/repos/owner/repo',
|
|
218
|
+
method: 'HEAD',
|
|
219
|
+
headers: {
|
|
220
|
+
authorization: 'token my-token'
|
|
230
221
|
}
|
|
231
|
-
}
|
|
222
|
+
}).reply(200)
|
|
232
223
|
|
|
233
224
|
const result = await checkGitHubRepo('owner', 'repo')
|
|
234
225
|
|
|
235
|
-
assert.strictEqual(authorization, 'token my-token')
|
|
236
226
|
assert.strictEqual(result.exists, true)
|
|
227
|
+
assert.strictEqual(result.status, 200)
|
|
237
228
|
})
|
|
238
229
|
|
|
239
230
|
it('handles network errors', async () => {
|
|
240
231
|
const { checkGitHubRepo } = loadValidateEcosystemLinksModule()
|
|
232
|
+
|
|
241
233
|
const mockPool = mockAgent.get('https://api.github.com')
|
|
242
234
|
mockPool.intercept({
|
|
243
235
|
path: '/repos/owner/repo',
|
|
@@ -254,37 +246,41 @@ describe('checkGitHubRepo', () => {
|
|
|
254
246
|
|
|
255
247
|
describe('validateAllLinks', () => {
|
|
256
248
|
let originalReadFileSync
|
|
257
|
-
let originalFetch
|
|
258
249
|
let originalSetTimeout
|
|
259
250
|
let originalConsoleLog
|
|
260
251
|
let originalStdoutWrite
|
|
252
|
+
let mockAgent
|
|
253
|
+
let originalDispatcher
|
|
261
254
|
|
|
262
255
|
beforeEach(() => {
|
|
263
256
|
originalReadFileSync = fs.readFileSync
|
|
264
|
-
originalFetch = global.fetch
|
|
265
257
|
originalSetTimeout = global.setTimeout
|
|
266
258
|
originalConsoleLog = console.log
|
|
267
259
|
originalStdoutWrite = process.stdout.write
|
|
260
|
+
originalDispatcher = getGlobalDispatcher()
|
|
261
|
+
|
|
262
|
+
mockAgent = new MockAgent()
|
|
263
|
+
mockAgent.disableNetConnect()
|
|
264
|
+
setGlobalDispatcher(mockAgent)
|
|
268
265
|
|
|
269
266
|
console.log = () => {}
|
|
270
267
|
process.stdout.write = () => true
|
|
271
268
|
|
|
272
|
-
global.setTimeout = (fn) => {
|
|
273
|
-
fn()
|
|
274
|
-
return 0
|
|
275
|
-
}
|
|
269
|
+
global.setTimeout = (fn) => { fn(); return 0 }
|
|
276
270
|
})
|
|
277
271
|
|
|
278
|
-
afterEach(() => {
|
|
272
|
+
afterEach(async () => {
|
|
279
273
|
fs.readFileSync = originalReadFileSync
|
|
280
|
-
global.fetch = originalFetch
|
|
281
274
|
global.setTimeout = originalSetTimeout
|
|
282
275
|
console.log = originalConsoleLog
|
|
283
276
|
process.stdout.write = originalStdoutWrite
|
|
277
|
+
setGlobalDispatcher(originalDispatcher)
|
|
278
|
+
await mockAgent.close()
|
|
284
279
|
})
|
|
285
280
|
|
|
286
281
|
it('validates links, deduplicates repositories and groups inaccessible links', async () => {
|
|
287
282
|
const { validateAllLinks } = loadValidateEcosystemLinksModule()
|
|
283
|
+
let requests = 0
|
|
288
284
|
|
|
289
285
|
fs.readFileSync = () => `
|
|
290
286
|
- [repo one](https://github.com/owner/repo)
|
|
@@ -292,21 +288,15 @@ describe('validateAllLinks', () => {
|
|
|
292
288
|
- [repo two](https://github.com/another/project)
|
|
293
289
|
`
|
|
294
290
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
if (pathname === '/repos/another/project') {
|
|
305
|
-
return { status: 200 }
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
throw new Error(`Unexpected url: ${url}`)
|
|
309
|
-
}
|
|
291
|
+
const mockPool = mockAgent.get('https://api.github.com')
|
|
292
|
+
mockPool.intercept({
|
|
293
|
+
path: '/repos/owner/repo',
|
|
294
|
+
method: 'HEAD'
|
|
295
|
+
}).reply(() => { requests++; return { statusCode: 404 } })
|
|
296
|
+
mockPool.intercept({
|
|
297
|
+
path: '/repos/another/project',
|
|
298
|
+
method: 'HEAD'
|
|
299
|
+
}).reply(() => { requests++; return { statusCode: 200 } })
|
|
310
300
|
|
|
311
301
|
const result = await validateAllLinks()
|
|
312
302
|
|
|
@@ -324,15 +314,8 @@ describe('validateAllLinks', () => {
|
|
|
324
314
|
|
|
325
315
|
fs.readFileSync = () => '# Ecosystem\nNo links here.'
|
|
326
316
|
|
|
327
|
-
let requests = 0
|
|
328
|
-
global.fetch = async () => {
|
|
329
|
-
requests++
|
|
330
|
-
return { status: 200 }
|
|
331
|
-
}
|
|
332
|
-
|
|
333
317
|
const result = await validateAllLinks()
|
|
334
318
|
|
|
335
|
-
assert.strictEqual(requests, 0)
|
|
336
319
|
assert.strictEqual(result.notFound.length, 0)
|
|
337
320
|
assert.strictEqual(result.found.length, 0)
|
|
338
321
|
})
|
|
@@ -28,6 +28,20 @@ test('Fastify should throw on multiple assignment to the same route', (t) => {
|
|
|
28
28
|
}
|
|
29
29
|
})
|
|
30
30
|
|
|
31
|
+
test('Fastify should throw on multiple assignment to the same route with array method', (t) => {
|
|
32
|
+
t.plan(1)
|
|
33
|
+
const fastify = Fastify()
|
|
34
|
+
|
|
35
|
+
fastify.route({ method: ['GET', 'POST'], url: '/', handler: () => {} })
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
fastify.route({ method: ['GET', 'POST'], url: '/', handler: () => {} })
|
|
39
|
+
t.assert.fail('Should throw fastify duplicated route declaration')
|
|
40
|
+
} catch (error) {
|
|
41
|
+
t.assert.strictEqual(error.code, 'FST_ERR_DUPLICATED_ROUTE')
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
|
|
31
45
|
test('Fastify should throw for an invalid schema, printing the error route - headers', async (t) => {
|
|
32
46
|
t.plan(1)
|
|
33
47
|
|
|
@@ -272,3 +272,24 @@ test('trust proxy with number and null socket remoteAddress', t => {
|
|
|
272
272
|
t.assert.ok(request.ip, 'ip is defined')
|
|
273
273
|
t.assert.strictEqual(request.ip, '1.1.1.1', 'gets ip from x-forwarded-for')
|
|
274
274
|
})
|
|
275
|
+
|
|
276
|
+
test('trust proxy does not trust x-forwarded-host/proto when socket is null', t => {
|
|
277
|
+
t.plan(2)
|
|
278
|
+
|
|
279
|
+
const headers = {
|
|
280
|
+
host: 'real.test',
|
|
281
|
+
'x-forwarded-host': 'spoofed.test',
|
|
282
|
+
'x-forwarded-proto': 'https'
|
|
283
|
+
}
|
|
284
|
+
const req = {
|
|
285
|
+
method: 'GET',
|
|
286
|
+
url: '/',
|
|
287
|
+
socket: null,
|
|
288
|
+
headers
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const TpRequest = buildRequest(Request, true)
|
|
292
|
+
const request = new TpRequest('id', 'params', req, 'query', 'log')
|
|
293
|
+
t.assert.strictEqual(request.host, 'real.test', 'falls back to host header')
|
|
294
|
+
t.assert.strictEqual(request.protocol, undefined, 'does not trust x-forwarded-proto')
|
|
295
|
+
})
|