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 load 'ProxyAndRecordSettings' from 'appsettings.json' ? #735

Closed
PrzemekScott opened this issue Mar 9, 2022 · 13 comments
Closed

How to load 'ProxyAndRecordSettings' from 'appsettings.json' ? #735

PrzemekScott opened this issue Mar 9, 2022 · 13 comments
Labels

Comments

@PrzemekScott
Copy link

PrzemekScott commented Mar 9, 2022

I've experimented with WM stand alone version locally, with such settings:

image

Now wanted to experiment with WM as web app and then set it on Azure, but not sure how to implement 'ProxyAndRecordSetting' in appsettings file. When I have it like below:
image

I'm getting such error:

System.InvalidOperationException: Cannot create instance of type 'WireMock.Settings.IProxyAndRecordSettings' because it is either abstract or an interface.

The way I run WM with configuration is from one of 'examples projects' :
image

thx

@StefH
Copy link
Collaborator

StefH commented Mar 9, 2022

@PrzemekScott
I don't think this is possible.

I'll investigate why I decided to use an interface instead of a class, and see if I can remove the interface.

@PrzemekScott
Copy link
Author

I see.
Is then any other way to run WM on Azure in "proxying mode" (when needed - less often) and in "matching mode" (when needed - most of the time) ?

@StefH
Copy link
Collaborator

StefH commented Mar 9, 2022

Only workaround for now is to split the settings in two sections:

"WireMockServerSettings": {
},
"ProxyAndRecordSettings": {
}

And then do two calls:

  1. GetSection as you have now on WireMockServerSettings
  2. GetSection on ProxyAndRecordSettings
  3. Combine the outcome from step 2 in the resolved object from step 1

@StefH
Copy link
Collaborator

StefH commented Mar 9, 2022

@PrzemekScott

I've created a preview version which only has classes for settings; no interfaces anymore.

Preview version = 1.4.37-ci-15956.

See https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions

#736

@PrzemekScott
Copy link
Author

Thanks @StefH. Will give it a try.

@PrzemekScott
Copy link
Author

@StefH ,
Thanks for that change. It works well, starting server with all settings from the appsettings.json file"

image

Yet, there is one thing which I do not understand.
When I Run the App - I'm using JB Rider as my IDE - in next several seconds the browser is opened with this url as below:

image

@StefH
Copy link
Collaborator

StefH commented Mar 10, 2022

Can you provide your full project?

@PrzemekScott
Copy link
Author

Unfortunately @StefH, I've started WM project as a POC under one of test automation projects in my organisation and all of such projects are set as 'Internal', it is also bonded with our internal tools, accesses, so, unfortunately I can't share it.

What we’ve checked is that colleagues working with Visual Studio IDE are not facing this “action” of opening browser when ‘Program’ is run - it's only happening when "Program" is run in my JB Rider (on macOS).

image

image

@StefH
Copy link
Collaborator

StefH commented Mar 10, 2022

Can you share your appsettings.json and the startup code?

From that I can try to reproduce it

@PrzemekScott
Copy link
Author

Sure I can share files.
Archive.zip

@StefH
Copy link
Collaborator

StefH commented Mar 11, 2022

When running as:
image

It just works fine?
image

@PrzemekScott
Copy link
Author

So as it also did for my colleagues using Visual Studio. I will try to contact Jet Brain and as for some support. Maybe, just an assumption, that when JB Rider is Run(ning) web app type App, it opens it on some predefined port. But I couldn't find it in settings.

Anyway, thank you StefH for help and changing interface to class in appsettings. I think we can consider this Question as closed.

@PrzemekScott
Copy link
Author

PrzemekScott commented Mar 11, 2022

;) actually I've just found it in launchSettings:

image

image

launchSettings json

@StefH StefH closed this as completed Mar 11, 2022
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