-
Notifications
You must be signed in to change notification settings - Fork 316
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
Fixed purchasing with PromotionalOffer
s using StoreKit 2
#2020
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -377,8 +377,6 @@ class StoreKit1IntegrationTests: BaseBackendIntegrationTests { | |
@available(iOS 15.2, tvOS 15.2, macOS 12.1, watchOS 8.3, *) | ||
func testPurchaseWithPromotionalOffer() async throws { | ||
try AvailabilityChecks.iOS15APIAvailableOrSkipTest() | ||
try XCTSkipIf(Self.storeKit2Setting == .enabledForCompatibleDevices, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
"This test is not currently passing on SK2") | ||
|
||
let user = UUID().uuidString | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -467,6 +467,33 @@ class PurchasesOrchestratorTests: StoreKitConfigTestCase { | |
} | ||
} | ||
|
||
@available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *) | ||
func testPurchaseSK2PackageWithInvalidPromotionalOfferSignatureThrowsError() async throws { | ||
try AvailabilityChecks.iOS15APIAvailableOrSkipTest() | ||
|
||
self.customerInfoManager.stubbedCachedCustomerInfoResult = self.mockCustomerInfo | ||
self.backend.stubbedPostReceiptResult = .success(self.mockCustomerInfo) | ||
|
||
let product = try await self.fetchSk2Product() | ||
let offer = PromotionalOffer.SignedData( | ||
identifier: "identifier \(Int.random(in: 0..<1000))", | ||
keyIdentifier: "key identifier \(Int.random(in: 0..<1000))", | ||
nonce: .init(), | ||
// This should be base64 | ||
signature: "signature \(Int.random(in: 0..<1000))", | ||
Comment on lines
+482
to
+483
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not base64 the result of this so it looks realistic? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is
So I'm testing that if it's not base64 (so it's just a random string), it produces the correct error instead of crashing or something. |
||
timestamp: Int.random(in: 0..<1000) | ||
) | ||
|
||
do { | ||
_ = try await orchestrator.purchase(sk2Product: product, promotionalOffer: offer) | ||
XCTFail("Expected error") | ||
} catch { | ||
expect(error).to(matchError(ErrorCode.invalidPromotionalOfferError)) | ||
expect(error.localizedDescription) | ||
.to(contain("The signature generated by RevenueCat could not be decoded: \(offer.signature)")) | ||
} | ||
} | ||
|
||
@available(iOS 15.0, tvOS 15.0, watchOS 8.0, macOS 12.0, *) | ||
func testPurchaseSK2PackageReturnsCustomerInfoForFailedTransaction() async throws { | ||
try AvailabilityChecks.iOS15APIAvailableOrSkipTest() | ||
|
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.
I improved error handling here (the last TODO) and added a few tests.