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

ExactMatcher does not accept ISO8601 DateTime? #383

Closed
yankeepenky opened this issue Dec 1, 2019 · 7 comments
Closed

ExactMatcher does not accept ISO8601 DateTime? #383

yankeepenky opened this issue Dec 1, 2019 · 7 comments
Labels

Comments

@yankeepenky
Copy link

yankeepenky commented Dec 1, 2019

Hi, I am trying to respond to the following sample request:

[GET] http://localhost/api/update?since=2019-12-01T22:10:25.000Z

using this mapping in a json file:

{
  "Headers": { "Content-Type": "application/json" },
  "Request": {
    "Path": {
      "Matchers": [
        {
          "Name": "ExactMatcher",
          "Pattern": "/api/update"
        }
      ]
    },
    "Params": [
      {
        "Name": "since",
        "Matchers": [
          {
            "Name": "ExactMatcher",
            "Pattern": "2019-12-01T22:10:25.000Z"
          }
        ]
      }
    ],
    "Methods": [ "get" ]
  },
  "Response": {
    "StatusCode": 200,
    "Headers": { "Content-Type": "application/json" },
    "BodyAsJson": { "result": [] }
  }
}

I am receiving a 404 response.
The mapping does not even get registered. The otuput log says:

[Error]: Static MappingFile : 'REST\mappings\update_1.json' could not be read. This file will be skipped.

Have you got any ideas why this won't work as expected??
thank you! (ps: great project I love it!)

@StefH
Copy link
Collaborator

StefH commented Dec 2, 2019

The error message REST\mappings\update_1.json is a different one, not related to ExactMatcher.

When I post your mapping and test it using a GET, it works fine:
image

@StefH
Copy link
Collaborator

StefH commented Dec 3, 2019

@yankeepenky Do you still need support on this issue?

@yankeepenky
Copy link
Author

sorry for my late reply!
first, the strange issue occured when using "Matchers": [ {"Name": "...", "Pattern": "..."}]. As soon as I changed that to "Patterns": [ "..." ] the file was read in successfully.

Now the _value of the matcher was still empty...
matcher


Next I changed from VS2015 to VS2017 in order to check the issue there. I now receive the following exception when trying to call any path with any http method:

xxx.Core.Exceptions.WebRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

Environment: VS2017, targeting .NET 4.7.2 (full framework)
As soon as I fixed that issue (which does not seem to be connected to wiremock) I'll report back.

@StefH
Copy link
Collaborator

StefH commented Dec 5, 2019

Just using Pattern should also work fine.

@yankeepenky
Copy link
Author

@StefH I checked the issue again, now while debugging your code:

This is the json file:
"Request": { "Path": { "Matchers": [ { "Name": "ExactMatcher", "Pattern": "/api/update" } ] }, "Params": [ { "Name": "since", "Matchers": [ { "Name": "ExactMatcher", "Pattern": "2019-12-01T22:10:25.000Z" } ] } ], "Methods": [ "get" ] },

The issue is the pattern being cast to a DateTime:
Serialization\MatcherMapper.cs line 39:
string[] stringPatterns = matcher.Patterns != null ? matcher.Patterns.OfType<string>().ToArray() : new[] { matcher.Pattern as string };

here matcher.Pattern is a DateTime and matcher.Pattern as string returns null.

Serialization occurs here: Server\FluentMockServer.Admin.cs Line 232
var mappingModels = DeserializeObjectToArray<MappingModel>(JsonConvert.DeserializeObject(value));

StefH added a commit that referenced this issue Dec 13, 2019
@StefH
Copy link
Collaborator

StefH commented Dec 13, 2019

@yankeepenky I understand your issue.
I fixed it, can you try version WireMock.Net.1.0.40-ci-12334 from MyGet?

@yankeepenky
Copy link
Author

@StefH Great news! all my tests succeeded! thank you for your fix...
I am waiting now for the next release - this issue was solved.

StefH added a commit that referenced this issue Dec 14, 2019
@StefH StefH added the bug label Dec 15, 2019
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