Trusted entitlements: Add internal mechanism to force signing errors for tests#1070
Conversation
| protected fun simulateSdkRestart(context: Context, forceServerErrors: Boolean = false) { | ||
| protected fun simulateSdkRestart( | ||
| context: Context, | ||
| entitlementVerificationMode: EntitlementVerificationMode? = null, |
There was a problem hiding this comment.
EntitlementVerificationMode already has DISABLED, so does this need to be null?
Oh I guess it's to be able to determine if it's been explicitly set? It might be useful to have a comment explaining that.
Update: oh just realized this is in tests, so makes sense.
There was a problem hiding this comment.
Yeah, it's pretty much a way to make sure it's explicitly set 👍
|
@NachoSoto Applied the suggested changes in #1071 here, since they seemed more related to this PR (I forgot to base the other PR off this branch) |
| val dangerousSettings: DangerousSettings = DangerousSettings(autoSyncPurchases = true), | ||
| // Should only be used for tests | ||
| var forceServerErrors: Boolean = false, | ||
| private val runningTests: Boolean = false, |
There was a problem hiding this comment.
I was trying to calculate this within AppConfig itself but was getting problems trying to mock these when running unit tests (which don't run in the integrationTest flavor).
Codecov Report
@@ Coverage Diff @@
## main #1070 +/- ##
=======================================
Coverage 85.64% 85.64%
=======================================
Files 176 176
Lines 6247 6263 +16
Branches 859 863 +4
=======================================
+ Hits 5350 5364 +14
Misses 563 563
- Partials 334 336 +2
|
| // Should only be used for tests | ||
| var forceServerErrors: Boolean = forceServerErrors | ||
| get() = runningTests && field | ||
| var forceSigningErrors: Boolean = forceSigningErrors | ||
| get() = runningTests && field |
**This is an automatic release.** ### Bugfixes * Default customer info schema version to latest known by SDK (#1080) via Toni Rico (@tonidero) * Handle other diagnostics-related exceptions (#1076) via Toni Rico (@tonidero) * Return error in queryPurchases if error connecting to billing client (#1072) via Toni Rico (@tonidero) ### Other Changes * Fix offline entitlements integration tests (#1085) via Toni Rico (@tonidero) * Add defaultsRelease variant tests run configuration (#1074) via Toni Rico (@tonidero) * Compose sample app: move to gradle catalog (#1081) via Toni Rico (@tonidero) * Compose sample app: automate builds (#1082) via Toni Rico (@tonidero) * Compose sample app (#1056) via Toni Rico (@tonidero) * Migrate to Gradle version catalog (#1059) via Cesar de la Vega (@vegaro) * Trusted entitlements: Add logs with verification mode (#1067) via Toni Rico (@tonidero) * Sync pending purchases before getting customer info (#1073) via Toni Rico (@tonidero) * Refactor syncing pending transactions logic out of `Purchases` (#1058) via Toni Rico (@tonidero) * Refactor CustomerInfo listener and cache logic into CustomerInfoUpdater (#1052) via Toni Rico (@tonidero) * Trusted entitlements: Add integration tests (#1071) via Toni Rico (@tonidero) * Trusted entitlements: Add internal mechanism to force signing errors for tests (#1070) via Toni Rico (@tonidero) Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Description
SDK-3182
This allows to force signing errors during tests so we can better test the trusted entitlements feature automatically.