Signal-iOS/Signal/test/util/ASWebAuthenticationSessionUtilTest.swift
Evan Hahn 0700f81817
Support 3D Secure for card donations
[3D Secure][0] is an additional authentication layer that some
credit/debit cards use. Typically, users open a browser and do some
authentication check before the transaction can proceed.

This adds 3DS support for credit/debit card donations.

If you want to try this yourself, I recommend using one of [Stripe's
test 3DS cards][1] in a staging build.

See also: [the equivalent commit in Signal Android][0].

[0]: https://stripe.com/docs/payments/3d-secure
[1]: https://stripe.com/docs/payments/3d-secure?platform=ios#three-ds-cards
[2]: d1df069669
2022-11-29 16:07:44 -06:00

34 lines
936 B
Swift

//
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
import XCTest
import AuthenticationServices
@testable import Signal
final class ASWebAuthenticationSessionUtilTest: XCTestCase {
func testSuccess() {
let inputUrl = URL(string: "https://example.com")!
switch ASWebAuthenticationSession.resultify(callbackUrl: inputUrl, error: nil) {
case let .success(url):
XCTAssertEqual(url, inputUrl)
default:
XCTFail("Didn't get a successful result")
}
}
func testFailure() {
enum TestError: Error { case test }
let inputError = TestError.test
switch ASWebAuthenticationSession.resultify(callbackUrl: nil, error: inputError) {
case let .failure(error):
XCTAssertEqual(error as? TestError, inputError)
default:
XCTFail("Didn't get a failure result")
}
}
}