Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to enable AppendGuidToSavedMappingFile when proxying multiple endpoints? #1149

Open
SergVro opened this issue Jul 29, 2024 · 2 comments
Open
Assignees
Labels

Comments

@SergVro
Copy link

SergVro commented Jul 29, 2024

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?

@StefH StefH self-assigned this Jul 29, 2024
@StefH
Copy link
Collaborator

StefH commented Jul 29, 2024

Can you confirm that the files are saved when using local proxy?

@SergVro
Copy link
Author

SergVro commented Jul 30, 2024

Can you confirm that the files are saved when using local proxy?

Yes, new mapping files are created. Both SaveMapping and SaveMappingToFile are respected when set in the .WithProxy call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants