Closed dariooo512 closed 11 months ago
@dariooo512 Your mapping file looks like a WireMock.Org mapping file.
When reading static mappings, you need to use a WireMock.Net mapping file.
(There is limited in this project for using WireMock.Org mapping files.)
See
Describe the bug
I can't figure out how to make ReadStaticMappings work. After calling ReadStaticMappings and verifying the server has mappings in the server.Mappings array, the following request yields 404.
Expected behavior:
After adding autogenerated mappings the server should return the body found in the json
Test to reproduce
Download and run this sample Program.zip
OR
Console.WriteLine("Hello, World!"); var server = WireMockServer.Start(); server.ReadStaticMappings(Directory.GetCurrentDirectory());
if (!server.Mappings.Any()) { throw new Exception("No mappings found"); }
var client = server.CreateClient(); var response = await client.GetAsync($"{client.BaseAddress}manageToken/getToken?Key=key&Secret=secret");
response.EnsureSuccessStatusCode();
var content = await response.Content.ReadAsStringAsync();
Console.WriteLine(content);
{ "id" : "f14d4844-a3e0-4130-a830-03f71a7cdbe8", "name" : "managetoken_gettoken", "request" : { "url" : "/manageToken/getToken?Key=key&Secret=secret", "method" : "GET" }, "response" : { "status" : 200, "body" : "{\"access_token\":\"token\",\"scope\":\"device_383334.0\",\"token_type\":\"Bearer\",\"expires_in\":3600}", "headers" : { "X-Frame-Options" : "DENY", "activityid" : "782ee60c-a48c-4d64-b9b3-8f99649df207", "Access-Control-Expose-Headers" : "", "Cache-Control" : "no-store", "Access-Control-Allow-Origin" : "*", "Access-Control-Allow-Methods" : "GET", "uber-trace-id" : "df44af849f44bab6%3Acccf9a31b54cfa0d%3A2d2865c70c60927b%3A1", "X-Content-Type-Options" : "nosniff", "Pragma" : "no-cache", "X-XSS-Protection" : "1; mode=block", "Access-Control-Allow-Headers" : "content-type", "Content-Type" : "application/json", "Date" : "Fri, 21 Jul 2023 15:08:55 GMT" } }, "uuid" : "f14d4844-a3e0-4130-a830-03f71a7cdbe8", "persistent" : true, "insertionIndex" : 1 }