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

Feature: Support running WireMock.Net as a sub-app in IIS #158

Closed
DavidKorn opened this issue Jun 27, 2018 · 12 comments
Closed

Feature: Support running WireMock.Net as a sub-app in IIS #158

DavidKorn opened this issue Jun 27, 2018 · 12 comments
Labels

Comments

@DavidKorn
Copy link
Collaborator

Is there an easy way to stand up WireMock.Net as a web app hosted on an internal IIS server? Our build & test pipeline pushes web apps to our various test environments, and it would make life a lot easier to deploy WireMock to those test environments in the same way. The goal would be to be able to hit http://staging.ourCo.com/mock/whatever and have WireMock generate the response to the /whatever path.

Meanwhile http://staging.ourCo.com/fancyapp would be a different site on the same IIS.

@StefH
Copy link
Collaborator

StefH commented Jun 28, 2018

You can host WireMock.Net as a web-api, this is described at https://github.com/WireMock-Net/WireMock.Net/wiki/WireMock-as-a-(Azure)-Web-App.

Does this help you?

@StefH StefH added the question label Jun 28, 2018
@DavidKorn
Copy link
Collaborator Author

@StefH Thanks for the pointer! I really appreciate all the samples. I had had some circumstantial issues early on that led me astray, but that sample works for me in IIS once I got my kinks worked out.

I still have one related kink: I'm hosting WireMock as a sub app on IIS, but the sub app base directory is still prepending to the request and throwing off the matching. For example, the sub app is in /mock, and if I hit http://localhost/mock/__admin/settings, the request being matched is still /mock/__admin/settings rather than /__admin/settings. I haven't yet tracked this down in the code, but I'm wondering if there is just some setting I need to set?

@StefH
Copy link
Collaborator

StefH commented Jul 1, 2018

Currently it seems that WireMock.Net does not yet support running in a sub-app in IIS. The easiest solution would be that the sub-app folder name would be configured using the FluentMockServerSettings.

I'll take a look if I can build that.

Edit...
Actually the solution should cover two scenarios:

  1. When running in IIS, it should be possible to define the sub-app folder, in order to determine the correct starting point in the path.
  2. When running normally, it should also be possible to define a sub-app folder, so that it can run at /test1 and also at /test2. However I'm not 100% this will work.

StefH added a commit that referenced this issue Jul 1, 2018
@StefH StefH changed the title How to host WireMock.Net as an internal web app? How to host WireMock.Net on IIS in a sub-app? Jul 1, 2018
@StefH
Copy link
Collaborator

StefH commented Jul 1, 2018

Hello @DavidKorn ,

You can review branch https://github.com/WireMock-Net/WireMock.Net/tree/iis_fix which includes the fix + updated example.

And I've created a preview NuGet, please test this and give me feedback.
https://www.nuget.org/packages/WireMock.Net.StandAlone/1.0.4.5-preview-01
and
https://www.nuget.org/packages/WireMock.Net/1.0.4.5-preview-01

@DavidKorn
Copy link
Collaborator Author

DavidKorn commented Jul 1, 2018

Thanks @StefH I'll take a look.

Edit: Removed pointless comment. I misunderstood your plan. :) I'll keep reviewing and testing but initially this looks great.

@DavidKorn
Copy link
Collaborator Author

Nicely done @StefH . It works perfectly in all my local testing. I'll work with my devops in the next few days to get the preview rolled out and I'll report back if there's any surprises. Thanks again for all your work to get make this tool so great.

Minor thing: The readme.md in the sample web project references two publish profiles, but those are missing and probably getting git-ignored in your commits. (Even more minor: That csproj includes the wwwroot folder but it doesn't exist from the repo, so that looks a little broken in solution explorer.)

@DavidKorn
Copy link
Collaborator Author

It looks like the AbsoluteUrl is wrong now. It doesn't include the subpath.

@StefH
Copy link
Collaborator

StefH commented Jul 2, 2018

Hello David,

1]
I've fixed the minors, see that same branch.

2]
I've fixed the AbsoluteUrl. So the request is now logged like:

"Path": "/param2",
"AbsolutePath": "/wiremock/param2",
"Url": "http://localhost/param2?key=testdd",
"AbsoluteUrl": "http://localhost/wiremock/param2?key=testdd",

I've also added the AbsolutePath, AbsoluteUrl and AbsolutePathSegments to the request, so they can also be used in the handlebars substitution.

3]
New NuGet is uploaded : 1.0.4.5-preview-02

@DavidKorn
Copy link
Collaborator Author

Quick update: We are testing on 1.0.4.5 preview 2, and so far things continue to work well.

You mentioned fixing the minor issues, but I don't think the publish profiles referenced in the readme.md are working. For me those get git-ignored, maybe that's why.

@StefH
Copy link
Collaborator

StefH commented Jul 4, 2018

I thought that I did override the ignore... I will take a look, but this will be after some time. No access to code right now.

@DavidKorn
Copy link
Collaborator Author

@StefH I think you can close this issue whenever you like. The main feature here is working great for us now.

@StefH
Copy link
Collaborator

StefH commented Jul 10, 2018

This weekend I'll see if the ignored files can be added to git. And I will create a official NuGet.

@StefH StefH changed the title How to host WireMock.Net on IIS in a sub-app? Feature: Support running WireMock.Net as a sub-app in IIS Jul 15, 2018
StefH added a commit that referenced this issue Jul 17, 2018
* Update examples (#158)

* IIS debug

* PathBase logic

* 1.0.4.5-preview-01

* Fix project and readme

* Fix issues

* fix picture alignment

* Add IIS publish examples

* 1.0.4.5
@StefH StefH closed this as completed Jul 17, 2018
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