Skip to content

HandlebarsSettings AllowedHandlebarsHelpers Configuration Not Applied #1415

@samlatham

Description

@samlatham

Describe the bug

This bug has been raised to address a question raised here #1410. I think have a fix but I'm currently unable to push my bugfix branch.

The HandlebarsSettings.AllowedHandlebarsHelpers configuration is ignored when trying to enable the Environment helper as documented here
https://github.com/wiremock/WireMock.Net?tab=readme-ov-file#handlebarsnet-environment-helper

Expected behavior:

When explicitly configuring AllowedHandlebarsHelpers those categories should be enabled:

e.g. this argument should enable the Environment helper

--AllowedHandlebarsHelpers Environment

Test to reproduce

This has been test in dokcer compose

  1. creating the service and supply the AllowedHandlebarsHelpers settings
image: sheyenrath/wiremock.net-alpine:latest
    container_name: wiremock-net-test
    ports:
      - "8080:8080"

    command:
      dotnet wiremock-net.dll
      --Urls http://*:8080
      --ReadStaticMappings true
      --WatchStaticMappings true
      --WatchStaticMappingsInSubdirectories true
      --WireMockLogger WireMockConsoleLogger
      --AllowedHandlebarsHelpers Environment
      --Port 8080
  1. Creating a mapping with a handlerbars transform
{
  "Request": {
    "Path": "/test-env",
    "Methods": ["GET"]
  },
  "Response": {
    "StatusCode": 200,
    "Body": "{{Environment.GetEnvironmentVariable \"PATH\"}}",
    "Headers": {
      "Content-Type": "text/plain"
    },
    "UseTransformer": true,
    "TransformerType": "Handlebars"
  }
}
  1. Call the mapping and see the error

{"Status":"Template references a helper that cannot be resolved. Helper 'Environment.GetEnvironmentVariable'"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions