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

Fix new Delete with body missing from IWireMockAdminApi interface #413

Merged

Conversation

NoahLerner
Copy link
Member

As requested.

@NoahLerner NoahLerner requested a review from StefH February 2, 2020 12:54
Copy link
Collaborator

@StefH StefH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add the code changes in that 1 file from PR #409 because this was also reverted.

@NoahLerner
Copy link
Member Author

I didn't realize that was reverted too. I resubmitted the code.

@NoahLerner NoahLerner requested a review from StefH February 2, 2020 13:55
Copy link
Collaborator

@StefH StefH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change does not work correctly, because the body is not parsed in this line:

if (request.Body != null && BodyParser.ShouldParseBody(method, options.AllowBodyForAllHttpMethods == true))
(DELETE has no body semantics, so this line will not parse body)

So maybe skip this PR or change it so that your just provide all GUID's in the query string?

@NoahLerner
Copy link
Member Author

This change does not work correctly, because the body is not parsed in this line:

if (request.Body != null && BodyParser.ShouldParseBody(method, options.AllowBodyForAllHttpMethods == true))

(DELETE has no body semantics, so this line will not parse body)
So maybe skip this PR or change it so that your just provide all GUID's in the query string?

I'm not sure what you mean by not working correctly? I tested it and it works fine... as long as AllowBodyForAllHttpMethods is set to true then the body arrives just fine along with the request to private ResponseMessage MappingsDelete(RequestMessage requestMessage).

Also, before opening this PR I looked into whether DELETE can have body semantics and found this documentation saying it may have a body.

Am I missing something?

@NoahLerner
Copy link
Member Author

And also in the RFC, it is not forbidden. It only says that sending a payload body on a DELETE request might cause some existing implementations to reject the request.. But we know this not to be the case in the WireMock.Net implementation...

@StefH
Copy link
Collaborator

StefH commented Feb 4, 2020

Currently, the logic form WireMock is that DELETE cannot have a body:

Because of this logic, all requests (normal + admin) will not allow a body for delete. This behaviour can indeed be changed by AllowBodyForAllHttpMethods, however this settings is actually meant for normal requests, for admin requests, this should actually not be applied (for admin requests: all is allowed)
This difference in logic is not yet implemented, the OwinRequestMapper.cs maps the request, without knowing if it's a admin request.

So a fix could be:

  1. allow body for all delete
  2. add special logic to the OwinRequestMapper.cs to determine if it's an admin-request or normal request. Or move the ShouldParseBody check to a later stage. (Maybe MappingMatcher..?)

@NoahLerner
Copy link
Member Author

  1. allow body for all delete

Then I think that this should be the fix since the RFC indicates that body is allowed for DELETE.
It also happens to be the simplest fix.
Do you agree?

@StefH
Copy link
Collaborator

StefH commented Feb 4, 2020

You also need to update some other unit-tests because of this update.

@NoahLerner
Copy link
Member Author

Yes I see that now. Thanks I'll get to it soon.

@NoahLerner NoahLerner requested a review from StefH February 4, 2020 19:16
Copy link
Collaborator

@StefH StefH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please take a look at some comments

test/WireMock.Net.Tests/WireMock.Net.Tests.csproj Outdated Show resolved Hide resolved
@NoahLerner NoahLerner requested a review from StefH February 5, 2020 10:24
Copy link
Collaborator

@StefH StefH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see remark about [Theory]

@NoahLerner NoahLerner requested a review from StefH February 5, 2020 17:13
Copy link
Collaborator

@StefH StefH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you very much

@StefH StefH merged commit 32248b6 into WireMock-Net:master Feb 5, 2020
@NoahLerner NoahLerner deleted the Fix_DeleteWithBodyMissingFromInterface branch February 12, 2020 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants