-
-
Notifications
You must be signed in to change notification settings - Fork 200
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
Wiremock - WatchStaticMappings only works until the first request is made #726
Comments
@jucamo8311 (A possible reason that it does not work is an invalid json file.) See
|
I use serilog for the log (the serilog MinimumLevel is set to dedug in order to print everything ) , checking this log what I can see is
Here I change the response in the mapping file SalesforceCRM.json, from this [{
"Guid": "05E2F022-C4B2-4406-9E31-E921DE415BF5",
"priority": 10,
"Request": {
"Path": {
"Matchers": [{
"Name": "WildcardMatcher",
"Pattern": "/services/apexrest/ConsultarCaso*",
"IgnoreCase": true
}
]
},
"Headers": [{
"Name": "Authorization",
"Matchers": [{
"Name": "WildcardMatcher",
"Pattern": "Bearer*",
"IgnoreCase": true
}
]
}
],
"Methods": ["get"]
},
"Response": {
"Headers": {
"Content-Type": "application/json;charset=UTF-8",
"X-Robots-Tag": "none",
"X-Content-Type-Options": "nosniff",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-XSS-Protection":"1; mode=block"
},
"BodyAsFile": "F:\\MockData\\filesResponses\\SalesforceCRM\\Test_Resp_OK_1.json",
"UseTransformerForBodyAsFile": true,
"UseTransformer": true
}
}
]
[{
"Guid": "05E2F022-C4B2-4406-9E31-E921DE415BF5",
"priority": 10,
"Request": {
"Path": {
"Matchers": [{
"Name": "WildcardMatcher",
"Pattern": "/services/apexrest/ConsultarCaso*",
"IgnoreCase": true
}
]
},
"Headers": [{
"Name": "Authorization",
"Matchers": [{
"Name": "WildcardMatcher",
"Pattern": "Bearer*",
"IgnoreCase": true
}
]
}
],
"Methods": ["get"]
},
"Response": {
"Headers": {
"Content-Type": "application/json;charset=UTF-8",
"X-Robots-Tag": "none",
"X-Content-Type-Options": "nosniff",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"X-XSS-Protection":"1; mode=block"
},
"BodyAsFile": "F:\\MockData\\filesResponses\\SalesforceCRM\\Test_Resp_OK_2.json",
"UseTransformerForBodyAsFile": true,
"UseTransformer": true
}
}
] After that I can see in the log that a message was printed
Making a call to the mock using postman, the response is the content of Test_Resp_OK_2.json. if I modify the file SalesforceCRM.json again changing the response file from Test_Resp_OK_2.json to Test_Resp_OK_1.json |
It's very strange. In .NET old (4.5.2) and .NETCore 3.1, it works / worked fine. For .NET 5.0, is does not always work correct. I did a small fix, can you try preview: 1.4.35-ci-15874 https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions |
Maybe related to? |
I checked that build but it behaves the same, I starting to think that maybe it is not a problem of the library, more of .net core framework itself, because testing I noticed something even weirder. On Windows 10 if I execute my application on a console and end the application it is necessary to close the windwos console itself in order to take the changes I made on the mapping file, which made no sense because the app ended and should take the update version of the file when I start it again. Anyway, tomorrow I am going to check BodyAsFileIsCached to see if make any diference |
New version (x.x.x.36) will be available on NuGet within some hours. Maybe can you retest that version. And maybe did you try this: |
I checked it, but nothing change. It doesn't take the mapping files update. Also I made a test with Framework 4.7.2 and like you said It works. So my conclucion is that something related to .net core framework doesnt work as expected |
Maybe related to this? https://www.c-sharpcorner.com/blogs/using-filesystemwatcher-with-net-core-30 |
@jucamo8311 Can you try preview: |
Yes , that does it , Tested with .Net core 6.0 win 10 x64. |
This bug has been present for some time now. Thanks for finding this! |
Describe the bug
I created a standalone console app to mock requests using WireMock.Net.StandAlone library , the configuration of the server is like below
Expected behavior:
I believe the correct behavior is to detect changes on MappingsFolder an update the mapping accordingly. In some way it seems to work before is made the first request, after that it’s not able to detect changes on the json mapping files (update , delete , add).
Test to reproduce
Other related info
Thanks, in Avance for your time, wiremock.net is a great library
The text was updated successfully, but these errors were encountered: