-
Notifications
You must be signed in to change notification settings - Fork 951
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add validation to catch blank ephemeral keys in CustomerConfiguration
We currently don't validate that an ephemeral key is non-empty when a user includes it in the `CustomerConfiguration`. This ends up giving users a pretty obscure error in the API response, and is difficult to debug today. Including this validation will catch this issue early and provide users a better debugging experience.
- Loading branch information
1 parent
bdd33e6
commit 2bd7d0d
Showing
4 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,6 +136,7 @@ | |
791D8D5E9AD66572132CF18A /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 6C599C4F3933B4A6F0D99004 /* [email protected] */; }; | ||
7B52F499141CCA2514A361F3 /* LinkKeyboardAvoidingScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 37130B660E4A5D6297F83EE8 /* LinkKeyboardAvoidingScrollView.swift */; }; | ||
7B6F620759307A9E1D223E8C /* Date+Distance.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3898FF5D7EBA6D48F7B16647 /* Date+Distance.swift */; }; | ||
7B730323DC024AB253FD972C /* CwlPreconditionTesting in Frameworks */ = {isa = PBXBuildFile; productRef = 055CD8CC02F886381222CFD8 /* CwlPreconditionTesting */; }; | ||
7B76E1348EF5FE3C19619E49 /* LinkPaymentMethodPicker-CellContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DC05704665DAAA925897779 /* LinkPaymentMethodPicker-CellContentView.swift */; }; | ||
7D840FBB66787B0A8BE16901 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 1A40E15840B1B116B2A6C188 /* [email protected] */; }; | ||
7E73F6BB38F72678C7302C5F /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 0F4F1936B8B820E7355BC438 /* [email protected] */; }; | ||
|
@@ -246,6 +247,7 @@ | |
F86342791A503A98C40004F4 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = F63F6E62695BEAC410F641F0 /* [email protected] */; }; | ||
F8CAEC73CE96F289226AE760 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 5D7B682C467DD8466DFAD143 /* [email protected] */; }; | ||
F90B7028426261188B66C834 /* Error+PaymentSheet.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EA56C3880C50858583CE468 /* Error+PaymentSheet.swift */; }; | ||
F99455BCF386126F4D2BD64E /* PaymentSheetConfigurationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E578E39D2BDD6444B6C306B4 /* PaymentSheetConfigurationTests.swift */; }; | ||
FA565C353EAD9D94B39CFE16 /* AddressViewController+Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88F07B4F8F79F5A01F830180 /* AddressViewController+Configuration.swift */; }; | ||
FAB721318163CB8DF4EA2286 /* Stripe3DS2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9300105117D75EDBB229C14F /* Stripe3DS2.framework */; }; | ||
FAEB5ABECF32197709B2B19E /* PaymentSheet+SwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = B9A9FDAE66ADA08D85D74E19 /* PaymentSheet+SwiftUI.swift */; }; | ||
|
@@ -548,6 +550,7 @@ | |
E32B3AC4CC1C4F2DEEC5F292 /* WalletHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WalletHeaderView.swift; sourceTree = "<group>"; }; | ||
E41AA4E90E5BB28D588FDE51 /* StripeCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = StripeCore.framework; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
E5240ECFD40B8605939C4E09 /* LinkMoreInfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkMoreInfoView.swift; sourceTree = "<group>"; }; | ||
E578E39D2BDD6444B6C306B4 /* PaymentSheetConfigurationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentSheetConfigurationTests.swift; sourceTree = "<group>"; }; | ||
E5AC1850BF283EEA0DF89679 /* SavedPaymentMethodsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SavedPaymentMethodsViewController.swift; sourceTree = "<group>"; }; | ||
E6DDBBAAC2892467CED23402 /* PaymentSheetError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentSheetError.swift; sourceTree = "<group>"; }; | ||
E77A5A5E70770575F1D02837 /* LinkEnabledPaymentMethodElement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LinkEnabledPaymentMethodElement.swift; sourceTree = "<group>"; }; | ||
|
@@ -588,6 +591,7 @@ | |
files = ( | ||
935E8F18F1468A215A06ED29 /* XCTest.framework in Frameworks */, | ||
8CFF112D4CA7DC217CC36FF7 /* StripePaymentSheet.framework in Frameworks */, | ||
7B730323DC024AB253FD972C /* CwlPreconditionTesting in Frameworks */, | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
}; | ||
|
@@ -996,6 +1000,7 @@ | |
children = ( | ||
CBB05D43F6A475F28E0BD38D /* DictionaryTests.swift */, | ||
BB48D1FD7CD00B3DF85C5FC1 /* Info.plist */, | ||
E578E39D2BDD6444B6C306B4 /* PaymentSheetConfigurationTests.swift */, | ||
7D8FE374BAAD0EDA9FEEF550 /* STPAnalyticsClient+PaymentSheetTests.swift */, | ||
); | ||
path = StripePaymentSheetTests; | ||
|
@@ -1359,6 +1364,9 @@ | |
73532AF26E428E7914BA99B8 /* PBXTargetDependency */, | ||
); | ||
name = StripePaymentSheetTests; | ||
packageProductDependencies = ( | ||
055CD8CC02F886381222CFD8 /* CwlPreconditionTesting */, | ||
); | ||
productName = StripePaymentSheetTests; | ||
productReference = 4C6AA41454A6757B3E26AE67 /* StripePaymentSheetTests.xctest */; | ||
productType = "com.apple.product-type.bundle.unit-test"; | ||
|
@@ -1441,6 +1449,9 @@ | |
"zh-Hant", | ||
); | ||
mainGroup = AEBF7882CCDBB20F4DF60861; | ||
packageReferences = ( | ||
8B63060E38D65571F89E0AB2 /* XCRemoteSwiftPackageReference "CwlPreconditionTesting" */, | ||
); | ||
productRefGroup = 5A3D81E5A62FDBB1DDA44C53 /* Products */; | ||
projectDirPath = ""; | ||
projectRoot = ""; | ||
|
@@ -1533,6 +1544,7 @@ | |
buildActionMask = 2147483647; | ||
files = ( | ||
D90987C72BBD76D20D60CE04 /* DictionaryTests.swift in Sources */, | ||
F99455BCF386126F4D2BD64E /* PaymentSheetConfigurationTests.swift in Sources */, | ||
52B734BA0B91706F37025523 /* STPAnalyticsClient+PaymentSheetTests.swift in Sources */, | ||
); | ||
runOnlyForDeploymentPostprocessing = 0; | ||
|
@@ -1886,6 +1898,24 @@ | |
defaultConfigurationName = Release; | ||
}; | ||
/* End XCConfigurationList section */ | ||
|
||
/* Begin XCRemoteSwiftPackageReference section */ | ||
8B63060E38D65571F89E0AB2 /* XCRemoteSwiftPackageReference "CwlPreconditionTesting" */ = { | ||
isa = XCRemoteSwiftPackageReference; | ||
repositoryURL = "https://github.com/mattgallagher/CwlPreconditionTesting"; | ||
requirement = { | ||
kind = upToNextMajorVersion; | ||
minimumVersion = 2.1.2; | ||
}; | ||
}; | ||
/* End XCRemoteSwiftPackageReference section */ | ||
|
||
/* Begin XCSwiftPackageProductDependency section */ | ||
055CD8CC02F886381222CFD8 /* CwlPreconditionTesting */ = { | ||
isa = XCSwiftPackageProductDependency; | ||
productName = CwlPreconditionTesting; | ||
}; | ||
/* End XCSwiftPackageProductDependency section */ | ||
}; | ||
rootObject = 803994135025BA7DC77E3F4A /* Project object */; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
StripePaymentSheet/StripePaymentSheetTests/PaymentSheetConfigurationTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// PaymentSheetConfigurationTests.swift | ||
// StripePaymentSheetTests | ||
// | ||
// Copyright © 2023 Stripe, Inc. All rights reserved. | ||
// | ||
|
||
import CwlPreconditionTesting | ||
import StripePaymentSheet | ||
import XCTest | ||
|
||
final class PaymentSheetConfigurationTests: XCTestCase { | ||
|
||
func test_customerConfigurationInit_assertsWhenEphemeralKeyIsBlank() throws { | ||
let exception = catchBadInstruction { | ||
_ = PaymentSheet.CustomerConfiguration(id: "foo", ephemeralKeySecret: "") | ||
} | ||
|
||
XCTAssertNotNil(exception) | ||
} | ||
} |