-
Notifications
You must be signed in to change notification settings - Fork 956
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
17e4252
commit debae23
Showing
3 changed files
with
25 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
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) | ||
} | ||
} |