Skip to content

ETagManager: refactored e-tag creation and tests#2671

Merged
NachoSoto merged 2 commits into
mainfrom
etag-manager-refactor
Jun 21, 2023
Merged

ETagManager: refactored e-tag creation and tests#2671
NachoSoto merged 2 commits into
mainfrom
etag-manager-refactor

Conversation

@NachoSoto

Copy link
Copy Markdown
Contributor

We had lots of different parts of the code doing request.url?.absoluteString and also using different values for e-tags.
This refactor combines all that to use a single eTag(for:) method.

I did this as part of #2665, which is getting closed, but it will still be useful if we ever decide to change the content of e-tags.

@NachoSoto NachoSoto requested a review from a team June 16, 2023 16:24

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was in the wrong enum: it's a response header not request.

@codecov

codecov Bot commented Jun 16, 2023

Copy link
Copy Markdown

Codecov Report

Merging #2671 (4a3ca23) into main (b441846) will decrease coverage by 0.11%.
The diff coverage is 100.00%.

❗ Current head 4a3ca23 differs from pull request most recent head 3b5b246. Consider uploading reports for the commit 3b5b246 to get more accurate results

@@            Coverage Diff             @@
##             main    #2671      +/-   ##
==========================================
- Coverage   86.53%   86.43%   -0.11%     
==========================================
  Files         208      208              
  Lines       14799    14748      -51     
==========================================
- Hits        12806    12747      -59     
- Misses       1993     2001       +8     
Impacted Files Coverage Δ
Sources/Networking/HTTPClient/HTTPClient.swift 98.40% <ø> (-0.04%) ⬇️
Sources/Networking/HTTPClient/ETagManager.swift 97.81% <100.00%> (-1.63%) ⬇️

... and 7 files with indirect coverage changes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So this is only going to be made visible for the tests right? I wonder if we should just duplicate this logic once in the tests... But it's ok I think, this is the kind of place I would use @VisibleForTesting in android :P

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What was I thinking, we still need to have a separate eTag value...

@NachoSoto NachoSoto marked this pull request as draft June 20, 2023 15:01
@NachoSoto NachoSoto added the WIP label Jun 20, 2023
We had lots of different parts of the code doing `request.url?.absoluteString` and also using different values for e-tags.
This refactor combines all that to use a single `eTag(for:)` method.

I did this as part of #2665, which is getting closed, but it will still be useful if we ever decide to change the content of e-tags.
@NachoSoto NachoSoto force-pushed the etag-manager-refactor branch from 4a3ca23 to ab72b7e Compare June 21, 2023 17:47
@NachoSoto NachoSoto removed the WIP label Jun 21, 2023
@NachoSoto NachoSoto marked this pull request as ready for review June 21, 2023 17:47
@NachoSoto NachoSoto enabled auto-merge (squash) June 21, 2023 17:48
@NachoSoto NachoSoto merged commit 7298dfa into main Jun 21, 2023
@NachoSoto NachoSoto deleted the etag-manager-refactor branch June 21, 2023 18:02
NachoSoto pushed a commit that referenced this pull request Jun 22, 2023
**This is an automatic release.**

