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

Test Failures Due to Authorization Issues After Upgrading to .NET 8 and HttpClient-Interception #716

Open
dasadhanala opened this issue Jan 18, 2024 · 1 comment
Labels
bug A defect in the code or documentation.

Comments

@dasadhanala
Copy link

We recently upgraded our project to .NET 8 and updated the HttpClient-Interception package to its latest version. Following this upgrade, we are encountering an issue where multiple tests are failing due to authorization failures.

Environment
.NET Version: 8.0
HttpClient-Interception Version: 4.1.0
OS: Windows

Issue Description
Prior to the upgrade, all our tests were passing consistently. The tests that are failing are specifically those that rely on HttpClient-Interception for mocking HTTP requests and responses. These tests are now failing with an "unauthorized" error, although no changes were made to the test setup or the codebase, apart from the version upgrades.

Steps to Reproduce
Upgrade the project to .NET 8.
Upgrade HttpClient-Interception to the latest version.
Run the existing tests which involve HTTP request mocking.

Expected Behavior
Tests that were passing previously should continue to pass after the upgrade, assuming no changes to the test logic or setup.

Actual Behavior
Tests involving mocked HTTP requests are failing with an "unauthorized" error.

Additional Information
Error logs/output:
Shouldly.ShouldAssertException : response.response.StatusCode
should be
HttpStatusCode.Created
but was
HttpStatusCode.Unauthorized

Could you please provide any insights into why this might be happening? Are there any breaking changes in the latest version of HttpClient-Interception that could affect authorization? Also, are there any additional configurations or steps that we need to consider after upgrading to .NET 8 and the latest version of HttpClient-Interception?

Any guidance or suggestions would be greatly appreciated.

Thank you for your help!

@dasadhanala dasadhanala added the bug A defect in the code or documentation. label Jan 18, 2024
@martincostello
Copy link
Member

Could you provide a minimal reproducible sample project demonstrating the failure? Otherwise it's hard to guide you on what might be wrong.

There shouldn't be any changes in the library that would break things for .NET 8. I use this library extensively in my personal projects that intercept authorization-related requests to third-party OAuth providers, and they haven't had any issues related to this library.

Two changes I am aware of that have impacted things using this library related to .NET 8 are:

  1. Some of the ASP.NET Core OAuth providers were updated to use newer API versions, causing paths to change. In these cases, the interceptions needed updating - example martincostello/alexa-london-travel-site@be766f1.
  2. Versions of AWS SDKs targeting net8.0 use HttpClient.Send() in some places, which wasn't supported for interception. This support was added by Add Interceptor Overload for Send #694 which was part of the 4.1.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A defect in the code or documentation.
Projects
None yet
Development

No branches or pull requests

2 participants