wiremock / wiremock/WireMock.Net

How to enable AppendGuidToSavedMappingFile when proxying multiple endpoints?

Open
#1,149 4 comments 0 reactions 1 assignee View on GitHub

@StefH is already working on this.

Since Jul 29, 2024.

question
Dominant language
C#
Stars
1.7k
Forks
240
Avg merge
5d 12h
Merged PRs (30d)
2

Description

I have a setup where I have a range of static mapping files for multiple endpoints. I also have proxy configuration for multiple services with lower priority to intercept the calls not matched by static mapping. My goal is to have a setup where calls not matched with static mapping files, are proxied to original service and a new mapping file for that call is stored under __admin/mappings. This kind of works, but files get overwritten if similar requests are issued. I found the AppendGuidToSavedMappingFile setting, but it does not seem to work in a "local" proxy configs like:

          server.Given(Request.Create().WithPath("/auth/token"))
            .AtPriority(1000)
            .RespondWith(
                Response.Create()
                    .WithProxy(
                        new ProxyAndRecordSettings
                        {
                            Url = "https://auto-generate-jwt.stg.se",
                            SaveMapping = true,
                            SaveMappingToFile = true,
                            AppendGuidToSavedMappingFile = true, // <-- this does not give any effect
                        }
                    )
            );

        server.Given(Request.Create().WithPath("/api/keys"))
            .AtPriority(1000)
            .RespondWith(
                Response.Create()
                    .WithProxy(
                        new ProxyAndRecordSettings
                        {
                            Url = "https://jwks.dev.se",
                            SaveMapping = true,
                            SaveMappingToFile = true,
                            AppendGuidToSavedMappingFile = true, // <-- this does not give any effect
                        })
            );

I tried the AppendGuidToSavedMappingFile with a "global" proxy config in WireMockServerSettings.ProxyAndRecordSettings and then it works, but that requires specifying proxy Url which overrides the proxy Url specified in the mapping configuration. Any tips on how to achieve proxying to multiple URLs plus AppendGuidToSavedMappingFile?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.