Skip to content

Add Authorization header matching to IRequestBuilder#26

Merged
sandermvanvliet merged 2 commits intosandermvanvliet:masterfrom
Joshhua5:feature/header-matching
Jan 15, 2025
Merged

Add Authorization header matching to IRequestBuilder#26
sandermvanvliet merged 2 commits intosandermvanvliet:masterfrom
Joshhua5:feature/header-matching

Conversation

@Joshhua5
Copy link

@Joshhua5 Joshhua5 commented Jan 2, 2025

Leveraged the existing header matching node and added configurable headers.

@Joshhua5 Joshhua5 force-pushed the feature/header-matching branch from 718e341 to ac3a4b7 Compare January 2, 2025 13:47
@Joshhua5
Copy link
Author

Joshhua5 commented Jan 2, 2025

I see there's complications when adding multiple headers, resulting in multiple matches.

So I've changed this PR to add another header type instead of an open dictionary.

Copy link
Owner

@sandermvanvliet sandermvanvliet 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 for creating this PR to extend the request matching 👍

I've left a few comments but nothing really major.

If you have the time would you be able to add an example of the usage to the README so that people are aware this is a possibility now?

/// </summary>
/// <param name="authenticationHeader">A authorization header value</param>
/// <returns>The current <see cref="IRequestBuilder"/> instance</returns>
IRequestBuilder Authorization(AuthenticationHeaderValue authenticationHeader);
Copy link
Owner

Choose a reason for hiding this comment

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

Could you change the name to AndAuthorization so that the usage is similar to AndContentType()?

So instead of

handler
    .RespondTo()
    .Post()
    .ForUrl("/api/infos/")
    .Authorization(new AuthenticationHeaderValue())
    .With(HttpStatus.OK);

have

handler
    .RespondTo()
    .Post()
    .ForUrl("/api/infos/")
    .AndAuthorization(new AuthenticationHeaderValue())
    .With(HttpStatus.OK);

@Joshhua5
Copy link
Author

Joshhua5 commented Jan 8, 2025

Changed applied :)

@sandermvanvliet sandermvanvliet changed the title Add Header matching to IRequestBuilder Add Authorization header matching to IRequestBuilder Jan 15, 2025
Copy link
Owner

@sandermvanvliet sandermvanvliet left a comment

Choose a reason for hiding this comment

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

Thanks for applying the changes 👍

@sandermvanvliet
Copy link
Owner

I'm going to merge this and then do a little work because the workflow doesn't run at the moment given that the test project references net6 still....

@sandermvanvliet sandermvanvliet merged commit 2a39953 into sandermvanvliet:master Jan 15, 2025
1 check failed
@sandermvanvliet
Copy link
Owner

Package has just been published as 2.11.0.0

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