-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Fix incorrect ETag values #3490
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
Conversation
Fix incorrect ETag for compressed files by resetting the compressed stream to the beginning before computing the SHA256 hash. See #3486.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR ensures the compressed stream is reset before computing the hash so that ETag values for compressed files are correct.
- Reset the compressed stream position in
EmbeddedResourceProvider
before hashing. - Introduce a shared constant for the empty-string hash in tests and replace hard-coded literals.
- Add assertions to verify the empty-string hash does not appear in the ETag tag.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs | Added EmptyStringSha256Hash constant, replaced literals, and added Assert.DoesNotContain checks on ETag. |
test/Swashbuckle.AspNetCore.IntegrationTests/ReDocIntegrationTests.cs | Mirrored the same constant and assertions changes for ReDoc tests. |
src/Shared/EmbeddedResourceProvider.cs | Inserted compressed.Seek(0, SeekOrigin.Begin) before hashing. |
Comments suppressed due to low confidence (2)
test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs:10
- The constant name suggests SHA256 but the code uses SHA1; consider renaming it to
EmptyStringSha1Hash
for accuracy.
private const string EmptyStringSha256Hash = "2jmj7l5rSw0yVb/vlWAYkK/YBwk=";
test/Swashbuckle.AspNetCore.IntegrationTests/ReDocIntegrationTests.cs:13
- The constant name suggests SHA256 but the code uses SHA1; consider renaming it to
EmptyStringSha1Hash
for accuracy.
private const string EmptyStringSha256Hash = "2jmj7l5rSw0yVb/vlWAYkK/YBwk=";
test/Swashbuckle.AspNetCore.IntegrationTests/SwaggerUIIntegrationTests.cs
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #3490 +/- ##
=======================================
Coverage 93.91% 93.91%
=======================================
Files 110 110
Lines 3810 3811 +1
Branches 723 723
=======================================
+ Hits 3578 3579 +1
Misses 232 232
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fix incorrect
ETag
for compressed files by resetting the compressed stream to the beginning before computing the SHA256 hash.See #3486 (comment).