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

Improve custom matching #249

Open
martincostello opened this issue Sep 17, 2020 · 3 comments
Open

Improve custom matching #249

martincostello opened this issue Sep 17, 2020 · 3 comments
Assignees
Labels
enhancement A change that enhances existing functionality or documentation.
Milestone

Comments

@martincostello
Copy link
Member

Issues #247 and #248 have highlighted that making conditional behaviour can be too difficult and unintuitive to achieve.

Consider implementing additional functionality to make it easy to add extra matching conditions to requests so that registrations for the same URL can be matched depending on arbitrary conditions. For example this could be used to cause fuzzing by having requests randomly fail.

Something like this where 50% of requests on average get rate-limited:

var builder200 = new HttpRequestInterceptionBuilder()
    .Requests()
    .ForHttps()
    .ForHost("api.github.com")
    .ForPath("orgs/justeat")
    .AndFor(() => DateTime.UtcNow.Millisecond % 2 != 0)
    .Responds()
    .WithJsonContent(new { id = 1516790, login = "justeat", url = "https://api.github.com/orgs/justeat" });

var builder429 = new HttpRequestInterceptionBuilder()
    .Requests()
    .ForHttps()
    .ForHost("api.github.com")
    .ForPath("orgs/justeat")
    .AndFor(() => DateTime.UtcNow.Millisecond % 2 == 0)
    .Responds()
    .WithStatus(HttpStatusCode.TooManyRequests)
    .WithJsonContent(new { error = "Too many requests" });

var options = new HttpClientInterceptorOptions()
    .Register(builder200)
    .Register(builder429);
@martincostello martincostello added the enhancement A change that enhances existing functionality or documentation. label Sep 17, 2020
@martincostello martincostello added this to the Future milestone Sep 17, 2020
@martincostello martincostello self-assigned this Sep 17, 2020
martincostello added a commit to martincostello/httpclient-interception that referenced this issue Sep 18, 2020
Prototype of updating the matching behaviour for justeattakeaway#249.
@stale
Copy link

stale bot commented Nov 15, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix An Issue or Pull Request that is technically valid, but has been decided not to be addressed. label Nov 15, 2020
@martincostello martincostello removed the wontfix An Issue or Pull Request that is technically valid, but has been decided not to be addressed. label Nov 15, 2020
@stale
Copy link

stale bot commented Jul 21, 2021

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix An Issue or Pull Request that is technically valid, but has been decided not to be addressed. label Jul 21, 2021
@martincostello martincostello removed the wontfix An Issue or Pull Request that is technically valid, but has been decided not to be addressed. label Jul 21, 2021
@stale
Copy link

stale bot commented Apr 17, 2022

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix An Issue or Pull Request that is technically valid, but has been decided not to be addressed. label Apr 17, 2022
@martincostello martincostello removed the wontfix An Issue or Pull Request that is technically valid, but has been decided not to be addressed. label Apr 17, 2022
@martincostello martincostello modified the milestones: Future, v4.1.0 Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A change that enhances existing functionality or documentation.
Projects
None yet
Development

No branches or pull requests

1 participant