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

Admin API fails to create a mapping with Request Body matching #486

Closed
yunj opened this issue Jul 9, 2020 · 5 comments
Closed

Admin API fails to create a mapping with Request Body matching #486

yunj opened this issue Jul 9, 2020 · 5 comments
Labels

Comments

@yunj
Copy link

yunj commented Jul 9, 2020

Describe the bug

Admin API is used to create a mapping which has some sort of request body match, but other matches get created except body.

Expected behavior:

Body match should appear when querying GET __admin/mappings.

Test to reproduce

Admin API is used to create the following mapping.

var model = new MappingModel
{
    Request = new RequestModel
    {
        Path = "test",
        Body = new BodyModel
        {
            Matcher = new MatcherModel
            {
                Name = "RegexMatcher",
                Pattern = "hello"
            }
        }
    },
    Response = new ResponseModel
    {
        Body = "world"
    }
};
await RestClient.For<IWireMockAdminApi>("http:https://localhost").PostMappingAsync(model);

The response from GET __admin/mappings

[
  {
    "Guid": "486b7f76-f29a-4928-9f16-bf6c3a2ce8f2",
    "Request": {
      "Path": {
        "Matchers": [
          {
            "Name": "WildcardMatcher",
            "Pattern": "test",
            "IgnoreCase": false
          }
        ]
      }
    },
    "Response": {
      "Body": "world"
    }
  }
]
@yunj yunj added the bug label Jul 9, 2020
@yunj yunj changed the title Admin API fails to create a mapping with Request Body Admin API fails to create a mapping with Request Body matching Jul 9, 2020
@StefH
Copy link
Collaborator

StefH commented Jul 9, 2020

Thank you.
I'll investigate.

@StefH
Copy link
Collaborator

StefH commented Jul 9, 2020

@yunj
The root cause is that you don't provide the Methods on you wish to match. The current code does not return the bodymatcher if there are no Methods defined or if the methods have a 'get'.

I'll investigate why I did add this check in the code.

For your solution now: set the Methods.

@StefH
Copy link
Collaborator

StefH commented Jul 9, 2020

#487

@StefH
Copy link
Collaborator

StefH commented Jul 9, 2020

Fixed.
New NuGet and Docker will be released soon.

@StefH StefH closed this as completed Jul 9, 2020
@yunj
Copy link
Author

yunj commented Jul 9, 2020

@StefH thanks very much for your quick fix.

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