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

WithHeader cannot handle multiple requests with the same header key values #814

Closed
robvangeloven opened this issue Sep 23, 2022 · 14 comments
Assignees
Labels

Comments

@robvangeloven
Copy link

When using the assertion "WithHeader" it will fail if there are multiple requests with the same header value (e.g. "Accept"):

Server.Should().HaveReceivedACall().WithHeader("Authorization", $"Bearer xxxxxxx");

This is because there is a ToDictionary in the WithHeader function that doesn't take into account that multiple calls might have been made before the assert fires.

@StefH StefH self-assigned this Sep 26, 2022
@StefH
Copy link
Collaborator

StefH commented Sep 26, 2022

@robvangeloven

I think I've fixed both issues (this & _callscount).

Can you please test preview version 1.5.6-ci-16474?

(https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions)

#816

@StefH
Copy link
Collaborator

StefH commented Oct 3, 2022

@robvangeloven

Did you have time to validate?

@robvangeloven
Copy link
Author

@StefH Sorry, only now have time to test. The package version you mention is (no longer) available. Which version should I take for testing?

@StefH
Copy link
Collaborator

StefH commented Oct 5, 2022

can you please try 16510?

@robvangeloven
Copy link
Author

Tried it and failed, decompilation seems to show that the code isn't merged into that branch yet. Is that possible?

@StefH
Copy link
Collaborator

StefH commented Oct 5, 2022

Sorry, wrong branch.

This id: 16511 should be it.

@robvangeloven
Copy link
Author

Tried it! However it now tries to match the first request made to WireMock whereas the request I'm trying to match (via the AtUrl call) is the last request

@StefH
Copy link
Collaborator

StefH commented Oct 7, 2022

@StefH
Copy link
Collaborator

StefH commented Oct 12, 2022

#816

@robvangeloven
Copy link
Author

@robvangeloven Thanks for testing.

Can you please take a look at this unit test file? https://github.com/WireMock-Net/WireMock.Net/pull/816/files#diff-e73254164873009a752dfd094e87fa8aae2d0c6c0c0b7ebe3b6d2f2b23b287c8

See line 463.

I've checked the unit test, but that one doesn't actually check any headers?

@StefH
Copy link
Collaborator

StefH commented Oct 13, 2022

Correct.

I did combine both your issues into 1 PR.

And I think both issues are solved.

In case you still have an issue, please provide a unit test.

@robvangeloven
Copy link
Author

Yes, retested everything and both issues are fixed!

@StefH
Copy link
Collaborator

StefH commented Oct 15, 2022

Thanks for retesting. A new NuGet version will be released this weekend.

@StefH
Copy link
Collaborator

StefH commented Oct 15, 2022

#816

@StefH StefH closed this as completed Oct 15, 2022
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