### Bugfixes
* `PurchasesOrchestrator`: update `CustomerInfoManager` cache after
processing transactions (#2676) via NachoSoto (@NachoSoto)
* `ErrorResponse`: drastically improved error messages, no more "unknown
error"s (#2660) via NachoSoto (@NachoSoto)
* `PaywallExtensions`: post purchases with `Offering` identifier (#2645)
via NachoSoto (@NachoSoto)
* Support `product_plan_identifier` for purchased subscriptions from
`Google Play` (#2654) via Josh Holtz (@joshdholtz)
### Performance Improvements
* `copy(with: VerificationResult)`: optimization to avoid copies (#2639)
via NachoSoto (@NachoSoto)
### Other Changes
* `ETagManager`: refactored e-tag creation and tests (#2671) via
NachoSoto (@NachoSoto)
* `getPromotionalOffer`: return `ErrorCode.ineligibleError` if receipt
is not found (#2678) via NachoSoto (@NachoSoto)
* `TimingUtil`: removed slow purchase logs (#2677) via NachoSoto
(@NachoSoto)
* `CI`: changed `Codecov` to `informational` (#2670) via NachoSoto
(@NachoSoto)
* `LoadShedderIntegrationTests`: verify requests are actually handled by
load shedder (#2663) via NachoSoto (@NachoSoto)
* `ETagManager.httpResultFromCacheOrBackend`: return response headers
(#2666) via NachoSoto (@NachoSoto)
* `Integration Tests`: added tests to verify 304 behavior (#2659) via
NachoSoto (@NachoSoto)
* `HTTPClient`: disable `URLSession` cache (#2668) via NachoSoto
(@NachoSoto)
* Documented `HTTPStatusCode.isSuccessfullySynced` (#2661) via NachoSoto
(@NachoSoto)
* `NetworkError.signatureVerificationFailed`: added status code to error
`userInfo` (#2657) via NachoSoto (@NachoSoto)
* `HTTPClient`: improved log for failed requests (#2669) via NachoSoto
(@NachoSoto)
* `ETagManager`: added new verbose logs (#2656) via NachoSoto
(@NachoSoto)
* `Signature Verification`: added test-only log for debugging invalid
signatures (#2658) via NachoSoto (@NachoSoto)
* Fixed `HTTPResponse.description` (#2664) via NachoSoto (@NachoSoto)
* Changed `Logger` to use `os_log` (#2608) via NachoSoto (@NachoSoto)
* `MainThreadMonitor`: increased threshold (#2662) via NachoSoto
(@NachoSoto)
* `debugRevenueCatOverlay`: display `receiptURL` (#2652) via NachoSoto
(@NachoSoto)
* `PurchaseTester`: added ability to display `debugRevenueCatOverlay`
(#2653) via NachoSoto (@NachoSoto)
* `debugRevenueCatOverlay`: ability to close on `macOS`/`Catalyst`
(#2649) via NachoSoto (@NachoSoto)
* `debugRevenueCatOverlay`: added support for `macOS` (#2648) via
NachoSoto (@NachoSoto)
* `LoadShedderIntegrationTests`: enable signature verification (#2655)
via NachoSoto (@NachoSoto)
* `ImageSnapshot`: fixed Xcode 15 compilation (#2651) via NachoSoto
(@NachoSoto)
* `OfferingsManager`: don't clear offerings cache timestamp when request
fails (#2359) via NachoSoto (@NachoSoto)
* `StoreKitObserverModeIntegrationTests`: added test for posting
renewals (#2590) via NachoSoto (@NachoSoto)
* Always initialize `StoreKit2TransactionListener` even on SK1 mode
(#2612) via NachoSoto (@NachoSoto)
* `ErrorUtils.missingReceiptFileError`: added receipt URL `userInfo`
context (#2650) via NachoSoto (@NachoSoto)
* Added `.xcprivacy` for Xcode 15 (#2619) via NachoSoto (@NachoSoto)
* `Trusted Entitlements`: added debug log with
`ResponseVerificationMode` (#2647) via NachoSoto (@NachoSoto)
* `debugRevenueCatOverlay`: simplified title (#2641) via NachoSoto
(@NachoSoto)
* Simplified `Purchases.updateAllCachesIfNeeded` (#2626) via NachoSoto
(@NachoSoto)
* `HTTPResponseTests`: fixed disabled test (#2643) via NachoSoto
(@NachoSoto)
* Add `InternalDangerousSettings.forceSignatureFailures` (#2635) via
NachoSoto (@NachoSoto)
* `IntegrationTests`: explicit `StoreKit 1` mode (#2636) via NachoSoto
(@NachoSoto)
* `Signing`: removed API for loading key from a file (#2638) via
NachoSoto (@NachoSoto)
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